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

Change color on line depending on the value

1 Answer 128 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Fredrik
Top achievements
Rank 1
Veteran
Iron
Fredrik asked on 02 Feb 2021, 03:55 PM

Lets say that in my RadCartesianChart I have a line series with values between -1 to 10.

If a point value is -1 I would like the opacity to change.

For example if it is red with opacity 1 I'd like it to change to red opacity 0.5 until the value goes above zero.

Is this possible?

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 05 Feb 2021, 11:38 AM

Hello Fredrik,

What comes up to my mind is to use the StrokeShapeStyle property of the LineSeries. You can create a custom Style targeting Path element and set its Opacity property. In your scenario, you could bind this property to property from your ViewModel. Then listen for datapoints values change and if an item with a value below zero appears, change the bound property.

<telerik:ScatterLineSeries.StrokeShapeStyle>
    <Style TargetType="Path">
        <Setter Property="Stroke" Value="Red"/>
        <Setter Property="Opacity" Value="0.5"/>
    </Style>
</telerik:ScatterLineSeries.StrokeShapeStyle>

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products, quickly just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ChartView
Asked by
Fredrik
Top achievements
Rank 1
Veteran
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or