in

C1 Community

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

Multiple chart in same ChartArea

Last post 02-20-2008 12:17 AM by pragati_sd. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-15-2008 6:18 AM

    Multiple chart in same ChartArea

    Hello!!

    I want to show two lines of charts within same chartarea. I'm trying  with the following code -

    ********************************************************************************************************************************

    Dim dtChart1 As New DataTable

    Dim dtChart2 As New DataTable

    dtChart1 = m_oIPOController.GetCrowdPricingDetails(m_oIPOCompanyInfo.IPOCompanyId, UserID).Tables(0)

    dtChart2 = m_oIPOController.GetCrowdPricingDetailsAll(m_oIPOCompanyInfo.IPOCompanyId).Tables(0)

    C1WebChart1.DataSource = dtChart1

    C1WebChart1.DataBind()

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(0).X.DataField = Convert.ToString(dtChart1.Columns(1).ColumnName)

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(0).Y.DataField = Convert.ToString(dtChart1.Columns(0).ColumnName)

    C1WebChart1.DataSource = dtChart2

    C1WebChart1.DataBind()

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(1).X.DataField = Convert.ToString(dtChart2.Columns(1).ColumnName)

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(1).Y.DataField = Convert.ToString(dtChart2.Columns(0).ColumnName)

     *******************************************************************************************************************************************************

    But, it is showing me only one line of chart.

    Can anyone help out??

    Pragati 

     

     

    Filed under:
  • 02-15-2008 7:51 AM In reply to

    Re: Multiple chart in same ChartArea

    You will have to keep the X axis for both the ChartGroups same and different field to the Y axis of both the chartgroups chartgroup0 and chartgroup1.
     
    Regards,
    Patrick
    <pragati_sd> wrote in message news:201984@10.0.1.98...

    Hello!!

    I want to show two lines of charts within same chartarea. I'm trying  with the following code -

    ********************************************************************************************************************************

    Dim dtChart1 As New DataTable

    Dim dtChart2 As New DataTable

    dtChart1 = m_oIPOController.GetCrowdPricingDetails(m_oIPOCompanyInfo.IPOCompanyId, UserID).Tables(0)

    dtChart2 = m_oIPOController.GetCrowdPricingDetailsAll(m_oIPOCompanyInfo.IPOCompanyId).Tables(0)

    C1WebChart1.DataSource = dtChart1

    C1WebChart1.DataBind()

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(0).X.DataField = Convert.ToString(dtChart1.Columns(1).ColumnName)

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(0).Y.DataField = Convert.ToString(dtChart1.Columns(0).ColumnName)

    C1WebChart1.DataSource = dtChart2

    C1WebChart1.DataBind()

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(1).X.DataField = Convert.ToString(dtChart2.Columns(1).ColumnName)

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(1).Y.DataField = Convert.ToString(dtChart2.Columns(0).ColumnName)

     *******************************************************************************************************************************************************

    But, it is showing me only one line of chart.

    Can anyone help out??

    Pragati 

     

     



    http://helpcentral.componentone.com/cs/forums/p/74338/201984.aspx#201984

  • 02-15-2008 8:02 AM In reply to

    Re: Multiple chart in same ChartArea

    Thanks for reply. But, will u plz tell me through the changes in Code??

    Actually both the datatables -  dtChart1 & dtChart2 are having same columns - BuyPrice & NoOfShares.

    But, I need those chart lines in same chart area with two colors of line.

    Pragati 

     

    Filed under:
  • 02-19-2008 7:53 AM In reply to

    Re: Multiple chart in same ChartArea

    Hi Pragati,
     
    I think you can get the data from both the tables in a new table and then use the following code to bind the chart as:
     
    <pragati_sd> wrote in message news:201988@10.0.1.98...

    Thanks for reply. But, will u plz tell me through the changes in Code??

    Actually both the datatables -  dtChart1 & dtChart2 are having same columns - BuyPrice & NoOfShares.

    But, I need those chart lines in same chart area with two colors of line.

    Pragati 

     



    http://helpcentral.componentone.com/cs/forums/p/74338/201988.aspx#201988

  • 02-19-2008 7:54 AM In reply to

    Re: Multiple chart in same ChartArea

    I think you can get the data from both the database into a new table and then bind the chart with the new table as:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim dv As Data.DataView = Me.SqlDataSource1.Select(New DataSourceSelectArguments)

    ' bind chart to table (each series will bind to a field on the table)_ c1chart.DataSource = dt

    Me.C1WebChart1.DataSource = dv

    Me.C1WebChart1.DataBind()

    ' clear data series collection

    Dim dsc As ChartDataSeriesCollection = Me.C1WebChart1.ChartGroups(0).ChartData.SeriesList

    dsc.Clear()

    ' add unit price series

    Dim ds As ChartDataSeries = dsc.AddNewSeries()

    'ds.AutoEnumerate = true' (in case you don't want to set the X values)

    ds.X.DataField = "ProductID"

    ds.Y.DataField = "CategoryID"

    ' add units in stock series

    Dim dsc1 As ChartDataSeriesCollection = Me.C1WebChart1.ChartGroups(1).ChartData.SeriesList

    dsc1.Clear()

    Dim ds1 As ChartDataSeries = dsc1.AddNewSeries()

    ds = dsc1.AddNewSeries()

    ds1.X.DataField = "ProductID"

    ds1.Y.DataField = "SupplierID"

    ' apply filters, sorting, etc

    End Sub

    Regards,

    Patrick

    <pragati_sd> wrote in message news:201988@10.0.1.98...

    Thanks for reply. But, will u plz tell me through the changes in Code??

    Actually both the datatables -  dtChart1 & dtChart2 are having same columns - BuyPrice & NoOfShares.

    But, I need those chart lines in same chart area with two colors of line.

    Pragati 

     



    http://helpcentral.componentone.com/cs/forums/p/74338/201988.aspx#201988

  • 02-20-2008 12:17 AM In reply to

    Re: Multiple chart in same ChartArea

    Thanks Patrick!!

    I've done it this way -

    **************************************************************************************************************************** 

    Dim dtChart1 As New DataTableDim dtChart2 As New DataTable

    dtChart1 = m_oIPOController.GetCrowdPricingDetails(m_oIPOCompanyInfo.IPOCompanyId, UserID).Tables(0)

    dtChart2 = m_oIPOController.GetCrowdPricingDetailsAll(m_oIPOCompanyInfo.IPOCompanyId).Tables(0)

    Dim dtMerge As New DataTableDim dtCopy As New DataTable

    dtCopy = dtChart1.Copy()

    dtCopy.Columns.RemoveAt(2)

    dtMerge.Merge(dtCopy, True, MissingSchemaAction.Add)

    dtMerge.Columns.Add("NoShares", GetType(System.Decimal))

    Dim r As DataRow = Nothing

    For Each dr As DataRow In dtChart2.Rows

    r = dtMerge.NewRow()

    r(
    "BuyPrice") = dr("BuyPrice")

    r("NumberOfShares") = DBNull.Value

    r("NoShares") = dr("NumberOfShares")

    dtMerge.Rows.Add(r)

    Next

    C1WebChart1.DataSource = dtMerge

    C1WebChart1.DataBind()

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(0).X.DataField = Convert.ToString(dtMerge.Columns(0).ColumnName)

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(0).Y.DataField = Convert.ToString(dtMerge.Columns(1).ColumnName)

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(1).X.DataField = Convert.ToString(dtMerge.Columns(0).ColumnName)

    C1WebChart1.ChartGroups.Group0.ChartData.SeriesList(1).Y.DataField = Convert.ToString(dtMerge.Columns(2).ColumnName)

    C1WebChart1.ChartArea.AxisX.Text = "Buy Price"

    C1WebChart1.ChartArea.AxisY.Text = "No of Shares"

    ****************************************************************************************************************************

    It works fine....

    Pragati

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