Web 2: Updating WebChart Data

Hello,

The following example WebChart is created from the Opening event of a WebPage.

Var data() As Double
data.Add(10)
data.Add(20)
data.Add(30)
data.Add(40)

Var data2() As Double
data2.Add(15)
data2.Add(25)
data2.Add(35)
data2.Add(45)


Var series1 As New WebChartLinearDataset("Bar Data", &cFF0000, True, data)
series1.ChartType = WebChartLinearDataset.ChartTypes.Bar
Me.AddDataset(series1)

Var series2 As New WebChartLinearDataset("Line Data", &c0000FF, True, data2)
series2.ChartType = WebChartLinearDataset.ChartTypes.Line
Me.AddDataset(series2)

Me.AddLabels("North", "South", "East", "West")

From a different event how do I update read the value of East (index 3) from Series1, perform a calculation on that value then update that value in the Chart.

I’m guessing I might access series1 from the chart as Chart1.RowAt or Chart1.DatasetAt? but I don’t seem to have it sussed yet.

Any pointers, would be appreciated.

Kind regards, Andrew

The best way I see to do this is the following:

var series1 as WebChartLinearDataset = WebChartLinearDataset( Chart1.DatasetAt(0) ) // Get the dataset to mofify
series1.RowAt(2) = series1.RowAt(2) + System.Random.InRange( -1, 1 ) // Change a value
chart1.DatasetAt(0) = series1 // Reassign the dataset

Hope that helps.

1 Like

@Anthony_G_Cyphers,

Wonderful thank you Anthony!

I wasn’t too far off, I think I just missed the second WebChartLinearDataset() on the first line.

An example like this really needs to be added to the docs or added to the Chart example project.

Thank you.

Kind regards, Andrew

Happy to help.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.