C1LineChart: Can three lines be displayed after databinding?

Posted by: debarupa2012 on 10 September 2017, 11:46 am EST

  • Posted 10 September 2017, 11:46 am EST

    I am trying to display a number of values for 3 different products in the same chart like the example here (http://demo.componentone.com/ASPNET/ControlExplorer/C1LineChart/DateTime.aspx).

    The values that are coming from the business classes are like the following:

    Product1, val1, val2, val3 etc.
    Product2, val21, val22, val23 etc.
    Product3, val31, val32, val33 etc.

    How can I achieve this? How do I use databind for these values or plot these values manually from the code behind?

    I tried to use the following but didn't work:
    C1LineChartToken.SeriesList.Add(New LineChartSeries)
    Dim cd As New ChartSeriesData
    Dim xl = New ChartXAxisList()
    xl.Add("Period1")
    xl.Add("Period2")
    cd.X = xl
    C1LineChartToken.SeriesList(0).Data = cd


    Please help!
    Thanks in advance!
  • Replied 10 September 2017, 11:46 am EST

    Is it possible to add a trendline to the linechart?
  • Replied 10 September 2017, 11:46 am EST

    Hello Vijay,

    Currently, there is no direct property to create trendlines in LineChart. I have made an enhancement request for the same to the developer; however, I cannot commit as to when/if it would be taken into consideration.

    As a workaround, you may use our Composite Chart and can refer to the following online demo of same:
    http://demo.componentone.com/ASPNET/ControlExplorer/C1CompositeChart/ComboRegression.aspx

    The logic for making trend lines has to be programmed by you and a new series is added with the required data.

    Regards
    Ashish
  • Replied 10 September 2017, 11:46 am EST

    Hello Debarupa,

    If you want to plot values by adding then manually to the serieslist, then you may create an array and set it to the X/Y property of LincChartSeries. Here is the basic code for same :

    Dim xp(9), xp2(9) As Double
    Dim yp(9), yp2(9) As Double

    Dim i As Integer
    For i = 0 To 9
    xp(i) = i
    yp(i) = i * i
    Next

    For i = 0 To 5
    xp2(i) = 2 * i
    yp2(i) = i * 1.5
    Next

    Dim lcs As New C1.Web.Wijmo.Controls.C1Chart.LineChartSeries
    lcs.Data.X.AddRange(xp)
    lcs.Data.Y.AddRange(yp)
    lcs.Label = "First Series"

    Dim lcs2 As New C1.Web.Wijmo.Controls.C1Chart.LineChartSeries
    lcs2.Data.X.AddRange(xp2)
    lcs2.Data.Y.AddRange(yp2)
    lcs2.Label = "Second Series"

    C1LineChart1.SeriesList.Add(lcs)
    C1LineChart1.SeriesList.Add(lcs2)


    In your code, it seems that you have not set the Y values and hence, the chart is not plotted.

    If you binding it to database, then you may create multiple objects of C1ChartBinding and can bind each to different column for plotting different data.

    Let me know if you have any questions or face any problem then kindly post a small sample replicating the issue so that I can check and can assist you accordingly.

    Regards
    Ashish
  • Replied 10 September 2017, 11:46 am EST

    Thanks Ashish, this is exactly what I was looking for.

    Thank you so much!!!
  • Replied 10 September 2017, 11:46 am EST

    Thanks a lot. If you have any sample code to get trend line points, please post.

    -Vijay
  • Replied 10 September 2017, 11:46 am EST

    Hello Vijay,

    As mentioned in previous post, you may refer to the following online demo of same:
    http://demo.componentone.com/ASPNET/ControlExplorer/C1CompositeChart/ComboRegression.aspx

    and can check the same at the following location on your machine:
    C:UsersstduserDocumentsComponentOne SamplesStudio for ASP.NET WijmoASP.NET WebFormsCSControlExplorer

    Regards
    Ashish
  • Replied 10 September 2017, 11:46 am EST

    Hello,

    The Trendline feature has been added in the latest version and can refer to the following demo implementing the same:
    http://demo.componentone.com/ASPNET/ControlExplorer/C1BarChart/Trendline.aspx

    Regards
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels