Back

Update

Updates the chart object

myChart.update()

Parameter
undefined

Samples

Update - One Dataset

app.LoadPlugin('ChartJS')

function OnStart()
{
    chart = app.LoadChartJS()
    
    lay = app.CreateLayout('Linear', 'VCenter, FillXY')
        
        data = {
            labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
        	datasets: [
        	    {
            		label: 'Downloads',
            		backgroundColor: "#9C27B0",
            		borderColor: "#7B1FA2",
            		borderWidth: 1,
            		data: [20, 10, 80, 12, 35]
            	}
        	]
        }
        
        barChart = chart.CreateChart(data, 'bar', 0.9, 0.5)
        lay.AddChild(barChart)

        btn = app.CreateButton("Update Data", 1)
        btn.SetMargins(0, 0.1, 0, 0)
        lay.AddChild(btn)
        btn.SetOnTouch(updateChart)
        
    app.AddLayout(lay)
}

function updateChart()
{
    /*  we change the value of March from 80 to 50
        datasets[0] refers to the first dataset object in the datasets array
    */
    barChart.data.datasets[0].data[2] = 50

    barChart.update()
}
Copy Run