问题
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