What is ContEx?
A pure Elixir server-side data plotting/charting library outputting SVG.
It has nice barcharts in particular and works great with LiveView.
Project is here: https://github.com/mindok/contex.
There’s a v0.1.0 package up on hex, but probably to link to github for another week or two.
The web-site https://contex-charts.org/ has some interactive samples so you can take a look, but there are some screenshots below so you don’t even have to follow a link
The code for the web-site is here: https://github.com/mindok/contex-samples. This code is currently the best documentation…
Is it ready for production?
It’s pretty early days. I’m announcing I think it may be useful even it it’s a bit raw in places. See limitations below.
Why did you write it?
For a couple of reasons:
- I have benefitted immensely from the open source community and decided that this could be a reasonable gift back to the community as a way of saying thanks. I know from reading the forums etc that there is a need for something like this
What are the main limitations?
- It’s early days, so the API is going to change and that might break any code that relies on it. Plus documentation is somewhere between extremely poor and non-existent.
- Interacting with the graphics (for example, brushing) isn’t possible without a lot of JS. If you need highly interactive graphics, use a JS charting library
- Some browsers (notably iOS-based) don’t pick up clicks from SVG elements, so if you rely on this and have no control over the end user’s browser, you may want to use something else
- There’s no state management in the chart generation at this point, so no smarts to send incremental diffs to the browser as a dataset changes. This may be reconsidered when Phoenix LiveView has better handling of changes to lists, although it is quite complex when it comes to managing and adjusting axes as data change.
Thanks for early feedback from @elcritch & others (suggestions not yet implemented, but will be very shortly)