Closed Prakriti-nith closed 6 years ago
I was using JQuery to get the Highchart object and then download it. For this, I was using jquery.min.js dependency. This dependency was not properly loaded in IRuby notebook (maybe conflicting with the existing dependencies of the jupyter notebook) and was creating problems. I have replaced the code to get the instance of HighCharts' object with the pure js code. It is now working fine in both IRuby notebook as well as in web frameworks.
Now, user along with format of the chart (in which it has to be exported) can provide the file name. For example,
hchart = Daru::View::Plot.new(data, options) hchart.export_image('daru', 'png')
This will download the chart as: daru.png
I just found that while exporting multiple highcharts simultaneously in web frameworks, it is exporting only the last one. I am trying to find a solution to resolve this issue.
By using exportChartLocal (useful link), not only the issue has been resolved but also the exporting works offline (export button in highcharts works online). In IRuby notebook, online exporting asks to leave the page and after that that jupyter notebook does not work (try exporting using exporting button) but this method (export) resolves all.
In IRuby notebook, offline-export supports only the exporting to png, jpeg and svg format. Export to PDF is not working (not even through the exporting button in highchart). Also, in IRuby notebook, online exporting asks to leave the page and after that that jupyter notebook does not work (try exporting using exporting button). Still, I am keeping the online exporting for the IRuby notebook so that at least chart can be exported to all the formats and offline-exporting for the web frameworks.
IRuby notebook example link ? Also along with documenting the method, write few example for user to understand the API.
I have commented out the export method in the examples here. I also tried running it in console, it is generating the correct script to download the chart.
@Shekharrajak The tests of updating the js files runs sometimes perfectly and sometimes doesn't (maybe because the highcharts js doesn't get loaded fully and network error occurs). I don't understand the exact reason. Can you please check this?
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
lib/daru/view/adapters/googlecharts.rb | 1 | 2 | 50.0% | ||
lib/daru/view/adapters/nyaplot.rb | 1 | 2 | 50.0% | ||
lib/daru/view/adapters/highcharts/display.rb | 48 | 50 | 96.0% | ||
<!-- | Total: | 179 | 183 | 97.81% | --> |
Totals | |
---|---|
Change from base Build 601: | 0.6% |
Covered Lines: | 1690 |
Relevant Lines: | 1740 |
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
lib/daru/view/adapters/googlecharts.rb | 1 | 2 | 50.0% | ||
lib/daru/view/adapters/nyaplot.rb | 1 | 2 | 50.0% | ||
<!-- | Total: | 181 | 183 | 98.91% | --> |
Totals | |
---|---|
Change from base Build 578: | 0.2% |
Covered Lines: | 2127 |
Relevant Lines: | 2208 |
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
lib/daru/view/adapters/googlecharts.rb | 1 | 2 | 50.0% | ||
lib/daru/view/adapters/nyaplot.rb | 1 | 2 | 50.0% | ||
<!-- | Total: | 181 | 183 | 98.91% | --> |
Totals | |
---|---|
Change from base Build 578: | 0.2% |
Covered Lines: | 2127 |
Relevant Lines: | 2208 |
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
lib/daru/view/adapters/googlecharts.rb | 1 | 2 | 50.0% | ||
lib/daru/view/adapters/nyaplot.rb | 1 | 2 | 50.0% | ||
<!-- | Total: | 181 | 183 | 98.91% | --> |
Totals | |
---|---|
Change from base Build 578: | 0.2% |
Covered Lines: | 2127 |
Relevant Lines: | 2208 |
@Shekharrajak can you please review the changes?
@Shekharrajak I have documented the usage in this wiki page.
@Prakriti-nith , please resolve the conflicts and run the examples once.
@Shekharrajak I tried the examples again both in IRuby notebook and rails, everything is working fine.
Added the methods
export_image
andexport_image_iruby
to export the Highchart in four formats: pdf, png, jpg and svg with the default format being pdf. This is working fine in rails app but I can't understand why it is not working in IRuby notebook. Still searching some way to make it work. I will add the example of rails app to demonstrate this feature.This example will first generate the chart and then download it in svg format like this: