Giter Club home page Giter Club logo

node-svgchart's Introduction

Introduction

node-svgchart aims to provide a general interface to generate charts on the server side without any need for an x-server or anything of the like.

You might find it useful for generating reports if you want to use the exact same charts on the frontend, or for supporting old browsers. If you're in an environment that does support a graphical interface (GUI), however, then you should probably consider simply screen-capturing the charts, using something like CutyCapt or wkhtmltopdf.

Dependencies

To get it up and running, you will need:

  • Node.js
  • ImageMagick

Compatibility

  • AnyChart 6.0.10
  • gRaphaël
  • ico
  • Highcharts (somewhat, be sure to disable animations)
  • amCharts (legends will disappear)
  • grafico (only in safe mode, and minified version doesn't work)

Usage

var chart = require("node-svgchart");

chart
    .require("path/to/my/chart/lib.js")
    .setup(function(e, callback) {
    	//Setup chart using your library. Write to #chart.
    	//Note: The global object is still "global", so explicitly access "e.window".
        //      -> this = e.window
        //IMPORTANT: You have to call the callback to make it continue. 
    })
    .create("myIdentifier", {
    	//Options that will be passed to rsvg
    	width: 500
    }, function(err, image) {
    	//image is a buffer.
    });

Installation

  1. Download files from github
  2. Extract files into a folder
  3. Go there and run npm install

Pictures

Ico line chart

amCharts OHLC chart

gRaphaël bar chart

Highcharts area chart

AnyChart scatter chart

Notes

  • Image object is not yet implemented by jsdom. There is a patch for it, though.
  • As soon as a library fiddles with prototypes, you have to use safe mode.

Todos

  • Proper unit tests
  • Proper SVG implementation (long term)
    • All the values should be SVGLengths, etc.
  • More examples
  • Documentation
  • More supported libraries

API

setSafeMode(bool on)

Turn safe mode on / off. If safe mode is off, the script code of your libraries will be rewritten to refrain from using "instanceof Array" because of context issues.

If that causes problems, you can disable that behavior. However, you will then have to use "window.Array" to create your arrays.

node-svgchart's People

Contributors

eusthenopteron avatar

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.