更新时间:2023-01-25 08:15:56
在进一步研究之后,我发现 colorField 用于将颜色设置为系列中的一个点(而不是整个系列).我发现 seriesColors 正是我想要的:
After looking into this further, I found that colorField is for setting color to a single point in the series (not to the entire series). I found seriesColors was what I was looking for:
http://docs.kendoui.com/api/dataviz/chart#configuration-seriesColors一个>
这是我重构的示例:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div id="chart"></div>
<script src="js/thirdParty/jquery.js"></script>
<script src="js/thirdParty/kendo.all.min.js"></script>
<script>
$(function () {
var data,
dataSource;
data = [{
type: "C1",
amount: 100,
year: 2008
}, {
type: "C2",
amount: 120,
year: 2008
}, {
type: "C2",
amount: 50,
year: 2009
}, {
type: "C1",
amount: 10,
year: 2010
}, {
type: "C1",
amount: 120,
year: 2011
}, {
type: "C2",
amount: 50,
year: 2011
}];
dataSource = new kendo.data.DataSource({
data: data,
group: {
field: "type"
},
sort: { field: "year" }
});
$("#chart").kendoChart({
dataSource: dataSource,
seriesColors: ["red", "blue"],
series: [{
type: "column",
field: "amount",
categoryField: "year",
name: "#= group.value #"
}],
})
});
</script>
</body>
</html>