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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Using Charts

Thread ID:

Created:

Updated:

Platform:

Replies:

144298 Apr 29,2019 03:54 PM UTC May 6,2019 09:17 AM UTC WinForms 5
loading
Tags: Chart
Ricardo Abranches
Asked On April 29, 2019 03:54 PM UTC

i tried to use the chart object acording to the example of https://help.syncfusion.com/windowsforms/chart/getting-started?cs-save-lang=1&cs-lang=vb

But it dos not work. here is my code.
i have a datatable with data, 2 columns "Mes" and "Total"

With Graf_3
            Dim dataSeriesModel As CategoryAxisDataBindModel = New CategoryAxisDataBindModel(oPane.Vendas_Ano(2015, 0))
            dataSeriesModel.CategoryName = "Mes"
            dataSeriesModel.YNames = New String() {"Total"}
            Dim chartSeries As ChartSeries = New ChartSeries("Total")
            chartSeries.CategoryModel = dataSeriesModel
            .PrimaryXAxis.ValueType = ChartValueType.Category
            .Refresh()
        End With

can some one give an example in vb.net that uses a 2 column datatable to draw a chart ?

thanks
Ricardo

Baby Palanidurai [Syncfusion]
Replied On April 30, 2019 12:06 PM UTC

Hi Ricardo, 

Greetings from Syncfusion. 

We have analyzed your query. Based on your requirement, we have prepared a sample in VB.NET. Please find the below code snippet to achieve this requirement, 

Dim dataSource As New BindingList(Of SalesData)() 
dataSource.Add(New SalesData("2000", 3)) 

Dim dataSeriesModel As New CategoryAxisDataBindModel(dataSource) 
dataSeriesModel.CategoryName = "Mes" 
dataSeriesModel.YNames = New String() { "Total" } 
Dim chartSeries As New ChartSeries("Total") 
chartSeries.CategoryModel = dataSeriesModel 
Me.chart1.PrimaryXAxis.ValueType = ChartValueType.Category 
Me.chart1.Series.Add(chartSeries) 
Me.Controls.Add(chart1) 

Screenshot: 
 


If the above sample doesn’t meet your requirement, kindly revert us with clear details about requirement. Thus will be helpful in furthermore analysis and provide you the solution sooner. 

Regards, 
Baby. 


Ricardo Abranches
Replied On May 5, 2019 11:28 AM UTC

Hello Baby
It did not solve my problem, but gave me the clues to solve it.
However, it raised a new problem. When using ".Series.Add (chartSeries)" each time the chart is updated, a series is created. How can I do to update the values of the created series?

Baby Palanidurai [Syncfusion]
Replied On May 6, 2019 08:42 AM UTC

Hi Ricardo, 
  
We have analyzed your query. Based on your requirement, we have prepared a sample with button click. In that sample, initially loaded a chart with single point. Then button click we have changed the chart series points values and assigned to the already created series instead of creating again. And then redraw the charts. 
 
Please find the below code snippet to achieve this requirement, 
 
Private buttonOk As New Button() 
Private chart1 As ChartControl = New Syncfusion.Windows.Forms.Chart.ChartControl() 
Public Sub New() 
              Me.buttonOk.Text = "Click to Change data" 
              AddHandler Me.buttonOk.Click, AddressOf ButtonOk_Click 
              Me.buttonOk.Width = 200 
              Me.Size = New Size(1200, 500) 
              Me.chart1.Location = New Point(10, 40) 
              Me.chart1.Size = New Size(1100, 400) 
              Dim dataSource As New BindingList(Of SalesData)() 
              dataSource.Add(New SalesData("2000", 3)) 
              Dim dataSeriesModel As New CategoryAxisDataBindModel(dataSource) 
              dataSeriesModel.CategoryName = "Mes" 
              dataSeriesModel.YNames = New String() { "Total" } 
              Dim chartSeries As New ChartSeries("Total") 
              chartSeries.CategoryModel = dataSeriesModel 
              Me.chart1.PrimaryXAxis.ValueType = ChartValueType.Category 
              Me.chart1.Series.Add(chartSeries) 
              Me.Controls.Add(buttonOk) 
              Me.Controls.Add(chart1) 
End Sub 
 
Private Sub ButtonOk_Click(ByVal sender As Object, ByVal e As EventArgs) 
              Dim dataSource As New BindingList(Of SalesData)() 
              dataSource.Add(New SalesData("2000", 13)) 
              Dim dataSeriesModel As New CategoryAxisDataBindModel(dataSource) 
              dataSeriesModel.CategoryName = "Mes" 
              dataSeriesModel.YNames = New String() { "Total" } 
              Me.chart1.Series(0).CategoryModel = dataSeriesModel 
              Me.chart1.Redraw(True) 
End Sub 
 
Screenshot: 
 
Before button click: 
 
 
After button click: 
 
 
 
 
 
If the above doesn’t meet your requirement, kindly revert us with more details about your requirement which will be helpful to give the best solution. 
  
Regards, 
Baby. 


Ricardo Abranches
Replied On May 6, 2019 09:10 AM UTC

Hi Baby,
thanks for your help :-)


Baby Palanidurai [Syncfusion]
Replied On May 6, 2019 09:17 AM UTC

Ricardo,

Most welcome. Kindly revert us, if you need further assistance. We are always happy in assisting you.


Regards,
Baby.

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon