gampleman / elm-visualization

A data visualization library for Elm
http://package.elm-lang.org/packages/gampleman/elm-visualization/latest/
MIT License
514 stars 48 forks source link

examples for box plot and basic scatter chart, added median to statistics #96

Closed Anton-4 closed 3 years ago

Anton-4 commented 4 years ago

I found the examples did not yet have a scatter plot example so I made one :slightly_smiling_face:. I also wanted to make a candlestick chart so I figured I'd get started with a box plot.

Anton-4 commented 4 years ago

I'm going to add a tooltip on hover for the scatterchart.

Anton-4 commented 4 years ago

Implementing a proper tooltip does require some complexity, see implementation in terezka/line-charts. Because it is a common use case I think it would be valuable if we could include it in the library and not just in examples. Let me know what you think.

PS: For my scatter chart I could not use the css hover trick used in the barchart because the hover text appeared behind other circles.

gampleman commented 4 years ago

A hover trick could work, although I would go a bit more sophisticated for a scatter chart and use a Voronoi overlay for getting nice mouse interaction.

The tricky bit with tooltips and the reason that I haven't added them to the library is:

  1. They can be pretty visualisation specific.
  2. Since often the visual marks are too tiny for proper mouse control, you often need a way to make the click targets much bigger.
  3. Tooltips are in general not mobile friendly. So it's best to encourage users to consider other design techniques.
  4. The technically tricky stuff is positioning. However, that can depend on how you are rendering the chart, which elm-visualization tends to be fairly agnostic about.

Also, I see no reason why elm-visualization charts shouldn't work with an external tooltip lib.

Anton-4 commented 4 years ago

Those are good arguments. I will check out the voronoi overlay, thanks for the tip :slightly_smiling_face:!

Anton-4 commented 4 years ago

I did not end up using the voronoi overlay, when the scatter points were close together the voronoi polygons got screwed up. The hover div appears when the mouse hovers over a point's circle or over the rectangle of the then "invisible" tooltip. I will resolve merge conflicts later today probably.

gampleman commented 3 years ago

Hi @Anton-4, we're getting pretty close to the next release and I'm wondering if you happen to have some time to tidy this up? If not I can take this over... Thanks a lot!

Anton-4 commented 3 years ago

Hi Jakub, I'm busy with a deadline for the next 2 weeks. I have time after that, would that delay be acceptable?

gampleman commented 3 years ago

Thanks for getting in touch @Anton-4. Ideally I'd like to make some progress quickly (I have some time for working on elm-visualization, which doesn't happen very often). If you don't mind, I'll do the changes suggested above?

Anton-4 commented 3 years ago

Go ahead :) my apologies for forgetting about this PR.

gampleman commented 3 years ago

No worries, I think I caused by not reviewing it promptly. Thanks again for getting this started!