Multi-Color Line

早过忘川 提交于 2019-12-11 03:48:22

问题


In the data, there is a object property called clr which is actually contains color information of corresponding object. I would like to draw a single line with multiple colors. However so far, I could not able to make it work.

Here is a small sample of my dataset.

{x: 11,y: 599,k: 500,clr:'blue'}, { x: 6,y: 699,k: 800,clr:'yellow'}

Here is the code sample which I had expected to work:

series: [{data: mydata,color: mydata.clr}],

http://jsfiddle.net/epvg86qu/19/


回答1:


As mentioned here, the colorField option is supported when series.type is set to "bar", "column", "bubble", "donut", "pie", "candlestick", "ohlc" or "waterfall".

The only way to do this seems to be by creating multiple series. See fiddle: http://jsfiddle.net/53ygp9ut/2/

function createChart() {
    $("#chart").kendoChart({
        xAxis: {},
        yAxis: {},
        seriesDefaults: {type: "scatterLine" },
        series: [{data: stats1, color: "blue"},
                 {data: stats2, color: "yellow"},
                 {data: stats3, color: "red"}],
    });
}

$(document).ready(createChart);



回答2:


Change your function to look like this, you have to tell Kendo to use the colorField:

function createChart() {
    $("#chart")
    .kendoChart({
        xAxis: {},
        yAxis: {},
        seriesDefaults: {type: "scatterLine" },
        series: [{data: stats2,colorField: "clr"}],
  })
}

Updated fiddle: http://jsfiddle.net/epvg86qu/20/



来源:https://stackoverflow.com/questions/30176594/multi-color-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!