PMSI-AlignAlytics / dimple

An object-oriented API for business analytics
Other
2.73k stars 556 forks source link

How to generate SVG using dimple in Node.js #276

Open KalaiselvanMahendran opened 7 years ago

KalaiselvanMahendran commented 7 years ago

Here my question is very simple,

I need to generate SVG using dimple in Node.js.

And i installed this node module npm install dimple-js but there is no proper documentation for this ?

i have tried this below code:

var jsdom = require("node-jsdom");
globals = {};
global.window = jsdom.jsdom().parentWindow;
global.document = jsdom.jsdom('<!doctype html></html>');

var d3 = require('dimple-js/lib/d3.v3.4.8.js');
var dimple = require('dimple-js/dist/dimple.v2.1.6.js');

module.exports = function(router){

    router.get('/', function(req, res){
        var svg = dimple.newSvg('body', 800, 600);
        var data = [
          { "Word":"Hello", "Awesomeness":2000 },
          { "Word":"World", "Awesomeness":3000 }
        ];
        var myChart = new dimple.chart(svg, data);
        myChart.addCategoryAxis("x", "Word");
        myChart.addMeasureAxis("y", "Awesomeness");
        myChart.addSeries(null, dimple.plot.bar);
        myChart.draw();
        res.json({success: true, svg: svg});
    });
}

but am getting below error

untitled

So is that possible to generate SVG using dimple in server side ?