A---- / highcharts-export-clientside

Module for Highcharts to exports charts client-side
http://a----.github.io/highcharts-export-clientside/
The Unlicense
49 stars 37 forks source link

Support NPM / Browserify #27

Open felixfbecker opened 8 years ago

felixfbecker commented 8 years ago

It seems like this module is only able to use global Highcharts object. It would be nice if it could be installed with NPM and require()d like Highcharts itself.

Would submit PR.

A---- commented 8 years ago

If you have time for a PR, sure! Could do for a AMD module too!

felixfbecker commented 8 years ago

Pretty much finished, just waiting for an answer on https://github.com/highcharts/export-csv/issues/72 so the dependency can be expressed correctly in package.json without globals or git references.

felixfbecker commented 8 years ago

Waiting for https://github.com/highcharts/export-csv/pull/79

felixfbecker commented 8 years ago

@A---- Am I understanding correctly that RGBColor and canvg are provided through highcharts/modules/canvas-tools as globals?

A---- commented 8 years ago

Yes :)

felixfbecker commented 8 years ago

That sucks... I don't really want to add a require statement in the code for globals - are there other options? I'm currently in the talks for proper NPM packages for canvg (includes rgbcolor) and export-csv. Is there anything else that is needed from canvas-tools? Is that Highcharts module in there needed?

A---- commented 8 years ago

Well, canvas-tools is a fork of canvg if I remember correctly. And you need it for the SVG to PNG/JPG conversion.

canvg seems Common.js-compatible now: https://github.com/gabelerner/canvg/blob/master/canvg.js

I had some issues with older versions but on more recent attemps, it worked alright.

felixfbecker commented 8 years ago

It also patches (global) Highcharts a custom renderer module: https://github.com/highcharts/highcharts-dist/blob/master/modules/canvas-tools.src.js#L2919

I'm currently working to get a NPM package of canvg. PR for export-csv is submitted and jspdf is available on NPM.

felixfbecker commented 8 years ago

@A---- How are you calling canvg? It must be an XML string, but where does that come from? Do you have a DOM document object initially or a Node object or do you get the string from Highcharts?

A---- commented 8 years ago

The exporting module of Highcharts provides a getSVG() method.

felixfbecker commented 8 years ago

I just found out that Highcharts now supports client side export natively: http://www.highcharts.com/docs/export-module/client-side-export

So this module isnt needed anymore.

ulrik59 commented 8 years ago

Is there any plan to publish on NPM ? Because Highcharts offline export module doesn't support JPEG and PDF yet...

deathran commented 8 years ago

Would love a npm package for this aswell :)