Multi-Color Line

2019-07-20 12:18发布

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/

2条回答
看我几分像从前
2楼-- · 2019-07-20 12:50

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/

查看更多
Anthone
3楼-- · 2019-07-20 13:09

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);
查看更多
登录 后发表回答