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

How to set line series color in code behind ?

3 Answers 65 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Tam
Top achievements
Rank 1
Tam asked on 24 Jan 2019, 08:04 AM

I want to set the line series stroke in code behind. The first parameter in SetValue () should be DependencyProperty, however I can't figure out how to do it. Here is my current code :

 

var provider = intervalChart.SeriesProvider;
foreach (var descriptor in provider.SeriesDescriptors)
{
    descriptor.Style.SetValue("Stoke", Windows.UI.Colors.Aqua);
}

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 24 Jan 2019, 12:42 PM
Hello Tam,

Please try it like this:

foreach (var descriptor in provider.SeriesDescriptors)
{
    if (descriptor.Style == null)
        descriptor.Style = new Style() { TargetType = typeof(LineSeries) };
 
    descriptor.Style.Setters.Add(new Setter(LineSeries.StrokeProperty, Windows.UI.Colors.Aqua));
}

I hope I was of help.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tam
Top achievements
Rank 1
answered on 24 Jan 2019, 04:02 PM

Thanks for your help. I have this exception :

System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'

0
Yana
Telerik team
answered on 25 Jan 2019, 08:42 AM
Hi Tam,

Please find attached my test project with Chart for UWP and setting series color in code-behind.  Do you reproduce the same exception with it? Can you check what is different in your case?

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Tam
Top achievements
Rank 1
Answers by
Yana
Telerik team
Tam
Top achievements
Rank 1
Share this question
or