谷歌饼图显示相反的颜色

时间:2014-06-24 13:58:42

标签: javascript jquery ajax charts google-visualization

我在javascript中有一个如下图所示的饼图:

function drawCurrentPieChart(title,days) {
    var name = document.getElementById("dropdownSubCategories").value;
    $
    .ajax({
        url : "piechartlist/",
        type : "GET",
        aync : true,
        dataType : "json",
        data : {days:days,
            categoryName : name + ""},
        error : function(e) {
            alert(e.message + "ERROR ");
        },
        success : function(response) {
            var jsonData = response;
            if (response == "") {
                alert("Error: Threshold is not valid or there is no status in the database within 24 hours.");
            } else {

                var data = [["Count","Color"]], colors = [];
                for(var c in jsonData){
                    data[data.length] = [jsonData[c]["color"],jsonData[c]["count"]];
                    colors[colors.length] = jsonData[c]["color"];
                }               

                data = google.visualization.arrayToDataTable(data);

                var options = {
                        title: title,
                        'chartArea': {'width': '100%', 'height': '80%'},
                           'legend': {'position': 'bottom'},
                        backgroundColor: 'transparent',
                        colors : colors 
                };

                var chart = new google.visualization.PieChart(document.getElementById('piechart'+days));
                chart.draw(data, options);
            }
        }
    });

当它绘制图表时,它会显示从数据库中收到的相反颜色(绿色为红色,红色为绿色等)可能是什么问题?

0 个答案:

没有答案