Git Product home page Git Product logo

dc-node's Introduction

dc-node

Server side support for DC.js. Renders graphs using jsdom.

dc = require('dc-node');

dc-node's People

Contributors

sclevine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dc-node's Issues

Render dc.barChart in Node.js

Good day I have the following code to try to render a Bar Chart from Node.js using Express Framework and JSDOM:

var express = require('express');
var router = express.Router();
var d3 = require('d3');
var d3request = require('d3-request');
var jsdom = require('jsdom');
global.d3_document = jsdom.jsdom();
var dc = require('dc');

/* GET bar for specific dataframe with given dimensions. */
router.get('/:dftitle/:xdim/:ydim/', function(req, res, next) {
  /* Use d3-request to get the data */ 
  d3request.tsv("http://localhost:3000/data/data.tsv", function(d){
    d.pay = +d.pay;
    d.bal = +d.bal;
    return d;
  }, function(data){
    const containerSelector = 'bar-chart-container';
    var htmlStub = '<html><head>Hello</head><body><div id="'+containerSelector+'"></div></body></html>';
    //Render the Chart
    jsdom.env({ features : { QuerySelector : true }, html : htmlStub
      , done : function(errors, window) {
        bcc = window.document.querySelector(containerSelector);
        global.d3_document = window.document;
        var BarChart = dc.barChart(bcc);
        console.log(BarChart);
        res.send(jsdom.serializeDocument(window.document));
      }
    });
  });
});

module.exports = router;

Its failing exactly at var BarChart = dc.barChart(bcc); with the error:

/usr/local/src/node/s3d3c/node_modules/d3/d3.js:1312
d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() {
^

TypeError: Cannot use 'in' operator to search for 'onwheel' in undefined
at Object.d3.behavior.zoom (/usr/local/src/node/s3d3c/node_modules/d3/d3.js:1312:44)
at Object.dc.coordinateGridMixin (/usr/local/src/node/s3d3c/node_modules/dc/dc.js:2760:29)
at Object.dc.barChart (/usr/local/src/node/s3d3c/node_modules/dc/dc.js:5277:35)
at Object.jsdom.env.done (/usr/local/src/node/s3d3c/routes/bars.js:25:27)
at /usr/local/src/node/s3d3c/node_modules/jsdom/lib/jsdom.js:275:18
at nextTickCallbackWith0Args (node.js:453:9)
at process._tickCallback (node.js:382:13)

Is it possible for this chart to be rendered server side using JSDOM? How does this library work? Can you help me out please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.