Is it possible to use the Google charts api to create charts without using html elements for rendering?

Viewed 29

I used this code to render some charts in my html page.

function drawChart(id, arrayPrice) {

    let dataChart = [
        ['', 'Price']
    ];
    for (let index = 0; index < arrayPrice.length; index++) {

        dataChart.push(['', arrayPrice[index]])
    }

    const firstPrice = dataChart[1][1];
    const lastPrice = dataChart[dataChart.length - 1][1];

    var data = google.visualization.arrayToDataTable(dataChart);

    var options = {
        width: 130,
        height: 50,
        colors: (firstPrice < lastPrice) ? ['#50afb2'] : ['#ab5780'],
        legend: 'none',
        tooltip: {
            trigger: 'none'
        },
        enableInteractivity: false,
        vAxis: {
            textPosition: 'none',
            gridlines: {
                color: 'transparent'
            },
            baselineColor: 'transparent'
        },
        hAxis: {
            textPosition: 'none',
            gridlines: {
                color: 'transparent'
            },
            baselineColor: 'transparent'
        },
        backgroundColor: { fill: 'transparent' }
    };

    var chart = new google.visualization.LineChart(document.getElementById(id));

    chart.draw(data, options);
}

I was wondering if it was possible to do this server-side with NodeJS without using html elements in which to do the rendering.

My goal is to generate chart images to download locally to the server.

0 Answers
Related