我正在尝试删除 pannable&之后的剑道图" Y轴小数位" 放大/缩小
如何从y轴中删除小数值,我尝试设置" Y轴标签格式..但它不起作用&#34 ;
代码我试过
jQuery("#chart_i139_XzCnAHHzIR").kendoChart({
"chartArea": { "background": "#FFFEFC" },
"renderAs": "canvas", "title": { "text": "p1" },
"legend": { "labels": { "template": "#= series.name #" }, "position": "top" },
"series": [{
"name": "Male", "type": "line",
"data": [35171, 36663, 30247, 36479, 34025, 37142, 37295, 36054, 38076, 37725, 34716, 39620, 38296],
"stack": false, "labels": { "format": "{0:n0}", "visible": true, "position": "above" },
"style": "smooth"
}, {
"name": "Female", "type": "line",
"data": [34295, 32586, 36872, 35556, 38839, 36932, 34039, 35055, 35429, 35689, 34528, 31777, 33405],
"stack": false, "labels": { "format": "{0:n0}", "visible": true, "position": "above" },
"style": "smooth"
}], "categoryAxis": [{
"labels": { "rotation": { "angle": "auto" } },
"majorGridLines": { "width": 1, "color": "#dfdfdf", "visible": false },
"line": { "visible": true },
"title": { "text": "years", "position": "left" },
"categories": ["2008", "2007", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2017", "2016", "2018", "2019"]
}], "valueAxis": [{ "majorGridLines": { "visible": false } }],
"transitions": false,
"tooltip": { "template": "#= series.name #: #= kendo.format(\u0027{0:n0}\u0027,value) #", "visible": true },
"pannable": true, "zoomable": true
});
答案 0 :(得分:4)
更简单的解决方案是将以下配置附加到图表选项' valueAxis字段:
valueAxis: {
labels: {
format: "{0:0}"
}
}
答案 1 :(得分:0)
添加此
后问题已得到解决.ValueAxis(axis => axis.Numeric()
.Labels(labels => labels.Format("{0:0}"))
.MajorUnit(1))
答案 2 :(得分:0)
尝试下面的Kendo图表配置:
{
series: [{
name: 'Grand Total',
data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
type: 'column',
}],
zoomable: {
mousewheel: {
lock: 'y',
},
selection: {
lock: 'y',
},
},
pannable: {
lock: 'y',
},
valueAxis: {
max: 12,
// labels: {
// format: '{0:0}',
// },
majorUnit: 1,
},
categoryAxis: {
categories: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
},
}
此处的密钥是valueAxis
。您需要设置max
和majorUnit
。如果执行valueAxis.labels.format: '{0:0}'
,是的,小数点消失了,但是在最大缩放比例下,似乎条形图未正确地对准y轴。实际上,条高度/水平正确,y轴标签错误,缺少小数点。注释/取消注释valueAxis.labels
和valueAxis.majorUnit
,以查看区别。