-
Notifications
You must be signed in to change notification settings - Fork 150
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 JSON Chart Specification Only #269
Comments
Hi @cbailiss :)! Yes, what are you doing is exactly what you want, in fact that's what The
// Generated by highcharter 2017-02-16 09:59:30
{
title: {
text: "Monthly Average Temperature"
},
yAxis: {
title: {
text: "Temperature"
}
},
...
// Generated by highcharter 2017-02-16 09:59:30
objectname = {
title: {
text: "Monthly Average Temperature"
},
yAxis: {
title: {
text: "Temperature"
}
},
...
// Generated by highcharter 2017-02-16 09:59:30
$(function(){
$('#selectorid').highcharts(
{
title: {
text: "Monthly Average Temperature"
},
yAxis: {
title: {
text: "Temperature"
}
},
... Now, for export as svg image/pdf image/ or evend the data: are you aware about the exporting/exporintg-csv plugin http://jkunst.com/highcharter/plugins.html#exporting-csv? Obviously this is final user oriented, not sure if this helps. Tell me if this more clearer, |
Thanks very much. Great to hear this enhancement is already in progress. Those additional arguments to the export_hc function (in particular as="is") should work for me. I'll install the dev version and test. When is the dev version likely to be pushed to CRAN? |
Possibly next month in a maintenance release. I'll modify Thanks |
Thanks for that. I have nothing to further to add on this. |
I am looking to generate charts in R, then take the chart definitions created by highcharter and use them in multiple different places - rendered on the web via javascript, also to image files (both svg and png) and to other "hardcopy" formats like PDF.
To do this, ideally I want to easily be able to retrieve the underlying High Charts JSON chart definition in R, i.e. generate a chart in R, preview it in RStudio in the normal way, then export the JSON and use that in different ways depending on the desired output format.
The export_hc function is almost what I am looking for. The one niggle is that the export_hc output actually includes javascript as well as the JSON chart definition. It would be cleaner to have an option to just get the JSON, e.g. the vegalite R package has a to_spec() function which just returns the JSON, with no javascript around it.
It looks like hc$x$hc_opts is actually the high charts JSON stored as R objects (rather than a string). So I can (at least in my quick test) get the JSON specification by using:
toJSON(hc$x$hc_opts, auto_unbox = TRUE, pretty = TRUE)
However, this feels like reading the internals of the hc object. This sort of approach might lead to trouble in the future:
In my test, the above toJSON call exactly matched the highcharts JSON, but I am not sure if this is true for all chart types or all options, etc.
Also, it may be that you change the way the hc_opts object works in the future. Ideally, a export_specification() method would be handy! This would provide a simple, clean, supported way of getting the High Charts JSON without needing to read the internals of an R object.
Hopefully this request can be reasonably easily implemented, as it looks like a subset of the existing export_hc() functionality.
The text was updated successfully, but these errors were encountered: