Back

clear

This method clears the chart canvas. Used extensively internally between animation frames, but you might find it useful.

myChart.clear()

Parameter
undefined

Samples

Example - Clear

app.LoadPlugin( "ChartJS" );

function OnStart() {
    chart = app.LoadChartJS()
    
    lay = app.CreateLayout("Linear", "FillXY, VCenter")
    lay.SetBackColor("#ffffff")

        data = {
            labels: ["Jan", "Feb", "Mar", "Apr", "May"],
            datasets: [{
                data: [50, 50, 30, 15, 30],
                backgroundColor: ["#f44336", "#e91e63", "#9c27b0", "#3f51b5", "#009688"],
                borderWidth: 4
            }]
        }

        pieChart = chart.CreateChart(data, "pie", 0.95, 0.4)
        lay.AddChild(pieChart)

        btn = app.CreateButton("STOP", 0.4)
        btn.SetMargins(0, 0.1, 0, 0)
        lay.AddChild(btn)
        btn.SetOnTouch(function() {
            pieChart.stop()
        });

        btn = app.CreateButton("RENDER", 0.4)
        btn.SetMargins(0, 0.025, 0, 0)
        lay.AddChild(btn)
        btn.SetOnTouch(function() {
            pieChart.render()
        })

    app.AddLayout( lay )
}
Copy Run