Chart js

105 views
Skip to first unread message

Fatih Elitas

unread,
Oct 23, 2025, 2:30:53 PMOct 23
to DroidScript
Hello;

I'm using the Chart JS plugin.
How can I save the resulting chart imagine in JPEG or PNG format?

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]
            }
        ]
        }
       
        hbar = chart.CreateChart(data, 'horizontalBar', 0.9, 0.5)
        lay.AddChild(hbar)
       
    app.AddLayout(lay)
}


Jumar

unread,
Oct 24, 2025, 10:30:34 PMOct 24
to DroidScript
Try this:

setTimeout(() => {
        hbar.Execute("chart.toBase64Image()", img => {
            app.WriteFile("myFile.png", img, "Base64")
        })
    }, 2000)

I wrap the code in timeout so that we made sure the chart is loaded before saving the image:

Fatih Elitas

unread,
Oct 27, 2025, 2:48:01 PMOct 27
to DroidScript
thank you jumar.

25 Ekim 2025 Cumartesi tarihinde saat 05:30:34 UTC+3 itibarıyla Jumar şunları yazdı:
Reply all
Reply to author
Forward
0 new messages