template
我建议不要使用format
(但是,当然,您可以使用模板获得相同的东西)。
例子:
按25.4
原样打印25.4%
seriesDefaults: {
type: "column",
labels: {
visible: true,
background: "transparent",
format : "{0:n}%"
}
},
3
您甚至可以使用以下方法使其显示一定数量的十进制数字format : "{0:n3}%"
:
seriesDefaults: {
type: "column",
labels: {
visible: true,
background: "transparent",
format : "{0:n3}%"
}
},
这是当您将数字存储为百分比时,即25%
存储为25
而不是存储为0.25
。
$(document).ready(function() {
$("#chart").kendoChart({
title: {
text: "Total Sales (percentage)"
},
legend: {
visible: false
},
seriesDefaults: {
type: "column",
labels: {
visible: true,
background: "transparent",
format : "{0:n2}%"
}
},
series: [
{
name: "Serie1",
data: [10, 20, 25, 30, 10, 5]
}
],
valueAxis: {
max: 50,
line: {
visible: false
},
minorGridLines: {
visible: true
}
},
categoryAxis: {
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
majorGridLines: {
visible: false
}
}
});
});
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.common.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.default.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.dataviz.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.dataviz.default.min.css" />
<script src="http://cdn.kendostatic.com/2014.3.1119/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.3.1119/js/kendo.all.min.js"></script>
<div id="chart" style="height: 300px"></div>