给定轴上的所有系列必须与折线图具有相同的数据类型

时间:2016-01-27 08:06:02

标签: javascript jquery charts linechart

我使用google js在折线图上工作,我已经提供了一些测试样本值,我收到了错误

All series on a given axis must be of the same data type

脚本

 function drawChart() {
            // var data = google.visualization.arrayToDataTable(chartData);
            var data = new google.visualization.DataTable();
            data.addColumn('number', 'Year');
            data.addColumn('string', 'Value');
            data.addColumn('number', 'Quantity');
            data.addRows([
                           [2008,'Value1',36],
                           [2009,'Value2',27],
                           [2010,'Value3',39]
            ]);
            var options = {
                title: "Company Performance Product Category Wise",
                pointSize: 5
            };
            var lineChart = new google.visualization.LineChart(document.getElementById('chart_div'));
            lineChart.draw(data, options);
        }

HTML

 <div id="chart_div" style="width: 600px; height: 400px">
        </div>

1 个答案:

答案 0 :(得分:0)

只有两列才能正常工作......

data.addColumn('string', 'Year');
data.addColumn('number', 'Quantity');
data.addRows([
 ['2008',36],
 ['2009',27],
 ['2010',39]
]);