none
Not able to display more than 500 points in MS Chart RRS feed

  • Question

  • Hi I wrote the following program in vb.net. I am reading 2000 data points XY points from csv file into oledb connection and displaying it into the MS cHART but it is displaying only first 500 points... any idea?

     

     Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\;Extended Properties=""Text;HDR=No;FMT=Delimited""")

            Dim da As New OleDbDataAdapter()

            Dim ds As New DataSet()



            Dim cd As New OleDbCommand("SELECT * FROM C:\Users\VICKY\Documents\TEMPDATA1.CSV", cn)

            cn.Open()


            da.SelectCommand = cd

            dt.Clear()
            ds.Clear()
            da.Fill(dt)

            da.Fill(ds)

            ' With Chart1.Series(0).Points.DefaultIfEmpty(dt.

            With Chart1.Series(0)
                .Points.DataBind(dt.DefaultView, "", "", Nothing)
                .ChartType = DataVisualization.Charting.SeriesChartType.Line
                .BorderWidth = 4
            End With

            Chart1.Update()


            cn.Close()

     

    Thanks for your help

    Saturday, January 7, 2012 8:52 AM

Answers

  • Vow..it works now...i added following to my code:

     

       For I As Integer = 0 To 20000
                dt.Rows.Add(I)
                With Chart1.Series(0)
                    .Points.DataBind(dt.DefaultView, "", "", Nothing)
                End With
                Chart1.Update()
            Next I

    So the final code looks like following , great thanks for your help Thorsten...

     

     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

            Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\;Extended Properties=""Text;HDR=No;FMT=Delimited""")
            Dim da As New OleDbDataAdapter()
            Dim ds As New DataSet()
            Dim cd As New OleDbCommand("SELECT * FROM C:\Users\VICKY\Documents\TEMPDATA1.CSV", cn)
            cn.Open()

            da.SelectCommand = cd

            dt.Clear()
            ds.Clear()
            da.Fill(dt)

            For I As Integer = 0 To 20000
                dt.Rows.Add(I)
                With Chart1.Series(0)
                    .Points.DataBind(dt.DefaultView, "", "", Nothing)
                End With
                Chart1.Update()
            Next I

            cn.Close()
        End Sub

    • Marked as answer by Vishal Patel Saturday, January 7, 2012 8:34 PM
    Saturday, January 7, 2012 8:34 PM

All replies

  • Hi,

    whats the row-count of your DataTable?

    Test-display more than 500 points in a chart:

    Public Class Form1
    
        Dim mRnd As New Random()
    
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Dim dt As New DataTable()
            dt.Columns.Add("")
    
            For i As Integer = 0 To 1000
                Dim dr As DataRow = dt.NewRow
                dr(0) = mRnd.Next(1000).ToString
                dt.Rows.Add(dr)
            Next
    
            Me.ClientSize = New Size(1024, Me.ClientSize.Height)
            Chart1.Dock = DockStyle.Fill
    
            With Chart1.Series(0)
                .Points.DataBind(dt.DefaultView, "", "", Nothing)
                .ChartType = DataVisualization.Charting.SeriesChartType.Line
                .BorderWidth = 1
            End With
        End Sub
    End Class
    

    Regards,

      Thorsten

    Saturday, January 7, 2012 10:30 AM
  • Your code works....i am able to display more than 500  points..but how can i increase row counts of my data table...

     

    thanks

    Saturday, January 7, 2012 5:52 PM
  • Your code works....i am able to display more than 500  points..but how can i increase row counts of my data table...

    ...

    The row-count is the amount of dataRows in your DataTable. If your DataBase-table (csv-file) only has 500 records the row count will be 500 when filling the table with the data...

    Regards,

      Thorsten

    Saturday, January 7, 2012 6:10 PM
  • Right..my row count is 2000
    Saturday, January 7, 2012 7:25 PM
  • well.. when i use the function dt.rows.count() it is giving me a value of 1839..so looks like the datatable has all the values it is just it is not displaying...it
    • Marked as answer by Vishal Patel Saturday, January 7, 2012 8:32 PM
    • Unmarked as answer by Vishal Patel Saturday, January 7, 2012 8:32 PM
    Saturday, January 7, 2012 7:33 PM
  • Vow..it works now...i added following to my code:

     

       For I As Integer = 0 To 20000
                dt.Rows.Add(I)
                With Chart1.Series(0)
                    .Points.DataBind(dt.DefaultView, "", "", Nothing)
                End With
                Chart1.Update()
            Next I

    So the final code looks like following , great thanks for your help Thorsten...

     

     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

            Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\;Extended Properties=""Text;HDR=No;FMT=Delimited""")
            Dim da As New OleDbDataAdapter()
            Dim ds As New DataSet()
            Dim cd As New OleDbCommand("SELECT * FROM C:\Users\VICKY\Documents\TEMPDATA1.CSV", cn)
            cn.Open()

            da.SelectCommand = cd

            dt.Clear()
            ds.Clear()
            da.Fill(dt)

            For I As Integer = 0 To 20000
                dt.Rows.Add(I)
                With Chart1.Series(0)
                    .Points.DataBind(dt.DefaultView, "", "", Nothing)
                End With
                Chart1.Update()
            Next I

            cn.Close()
        End Sub

    • Marked as answer by Vishal Patel Saturday, January 7, 2012 8:34 PM
    Saturday, January 7, 2012 8:34 PM

  •         For I As Integer = 0 To 20000
                dt.Rows.Add(I)
                With Chart1.Series(0)
                    .Points.DataBind(dt.DefaultView, "", "", Nothing)
                End With
                Chart1.Update()
            Next I

     

    This I dont understand. You first fill the Table with the DataAdapter with the data, which is correct IMO.

    But then you add 20001 rows with one field and a value of the current loopCounter and also bind the data 20001 times to the chart. That I do not understand...

    Regards,

      Thorsten


    Saturday, January 7, 2012 9:46 PM