Setting each Data Point Colors not the Whole DataSeries

5 posts, 0 answers
  1. Gino
    Gino avatar
    5 posts
    Member since:
    Apr 2009

    Posted 13 May 2009 Link to this post


    Is there a way in RadChart specifically for BarSeries to set the color of a specific DataPoint and not the whole DataSeries? Please note that I want to retain the default style and look of the Bars.

    Please help. Thank you!!!


  2. Giuseppe
    Giuseppe avatar
    2363 posts

    Posted 15 May 2009 Link to this post

    Hi Gino,

    We would suggest you to review this online example here that demonstrates the desired functionality. You can find more information on the MVVM approach used in the sample here.

    Hope this helps.

    All the best,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Taylor
    Taylor avatar
    9 posts
    Member since:
    May 2009

    Posted 26 May 2009 Link to this post

    To make the original question a bit more difficult, say you wanted to do this with a stacked bar chart, so that you could individually change the color of each piece of the stack.  I'm running into problems with the following code:

    List<BarDataPoint> pointList = new List<BarDataPoint>(); 
                pointList.Add(new BarDataPoint("MTD", 1, list[2][1].value, Color.FromArgb(255, 255, 0, 0))); 
                pointList.Add(new BarDataPoint("FYTD", 2, list[2][0].value, Color.FromArgb(255, 255, 0, 255))); 
                rc.DefaultSeriesDefinition = new BarSeriesDefinition() { ItemStyle = this.CustomStyle }; 
                SeriesMapping mapping = new SeriesMapping(); 
                mapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); 
                rc.ItemsSource = pointList
                tickPoints = rcTQISummary.DefaultView.ChartArea.AxisX.TickPoints; 
                for (int i = 0; i < tickPoints.Count; i++) 
                    TickPoint tickPoint = tickPoints[i]; 
                    tickPoint.Label = pointList[i].XLabel; 

    This block works fine, but when trying to edit it to work with a stacked bar definition, I'm hitting a block.  I don't see how to use the ItemSource definition of the chart with multiple series definitions (as you need for stacked bar charts), but if I get rid of the Item source property, I'm not sure how to bind my colors to the bar.

    As a bit of background, I created the BarDataPoint to hold the YValue, XLabel, and a Brush so that the data bind would be able to find the color for the bar by binding to the BarColor property of my BarDataPoint class.

    Do you guys have any examples of doing this with a stacked bar graph?  I'm at a loss.


    Taylor Smith
  4. Taylor
    Taylor avatar
    9 posts
    Member since:
    May 2009

    Posted 28 May 2009 Link to this post

    I got this working with the stacked bar chart.  Basically, I created a wrapper class that held multiple BarDataPoint objects.  Each of these objects represented one stacked bar and I was therefore able to change the color of each section of the bar individually from the others while still data binding to the ItemSource.
  5. Dennis
    Dennis avatar
    10 posts
    Member since:
    Mar 2010

    Posted 16 Mar 2010 Link to this post

    It would be nice to see your finished code.  Would help me in my current situation.
Back to Top