Skip to content
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

Missing support #265

Closed
cstjean opened this issue Feb 4, 2019 · 8 comments
Closed

Missing support #265

cstjean opened this issue Feb 4, 2019 · 8 comments

Comments

@cstjean
Copy link
Contributor

cstjean commented Feb 4, 2019

using PlotlyJS
using PlotlyJS: SyncPlot

SyncPlot(Plot(scattergl(x=[1,2,3], y=[1,missing, 3], mode=:markers)))

yields Cannot serialize type Missing. I think it would be OK to convert them to NaN? That's what Plots.jl does IIRC.

@sglyon
Copy link
Member

sglyon commented Feb 4, 2019

Yeah I think that makes sense to me.

What do you think the right approach to that would be? Right now we lean on how JSON.jl wants to serialize things and define a few methods for JSON.lower here.

I don't think we should be type pirates and define JSON.lower(::Missing) = NaN, but as of right now we don't have a layer in PlotlyJS.jl to intercept something like that

@cstjean
Copy link
Contributor Author

cstjean commented Feb 4, 2019

@TotalVerb We'd like to serialize (write) missing as null, with JSON.jl. I saw your big PR, but it doesn't seem to be documented anywhere. What would be the solution for us? I'm a bit confused whether we should implement a Writer, a Context, or a Serialization.

@TotalVerb
Copy link
Contributor

TotalVerb commented Feb 5, 2019

JSON.jl already serializes Missing as null: https://github.com/JuliaIO/JSON.jl/blob/master/src/Writer.jl#L266

It's possible this has not been tagged. I'll check this. Edit: No, it should be in 0.20.0.

@TotalVerb
Copy link
Contributor

I believe the issue is that one of the JSON.lower overrides is calling JSON.lower before returning the result, which is not the intended usage. Please see #266 for a solution.

@sglyon
Copy link
Member

sglyon commented Feb 5, 2019

Thanks @TotalVerb!

@cstjean I just tried your example with the latest master of PlotlyJS.jl (doesn't include #266) and the code snippet you posted above and it works for me without any modification needed...

What version of JSON.jl and julia do you have? What about your OS (though I can't imagine why that would matter for this issue)?

@TotalVerb
Copy link
Contributor

TotalVerb commented Feb 5, 2019

Right, #266 will have no effect if (::SyncPlot).plot is never Missing and is always a type that this package is aware has already defined lower. Nevertheless, the recursive lower call is not needed; I am aware the documentation for JSON recommends it and thus is actively misleading here (I regret that it was written when we had a different design philosophy in mind when the feature was first implemented.)

@cstjean
Copy link
Contributor Author

cstjean commented Feb 5, 2019

I can't check right now, but I assume that I just had a lower JSON version installed because of some upper-bound somewhere. Thank you for your help both!

@cstjean cstjean closed this as completed Feb 5, 2019
@sglyon
Copy link
Member

sglyon commented Feb 5, 2019

ok sounds good, if you check and it it still an issue please reopen.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants