Individual Colors to Bars

3 posts, 0 answers
  1. wael
    wael avatar
    2 posts
    Member since:
    May 2014

    Posted 02 Feb 2015 Link to this post

    How Do I Assign Individual Colors to Bars?


    i want to do something like that 

    http://www.telerik.com/help/aspnet-ajax/chart-how-to-assign-individual-colors-to-bars.html

    from code behind in silverlight

    there is my sample code 

     Telerik.Windows.Controls.RadChart chart = new Telerik.Windows.Controls.RadChart();
     chart.PaletteBrushes = new BrushCollection();
                                    chart.PaletteBrushes.Add(new SolidColorBrush() { Color = Colors.Orange });
                                    chart.PaletteBrushes.Add(new SolidColorBrush() { Color = Colors.Green });
                                    chart.PaletteBrushes.Add(new SolidColorBrush() { Color = Colors.Orange });
                                    chart.PaletteBrushes.Add(new SolidColorBrush() { Color = Colors.DarkGray });
      DataSeries barSeries=new DataSeries();
                                    foreach (Indicator ind in cd.Indicators)
                                    {

                                       
                                            barSeries.Add(new DataPoint() { YValue = double.Parse(ind.value), XCategory = ind.Name });
                                            barSeries.LegendLabel = ind.Name;
                                            
                                            
                                        
                                    }
     int colorindex = 0;
                                  foreach (var bar in barSeries)
                                                {
                                                    BarSeriesDefinition bardef = new BarSeriesDefinition();
                                                    bardef.Appearance.Fill = chart.PaletteBrushes[colorindex];
                                                    bar.DataItem = bardef;
                                                    colorindex++;
                                                }
     chart.DefaultView.ChartArea.DataSeries.Add(barSeries);


  2. wael
    wael avatar
    2 posts
    Member since:
    May 2014

    Posted 02 Feb 2015 in reply to wael Link to this post

    this sample code return all bars with the first color in PaletteBrushes
  3. DevCraft banner
  4. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 03 Feb 2015 Link to this post

    Hello,

    You can check out our online help topic on how to have a custom item style. Furthermore this is related with the older chart control of ours. We have a newer one - RadChartView. If you haven't, I suggest you to try it out as our efforts are focused on the newer control.

    Regards,
    Peshito
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top