我的柱形图如下:
我添加了数据的值,正如您所看到的那样,相对于Y轴的列没有意义 - 为什么会这样?
图表选项:
var options = {
title: 'Task Estimates',
backgroundColor: { fill: 'transparent' },
chartArea: { width: '50%' },
height: '400px',
hAxis: { direction: -1, slantedText: true, slantedTextAngle: 45, title: 'Tasks' },
};
var url = "http://theurl";
$.getJSON(url, function (jsonChartData) {
var data = new google.visualization.DataTable(jsonChartData);
var chart = new google.visualization.ColumnChart(chartHtmlElement);
chart.draw(data, options);
});
json是:
{
"cols":[
{ "id":"A", "label":"Task", "type":"string", "role":null },
{ "id":"B", "label":"Days Estimated", "type":"number", "role":null },
{ "id":"C", "label":"Days Actual", "type":"number", "role":null }
],
"rows":[
{ "c":[ { "v":"Task 3" }, { "v":"7" }, { "v":"4" } ] },
{ "c":[ { "v":"Task 1" }, { "v":"10" }, { "v":"24" } ] },
{ "c":[ { "v":"Task 2" }, { "v":"100" }, { "v":"0" } ] }
],
"p":null
}
我做错了什么?是否还需要指定其他方法才能使轴正常工作?
的jsfiddle
答案 0 :(得分:2)
您输入的数字为字符串,应以数字形式输入:
{
"cols":[
{
"id":"A",
"label":"Task",
"type":"string",
"role":null
},
{
"id":"B",
"label":"Days Estimated",
"type":"number",
"role":null
},
{
"id":"C",
"label":"Days Actual",
"type":"number",
"role":null
}
],
"rows":[
{
"c":[
{
"v":"Task 3"
},
{
"v":7
},
{
"v":4
}
]
},
{
"c":[
{
"v":"Task 1"
},
{
"v":10
},
{
"v":24
}
]
},
{
"c":[
{
"v":"Task 2"
},
{
"v":100
},
{
"v":0
}
]
}
],
"p":null
}