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

Removing points when using a collection of chartseries

2 Answers 254 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 01 May 2012, 05:25 AM
Hi,

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 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 03 May 2012, 11:53 AM
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.
0
Nick
Top achievements
Rank 1
answered on 04 May 2012, 12:47 AM
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.

 
Tags
Chart (Obsolete)
Asked by
Nick
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Nick
Top achievements
Rank 1
Share this question
or