Cannot change the color of RadChart Line series

2 posts, 0 answers
  1. Kannan
    Kannan avatar
    8 posts
    Member since:
    Aug 2012

    Posted 03 Sep 2012 Link to this post

    Hi,

    I am using RadChart for Silverlight 5 and in my chart series i am creating 4 stacked Bar series and a 3 line series runtime in code behind.
    I am able to change the Stacked Bar series color.But i am unable to change the color of line series which is alos created in the sam chart control, it is taking the default color only.
    Can you please to suggest me a solution to resolve the problem.

    I have pasted my code as below for your reference.
    private void LoadPlannedChart(Collection<WcfServiceRef.DSR_ProgressData_BO> lstPlannedChartData)
            {
      
                try
                {
                    RadChart1.SeriesMappings.Clear();
                    var lstlegend = lstResultData.GroupBy(cm => new { cm.ActualDailyExecutionrate, cm.AverageOriginalTargetDailyExecutionRate, cm.AverageRequiredDailyExecutionrate },
                                                            (key, group) => new
                                                            {
                                                                key1 = Convert.ToDecimal(key.ActualDailyExecutionrate),
                                                                key2 = Convert.ToDecimal(key.AverageOriginalTargetDailyExecutionRate),
                                                                key3 = Convert.ToDecimal(key.AverageRequiredDailyExecutionrate)
                                                            });
      
                    // RadChart1 = new Telerik.Windows.Controls.RadChart();
      
                    SeriesMapping PlannedseriesMapping = new SeriesMapping { LegendLabel = "Planned" };
                    PlannedseriesMapping.SeriesDefinition = new StackedBarSeriesDefinition() { ShowItemLabels = false, ShowItemToolTips = true };
      
      
      
                    SeriesMapping PassedseriesMapping = new SeriesMapping { LegendLabel = "Passed" };
                    PassedseriesMapping.SeriesDefinition = new StackedBarSeriesDefinition() { ShowItemLabels = false, ShowItemToolTips = true };
      
      
                    SeriesMapping FailedseriesMapping = new SeriesMapping { LegendLabel = "Failed" };
                    FailedseriesMapping.SeriesDefinition = new StackedBarSeriesDefinition() { ShowItemLabels = false, ShowItemToolTips = true };
      
                    SeriesMapping NotCompltedseriesMapping = new SeriesMapping { LegendLabel = "NotCompeleted" };
                    NotCompltedseriesMapping.SeriesDefinition = new StackedBarSeriesDefinition() { ShowItemLabels = false, ShowItemToolTips = true };
      
                    SeriesMapping BlockedseriesMapping = new SeriesMapping { LegendLabel = "Blocked" };
                    BlockedseriesMapping.SeriesDefinition = new StackedBarSeriesDefinition() { ShowItemLabels = false, ShowItemToolTips = true };
      
                    SeriesMapping DeScopedseriesMapping = new SeriesMapping { LegendLabel = "DeScoped" };
                    DeScopedseriesMapping.SeriesDefinition = new StackedBarSeriesDefinition() { ShowItemLabels = false, ShowItemToolTips = true };
      
      
                    SeriesMapping TCExecRateseriesMapping = new SeriesMapping { LegendLabel = "TCExecRate( " + lstlegend.ElementAt(0).key2 + " )"};
                    TCExecRateseriesMapping.SeriesDefinition = new LineSeriesDefinition() { ShowItemLabels = false, ShowPointMarks = true, ShowItemToolTips = true };
                      
      
                    SeriesMapping ACExecRateseriesMapping = new SeriesMapping { LegendLabel = "ACExecRate( " + lstlegend.ElementAt(0).key1 + " )" };
                    ACExecRateseriesMapping.SeriesDefinition = new LineSeriesDefinition() { ShowItemLabels = false, ShowPointMarks = true, ShowItemToolTips = true};
      
                    SeriesMapping ReqExecRateseriesMapping = new SeriesMapping { LegendLabel = "ReqExecRate( " + lstlegend.ElementAt(0).key3 + " )" };
                    ReqExecRateseriesMapping.SeriesDefinition = new LineSeriesDefinition() { ShowItemLabels = false, ShowPointMarks = true, ShowItemToolTips = true };
      
                    ////set Colors
                    Color PassedColor = Color.FromArgb(255, 0, 176, 80);
                    PassedseriesMapping.SeriesDefinition.Appearance.Fill = new SolidColorBrush(PassedColor);
                    Color PlannedColor = Color.FromArgb(255, 112, 146, 190);
                    PlannedseriesMapping.SeriesDefinition.Appearance.Fill = new SolidColorBrush(PlannedColor);
                    Color FailedColor = Color.FromArgb(255, 148, 138, 84);
                    FailedseriesMapping.SeriesDefinition.Appearance.Fill = new SolidColorBrush(FailedColor);
                    Color NotCompletedColor = Color.FromArgb(255, 65, 152, 175);
                    NotCompltedseriesMapping.SeriesDefinition.Appearance.Fill = new SolidColorBrush(NotCompletedColor);
                    Color BlockedColor = Color.FromArgb(255, 143, 55, 53);
                    BlockedseriesMapping.SeriesDefinition.Appearance.Fill = new SolidColorBrush(BlockedColor);
                    Color DeScopedColor = Color.FromArgb(255, 147, 169, 207);
                    DeScopedseriesMapping.SeriesDefinition.Appearance.Fill = new SolidColorBrush(DeScopedColor);
      
                    Color TCExecRateseriesMappingColor = Color.FromArgb(255, 255, 255, 0);
                    TCExecRateseriesMapping.SeriesDefinition.Appearance.Fill = new SolidColorBrush(Colors.Yellow);
      
                    Color ReqExecRateseriesMappingColor = Color.FromArgb(255, 181, 202, 146);
                    ReqExecRateseriesMapping.SeriesDefinition.Appearance.Fill = new SolidColorBrush(ReqExecRateseriesMappingColor);
      
                    
                    //lstPlannedData = new Collection<DSR_ProgressData_BO>();
      
                    //var lstFutureData = (from lst in lstResultData where lst.ActivityDate > DateTime.Today select lst).Take(7);
                    //var lstPastData = (from lst in lstResultData where lst.ActivityDate <= DateTime.Today select lst).Take(8);
                    ////var lstPastData = (from lst in lstResultData where lst.ActivityDate <= DateTime.Today select lst).OrderByDescending(d => d.ActivityDate).Take(8);
                  
                    //foreach (DSR_ProgressData_BO lstData in lstPastData)
                    //{
                    //    lstPlannedData.Add(lstData);
                    //}
      
                    //foreach (DSR_ProgressData_BO lstData in lstFutureData)
                    //{
                    //    lstPlannedData.Add(lstData);
                    //}
      
      
      
      
                    foreach (DSR_ProgressData_BO _Data in lstPlannedChartData)
                    {
                        //TextBlock txtTick = (TextBlock)MyVisualTreeHelper.SearchFrameworkElement(rangeSlider, "txtTick");
                        //txtTick.Text = _Data.ActivityDate.ToString("dd/MM/yyyy");
                        //lstDates.Add(_Data.ActivityDate.ToString("dd/MM/yyyy"));
      
                        PlannedseriesMapping.ItemMappings.Add(new ItemMapping("Planned", DataPointMember.YValue));
                        PlannedseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
      
      
      
      
                        PassedseriesMapping.ItemMappings.Add(new ItemMapping("Passed", DataPointMember.YValue));
      
                        PassedseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
      
      
      
      
                        FailedseriesMapping.ItemMappings.Add(new ItemMapping("Failed", DataPointMember.YValue));
      
                        FailedseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
      
      
      
      
      
                        NotCompltedseriesMapping.ItemMappings.Add(new ItemMapping("NotCompleted", DataPointMember.YValue));
      
                        NotCompltedseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
      
                        DeScopedseriesMapping.ItemMappings.Add(new ItemMapping("DeScoped", DataPointMember.YValue));
      
                        DeScopedseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
                        BlockedseriesMapping.ItemMappings.Add(new ItemMapping("Blocked", DataPointMember.YValue));
      
                        BlockedseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
      
                        TCExecRateseriesMapping.ItemMappings.Add(new ItemMapping("AverageOriginalTargetDailyExecutionRate", DataPointMember.YValue));
      
                        TCExecRateseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
      
      
      
      
      
                        ACExecRateseriesMapping.ItemMappings.Add(new ItemMapping("ActualDailyExecutionrate", DataPointMember.YValue));
                        ACExecRateseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
      
      
      
                        ReqExecRateseriesMapping.ItemMappings.Add(new ItemMapping("AverageRequiredDailyExecutionrate", DataPointMember.YValue));
      
                        ReqExecRateseriesMapping.ItemMappings.Add(new ItemMapping("ActivityDate", DataPointMember.XCategory));
      
      
                    }
      
                     
      
                    RadChart1.SeriesMappings.Add(PassedseriesMapping);
      
                    RadChart1.SeriesMappings.Add(FailedseriesMapping);
                    RadChart1.SeriesMappings.Add(PlannedseriesMapping);
                    RadChart1.SeriesMappings.Add(NotCompltedseriesMapping);
      
                    RadChart1.SeriesMappings.Add(BlockedseriesMapping);
                    RadChart1.SeriesMappings.Add(DeScopedseriesMapping);
      
                    RadChart1.SeriesMappings.Add(TCExecRateseriesMapping);
      
                    RadChart1.SeriesMappings.Add(ACExecRateseriesMapping);
                    RadChart1.SeriesMappings.Add(ReqExecRateseriesMapping);
                    RadChart1.ItemsSource = lstPlannedChartData;
                     
                    //RadChart1.Width = 600;
                    //RadChart1.Height = 375;
                    RadChart1.DefaultView.ChartArea.AxisX.IsDateTime = true;
                    RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd/MM/yyyy";
                    RadChart1.DefaultView.ChartArea.AxisX.LabelRotationAngle = -90;
      
                    RadChart1.DefaultView.ChartLegendPosition = Telerik.Windows.Controls.Dock.Bottom;
                    RadChart1.DefaultView.ChartTitle.Content = "Planned Vs Actual";
                      
                }
                catch (Exception ex)
                {
                    throw ex;
                }
      
            }



    Regards,
    Kannan S
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 05 Sep 2012 Link to this post

    Hi,

    I reviewed the code, and it looks correct. However, based on the supplied information, it is hard to determine why the style settings are not applied. To further trace the issue, it will be best if you open a formal support ticket, and send us a small working example, demonstrating your setup. I will review it locally, and advise you further. Additionally, you may want to review the other alternatives to styling the series, outlined in this article:

    http://www.telerik.com/help/silverlight/radchart-styling-and-appearance-styling-chart-series.html

    Greetings,
    Yavor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top