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

Thread is closed for posting
5 posts, 0 answers
  1. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 13 Nov 2009 Link to this post

    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. 
  2. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 13 Nov 2009 Link to this post

    Here is an example
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 17 Nov 2009 Link to this post

    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 :)
  5. Joel
    Joel avatar
    166 posts
    Member since:
    Oct 2006

    Posted 17 Nov 2009 Link to this post

    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 
     

  6. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 17 Nov 2009 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017