layerchart icon indicating copy to clipboard operation
layerchart copied to clipboard

Expose consistent `data` prop

Open techniq opened this issue 7 months ago • 1 comments

In 2.0.0, we've started to add data directly to hierarchy and graph layout components instead of using <Chart {data}>. This simplifies the typing of <Chart {data}> and removes unnecessary indirection.

  • Graph
    • [x] <ForceSimulation {data}>
    • [x] <Dagre {data}>
    • [ ] <Sankey> - needs data passed directly
  • Hierarchy
    • [ ] <Pack {hierarchy}> - needs renamed to data
    • [ ] <Partition {hierarchy}> - needs renamed to data
    • [ ] <Tree {hierarchy}> - needs renamed to data
    • [ ] <Treemap {hierarchy}> - needs renamed to data

It would also be useful to add data to many other marks such as Axis. Some components already support this, such as

  • Bars
  • Hull
  • Labels
  • Link
  • Pie
  • Points
  • Spline

This is currently leveraged for series support in simplified charts like BarChart and LineChart, but would be useful is most all marks.

Lastly, adding data via marks would then be useful to register it with the chart context to be used to determine overall scale domains (similar to Observable Plot, SveltePlot, visx XYChart, data-ui, and others)

techniq avatar May 31 '25 17:05 techniq

d3-hierarchy's stratify converts a flat array to a hierarchy and not just pure nested structure like hierarchy(data, children) which might complicate taking in <Treemap {daa}> instead of <Treemap {hierarchy}> although we might consider applying stratify internally as well if an Array vs object/tree is passed 🤔.

techniq avatar Jun 11 '25 14:06 techniq