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

Merged
merged 19 commits into from Aug 4, 2018

Conversation

Projects
None yet
3 participants
@Prakriti-nith
Contributor

Prakriti-nith commented Jun 19, 2018

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.

@Prakriti-nith Prakriti-nith changed the title from Export Googlecharts to [WIP] Export Googlecharts Jun 19, 2018

@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jun 19, 2018

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.
Error produced is:

Javascript error adding output!
TypeError: right-hand side of 'in' should be an object, got undefined
See your browser Javascript console for more details.

Regarding exporting to pdf format:
I have used jspdf which is working fine in rails app but again is producing an error in IRuby notebook as the jspdf dependency is not loaded properly in IRuby notebook.

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 ).

@Prakriti-nith Prakriti-nith changed the title from [WIP] Export Googlecharts to Export Googlecharts Jun 20, 2018

Prakriti-nith added some commits Jun 21, 2018

@Prakriti-nith Prakriti-nith force-pushed the Prakriti-nith:export_googlechart branch from 8223bdd to 8a57955 Jun 26, 2018

Prakriti-nith added some commits Jun 27, 2018

@coveralls

This comment has been minimized.

coveralls commented Jul 15, 2018

Pull Request Test Coverage Report for Build 668

  • 116 of 116 (100.0%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 98.129%

Totals Coverage Status
Change from base Build 664: 0.1%
Covered Lines: 3199
Relevant Lines: 3260

💛 - Coveralls
@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jul 18, 2018

@Shekharrajak can you please review this PR and let me know if there are any changes that I have to make?

@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jul 22, 2018

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.
Refer this comment for PNG exporting.
Refer this comment for PDF and JPEG exporting

# @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)

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 22, 2018

Collaborator

Listener in this PR?

This comment has been minimized.

@Prakriti-nith

Prakriti-nith Jul 22, 2018

Contributor

The code to export the chart in PNG format must be inside the ready listener.

Prakriti-nith added some commits Jul 26, 2018

@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jul 28, 2018

@Shekharrajak please review this PR

# IRuby notebook.
#
# @see #Daru::View::Plot.export
def export(plot, export_type='png', file_name='chart')

This comment has been minimized.

@Shekharrajak

Shekharrajak Jul 29, 2018

Collaborator

What if user enters the export_type which is not going to work? Where is the exception for that ?

@Prakriti-nith

This comment has been minimized.

Contributor

Prakriti-nith commented Jul 29, 2018

I have created a new module DisplayJavascript as the module length of Display increased to > 200 and rubocop was throwing the error.

@Prakriti-nith Prakriti-nith force-pushed the Prakriti-nith:export_googlechart branch from 834ac0a to 2fb8e29 Aug 4, 2018

@Prakriti-nith Prakriti-nith changed the title from Export Googlecharts to Export Googlecharts to PNG Aug 4, 2018

@Shekharrajak Shekharrajak changed the title from Export Googlecharts to PNG to Export Googlecharts: PNG Aug 4, 2018

@Shekharrajak Shekharrajak merged commit 5bce655 into SciRuby:master Aug 4, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.1%) to 98.129%
Details
@Shekharrajak

This comment has been minimized.

Collaborator

Shekharrajak commented Aug 4, 2018

Please note : JPEG, SVG, PDF yet to be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment