我有问题将数据绘制成折线图。没有任何东西出现接受标签。我的数据来自json文件。
这是我的json文件格式:
[{
"country": "India",
"value": [
3.907,
7.943,
7.848,
6.284,
7.263
]
},{
"country": "World",
"value": [
1.988,
2.733,
3.994,
3.464,
4.001
]
}]
这是我的jquery。在系列部分,我把数据作为“价值”。这是错的吗??希望有人可以帮助我...... 提前谢谢。
function createChart() {
var ds = new kendo.data.DataSource({
transport: {
read: {
url: "country.JSON", dataType: "json"
}
}
});
$j("#chart_div").kendoChart({
dataSource: ds,
title: {
text: "Gross domestic product growth"
},
seriesDefaults: {
type: "line",
style: "smooth"
},
series: [{
data: "value",
name: "India"
}, {
field: "value",
name: "World"
}, {
field: "value",
name: "Russia"
}],
valueAxis: {
labels: {
format: "{0}%"
},
line: {
visible: false
},
axisCrossingValue: -10
},
categoryAxis: {
categories: [2002, 2003, 2004, 2005, 2006],
majorGridLines: {
visible: false
},
labels: {
rotation: "auto"
}
}
});
}
答案 0 :(得分:0)
下面的代码显示了将json数据传递给createChart函数以创建Kendo折线图的方法
function createChart() { $("#chart").kendoChart({ title: { text: "Gross domestic product growth" }, legend: { position: "bottom" }, chartArea: { background: "" }, seriesDefaults: { type: "line", style: "smooth" }, series: [{ "country": "India", "value": [ 3.907,7.943,7.848, 6.284,7.263] },{ "country": "World", "value": [1.988,2.733,3.994,3.464,4.001] }], valueAxis: { labels: { format: "{0}%" }, line: { visible: false }, axisCrossingValue: -10 }, categoryAxis: { categories: [2002, 2003, 2004, 2005, 2006], majorGridLines: { visible: false }, labels: { rotation: "auto" } }, tooltip: { visible: true, format: "{0}%", template: "#= series.name #: #= value #" } }); } $(document).ready(createChart);