Updates the data of a chart
Parameter
An array of arrays of numbers for the new data values
Samples
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: [5, 10, -4, 12, 15] } ] } 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() { var newData = [ [20, 45, 80, 70, 30] ] barChart.updateData(newData) }
app.LoadPlugin( "ChartJS" ) function OnStart() { chart = app.LoadChartJS() lay = app.CreateLayout("Linear", "FillXY, VCenter"); lay.SetBackColor("#ffffff"); var data = { labels: ["Jan", "Feb", "Mar", "Apr", "May"], datasets: [{ data: [20, 10, 30, 50, 76], backgroundColor: [ 'rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)' ], borderWidth: 4 }, { data: [50, 50, 30, 15, 30], backgroundColor: [ 'rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)' ], borderWidth: 4 }] } doughnutChart = chart.CreateChart(data, "doughnut", 0.95, 0.4) lay.AddChild(doughnutChart) btn = app.CreateButton("Update Both Dataset", 1) btn.SetMargins(0, 0.1, 0, 0) lay.AddChild(btn) btn.SetOnTouch(updateChart) app.AddLayout( lay ) } function updateChart() { var newData = [ [20, 45, 80, 70, 30], [100, 90, 80, 70, 60] ]; doughnutChart.updateData(newData) }