This is a migrated thread and some comments may be shown as answers.

ScatterLine Char - How to make Dynamic the color of the line

1 Answer 115 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 30 Aug 2016, 08:27 AM

Hi have one question. 

I want to change the color of the line(between points) depending on the values on the Y-axis. If the line is below 0 then the line is red color, otherwise the line is  green color

 

 <div kendo-chart
     k-options="chartOptions"
     k-data-source="pctSource"
     style="height: 300px;">
</div>

 $scope.chartOptions = {
            legend: { visible: false },
            seriesDefaults: { type: 'scatterLine' },
            series: [{ xField: "time", yField: "percent", colorField: "userColor", color: "#4572A7" }],
            highlight: {
                border: {
                    opacity: 1,
                    width: 5,
                    color: "black"
                }
            },
            xAxis: {
                max: 120,
                labels: { format: "{0} min" },
                title: { text: "" },
                majorGridLines: {
                    visible: false
                }
            },
            yAxis: {
                max: $scope.pctCharAxisYMaxValue,
                min: $scope.pctCharAxisYMinValue,

                labels: { format: "{0}%" },
                title: { text: "" }
            },
            tooltip: {
                visible: true,
                template: "${dataItem.toolTipLabel}<br/>${dataItem.percent}"
            }
        }

 

 

1 Answer, 1 is accepted

Sort by
0
Eduardo Serra
Telerik team
answered on 30 Aug 2016, 02:51 PM
Hello Oliver,

A line from the same series cannot have two different colors, but a line made of two different series can. To end up with the look you're looking for, work with your data before sending it to the chart and separate it in two series, those with a Y value greater than 0 and those with a Y value smaller than 0.

I prepared a sample in the Kendo UI Dojo to show you how it can be done; take a look at it here.

I hope this helps!

Regards,
Eduardo Serra
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Charts
Asked by
Oliver
Top achievements
Rank 1
Answers by
Eduardo Serra
Telerik team
Share this question
or