Give a tip how to read a vegalite json file and convert to VL spec in the document
petershintech opened this issue · comments
Recently, I got the following tip how to convert a json file to VL spec. It allows to manipulate vl spec easily using a dictionary and convert it to a plot. I think it might be useful to many VegaLite.jl users. How about adding the tip in the document?
using VegaLite: VLSpec
using JSON
using DataStructures: OrderedDict
p = VLSpec(JSON.parse(open("vegalite.json", dicttype=OrderedDict)))
(Used ```OrderedDict`` to preserve the order of items)
Just following up from the discourse thread, you can use loadspec to get a VLSpec from a json file. I interpreted the question has wanting to create a spec from a non-literal string, which does seem to require the VLSpec(JSON.parse(...))
incantation. Either way, perhaps one or both of these should be documented? Happy to open a PR if so.
Thank @ToucheSir for the additional help. Yes, I can see loadspec
is what I was looking for. Again, I think the useful function should be mentioned in the VegaLite document but not sure if I can submit a proper PR for it. Hope I can have attention to this request from one of maintainers.
I think we already mention it at https://www.queryverse.org/VegaLite.jl/stable/userguide/vlspec/#Loading-and-saving-vega-lite-specifications-1? Or do you think we should do something beyond that? I'm going to close this issue for now, but feel free to reopen if you think there is more we should do!