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

Chart Not Displaying Bars

1 Answer 77 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 15 Jun 2012, 02:13 PM
I am having a problem with a chart I am trying to implement where it will not show any bars going up the bar graph.  A pie chart will display all of the data, but all other chart types fail.  I have confirmed the data is being entered into the dt and my code below shows you how I am doing this.  I have also included a screenshot of what the output on the graph is as well as a screenshot of the data after the loop completes.  Any help would be greatly appreciated.  

Protected Sub CreateChart()
        Dim dt As New DataTable
        Dim dc As DataColumn
        Dim dr As DataRow
        Dim ctr As Integer = 0
 
        Dim usableMonths As String = Me.Invoice.Custom45.ToString()
        Dim usableData As String = Me.Invoice.Custom46.ToString()
 
        Dim months() As String = usableMonths.Split(New [Char]() {","c})
        Dim data() As String = usableData.Split(New [Char]() {","c})
 
        dc = New DataColumn("XValues", Type.GetType("System.Int32"))
        dc.AutoIncrement = True
        dc.AutoIncrementSeed = 300
        dt.Columns.Add(dc)
 
        dc = New DataColumn("XDesc", Type.GetType("System.String"))
        dt.Columns.Add(dc)
 
        dc = New DataColumn("YValues", Type.GetType("System.Double"))
        dt.Columns.Add(dc)
 
        While ctr <= months.Length - 2
            dr = dt.NewRow
 
            If String.IsNullOrEmpty(months(ctr).ToString().Trim()) Then
                dr(1) = " "
            Else
                dr(1) = months(ctr)
            End If
 
            If String.IsNullOrEmpty(data(ctr).ToString().Trim()) Then
                dr(2) = 0
            Else
                dr(2) = Convert.ToDouble(data(ctr))
            End If
 
            dt.Rows.Add(dr)
 
            ctr += 1
        End While
 
        dt.AcceptChanges()
 
        Me.RadChart1.DataSource = dt
 
        Dim usage As New Telerik.Charting.ChartSeries("Usage", Telerik.Charting.ChartSeriesType.Bar)
        usage.DataXColumn = "XValues"
        usage.DataYColumn = "YValues"
        usage.Appearance.BarWidthPercent = 30
        usage.DefaultLabelValue = String.Empty
        usage.Visible = True
 
        Me.RadChart1.Series.Add(usage)
        Me.RadChart1.Width = Unit.Pixel(480)
        Me.RadChart1.Height = Unit.Pixel(200)
        Me.RadChart1.ChartTitle.Visible = False
        Me.RadChart1.Legend.Visible = False
        Me.RadChart1.PlotArea.XAxis.DataLabelsColumn = "XDesc"
        Me.RadChart1.PlotArea.XAxis.Appearance.TextAppearance.AutoTextWrap = Telerik.Charting.Styles.AutoTextWrap.True
        Me.RadChart1.PlotArea.XAxis.Appearance.MajorGridLines.Visible = False
        Me.RadChart1.PlotArea.XAxis.Appearance.MinorGridLines.Visible = False
        Me.RadChart1.PlotArea.YAxis.Appearance.MinorGridLines.Visible = False
        Me.RadChart1.PlotArea.Appearance.Dimensions.Margins.Top = Telerik.Charting.Styles.Unit.Pixel(20)
        Me.RadChart1.PlotArea.Appearance.Dimensions.Margins.Right = Telerik.Charting.Styles.Unit.Pixel(10)
        Me.RadChart1.PlotArea.Appearance.Dimensions.Margins.Bottom = Telerik.Charting.Styles.Unit.Pixel(40)
        Me.RadChart1.PlotArea.Appearance.Dimensions.Margins.Left = Telerik.Charting.Styles.Unit.Pixel(50)
        Me.RadChart1.Skin = "Classic"
 
        Me.RadChart1.DataBind()
    End Sub

1 Answer, 1 is accepted

Sort by
0
Tony
Top achievements
Rank 1
answered on 15 Jun 2012, 02:21 PM
We figured this out.  The dc.AutoIncrementSeed was set to 300 when it should have been 1
Tags
Chart (Obsolete)
Asked by
Tony
Top achievements
Rank 1
Answers by
Tony
Top achievements
Rank 1
Share this question
or