When using a package such as PlotlyJS.jl, ( Such as I am). How does one find all kwargs available for a particular function. PoltyJS does not document what they are. They do show you how to use them but it seems not be one to one from plotly documentation. To have to dig through the official plotly docs and just guess at what works what doesn’t is very time consuming, frustrating, and make me not even want to use Julia. At times I am better off just writing the JS code. I need some help / some convincing this is worth it. I love fact I can use Genie and generate dashboard with PlotlyJS, but if I spend more time guessing than coding, it’s huge was of my time.
If that’s really the case with PlotlyJS, then it’s a package-specific problem (actually a problem with the package’s documentation). You can open an issue in the package’s repository to note this problem.
A few workarounds:
- use Plots.jl instead
- try to see kwargs with
methods(function)
julia> f(; a=1,b=1) = nothing
f (generic function with 1 method)
julia> methods(f)
# 1 method for generic function "f":
[1] f(; a, b) in Main at REPL[2]:1
Just note that none of the problems you listed are related to Julia itself. I’m also a former JS user (although I was using it far before Julia), so I don’t think you’ll have hard time adapting.
Generally something like
julia> f(; x, y) = 1
f (generic function with 1 method)
julia> methods(f)
# 1 method for generic function "f":
[1] f(; x, y) in Main at REPL[3]:1
should work, except for functions that just use kwargs...
and pass it on.
The best solution may be looking at the source and contributing docs.
Hi @Dustin_Hess tanks for the question
@anon37204545 is correct – this is a package specific issue
In developing PlotlyJS.jl I chose to support everything that the js library does. Because plotly.js was changing really quickly at the time I chose to just accept arbitrary kwargs and then pass them along to plotly.js and hope for the best.
This means that PlotlyJS.jl supports exactly what plotly.js does — with the same argument names and “locations” in the json tree. Following the plotly.js attribute reference should work 1:1 – Single-page reference in JavaScript
However, I agree this isn’t a great long-run solution and I believe things are stable enough that I can revisit things.
One potential plan that I could implement to help this is:
- Pin the version of plotly.js used by each version of PlotlyJS.jl so I know exactly which attributes will be accepted by plotly.js
- Process the jsonschema for that version of plotly.js to add both docstrings and a dynamic check for attributes that should or shouldn’t exist
Hi All
Thanks for all your replies. They were helpful. For now I have been able produce the dashboard to my satisfaction. @Tamas_Papp this helped a bit.
@sglyon Thanks for the reply. Also keep up the good work. I re-read my post realized it sounded a bit negative. I hope so see the improvements you mentioned in near future.