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?
How to export angularjs-nvd3 chart to a file
Did you find some way to do it? I'm now taking a look on saving SVG to server #8380423 –
Dearden
So far, I have not found a way to do it –
Mincey
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 calledrenderEnd
that gets called when your chart is fully drawn. In thisrenderEnd
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!
© 2022 - 2024 — McMap. All rights reserved.