techniq / layerchart

Composable Svelte chart components to build a wide range of visualizations
https://www.layerchart.com
MIT License
509 stars 10 forks source link

Chart improvements #183

Open techniq opened 2 months ago

techniq commented 2 months ago

Layout components

techniq commented 2 months ago

@mhkeller gathering some changes I've made (or plan to) within LayerChart, some of which might be worth pushing upstream to LayerCake (such as full width Canvas). Integration with LayerChart contexts like TransformContext, GeoContext, and TooltipContext makes some of these changes impractical to move ATM.

mhkeller commented 2 months ago

Thanks I'll keep an eye on it. What does full width Canvas do?

techniq commented 2 months ago

If you applied a padding (such as <Chart padding={{ top: 60 }}>) and zoom or translate the canvas, the chart would be "clipped" since the <canvas> is absolute positioned and inset based on the padding. The change uses context.translate() and the full container size (which aligns the results with <svg transform="...">)

The Choropleth example demonstrated this (compare to an older commit preview).

Before After
image image

You have to scale/zoom or drag/translate to see the issue (not really an issue with most static charts). This would be a problem with more chart types, but I've mostly only focused on Canvas support for geo (since it typically benefits the most with complex geojson). Also hoping to find a fix for the infinite loop issue before I expand out too much (might wait til Svelte 5).