如何使用函数获取剑道图中的月份名称 [英] How to get the month names in kendo chart by using function
本文介绍了如何使用函数获取剑道图中的月份名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建一个函数来获取在剑道图表 x 轴中显示的月份为 Jan,feb..
How to create a function to get the month as Jan,feb.. displayed in kendo chart x axis.
var internetUsers = [ {
"Month": "1",
"year": "2010",
"value": 1
}, {
"Month": "2",
"year": "2010",
"value": 2
}, {
"Month": "3",
"year": "2010",
"value": 3
}, {
"Month": "4",
"year": "2010",
"value": 4
}, {
"Month": "5",
"year": "2010",
"value": 5
},
{
"Month": "6",
"year": "2010",
"value": 6
}, {
"Month": "7",
"year": "2010",
"value": 7
}, {
"Month": "8",
"year": "2010",
"value": 8
}];
function createChart() {
$("#chart").kendoChart({
theme: $(document).data("kendoSkin") || "default",
dataSource: {
data: internetUsers,
group: {
field: "year"
},
sort: {
field: "year",
dir: "asc"
}
},
title: {
text: "Sales"
},
legend: {
position: "bottom"
},
seriesDefaults: {
type: "column"
},
series: [{
field: "value"
}],
valueAxis: {
labels: {
format: "{0}$"
},
line: {
visible: false
},
axisCrossingValue: 0
},
categoryAxis: {
field: "Month"
},
tooltip: {
visible: true,
format: "{0}%",
template: "#= series.name #: #= value #"
}
});
}
$(document).ready(function() {
setTimeout(function() {
// Initialize the chart with a delay to make sure
// the initial animation is visible
createChart();
$("#example").bind("kendo:skinChange", function(e) {
createChart();
});
}, 400);
});
</script>
推荐答案
可以使用kendoui的时间格式功能:
You could use kendoui's time format function:
kendo.toString(new Date(2000, value, 1), "MMMM"); // if value = 9, it would output September
查看kendoui的日期格式页面.这是非常有帮助的.http://docs.telerik.com/kendo-ui/getting-开始/框架/全球化/日期格式
Check out kendoui's date format page. It is VERY helpful. http://docs.telerik.com/kendo-ui/getting-started/framework/globalization/dateformatting
这篇关于如何使用函数获取剑道图中的月份名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文