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

access to Graph Data Points

5 Answers 74 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ghayth Hilal
Top achievements
Rank 1
Ghayth Hilal asked on 29 Mar 2016, 07:56 PM

I'm trying to get access to The Graph (bar graph) data points in order to change their background colors.

Anyone knows how to get to these data points?

5 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 01 Apr 2016, 11:54 AM
Hi ,

Graph series have a ColorPalette property that you can modify according to your requirements.

You can refer to Formatting a Graph(Formatting Series colors) help article that describes how to add custom colors to series ColorPalette.


Regards,
Katia
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
Ghayth Hilal
Top achievements
Rank 1
answered on 01 Apr 2016, 02:53 PM

Thank you for your Reply Katia;

I've attached 3 images describing the problem I'm having with my Chart.
My data has 2 columns: 'Year' and 'Amount'
I need a column chart that shows each 'Year' in a Column with a different color.

The nicest looking chart I got was when I assign the Chart categories to 'Year' and Chart values to 'Amount', but this makes all the columns of the same color (see attached image g1.png).

When I assigned the Chart series to 'Year' and Chart values to 'Amount', I got all the columns to be attached to each other, and the x-axis title to be 'All' instead of each column having it's own title (see attached image g2.png).

Last, I've assigned the Chart categories and Chart series to be 'Year' and the Chart value to be 'Amount'.
the result was a thin, left aligned columns (see attached image g3.png).

I'm best looking one is my first attempt, so I thought I can solve the column colors issue by accessing the graph data points and override the assigned colors

0
Katia
Telerik team
answered on 04 Apr 2016, 04:19 PM
Hi ,

As your data is not grouped by the series, ColorPalette property will not be in use as it assigns colors to different series but not to different data point values.

In order to set a custom color per column, you need to set conditional formatting rules for barSeries (see the attached report). However, when the values for data points are unknown you might need to create the Graph item programmatically and add your custom logic for setting the colors.


Regards,
Katia
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
Ghayth Hilal
Top achievements
Rank 1
answered on 11 Apr 2016, 02:24 PM

Hello Katia;

I've been working on this for quite some time with no luck.
can you please send me or point me to a sample that clearly shows how to create Graph item programmatically and set the background color to them ?

thank you.

 

0
Katia
Telerik team
answered on 14 Apr 2016, 10:37 AM
Hi ,

You can find attached a simplified example demonstrating how to set BackgroundColor for DataPoints programmatically. This approach can be applied to your scenario after considering your real data and other specifics.

In general, when you want to control the report programmatically you can first test the approach in the Designer and then review the code automatically generated in .Designer.cs file. This will give you an idea how the items are generated in code behind. You can modify the sample code according to your requirements and place after InitializeComponent() method.


Regards,
Katia
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
General Discussions
Asked by
Ghayth Hilal
Top achievements
Rank 1
Answers by
Katia
Telerik team
Ghayth Hilal
Top achievements
Rank 1
Share this question
or