Removing points when using a collection of chartseries

Thread is closed for posting
3 posts, 0 answers
  1. Nick
    Nick avatar
    2 posts
    Member since:
    May 2012

    Posted 01 May 2012 Link to this post


    I'm trying to hide all sections on a line graph where the Y value = 0.

    All the solutions i have found require me to use a single series bound to the charts data source property. I'm using a list of chart series that i add to the chart object, so the ItemDataBound event does not get fired.

    Attached is the output graph, i need to remove all points before the arrows on each series.

    Is there a way to do this? 

    Much appreciated
  2. Petar Marchev
    Petar Marchev avatar
    1023 posts

    Posted 03 May 2012 Link to this post

    Hi Nick,
    There is no out-of-the-box feature that would allow such a behavior. The chart thinks of zeros as valid values and that is why points are being plotted and a line is being drawn.

    1. I suggest that you consider removing these items (with zero values) from the items source before you pass it to the chart. 

    2. Another suggestion I can make is to attach a handler to the BeforeLayout event and iterate through all ChartSeriesItems. When you find an item with a value of 0 you can set its Empty property to true. And you can set the Appearance of these empty points to have a transparent color. Code below should help:
    <telerik:ChartSeries Type="Line" DataYColumn="Y" Appearance-EmptyValue-Line-Color="Transparent" />
    void radChart1_BeforeLayout(object sender, EventArgs e)
     foreach (var series in this.radChart1.Series)
      foreach (var item in series.Items)
       if (item.YValue == 0d)
         item.Empty = true;

    Note that this code will wipe away all items that have zero values, not just the ones before data starts appearing (before the "arrow"), so please remember to update this code to fit your scenario. 

    All the best,
    Petar Marchev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Nick
    Nick avatar
    2 posts
    Member since:
    May 2012

    Posted 03 May 2012 Link to this post

    Hi Petar,

    Thanks for that, much  appreciated.

    Option 2 worked with some tweaking, for other peoples info here what i did to get this to work when using the radchart object on the server side and chart series:

    Where ever the chart series get added to the radchart object  set these parameters:
    Series.Appearance.EmptyValue.Mode = Styles.EmtyValuesMode.Zero
    Series.Appearance.EmptyValue.Line.Color = Drawing.Color.Transparent
    Series.Appearance.EmptyValue.PointMark.Visible = False
    And use the code in the BeforeLayout as is shown in Petars code.

Back to Top