SciNim / nim-plotly

plotly wrapper for nim-lang
https://scinim.github.io/nim-plotly/
MIT License
181 stars 15 forks source link

Add error bar plots #4

Closed Vindaar closed 6 years ago

Vindaar commented 6 years ago

First of all thanks for the great work so far!

I went ahead and added support for error bars on plots by introducing an ErrorBar type and xs_err / ys_err fields to the Trace.

I'm not sure if I'm super happy with my implementation here, but it seems to work just fine. It supports the whole range of plotly.js error bars, namely:

A simple example based on the scatter plot is also added.

What this PR also includes (I can cherry pick the error bar stuff out, if you don't like this): I changed a few procs to use the result variable instead of return, changed the style of the whitespace for the argument type and replaced the proc keyword with the new func keyword in api.nim.

Vindaar commented 6 years ago

Squashed some of the commits.

Vindaar commented 6 years ago

I'll move the ErrorBar related functions to its own module tomorrow. Maybe I should split the api.nim into a plotly_types.nim, color.nim, errorbar.nim and keep the JSON related code in the api.nim?

brentp commented 6 years ago

Maybe I should split the api.nim into a plotly_types.nim, color.nim, errorbar.nim and keep the JSON related code in the api.nim

I think that would make sense.

Vindaar commented 6 years ago

Went ahead and did that refactor, also made the ErrorBarKind public (had to do that anyways to have it inside of the plotly_types module).