Charts in erpnext

If i want to add a chart to the report did i have to add it to the js file in the page module in a wrapper function

Refer the link

page.chart = new frappe.ui.Chart({
    // attach the chart here
    wrapper: $('<div>').appendTo(page.body),

    // pass the data, like
    // ['x', '2016-01-01', '2016-01-02']
    // ['Value', 20, 30]
    data: {
        x: 'x',
        xFormat: '%Y-%m-%d',
        columns: [data[0], data[1]],
    },
    legend: {
        show: false
    },
    axis: {
        x: {
            type: 'timeseries',
        },
        y: {
            min: 0,
            padding: {bottom: 10}
        }
    }
});

where i have to put this code,will it work if i put it into that .js file

1 Like