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

Ho to prevent null values in series from showing line to axis

4 Answers 61 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 2
Joel asked on 13 Nov 2009, 09:36 PM
I have a line chart with 2 series.  series1 will always have less values than series2.   The last value of series1 causes the line do drop to the x axis, I would like it to just end.

  Private Sub MakeGraph(ByVal myyear As Int32, ByVal _Val1 As String, ByVal _val2 As String) 
        Dim table As DataTable 
        table = Get52WeekGraph 
        rctrend.DataSource = table 
        rctrend.DataBind() 
        rctrend.PlotArea.XAxis.DataLabelsColumn = "weekname" 
        Dim series1 As New Telerik.Charting.ChartSeries() 
        Dim series2 As New Telerik.Charting.ChartSeries() 
        rctrend.Series.Clear() 
        Dim minval As Double = 1000000 
        Dim maxval As Double = 0 
        For Each rowView As DataRowView In table.DefaultView 
            Dim seriesItem1 As New Telerik.Charting.ChartSeriesItem() 
            seriesItem1.Label.Visible = False 
            If Not IsDBNull(rowView("tyval")) Then 
                seriesItem1.YValue = CDbl(rowView("tyval")) 
                If seriesItem1.YValue < minval Then minval = seriesItem1.YValue 
                If seriesItem1.YValue > maxval Then maxval = seriesItem1.YValue 
                series1.DataLabelsColumn = rowView("weekname") 
            End If 
 
            series1.AddItem(seriesItem1) 
            Dim seriesItem2 As New Telerik.Charting.ChartSeriesItem() 
            seriesItem2.Label.Visible = False   
            If Not IsDBNull(rowView("lyval")) Then 
                seriesItem2.YValue = CDbl(rowView("lyval")) 
                If seriesItem2.YValue < minval Then minval = seriesItem2.YValue 
                If seriesItem2.YValue > maxval Then maxval = seriesItem2.YValue 
                series1.DataLabelsColumn = rowView("weekname") 
            End If 
            series2.AddItem(seriesItem2) 
        Next 
 
        series1.Name = _Val1 
        series2.Name = _val2 
 
        Dim valdiff As Double 
        Dim mybuff As Double 
        Dim mystep As Double 
        valdiff = maxval - minval 
 
 
        mybuff = valdiff * 0.2 
        minval = CInt(minval - mybuff) 
        maxval = CInt(maxval + mybuff) 
        mystep = (maxval - minval) / 10 
 
        rctrend.Series.Add(series1) 
        rctrend.Series.Add(series2) 
        rctrend.PlotArea.Chart.DefaultType = Telerik.Charting.ChartSeriesType.Line 
        rctrend.PlotArea.YAxis.AutoScale = False 
        rctrend.PlotArea.YAxis.IsZeroBased = False 
        rctrend.PlotArea.YAxis.MinValue = minval 
        rctrend.PlotArea.YAxis.MaxValue = maxval 
        rctrend.PlotArea.YAxis.Step = mystep 
        rctrend.PlotArea.XAxis.MaxValue = 52 
 
        rctrend.ChartTitle.TextBlock.Text = "Score" 
End Sub 
d with the last real value. 

4 Answers, 1 is accepted

Sort by
0
Joel
Top achievements
Rank 2
answered on 13 Nov 2009, 09:44 PM
Here is an example
0
Schlurk
Top achievements
Rank 2
answered on 17 Nov 2009, 08:47 PM
I had a discussion regarding this a while back and a Telerik team member posted in the thread with a solution. The thread can be found here. You basically set the line to be transparent :)
0
Joel
Top achievements
Rank 2
answered on 17 Nov 2009, 09:19 PM
Thank you Schlurk.  I added the following lines right after the series are created and it did not seem to have any effect on the display results unfortunately.



        series1.Appearance.EmptyValue.Mode = Styles.EmtyValuesMode.Zero 
        series1.Appearance.EmptyValue.Line.Color = Drawing.Color.Transparent 
        series1.Appearance.EmptyValue.PointMark.Visible = False 
        series2.Appearance.EmptyValue.Mode = Styles.EmtyValuesMode.Zero 
        series2.Appearance.EmptyValue.Line.Color = Drawing.Color.Transparent 
        series2.Appearance.EmptyValue.PointMark.Visible = False 
 

0
Schlurk
Top achievements
Rank 2
answered on 17 Nov 2009, 09:28 PM
I posted this earlier in the thread, and this doesn't work with all of the series types but you could use the following code in the ItemDataBound event:
 
if (e.SeriesItem.YValue == 0.0)  
{  
     e.SeriesItem.Parent.Items.Remove(e.SeriesItem);  
}  

I've used this in previous implementations and it's worked like a charm, but again it depends on your series type. Let me know if this works instead.
Tags
Chart (Obsolete)
Asked by
Joel
Top achievements
Rank 2
Answers by
Joel
Top achievements
Rank 2
Schlurk
Top achievements
Rank 2
Share this question
or