How Data rendering to jsreport?

  • I would like to know how Data come to jsreport . I saw the script file and understand
    that how data displayed in the jsreport , however I don't know where actually data is rendering from. I need to change the country name like 'France ' into China . I tried to change it but after changed I lost graph's visual data because of condition in that beforeRender function. So please, anyone help me .

     function beforeRender(req, res, done) { = || 'France'; = [];
       getData(req, function (err) {
        if (err) {
            return done(err);
        (c) {
            c.ordersCount = (o) {
                return o.CustomerID === c.CustomerID;
        var ordersByQuarter = {}; (o) {
            o.OrderDate = new Date(o.OrderDate);
            var key = o.OrderDate.getFullYear() + '/' + (o.OrderDate.getMonth() + 1);
            ordersByQuarter[key] = ordersByQuarter[key] || { value: 0, orderDate: o.OrderDate };
        = ordersByQuarter

    After changed country name

  • administrators

    Data is sent to jsreport in two ways:

    • you can pass it in HTTP's request payload (data property) when rendering reports with the jsreport HTTP API
    • when using jsreport-studio you can create data files and use it with your templates in order to populate with some sample data while you are developing the report

    but it seems like your example is not using any data file and it is actually fetching data from elsewhere, take a look in getData function, i can't see the source of your getData function so i assume that it is fetching data from another server and use it to fill

    also to provide help to you more quickly try to upload a fully working example in the playground

  • Thank you so much !!

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.