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

Set color of point in code behind

1 Answer 184 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Gitle
Top achievements
Rank 1
Gitle asked on 10 Oct 2018, 10:56 AM

I am trying to create a pointseries with the points having a custom color in codebehind. Is there a simple way to do this?

 

As far as I understand, the only way to set the color of a pointseries is to use a custom pointtemplate, and pointtemplates can only easily be created in XAML, in code behind I would have to create the xaml as a string and then convert it into a datatemplate or something. But that seems like a lot of complexity for something as simple as setting the color of a chart.

I cannot define everything in XAML because series are created on the go and the colors can vary depending on settings.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 12 Oct 2018, 08:17 AM
Hello Gitle,

To achieve your requirement you can use also the DefaultVisualStyle or the DefaultVisualStyleSelector properties of the series. They are easier to adjust in code-behind because expect a value of type Style or a StyleSelector. In your case the selector should do the work. Can you please try those and let me know how it goes?

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ChartView
Asked by
Gitle
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or