in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Can Recordset be datasource to a chart?

Last post 08-28-2007 12:13 PM by C1_GregL. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-08-2007 6:47 AM

    Can Recordset be datasource to a chart?

    Hellou,
    I would like to know if RecordSet can be Datasource to a chart. If so, how could I then set values for X and Y axis?

    Thanx for your help.

    Dado
  • 08-10-2007 11:19 AM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: Can Recordset be datasource to a chart?

    Not directly because Recordset objects do not implement the right datasource interface, but with an OleDBDataAdapter you can fill a dataTable with a recordset and simply assign the dataTable to the DataSource property of the chart.

    Imports System.Data.OleDB
    ...
    Dim da As New OleDbDataAdapter
    Dim dt As New DataTable("Table Name")
    da.Fill(dt, yourRecordSet)
    C1Chart1.DataSource = dt


    And then you set the X and Y dataFields to the column names from your recordset.

    C1Chart1.ChartGroups(0).ChartData.SeriesList(0).X.DataField = "col 1"
    C1Chart1.ChartGroups(0).ChartData.SeriesList(0).Y.DataField = "col 2"


    hope that helps some,
    -Greg L
  • 08-23-2007 4:29 PM In reply to

    Re: Can Recordset be datasource to a chart?

    What about C#.

    Plus, I don't see those properties in my Properties Window. This is the WebChart for .Net 2.0 correct?



    Michael
  • 08-28-2007 12:13 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: Can Recordset be datasource to a chart?

    Hi Michael,
    >>What about C#.

    using System.Data.OleDB;
    ...
    OleDbDataAdapter da = new OleDbDataAdapter();
    DataTable dt = new DataTable();
    da.Fill(dt, yourRecordSet);
    C1WebChart1.DataSource = dt;
    C1WebChart1.ChartGroups[0].ChartData.SeriesList[0].X.DataField = "col 1";
    C1WebChart1.ChartGroups[0].ChartData.SeriesList[0].Y.DataField = "col 2";

    I am assuming you have a recordset already set up.

     >>Plus, I don't see those properties in my Properties Window. This is the WebChart for .Net 2.0 correct?

    There is another forum for WebChart.  The DataSource property can be set in code but not in the designer.

    regards,
    Greg L

Page 1 of 1 (4 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.