access to Graph Data Points

6 posts, 0 answers
  1. Ghayth Hilal
    Ghayth Hilal avatar
    9 posts
    Member since:
    Oct 2009

    Posted 29 Mar Link to this post

    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?

  2. Katia
    Admin
    Katia avatar
    301 posts

    Posted 01 Apr Link to this post

    Hi Ghayth,

    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
  3. DevCraft banner
  4. Ghayth Hilal
    Ghayth Hilal avatar
    9 posts
    Member since:
    Oct 2009

    Posted 01 Apr Link to this post

    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

  5. Katia
    Admin
    Katia avatar
    301 posts

    Posted 04 Apr Link to this post

    Hi Ghayth,

    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
  6. Ghayth Hilal
    Ghayth Hilal avatar
    9 posts
    Member since:
    Oct 2009

    Posted 11 Apr in reply to Katia Link to this post

    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.

     

  7. Katia
    Admin
    Katia avatar
    301 posts

    Posted 14 Apr Link to this post

    Hi Ghayth,

    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
Back to Top
DevCraft banner