a-b-street / abstreet

Transportation planning and traffic simulation software for creating cities friendlier to walking, biking, and public transit
https://a-b-street.github.io/docs/
Apache License 2.0
7.66k stars 340 forks source link

Explore integration with plotly #196

Closed dabreegster closed 3 years ago

dabreegster commented 4 years ago

https://igiagkiozis.github.io/plotly/content/getting_started.html

This can generate SVG, so this could be used directly. I don't think the result could leverage plotly's interactive stuff, but it'd still be quite useful for different types of diagrams.

JavedNissar commented 4 years ago

How do you imagine this integration working in practice? Like, what do you see as the user flow?

dabreegster commented 4 years ago

1) I don't have an example offhand, but we find something plotly can produce that isn't implemented yet in ezgui and want to add a static diagram to an info panel, like https://github.com/dabreegster/abstreet/blob/f02fdec8e39ef094504a31d03933b0cc82b20174/game/src/info/intersection.rs#L223. 2) The info panel code would fetch the data, probably from Analytics, and call plotly's existing APIs to build a graph. I haven't dug into plotly in a while, but hopefully it handles tricky things like setting good x/y axis scales, drawing large/overlapping labels, etc. 3) Render the plotly object to an SVG string 4) Turn the SVG into normal geometry and draw it: let batch = GeomBatch::from_svg_contents(svg_data)

Probably best to find a specific use case. It's possible that using plotly isn't worth the effort, and making custom ezgui widgets is better, so we can have interactive mouseover.

dabreegster commented 3 years ago

I'll keep plotly in mind as we work on data viz, but I think all our custom stuff in widgetry is working well enough for now.