(Pre-)announcing elm-charts

604 views
Skip to first unread message

Simon

unread,
Nov 3, 2015, 5:43:32 AM11/3/15
to Elm Discuss
I'm about to push this to elm packages but, as this is my first package, I would welcome some comments on code and commenting in advance of that




Max Goldstein

unread,
Nov 3, 2015, 9:06:31 AM11/3/15
to Elm Discuss
Hi Simon,

Is it necessary to export the ChartType union type? If you do, you won't be able to add any charts until 2.0.0. It seems that it's used mostly internally and by chartInit, which also seems like it could be made private.

Is it necessary to take the title parameter in the three different chart functions when it can be set by the title function later? In my animation library, animations are created with only one parameter (the start time), and everything else is set using other functions. The result looks like a DSL if you squint a bit, but is fully type-safe:

myAnim = animation 0 |> from 100 |> to 300 |> duration (4*second) |> delay (1*second)

It's just an opinion, but I like this style of API compared to high-arity functions. It's easier to read, and to extend (add another helper and release a minor release, rather than another argument and break things). So that's why I suggest some of this stuff (and only suggest, it's your library).

If you want each data point to have a label and vice versa, you can take a List (Float, String) as a single argument rather than two lists. This is a slight imposition on the client, who must call List.map2 (,) aList anotherList, but it guarantees you have the same number of floats and strings.

Hope that helps!

Max Goldstein

unread,
Nov 3, 2015, 9:38:15 AM11/3/15
to Elm Discuss
Oh and I forgot to add that Elm uses the American spelling Color for its module name, so you should probably change that to be consistent, or at least provide both spellings.

Spiros Eliopoulos

unread,
Nov 3, 2015, 11:12:42 AM11/3/15
to elm-discuss

On Tue, Nov 3, 2015 at 9:38 AM, Max Goldstein <maxgol...@gmail.com> wrote:
Oh and I forgot to add that Elm uses the American spelling Color for its module name, so you should probably change that to be consistent, or at least provide both spellings.

Too far.

Simon

unread,
Nov 4, 2015, 5:13:29 AM11/4/15
to Elm Discuss
Thanks a lot Max,
I based my API on your animation library so it makes sense to move setting title to a separate function.
Also appreciate your comments on ChartType - would not have thought about that 
Simon

Simon

unread,
Nov 4, 2015, 5:24:14 AM11/4/15
to Elm Discuss
p.s. how do you / others organise their code when developing a package? 

I have tried 
  • emulating the directory structure resulting from `elm-package install` and editing elm-package.json / exact-dependencies.json but that is hard to manage
  • developing in a simple directory with a separate Main.elm. That's what I did here but I end up with start-app in elm-package.json which is not a dependency of the library as such
Simon

Thomas Weiser

unread,
Nov 6, 2015, 3:39:49 PM11/6/15
to elm-d...@googlegroups.com

As in your second option I use a separate directory having its own elm-package.json tailored to the needs of the test application. Include the original sources with something like

  "source-directories": [
    "src",
    "../src"
  ]

Simon

unread,
Nov 10, 2015, 2:30:46 AM11/10/15
to Elm Discuss
Thanks so much - that works!!!

Pete Vilter

unread,
Nov 19, 2015, 4:54:46 AM11/19/15
to Elm Discuss
Nice work! I think the Vega "visualization grammar" could serve as inspiration for a more chart API which supports more kinds of composition — it's amazing how wide a range of visualizations they've been able to create with a pretty small set of concepts. Been meaning to make an Elm version of it for a while now.

Simon

unread,
Nov 19, 2015, 6:46:51 AM11/19/15
to Elm Discuss
OK, so that is pretty cool!
I have rapidly found myself reinventing the wheel, and learning more about SVG than I really needed, but that was necessary in order to deliver a pure-Elm (no pun intended) library.
If I understand correctly, with Vega we would need to wire up some native code and the vega library itself. Notionally I could try to do that, but we get into sensitive area for Elm more generally there. I sense though that you would know how to navigate that rather well as an elm-lang maintainer. What do you suggest?

