How to show only one ItemLabel in line series in radchart

2 posts, 0 answers
  1. Dinesh
    Dinesh avatar
    9 posts
    Member since:
    Nov 2012

    Posted 30 Jan 2013 Link to this post

    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.
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 04 Feb 2013 Link to this post

    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.

  3. DevCraft banner
Back to Top