Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Export vaadin chart to CSV
In my web application, the user is able to see a lot of data through graphs.
I was wondering if it is possible to export the data to a CSV or excel file, simply to allow the user to manipulate the data offline.
I've seen a lot of export-plugins, but since the data I want already is formatted and lies in the charts, it would be so awesome if it was possible to export these data.
Hope you guys can help :)
Have a great day - even though it's a monday ;-)
I see the original software had a pluging for it:
Anybody knows if and how this could be compatible?
I must admit I was a bit doubtful about how this would work, but did a small test and seems to be working fine.
- Add HighchartsPluginResources similar to HighchartResources class in client package and create a TextResource for the plugin js file.
- Add plugin js file in same folder but under src/main/resources.
- Create HighchartsPluginScriptLoader class extending HighchartsScriptLoader. Override injectResources so that both original and new plugin resources are injected.
- In project widgetset.gwt.xml file replace the original script loader with extended one:
<replace-with class="uy.com.chartexport.client.HighchartsPluginScriptLoader"> <when-type-is class="com.vaadin.addon.charts.client.HighchartsScriptLoader"/> </replace-with>
And remember to enable chart exporting.
A simple project with the mentioned changes is available in github https://github.com/alvarezguille/charts-export-csv
Hope this helps!
Seems genious! :)
I tried it, but I can't seem to compile the widgetset, it can't find the scriptloader, even though it is in the right place.
[ERROR] Could not find uy.com.chartexport.client.HighchartsPluginScriptLoader in types compiled from source. Is the source glob too strict?
[ERROR] Errors in 'com/vaadin/addon/charts/client/HighchartsScriptLoader.java'
[ERROR] Line 27: Rebind result 'uy.com.chartexport.client.HighchartsPluginScriptLoader' could not be found
Adding '1' new generated units
Why does it do this? It does exist, and in the right package. :-(
For some reason I used uy in package name which you might've missed.
Is your HighchartsPluginScriptLoader also un uy.com.chartexport.... package?
After I changed the structure to the following and compiled the widgetset, it worked!
You're awesome mate!
Cool! Glad it worked!