-
Notifications
You must be signed in to change notification settings - Fork 20
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 Googlecharts: PNG #98
Export Googlecharts: PNG #98
Conversation
There is a bug that whenever we update the GoogleCharts jsapi (http://www.google.com/jsapi), GoogleCharts produces an error in IRuby notebook and do not work. For now, I have commented out that portion to update jsapi.
Regarding exporting to pdf format: I have searched for another idea using cloudformatter (examples) based on this example. I have also tried out an example using the above but again I am not sure if it will work in IRuby notebook. This is good because we can provide buttons as in highcharts (1. both for google datatables and charts, 2. Provides export in pdf, jpg and png format ). |
8223bdd
to
8a57955
Compare
Pull Request Test Coverage Report for Build 668
💛 - Coveralls |
@Shekharrajak can you please review this PR and let me know if there are any changes that I have to make? |
Right now in this PR, export to PNG format is done ( for corecharts and geocharts ). I have tried exporting to PDF and JPEG too using cloudformatter and jspdf in this PR but they were not working in IRuby notebook. I have commented out the examples in this notebook. |
# @param event [String] name of the event tha will be fired | ||
# @param callback [String] callback function name for the event | ||
# @return [Array] array of listeners | ||
def add_listener(event, callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listener in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code to export the chart in PNG format must be inside the ready
listener.
@Shekharrajak please review this PR |
# IRuby notebook. | ||
# | ||
# @see #Daru::View::Plot.export | ||
def export(plot, export_type='png', file_name='chart') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if user enters the export_type which is not going to work? Where is the exception for that ?
I have created a new module |
834ac0a
to
2fb8e29
Compare
Please note : JPEG, SVG, PDF yet to be implemented. |
I have added the feature to export to PNG. As
chart.getImageURI()
works only on corecharts and geocharts, it was not possible to provide the export option for google datatables. Also,chart.getImageURI()
provides access to a PNG image of a chart only.To use this feature, just do plot.export('png', 'file_name') and the chart will be downloaded as the png file.
I am working on how to export the chart to pdf also. Further, if possible I will try to add the button (just like in highcharts) to export the googlecharts in different formats in a separate PR.