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

How to show only one ItemLabel in line series in radchart

1 Answer 104 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Dinesh
Top achievements
Rank 1
Dinesh asked on 30 Jan 2013, 08:58 AM
I'm using radchart,in tht chart i'm able to show 4 series(binding by programmatically) and in that one of the series is line as the value will be same for each x axis value.Now i want to hide the all ItemLabel except one ItemLabel i.e showing the item label at last x axis value,is there any way to show only one ItemLabel for the series.I'm able to remove the values but the how to remove the background color also.

here is code which i have written in the chart binding.

productChart.DataBound += (o, a) =>
            {
                var dataSeries = productChart.DefaultView.ChartArea.DataSeries[3];
                if (dataSeries != null)
                {
                    foreach (var point in dataSeries.ToList())
                    {
                        string units = point.XCategory;
                        //if (units == "LIVE Non-Field")
                        if (units == "Office for Mac")
                        {
                            Style pathStyle1 = new Style(typeof(System.Windows.Shapes.Path));
                            pathStyle1.Setters.Add(new Setter(Shape.StrokeProperty, new SolidColorBrush(Color.FromArgb(255, 120, 193, 121))));
                            pathStyle1.Setters.Add(new Setter(Shape.StrokeThicknessProperty, 2));

                            Style lineStyle1 = new Style(typeof(Telerik.Windows.Controls.Charting.LineSeries));
                            lineStyle1.Setters.Add(new Setter(LineSeries.BorderLineStyleProperty, pathStyle1));

                            point.LabelFormat = "#Y{P0}";

                            objSeriesMapping4.SeriesDefinition.SeriesItemLabelStyle = this.CustomStyle1;

                            //objSeriesMapping4.SeriesDefinition.SeriesItemLabelStyle = (Style)lineStyle1;
                            //objSeriesMapping4.SeriesDefinition.SeriesItemLabelStyle = this.CustomStyle;
                        }
                        else
                        {
                            objSeriesMapping4.SeriesDefinition.SeriesItemLabelStyle = this.CustomStyle;

                            Style pathStyle1 = new Style(typeof(System.Windows.Shapes.Path));
                            pathStyle1.Setters.Add(new Setter(Shape.StrokeProperty, new SolidColorBrush(Color.FromArgb(0, 255, 255, 255))));
                            pathStyle1.Setters.Add(new Setter(Shape.StrokeThicknessProperty, 2));

                            Style lineStyle1 = new Style(typeof(Telerik.Windows.Controls.Charting.LineSeries));
                            lineStyle1.Setters.Add(new Setter(LineSeries.BorderLineStyleProperty, pathStyle1));

                            point.Label = " ";
                            
                            //objSeriesMapping4.SeriesDefinition.SeriesItemLabelStyle = (Style)lineStyle1;
                        }
                    }
                }
            };

and CustomStyle,

<Style x:Name="CustomStyle" TargetType="telerik:SeriesItemLabel">
                                    <Setter Property="Foreground" Value="White" />
                                    <Setter Property="Background" Value="Transparent"/>
                                </Style>
                                <Style x:Name="CustomStyle1" TargetType="telerik:SeriesItemLabel">
                                    <Setter Property="Foreground" Value="White" />
                                    <Setter Property="Background" Value="Green"/>
                                </Style>

Thanks in Advance.

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 04 Feb 2013, 08:59 AM
Hi Dinesh,

You can find this task discussed in this help topic and this approach works correctly for me. I would suggest removing some of the styles to see what exactly causes the labels background to remain visible.

Best regards,
Ves
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
Dinesh
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or