7

I would like to use nvd3 chart library in my AngularJS app by using angularjs-nvd3-directives Is there a way to export any given nvd3 chart to any of the graphics file formats?

Eugene Goldberg
  • 14,286
  • 20
  • 94
  • 167
  • Did you find some way to do it? I'm now taking a look on saving SVG to server http://stackoverflow.com/questions/8379923/save-svg-image-rendered-by-a-javascript-to-local-disk-as-png-file/8861315#8861315 – Braulio Jul 02 '14 at 20:23
  • So far, I have not found a way to do it – Eugene Goldberg Jul 07 '14 at 19:31

1 Answers1

0

Please post a code sample for detailed help

To capture your chart to a file for use

  • Register a callback in on-ready in your nvd3 directive. This callback receives a 2 parameters as show below

$scope.callback = function(scope,element){ $scope.myChartScope = scope; } This $scope.myChartScope should contain a reference to your svg element, console.log it to see its contents

  • In your options object for the line chart, there is a dispatch object which has an attribute called renderEnd that gets called when your chart is fully drawn. In this renderEnd you can then access your $scope.myChartScope.svg and then do what you want with it.

    You can use a library like https://github.com/exupero/saveSvgAsPng to save your SVG to an image file All done on the client side

I hope this answers your question!

Lxrd-AJ
  • 592
  • 7
  • 16