We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Proper way to bind multiple series from SAME datasource

Thread ID:

Created:

Updated:

Platform:

Replies:

109162 May 31,2013 09:07 AM Jun 5,2013 03:14 PM Windows Forms 1
loading
Tags: Chart
Dennis Beaugrand
Asked On May 31, 2013 09:07 AM

How should I bind to one Context to a table that has 2 fields that I would like to plot as series?

I see that CartDataModel.YNames is an array but all the examples just use one member



Do I create two identical ChartDataBind Models like this:
        Dim Model1 As New ChartDataBindModel(Main.Context.NmsSummaries.Local.ToBindingList)
        Model1.XName = "TheDate"

        Model1.YNames = New String() {"Val1"}  ' why is this a array??
        Dim Series1 As New ChartSeries("Val1", ChartSeriesType.Line)
        Series1.Text = Series1.Name
        Series1.SeriesModel = Model1
        CC1.Series.Add(Series1)


        Dim Model2 As New ChartDataBindModel(Main.Context.NmsSummaries.Local.ToBindingList)
        Model2.XName = "TheDate"

        Model1.YNames = New String() {"Val2"}
        Dim Series2 As New ChartSeries("Val2", ChartSeriesType.Line)
        Series2.Text = Series2.Name
        Series2.SeriesModel = Model2
        CC1.Series.Add(Series1)


Or can I reuse the model somehow with  something like this that uses an array of YNames?

      Dim Model1 As New ChartDataBindModel(Main.Context.NmsSummaries.Local.ToBindingList)
        Model1.XName = "TheDate"

        Model1.YNames = New String() {"Val1", "Val2"} ' 
        Dim Series1 As New ChartSeries("Val1", ChartSeriesType.Line)
        Series1.Text = Series1.Name
        Series1.SeriesModel = Model1
        Series1.YVAL = Model1.YNames(0) ' - does not work
        CC1.Series.Add(Series1)


        Dim Series2 As New ChartSeries("Val2", ChartSeriesType.Line)
        Series2.Text = Series2.Name
        Series2.SeriesModel = Model1
        Series1.YVAL = Model1.YNames(1) ' - does not work
        CC1.Series.Add(Series1)



Anandaraj T [Syncfusion]
Replied On June 5, 2013 03:14 PM

Hi Dennis,

Thanks for using Syncfusion products.

The property "YNames" of ChartDataBindModel object is used to bind data in columns of the table to the y values of chart series points. This property is defined as an array because chart types like range area chart and heat map chart requires a minimum of two y values to plot and they need one column data for each y value. Hence, the "YNames" property cannot be used to bind a ChartDataBindModel  object with more than one series.

Please refer the following code snippet to bind a table data to more than one series:
[VB]

Function ReturnDataBindModel (ByVal ColumnName As String) As ChartDataBindModel

Dim Model1 As New ChartDataBindModel(Main.Context.NmsSummaries.Local.ToBindingList)

Model1.XName=”TheDate”

Model1.YNames=New String() {ColumnName}

Return Model1

End Sub

 

Sub Main()

Dim Series1 As New ChartSeries(“Val1”, ChartSeriesType.Line)

Series1.Text=Series1.Name

Series1.SeriesModel=ReturnDataBindModel(“Val1”)

CC1.Series.Add(Series1)

 

Dim Series2 As New ChartSeries(“Val2”, ChartSeriesType.Line)

Series2.Text=Series2.Name

Series2.SeriesModel=ReturnDataBindModel(“Val2”)

CC2.Series.Add(Series2)

End Sub

The ChartDataBindModel object can be reused as in the above code snippet to bind a table data with multiple series or we have to use one ChartDataBindModel  object for each series.

Please let us know if you have any concerns.

Regards,

Anandaraj

 



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;