Skip to content
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

Prakriti-nith
Copy link
Contributor

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 Export Googlecharts [WIP] Export Googlecharts Jun 19, 2018
@Prakriti-nith
Copy link
Contributor Author

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 [WIP] Export Googlecharts Export Googlecharts Jun 20, 2018
@coveralls
Copy link

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
Copy link
Contributor Author

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

@Prakriti-nith
Copy link
Contributor Author

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listener in this PR?

Copy link
Contributor Author

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.

@Prakriti-nith
Copy link
Contributor Author

@Shekharrajak please review this PR

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

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 ?

@Prakriti-nith
Copy link
Contributor Author

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 changed the title Export Googlecharts Export Googlecharts to PNG Aug 4, 2018
@Shekharrajak Shekharrajak changed the title Export Googlecharts to PNG Export Googlecharts: PNG Aug 4, 2018
@Shekharrajak Shekharrajak merged commit 5bce655 into SciRuby:master Aug 4, 2018
@Shekharrajak
Copy link
Member

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants