-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export charts as png/svg/pdf #20
Comments
I've tried to get this working with html2canvas. It works up to a point, ,but unfortunately the labels and axes aren't rendered correctly - see example below |
Further to my previous comment, the reason that it doesn't work properly is that html2canvas can't render the css styles unless they're defined inline. So by setting the styles inline on the elements, the chart can be rendered correctly using html2canvas. FYI - I got my download png working with the following code to be triggered on ng-click of a button. The chart needs to be inside a div with id 'exportchart', and the download name would probably be set dynamically instead of sample.png
Hope this is useful |
@dilignt Thank you, I would like to link your solution in the documentation. Can you create a sample implementation on Plunker? You can use this version to build ontop (http://plnkr.co/edit/EWC4Hr) |
Here it is - http://plnkr.co/edit/wdiksu On 4 February 2015 at 07:30, Max Klenk notifications@github.com wrote:
|
Amazing! Thank you very much. |
The axes are normally set using the c3.css file, for export these styles have to be inlined. But I have no idea why the bars aren't filled. |
I actually did this using canvg.js i had tried html2canvas in the past and it didn't work... this script works with charts just made with plane old D3 but for some reason the ones made with c3 have the not filled in bars issue. |
could you please rewrite plunker code ? i tried but the c3 chart i download is blank. |
The angular-chart dependency is no longer available which is why it's not working. I don't where there is a different CDN of angular-chart but if you download the plunker and replace angular-chart.js with a local dependency it should work |
You can link to angular-chart resources on github using https://rawgit.com/ |
Hi @dilignt Thank i'll try that.. https://github.com/annatomka/ng-c3-export i also referred this to download charts. Limitation is that it doesn't work on IE and Safari browsers. |
@maxklenk where is the rawgit angular-chart v0.2 resource? This v0.3 one has a different API, and I notice that the upgrade instructions doesn't mention how to upgrade |
@dilignt you can link to files from specific versions like this: And yes, between v0.2 and v0.3 there was an API change, can I help you what is not clear in the upgrade guide? |
Thanks @maxklenk. Where is the angular-chart.min.css file on rawgit? I tried https://rawgit.com/GraFiddle/angular-chart/0.2.9/angular-chart.min.css but this doesn't work. The upgrade guide doesn't mention groups within the options - you describe changing the rows options and changing them to dimensions but nothing about groups so it's unclear what to do here. How would you convert this to 0.3?
|
The new structure looks like this:
$scope.options = {
data: [
{
data1: 1,
data2: 4
},
{
data1: 2,
data2: 2
}],
dimensions: {
'data1': {},
'data2': {}
},
chart: {
data: {
type: 'bar',
groups: [
['data1', 'data2']
]
}
}
}; I also updated the plunker http://plnkr.co/edit/JzkdibGX1rZUBvIGhAxq?p=preview |
Thanks for the clarification and the updated plunker. There's something not quite right about the chart styling - the background of the downloaded image is now black but it used to be white. I thought this was the css file change but I'm not sure |
Discussed here: c3js/c3#313
Working solution: https://github.com/times/axisJS
The text was updated successfully, but these errors were encountered: