kendo bar chart colors of categories

和自甴很熟 提交于 2019-12-06 09:47:15

The series object has a property called colorField that can be used for this: http://docs.telerik.com/KENDO-UI/api/javascript/dataviz/ui/chart#configuration-series.colorField

You can use it in one of the following 2 ways:

Updated JSBIN

$("#chart1").kendoChart({
  theme: "flat",
  dataSource: {
    data:[
    {key: "Red Category", value: "2", usercolor: "red"},
    {key: "Green Category", value: "3", usercolor: "green"},
  ]},
  seriesDefaults: {
    type: "bar", 
  },
  series: [{ 
      field: "value",
      categoryField: "key",
      colorField: "usercolor",
  }],  
});

$("#chart2").kendoChart({
  theme: "flat",
  seriesDefaults: {
    type: "bar", 
  },
  series: [{ 
      field: "value",
      colorField: "usercolor",
      data: [
        {value: "2", usercolor: "red"},
        {value: "3", usercolor: "green"},
      ],
  }],  
  categoryAxis:{
    categories:["Red Category", "Green Category"],
  }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!