RadChart Programmatically

2 posts, 0 answers
  1. Gonzalo
    Gonzalo avatar
    76 posts
    Member since:
    Oct 2012

    Posted 13 Mar 2012 Link to this post

    Is there a way to write this in winforms. I got this example from silverlight docs.
    Private Function CreateChart_DefaultView() As Telerik.Windows.Controls.RadChart
        Dim telerikChart As New Telerik.Windows.Controls.RadChart()
        'Chart Title
        telerikChart.DefaultView.ChartTitle.Content = "Year 2009"
        telerikChart.DefaultView.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center
        'Chart Legend
        telerikChart.DefaultView.ChartLegend.UseAutoGeneratedItems = True
        'Line Chart
        Dim lineSeries As New DataSeries()
        lineSeries.LegendLabel = "Turnover"
        lineSeries.Definition = New LineSeriesDefinition()
        Dim dataPoint As New DataPoint()
        dataPoint.YValue = 154
        dataPoint.XCategory = "Jan"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 138
        dataPoint.XCategory = "Feb"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 143
        dataPoint.XCategory = "Mar"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 120
        dataPoint.XCategory = "Apr"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 135
        dataPoint.XCategory = "May"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 125
        dataPoint.XCategory = "Jun"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 179
        dataPoint.XCategory = "Jul"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 170
        dataPoint.XCategory = "Aug"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 198
        dataPoint.XCategory = "Sep"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 187
        dataPoint.XCategory = "Sep"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 193
        dataPoint.XCategory = "Nov"
        lineSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 176
        dataPoint.XCategory = "Dec"
        lineSeries.Add(dataPoint)
        telerikChart.DefaultView.ChartArea.DataSeries.Add(lineSeries)
        'Bar Chart
        Dim barSeries As New DataSeries()
        barSeries.LegendLabel = "Expenses"
        barSeries.Definition = New BarSeriesDefinition()
        dataPoint = New DataPoint()
        dataPoint.YValue = 45
        dataPoint.XCategory = "Jan"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 48
        dataPoint.XCategory = "Feb"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 53
        dataPoint.XCategory = "Mar"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 41
        dataPoint.XCategory = "Apr"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 32
        dataPoint.XCategory = "May"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 28
        dataPoint.XCategory = "Jun"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 63
        dataPoint.XCategory = "Jul"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 74
        dataPoint.XCategory = "Aug"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 77
        dataPoint.XCategory = "Sep"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 85
        dataPoint.XCategory = "Oct"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 89
        dataPoint.XCategory = "Nov"
        barSeries.Add(dataPoint)
        dataPoint = New DataPoint()
        dataPoint.YValue = 80
        dataPoint.XCategory = "Dec"
        barSeries.Add(dataPoint)
        telerikChart.DefaultView.ChartArea.DataSeries.Add(barSeries)
        Return telerikChart
    End Function
    I am well versed on using winforms chart control. I would like to do the same using RadChart. A few examples would be nice. Thank you.

    G
  2. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 16 Mar 2012 Link to this post

    Hello Gonzalo,

    As I can see from the code snippet you sent , the Chart was manually populated with data. This is absolutely possible with RadChart for Winforms. Since you are new to the control, I suggest that you review our documentation as well as online demos which I believe you will find a helpful starting guide.
    You'll find this approach of manually populating the chart with data also derscribed in the resources I mentioned.

    Regards,
    Evgenia
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top