How to export angularjs-nvd3 chart to a file
Asked Answered
M

1

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?

Mincey answered 29/3, 2014 at 12:54 Comment(2)
Did you find some way to do it? I'm now taking a look on saving SVG to server #8380423Dearden
So far, I have not found a way to do itMincey
P
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!

Perspiration answered 4/3, 2016 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.