Simon

Nicholas Kennedy

unread,
Nov 19, 2015, 9:02:07 AM11/19/15
to Elm Discuss
Hey, Awesome! I actually had the same idea a month back, but got busy! For the record, your code looks a lot better ;).

https://github.com/NicholasGW/elm-charts

I already got donut charts working using bezier curves, and was working on line charts...perhaps we can combine some work? In any case I'd love to contribute as I think Elm is a great fit for charts and would be wonderfully straightforward.

Cheers,

Nick

Simon

unread,
Nov 19, 2015, 9:30:06 AM11/19/15
to Elm Discuss
I'd love to collaborate!!

Thanks for the comment about the code, but note that I got the basic design ideas from the Elm-Animation package. I would imagine that line charts would fit easily into my framework, in the sense that the current Model has the right sot of data for them. I don't know about the donuts but will look at your example.

Before proceeding further I do want to hear from Pete, as to whether there is a good way to use existing JS libraries directly (rather than their ideas only).

How does that sound?

For anyone interested, you can see my library 'in production' at https://eu-lobbyists.herokuapp.com/summary

Simon

Simon

unread,
Nov 20, 2015, 4:30:06 AM11/20/15
to Elm Discuss
FYI - library updated to 0.16

Nicholas Kennedy

unread,
Nov 20, 2015, 9:02:16 AM11/20/15
to Elm Discuss
Sure thing! I'm doing a startup weekend this weekend but I'll be sure to take a look at elm-animation. I was thinking the same as I've used d3/nvd3 quite a bit so just wrapping them might be cool too. In any case I think charts in elm would be super awesome so I'm definitely down to contribute!

Nick

Max Goldstein

unread,
Nov 20, 2015, 11:57:22 AM11/20/15
to Elm Discuss
Looking forward to seeing what you make! elm-animation has been updated for 0.16 with version 1.0.2 so hopefully it is helpful.

Pete Vilter

unread,
Nov 20, 2015, 9:16:08 PM11/20/15
to Elm Discuss
Hey Simon,
You can write native libraries, but the way you do it is about to change (in 0.17) so now might not be the best time to embark on a big project.

Plus, a pure elm version of Vega seems not that crazy, and seems like it would be interesting and fun to implement.

In either case, the first step is to write Elm types that mirror Vega's JSON schema. (This might even be helpful to the Vega community, since IMO JSON schemas are super hard to read). From there, you can generate JSON and pass it to Vega, or render it yourself.

Also check out this library, which has a common lineage of ideas with Vega: https://groups.google.com/forum/m/#!msg/elm-discuss/2rWiZTgsViE/V4zMyy85kngJ

—Pete
On Fri, Nov 20, 2015 at 8:57 AM Max Goldstein <maxgol...@gmail.com> wrote:
Looking forward to seeing what you make! elm-animation has been updated for 0.16 with version 1.0.2 so hopefully it is helpful.

--
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/7rgBQvwFSHE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon

unread,
Nov 22, 2015, 1:40:05 AM11/22/15
to Elm Discuss
OK, gonna read up about some of these libraries. For my own needs, I could see how building the Json to pass via a port to vega would be a good next step, so that is perhaps a reasonable first goal.

I also tried to look at elm-diagrams, but I'm using 0.16 and the compile errors went beyond just the `<-` problems, and seemed to include some real type mis-matches

Simon

Pete Vilter

unread,
Nov 22, 2015, 1:45:22 PM11/22/15
to Elm Discuss
Yeah, I'll take a pass at that library at some point :)

A task or even a native pure function may be more appropriate than a port for this situation; not sure.

wuct

unread,
Jul 20, 2016, 12:51:34 PM7/20/16
to Elm Discuss

Hi guys,
I have created a chart lib for E...@0.17 which currently supports bar charts, line charts and scatter plots.
I am looking forward to having your comments and suggestions!

https://github.com/wuct/elm-charts

Reply all
Reply to author
Forward
0 new messages