@rokkit/chart 1.0.0-next.15 → 1.0.0-next.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +150 -46
- package/dist/Plot/index.d.ts +9 -0
- package/dist/PlotState.svelte.d.ts +49 -0
- package/dist/crossfilter/createCrossFilter.svelte.d.ts +13 -0
- package/dist/elements/index.d.ts +6 -0
- package/dist/geoms/lib/areas.d.ts +52 -0
- package/dist/geoms/lib/bars.d.ts +3 -0
- package/dist/index.d.ts +51 -0
- package/dist/lib/brewer.d.ts +9 -0
- package/dist/lib/brewing/BoxBrewer.svelte.d.ts +10 -0
- package/dist/lib/brewing/CartesianBrewer.svelte.d.ts +8 -0
- package/dist/lib/brewing/PieBrewer.svelte.d.ts +8 -0
- package/dist/lib/brewing/ViolinBrewer.svelte.d.ts +9 -0
- package/dist/lib/brewing/axes.svelte.d.ts +66 -0
- package/dist/lib/brewing/bars.svelte.d.ts +56 -0
- package/dist/lib/brewing/brewer.svelte.d.ts +114 -0
- package/dist/lib/brewing/colors.d.ts +17 -0
- package/dist/lib/brewing/dimensions.svelte.d.ts +35 -0
- package/dist/lib/brewing/index.svelte.d.ts +118 -0
- package/dist/lib/brewing/legends.svelte.d.ts +48 -0
- package/dist/lib/brewing/marks/arcs.d.ts +17 -0
- package/dist/lib/brewing/marks/areas.d.ts +31 -0
- package/dist/lib/brewing/marks/bars.d.ts +1 -0
- package/dist/lib/brewing/marks/boxes.d.ts +24 -0
- package/dist/lib/brewing/marks/lines.d.ts +24 -0
- package/dist/lib/brewing/marks/points.d.ts +40 -0
- package/dist/lib/brewing/marks/violins.d.ts +20 -0
- package/dist/lib/brewing/patterns.d.ts +14 -0
- package/dist/lib/brewing/scales.d.ts +28 -0
- package/dist/lib/brewing/scales.svelte.d.ts +24 -0
- package/dist/lib/brewing/stats.d.ts +23 -0
- package/dist/lib/brewing/symbols.d.ts +7 -0
- package/dist/lib/brewing/types.d.ts +162 -0
- package/dist/lib/chart.d.ts +38 -0
- package/dist/lib/context.d.ts +13 -0
- package/dist/lib/grid.d.ts +72 -0
- package/dist/lib/plot/chartProps.d.ts +177 -0
- package/dist/lib/plot/crossfilter.d.ts +13 -0
- package/dist/lib/plot/facet.d.ts +24 -0
- package/dist/lib/plot/frames.d.ts +47 -0
- package/dist/lib/plot/helpers.d.ts +3 -0
- package/dist/lib/plot/preset.d.ts +29 -0
- package/dist/lib/plot/scales.d.ts +5 -0
- package/dist/lib/plot/stat.d.ts +32 -0
- package/dist/lib/plot/types.d.ts +89 -0
- package/dist/lib/scales.svelte.d.ts +35 -0
- package/dist/lib/swatch.d.ts +12 -0
- package/dist/lib/ticks.d.ts +36 -0
- package/dist/lib/utils.d.ts +61 -0
- package/dist/lib/xscale.d.ts +11 -0
- package/dist/patterns/index.d.ts +4 -0
- package/dist/patterns/patterns.d.ts +72 -0
- package/dist/patterns/scale.d.ts +30 -0
- package/dist/symbols/constants/index.d.ts +1 -0
- package/dist/symbols/index.d.ts +5 -0
- package/package.json +41 -45
- package/src/AnimatedPlot.svelte +215 -0
- package/src/Chart.svelte +98 -0
- package/src/FacetPlot/Panel.svelte +23 -0
- package/src/FacetPlot.svelte +90 -0
- package/src/Plot/Arc.svelte +29 -0
- package/src/Plot/Area.svelte +25 -0
- package/src/Plot/Axis.svelte +73 -0
- package/src/Plot/Bar.svelte +96 -0
- package/src/Plot/Grid.svelte +30 -0
- package/src/Plot/Legend.svelte +167 -0
- package/src/Plot/Line.svelte +27 -0
- package/src/Plot/Point.svelte +27 -0
- package/src/Plot/Root.svelte +107 -0
- package/src/Plot/Timeline.svelte +95 -0
- package/src/Plot/Tooltip.svelte +81 -0
- package/src/Plot/index.js +9 -0
- package/src/Plot.svelte +181 -0
- package/src/PlotState.svelte.js +277 -0
- package/src/Sparkline.svelte +69 -0
- package/src/Symbol.svelte +21 -0
- package/src/Texture.svelte +18 -0
- package/src/charts/AreaChart.svelte +25 -0
- package/src/charts/BarChart.svelte +26 -0
- package/src/charts/BoxPlot.svelte +21 -0
- package/src/charts/BubbleChart.svelte +23 -0
- package/src/charts/LineChart.svelte +26 -0
- package/src/charts/PieChart.svelte +25 -0
- package/src/charts/ScatterPlot.svelte +25 -0
- package/src/charts/ViolinPlot.svelte +21 -0
- package/src/crossfilter/CrossFilter.svelte +38 -0
- package/src/crossfilter/FilterBar.svelte +32 -0
- package/src/crossfilter/FilterSlider.svelte +79 -0
- package/src/crossfilter/createCrossFilter.svelte.js +120 -0
- package/src/elements/Bar.svelte +22 -24
- package/src/elements/ColorRamp.svelte +20 -22
- package/src/elements/ContinuousLegend.svelte +20 -17
- package/src/elements/DefinePatterns.svelte +24 -0
- package/src/elements/DiscreteLegend.svelte +15 -15
- package/src/elements/Label.svelte +4 -8
- package/src/elements/SymbolGrid.svelte +22 -0
- package/src/elements/index.js +6 -0
- package/src/examples/BarChartExample.svelte +81 -0
- package/src/geoms/Arc.svelte +81 -0
- package/src/geoms/Area.svelte +50 -0
- package/src/geoms/Bar.svelte +142 -0
- package/src/geoms/Box.svelte +103 -0
- package/src/geoms/LabelPill.svelte +17 -0
- package/src/geoms/Line.svelte +99 -0
- package/src/geoms/Point.svelte +105 -0
- package/src/geoms/Violin.svelte +46 -0
- package/src/geoms/lib/areas.js +131 -0
- package/src/geoms/lib/bars.js +172 -0
- package/src/index.js +67 -16
- package/src/lib/brewer.js +25 -0
- package/src/lib/brewing/BoxBrewer.svelte.js +56 -0
- package/src/lib/brewing/CartesianBrewer.svelte.js +17 -0
- package/src/lib/brewing/PieBrewer.svelte.js +14 -0
- package/src/lib/brewing/ViolinBrewer.svelte.js +55 -0
- package/src/lib/brewing/axes.svelte.js +270 -0
- package/src/lib/brewing/bars.svelte.js +201 -0
- package/src/lib/brewing/brewer.svelte.js +230 -0
- package/src/lib/brewing/colors.js +22 -0
- package/src/lib/brewing/dimensions.svelte.js +56 -0
- package/src/lib/brewing/index.svelte.js +205 -0
- package/src/lib/brewing/legends.svelte.js +137 -0
- package/src/lib/brewing/marks/arcs.js +43 -0
- package/src/lib/brewing/marks/areas.js +59 -0
- package/src/lib/brewing/marks/bars.js +49 -0
- package/src/lib/brewing/marks/boxes.js +75 -0
- package/src/lib/brewing/marks/lines.js +48 -0
- package/src/lib/brewing/marks/points.js +57 -0
- package/src/lib/brewing/marks/violins.js +90 -0
- package/src/lib/brewing/patterns.js +31 -0
- package/src/lib/brewing/scales.js +51 -0
- package/src/lib/brewing/scales.svelte.js +82 -0
- package/src/lib/brewing/stats.js +66 -0
- package/src/lib/brewing/symbols.js +10 -0
- package/src/lib/brewing/types.js +73 -0
- package/src/lib/chart.js +220 -0
- package/src/lib/context.js +131 -0
- package/src/lib/grid.js +85 -0
- package/src/lib/plot/chartProps.js +76 -0
- package/src/lib/plot/crossfilter.js +16 -0
- package/src/lib/plot/facet.js +58 -0
- package/src/lib/plot/frames.js +80 -0
- package/src/lib/plot/helpers.js +14 -0
- package/src/lib/plot/preset.js +53 -0
- package/src/lib/plot/scales.js +56 -0
- package/src/lib/plot/stat.js +92 -0
- package/src/lib/plot/types.js +65 -0
- package/src/lib/scales.svelte.js +151 -0
- package/src/lib/swatch.js +13 -0
- package/src/lib/ticks.js +46 -0
- package/src/lib/utils.js +111 -118
- package/src/lib/xscale.js +31 -0
- package/src/patterns/DefinePatterns.svelte +32 -0
- package/src/patterns/PatternDef.svelte +27 -0
- package/src/patterns/index.js +4 -0
- package/src/patterns/patterns.js +208 -0
- package/src/patterns/scale.js +87 -0
- package/src/spec/chart-spec.js +29 -0
- package/src/symbols/RoundedSquare.svelte +33 -0
- package/src/symbols/Shape.svelte +37 -0
- package/src/symbols/constants/index.js +4 -0
- package/src/symbols/index.js +9 -0
- package/src/symbols/outline.svelte +60 -0
- package/src/symbols/solid.svelte +60 -0
- package/src/chart/FacetGrid.svelte +0 -51
- package/src/chart/Grid.svelte +0 -34
- package/src/chart/Legend.svelte +0 -16
- package/src/chart/PatternDefs.svelte +0 -13
- package/src/chart/Swatch.svelte +0 -93
- package/src/chart/SwatchButton.svelte +0 -29
- package/src/chart/SwatchGrid.svelte +0 -55
- package/src/chart/Symbol.svelte +0 -37
- package/src/chart/Texture.svelte +0 -16
- package/src/chart/TexturedShape.svelte +0 -27
- package/src/chart/TimelapseChart.svelte +0 -97
- package/src/chart/Timer.svelte +0 -27
- package/src/chart.js +0 -9
- package/src/components/charts/Axis.svelte +0 -66
- package/src/components/charts/Chart.svelte +0 -35
- package/src/components/index.js +0 -23
- package/src/components/lib/axis.js +0 -0
- package/src/components/lib/chart.js +0 -187
- package/src/components/lib/color.js +0 -327
- package/src/components/lib/funnel.js +0 -204
- package/src/components/lib/index.js +0 -19
- package/src/components/lib/pattern.js +0 -190
- package/src/components/lib/rollup.js +0 -55
- package/src/components/lib/shape.js +0 -199
- package/src/components/lib/summary.js +0 -145
- package/src/components/lib/theme.js +0 -23
- package/src/components/lib/timer.js +0 -41
- package/src/components/lib/utils.js +0 -165
- package/src/components/plots/BarPlot.svelte +0 -36
- package/src/components/plots/BoxPlot.svelte +0 -54
- package/src/components/plots/ScatterPlot.svelte +0 -30
- package/src/components/store.js +0 -70
- package/src/constants.js +0 -66
- package/src/elements/PatternDefs.svelte +0 -13
- package/src/elements/PatternMask.svelte +0 -20
- package/src/elements/Symbol.svelte +0 -38
- package/src/elements/Tooltip.svelte +0 -23
- package/src/funnel.svelte +0 -35
- package/src/geom.js +0 -105
- package/src/lib/axis.js +0 -75
- package/src/lib/colors.js +0 -32
- package/src/lib/geom.js +0 -4
- package/src/lib/shapes.js +0 -144
- package/src/lib/timer.js +0 -44
- package/src/lookup.js +0 -29
- package/src/plots/BarPlot.svelte +0 -55
- package/src/plots/BoxPlot.svelte +0 -0
- package/src/plots/FunnelPlot.svelte +0 -33
- package/src/plots/HeatMap.svelte +0 -5
- package/src/plots/HeatMapCalendar.svelte +0 -129
- package/src/plots/LinePlot.svelte +0 -55
- package/src/plots/Plot.svelte +0 -25
- package/src/plots/RankBarPlot.svelte +0 -38
- package/src/plots/ScatterPlot.svelte +0 -20
- package/src/plots/ViolinPlot.svelte +0 -11
- package/src/plots/heatmap.js +0 -70
- package/src/plots/index.js +0 -10
- package/src/swatch.js +0 -11
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,55 +1,159 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rokkit/chart
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Data-driven D3 chart components for Svelte 5, inspired by the composable approach of [dc.js](https://dc-js.github.io/dc.js/).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- [Svelte](https://svelte.dev/) makes UI development fun again. It provides modularization, interactivity, reactivity, and responsiveness.
|
|
5
|
+
## Install
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
```bash
|
|
8
|
+
bun add @rokkit/chart
|
|
9
|
+
# or
|
|
10
|
+
npm install @rokkit/chart
|
|
11
|
+
```
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
- [Animated, Responsive, and Reactive Data Visualization with Svelte](https://www.infoq.com/news/2020/10/svelte-d3-animation-data-vis/)
|
|
12
|
-
- [Barchart Race using Svelte & D3](https://t.co/iIoJw4f7Jc?amp=1) by [Amelia Wattenberger](https://mobile.twitter.com/Wattenberger) & [Russell Goldenberg](https://mobile.twitter.com/codenberg)
|
|
13
|
-
- [The D3.js Graph Gallery](https://www.d3-graph-gallery.com/index.html)
|
|
14
|
-
- [DC.js](https://dc-js.github.io/dc.js/) is an awesome implementation of interactive animated charts using D3.
|
|
13
|
+
## Overview
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
`@rokkit/chart` provides composable SVG chart components built on D3. All components are placed inside `Plot.Root`, which manages shared state (scales, dimensions, color mapping) via Svelte context. Child components read from that context — you do not wire them together manually.
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
## Usage
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
### Basic bar chart
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script>
|
|
23
|
+
import { Plot } from '@rokkit/chart'
|
|
24
|
+
|
|
25
|
+
const data = [
|
|
26
|
+
{ month: 'Jan', sales: 120, returns: 30 },
|
|
27
|
+
{ month: 'Feb', sales: 150, returns: 20 },
|
|
28
|
+
{ month: 'Mar', sales: 90, returns: 40 }
|
|
29
|
+
]
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<Plot.Root {data} width={600} height={400} fill="month">
|
|
33
|
+
<Plot.Grid />
|
|
34
|
+
<Plot.Axis type="x" field="month" label="Month" />
|
|
35
|
+
<Plot.Axis type="y" field="sales" label="Sales" />
|
|
36
|
+
<Plot.Bar x="month" y="sales" />
|
|
37
|
+
<Plot.Legend />
|
|
38
|
+
</Plot.Root>
|
|
22
39
|
```
|
|
23
40
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
### Using `@rokkit/data` for preprocessing
|
|
42
|
+
|
|
43
|
+
```svelte
|
|
44
|
+
<script>
|
|
45
|
+
import { Plot } from '@rokkit/chart'
|
|
46
|
+
import { dataset } from '@rokkit/data'
|
|
47
|
+
|
|
48
|
+
const raw = [
|
|
49
|
+
{ category: 'Electronics', name: 'A', revenue: 450 },
|
|
50
|
+
{ category: 'Clothing', name: 'B', revenue: 320 },
|
|
51
|
+
{ category: 'Electronics', name: 'C', revenue: 620 }
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
const data = dataset(raw)
|
|
55
|
+
.groupBy('category')
|
|
56
|
+
.summarize('name', { total: (vals) => vals.reduce((s, v) => s + v.revenue, 0) })
|
|
57
|
+
.rollup()
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<Plot.Root {data} fill="category" width={500} height={350}>
|
|
61
|
+
<Plot.Axis type="x" field="category" />
|
|
62
|
+
<Plot.Axis type="y" field="total" />
|
|
63
|
+
<Plot.Bar x="category" y="total" />
|
|
64
|
+
<Plot.Legend />
|
|
65
|
+
</Plot.Root>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Using `ChartBrewer` for advanced control
|
|
69
|
+
|
|
70
|
+
`ChartBrewer` is the reactive state manager that `Plot.Root` uses internally. Use it directly when you need programmatic access to scales, axes, or legend state outside of the component tree.
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
import { ChartBrewer, createScales, createBars } from '@rokkit/chart'
|
|
74
|
+
|
|
75
|
+
const brewer = new ChartBrewer({
|
|
76
|
+
width: 600,
|
|
77
|
+
height: 400,
|
|
78
|
+
margin: { top: 20, right: 30, bottom: 40, left: 50 },
|
|
79
|
+
padding: 0.2,
|
|
80
|
+
animationDuration: 300
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
brewer.setData(data)
|
|
84
|
+
brewer.setFields({ x: 'month', y: 'sales', color: 'month' })
|
|
85
|
+
brewer.createScales()
|
|
86
|
+
|
|
87
|
+
const scales = brewer.getScales()
|
|
88
|
+
const dimensions = brewer.getDimensions()
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API
|
|
92
|
+
|
|
93
|
+
### Components (`Plot` namespace)
|
|
94
|
+
|
|
95
|
+
| Component | Description |
|
|
96
|
+
| ------------- | --------------------------------------------------------- |
|
|
97
|
+
| `Plot.Root` | Chart container. Manages dimensions, scales, and context. |
|
|
98
|
+
| `Plot.Bar` | Bar series. Reads x/y fields and renders SVG rects. |
|
|
99
|
+
| `Plot.Axis` | X or Y axis with optional label and tick formatting. |
|
|
100
|
+
| `Plot.Grid` | Background grid lines derived from axis scales. |
|
|
101
|
+
| `Plot.Legend` | Color legend; clicking items filters the visible series. |
|
|
102
|
+
|
|
103
|
+
### `Plot.Root` props
|
|
104
|
+
|
|
105
|
+
| Prop | Type | Default | Description |
|
|
106
|
+
| ------------------- | ------------------ | ------------------------------------- | --------------------------------------------------------------------- |
|
|
107
|
+
| `data` | `array \| dataset` | `[]` | Chart data. Accepts a plain array or a `@rokkit/data` dataset object. |
|
|
108
|
+
| `width` | `number` | `600` | SVG width in pixels. |
|
|
109
|
+
| `height` | `number` | `400` | SVG height in pixels. |
|
|
110
|
+
| `margin` | `object` | `{top:20,right:30,bottom:40,left:50}` | Chart margins. |
|
|
111
|
+
| `fill` | `string` | `null` | Field name used for color mapping. |
|
|
112
|
+
| `responsive` | `boolean` | `true` | Resize with the container. |
|
|
113
|
+
| `animationDuration` | `number` | `300` | Transition duration in ms. |
|
|
114
|
+
|
|
115
|
+
### `Plot.Bar` props
|
|
116
|
+
|
|
117
|
+
| Prop | Type | Default | Description |
|
|
118
|
+
| ------------------- | ---------- | ----------- | --------------------------------------------- |
|
|
119
|
+
| `x` | `string` | — | Field for x-axis values. |
|
|
120
|
+
| `y` | `string` | — | Field for y-axis values. |
|
|
121
|
+
| `fill` | `string` | — | Field for color mapping (overrides root). |
|
|
122
|
+
| `color` | `string` | `'#4682b4'` | Fallback bar color when no fill field is set. |
|
|
123
|
+
| `opacity` | `number` | `1` | Bar opacity. |
|
|
124
|
+
| `animationDuration` | `number` | `300` | Per-bar transition duration in ms. |
|
|
125
|
+
| `onClick` | `function` | `null` | Click handler; receives the data row. |
|
|
126
|
+
|
|
127
|
+
### `Plot.Axis` props
|
|
128
|
+
|
|
129
|
+
| Prop | Type | Default | Description |
|
|
130
|
+
| ------------ | ------------ | ------- | --------------------------------- |
|
|
131
|
+
| `type` | `'x' \| 'y'` | `'x'` | Axis orientation. |
|
|
132
|
+
| `field` | `string` | — | Data field this axis represents. |
|
|
133
|
+
| `label` | `string` | `''` | Axis label. |
|
|
134
|
+
| `ticks` | `number` | — | Suggested tick count. |
|
|
135
|
+
| `tickFormat` | `function` | — | D3 tick formatter. |
|
|
136
|
+
| `grid` | `boolean` | `false` | Render grid lines from this axis. |
|
|
137
|
+
|
|
138
|
+
### Utility functions
|
|
139
|
+
|
|
140
|
+
| Export | Description |
|
|
141
|
+
| ----------------------------------------- | ------------------------------------------- |
|
|
142
|
+
| `createDimensions(width, height, margin)` | Compute chart area dimensions with margins |
|
|
143
|
+
| `createScales(data, fields, dimensions)` | Generate D3 band/linear scales |
|
|
144
|
+
| `createBars(data, scales, fields)` | Compute bar x/y/width/height attributes |
|
|
145
|
+
| `createGroupedBars(data, scales, fields)` | Compute grouped bar layout |
|
|
146
|
+
| `createLegend(data, colorScale)` | Build legend item array |
|
|
147
|
+
| `filterByLegend(data, activeItems)` | Filter data rows by active legend selection |
|
|
148
|
+
| `createXAxis(scale, options)` | Build D3 x-axis descriptor |
|
|
149
|
+
| `createYAxis(scale, options)` | Build D3 y-axis descriptor |
|
|
150
|
+
| `createGrid(scales, dimensions)` | Build grid line descriptors |
|
|
151
|
+
|
|
152
|
+
## Dependencies
|
|
153
|
+
|
|
154
|
+
- `d3-scale`, `d3-axis`, `d3-format`, `d3-selection`, `d3-array`, `d3-transition`, `d3-scale-chromatic`
|
|
155
|
+
- `@rokkit/core`, `@rokkit/data`, `@rokkit/states`
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
Part of [Rokkit](https://github.com/jerrythomas/rokkit) — a Svelte 5 component library and design system.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as Root } from "./Root.svelte";
|
|
2
|
+
export { default as Axis } from "./Axis.svelte";
|
|
3
|
+
export { default as Bar } from "./Bar.svelte";
|
|
4
|
+
export { default as Legend } from "./Legend.svelte";
|
|
5
|
+
export { default as Grid } from "./Grid.svelte";
|
|
6
|
+
export { default as Line } from "./Line.svelte";
|
|
7
|
+
export { default as Area } from "./Area.svelte";
|
|
8
|
+
export { default as Point } from "./Point.svelte";
|
|
9
|
+
export { default as Arc } from "./Arc.svelte";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export class PlotState {
|
|
2
|
+
constructor(config?: {});
|
|
3
|
+
axisOrigin: undefined[];
|
|
4
|
+
orientation: string;
|
|
5
|
+
colorScaleType: any;
|
|
6
|
+
xScale: any;
|
|
7
|
+
yScale: any;
|
|
8
|
+
colors: Map<unknown, {
|
|
9
|
+
fill: string;
|
|
10
|
+
stroke: string;
|
|
11
|
+
}>;
|
|
12
|
+
patterns: Map<unknown, string> | SvelteMap<any, any>;
|
|
13
|
+
symbols: Map<unknown, string> | SvelteMap<any, any>;
|
|
14
|
+
colorField: any;
|
|
15
|
+
patternField: any;
|
|
16
|
+
symbolField: any;
|
|
17
|
+
geomTypes: SvelteSet<any>;
|
|
18
|
+
xAxisY: any;
|
|
19
|
+
yAxisX: any;
|
|
20
|
+
update(config: any): void;
|
|
21
|
+
registerGeom(config: any): string;
|
|
22
|
+
updateGeom(id: any, config: any): void;
|
|
23
|
+
unregisterGeom(id: any): void;
|
|
24
|
+
geomData(id: any): any[];
|
|
25
|
+
label(field: any): any;
|
|
26
|
+
format(field: any): any;
|
|
27
|
+
tooltip(): any;
|
|
28
|
+
geomComponent(type: any): any;
|
|
29
|
+
preset(): {
|
|
30
|
+
colors: any;
|
|
31
|
+
patterns: any;
|
|
32
|
+
symbols: any;
|
|
33
|
+
};
|
|
34
|
+
get margin(): {
|
|
35
|
+
top: number;
|
|
36
|
+
right: number;
|
|
37
|
+
bottom: number;
|
|
38
|
+
left: number;
|
|
39
|
+
};
|
|
40
|
+
get innerWidth(): number;
|
|
41
|
+
get innerHeight(): number;
|
|
42
|
+
get mode(): string;
|
|
43
|
+
get hovered(): null;
|
|
44
|
+
setHovered(data: any): void;
|
|
45
|
+
clearHovered(): void;
|
|
46
|
+
#private;
|
|
47
|
+
}
|
|
48
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
49
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function createCrossFilter(): {
|
|
2
|
+
/** @readonly — reactive Map of current filter state */
|
|
3
|
+
readonly filters: SvelteMap<any, any>;
|
|
4
|
+
/** @readonly — increments on every mutation; read inside $effect to react to any filter change */
|
|
5
|
+
readonly version: number;
|
|
6
|
+
isFiltered: (dimension: string) => boolean;
|
|
7
|
+
isDimmed: (dimension: string, value: unknown) => boolean;
|
|
8
|
+
toggleCategorical: (dimension: string, value: unknown) => void;
|
|
9
|
+
setRange: (dimension: string, range: [number, number]) => void;
|
|
10
|
+
clearFilter: (dimension: string) => void;
|
|
11
|
+
clearAll: () => void;
|
|
12
|
+
};
|
|
13
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Bar } from "./Bar.svelte";
|
|
2
|
+
export { default as ColorRamp } from "./ColorRamp.svelte";
|
|
3
|
+
export { default as ContinuousLegend } from "./ContinuousLegend.svelte";
|
|
4
|
+
export { default as Label } from "./Label.svelte";
|
|
5
|
+
export { default as DefinePatterns } from "./DefinePatterns.svelte";
|
|
6
|
+
export { default as SymbolGrid } from "./SymbolGrid.svelte";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds area path geometry for multi-series area charts.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object[]} data
|
|
5
|
+
* @param {{ x: string, y: string, color?: string }} channels
|
|
6
|
+
* @param {Function} xScale
|
|
7
|
+
* @param {Function} yScale
|
|
8
|
+
* @param {Map<unknown, {fill: string, stroke: string}>} colors
|
|
9
|
+
* @param {'linear'|'smooth'|'step'} [curve]
|
|
10
|
+
* @param {Map<unknown, string>} [patterns]
|
|
11
|
+
* @returns {{ d: string, fill: string, stroke: string, key: unknown, patternId: string|null }[]}
|
|
12
|
+
*/
|
|
13
|
+
export function buildAreas(data: Object[], channels: {
|
|
14
|
+
x: string;
|
|
15
|
+
y: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
}, xScale: Function, yScale: Function, colors: Map<unknown, {
|
|
18
|
+
fill: string;
|
|
19
|
+
stroke: string;
|
|
20
|
+
}>, curve?: "linear" | "smooth" | "step", patterns?: Map<unknown, string>): {
|
|
21
|
+
d: string;
|
|
22
|
+
fill: string;
|
|
23
|
+
stroke: string;
|
|
24
|
+
key: unknown;
|
|
25
|
+
patternId: string | null;
|
|
26
|
+
}[];
|
|
27
|
+
/**
|
|
28
|
+
* Builds stacked area paths using d3 stack layout.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object[]} data
|
|
31
|
+
* @param {{ x: string, y: string, color: string }} channels
|
|
32
|
+
* @param {Function} xScale
|
|
33
|
+
* @param {Function} yScale
|
|
34
|
+
* @param {Map<unknown, {fill: string, stroke: string}>} colors
|
|
35
|
+
* @param {'linear'|'smooth'|'step'} [curve]
|
|
36
|
+
* @param {Map<unknown, string>} [patterns]
|
|
37
|
+
* @returns {{ d: string, fill: string, stroke: string, key: unknown, patternId: string|null }[]}
|
|
38
|
+
*/
|
|
39
|
+
export function buildStackedAreas(data: Object[], channels: {
|
|
40
|
+
x: string;
|
|
41
|
+
y: string;
|
|
42
|
+
color: string;
|
|
43
|
+
}, xScale: Function, yScale: Function, colors: Map<unknown, {
|
|
44
|
+
fill: string;
|
|
45
|
+
stroke: string;
|
|
46
|
+
}>, curve?: "linear" | "smooth" | "step", patterns?: Map<unknown, string>): {
|
|
47
|
+
d: string;
|
|
48
|
+
fill: string;
|
|
49
|
+
stroke: string;
|
|
50
|
+
key: unknown;
|
|
51
|
+
patternId: string | null;
|
|
52
|
+
}[];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export function buildGroupedBars(data: any, channels: any, xScale: any, yScale: any, colors: any, innerHeight: any, patterns: any): any;
|
|
2
|
+
export function buildStackedBars(data: any, channels: any, xScale: any, yScale: any, colors: any, innerHeight: any, patterns: any): any;
|
|
3
|
+
export function buildHorizontalBars(data: any, channels: any, xScale: any, yScale: any, colors: any, _innerHeight: any): any;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export namespace PlotLayers {
|
|
2
|
+
export { Root };
|
|
3
|
+
export { Axis };
|
|
4
|
+
export { Bar };
|
|
5
|
+
export { Grid };
|
|
6
|
+
export { Legend };
|
|
7
|
+
export { Line };
|
|
8
|
+
export { Area };
|
|
9
|
+
export { Point };
|
|
10
|
+
export { Arc };
|
|
11
|
+
}
|
|
12
|
+
export { default as PlotChart } from "./Plot.svelte";
|
|
13
|
+
export { default as FacetPlot } from "./FacetPlot.svelte";
|
|
14
|
+
export { default as AnimatedPlot } from "./AnimatedPlot.svelte";
|
|
15
|
+
export { default as GeomBar } from "./geoms/Bar.svelte";
|
|
16
|
+
export { default as GeomLine } from "./geoms/Line.svelte";
|
|
17
|
+
export { default as GeomArea } from "./geoms/Area.svelte";
|
|
18
|
+
export { default as GeomPoint } from "./geoms/Point.svelte";
|
|
19
|
+
export { default as GeomArc } from "./geoms/Arc.svelte";
|
|
20
|
+
export { default as GeomBox } from "./geoms/Box.svelte";
|
|
21
|
+
export { default as GeomViolin } from "./geoms/Violin.svelte";
|
|
22
|
+
export { default as Chart } from "./Chart.svelte";
|
|
23
|
+
export { default as Sparkline } from "./Sparkline.svelte";
|
|
24
|
+
export { default as BarChart } from "./charts/BarChart.svelte";
|
|
25
|
+
export { default as LineChart } from "./charts/LineChart.svelte";
|
|
26
|
+
export { default as AreaChart } from "./charts/AreaChart.svelte";
|
|
27
|
+
export { default as PieChart } from "./charts/PieChart.svelte";
|
|
28
|
+
export { default as ScatterPlot } from "./charts/ScatterPlot.svelte";
|
|
29
|
+
export { default as BoxPlot } from "./charts/BoxPlot.svelte";
|
|
30
|
+
export { default as ViolinPlot } from "./charts/ViolinPlot.svelte";
|
|
31
|
+
export { default as BubbleChart } from "./charts/BubbleChart.svelte";
|
|
32
|
+
export { PlotState } from "./PlotState.svelte.js";
|
|
33
|
+
export { ChartBrewer } from "./lib/brewing/index.svelte.js";
|
|
34
|
+
export * from "./lib/brewing/index.svelte.js";
|
|
35
|
+
export { CartesianBrewer } from "./lib/brewing/CartesianBrewer.svelte.js";
|
|
36
|
+
export { PieBrewer } from "./lib/brewing/PieBrewer.svelte.js";
|
|
37
|
+
export { BoxBrewer } from "./lib/brewing/BoxBrewer.svelte.js";
|
|
38
|
+
export { ViolinBrewer } from "./lib/brewing/ViolinBrewer.svelte.js";
|
|
39
|
+
export { createCrossFilter } from "./crossfilter/createCrossFilter.svelte.js";
|
|
40
|
+
export { default as CrossFilter } from "./crossfilter/CrossFilter.svelte";
|
|
41
|
+
export { default as FilterBar } from "./crossfilter/FilterBar.svelte";
|
|
42
|
+
export { default as FilterSlider } from "./crossfilter/FilterSlider.svelte";
|
|
43
|
+
import Root from './Plot/Root.svelte';
|
|
44
|
+
import Axis from './Plot/Axis.svelte';
|
|
45
|
+
import Bar from './Plot/Bar.svelte';
|
|
46
|
+
import Grid from './Plot/Grid.svelte';
|
|
47
|
+
import Legend from './Plot/Legend.svelte';
|
|
48
|
+
import Line from './Plot/Line.svelte';
|
|
49
|
+
import Area from './Plot/Area.svelte';
|
|
50
|
+
import Point from './Plot/Point.svelte';
|
|
51
|
+
import Arc from './Plot/Arc.svelte';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get fill patterns for a set of values
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} values - Array of values
|
|
5
|
+
* @param {Object} swatch - Object with keys for color, gray, and pattern
|
|
6
|
+
* @param {Boolean} gray - Boolean to determine if gray or color
|
|
7
|
+
* @returns {Object} - Object with keys for pattern and color
|
|
8
|
+
*/
|
|
9
|
+
export function getFillPatterns(values: any[], swatch: Object, gray?: boolean): Object;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brewer for box plots. Always computes quartile statistics regardless of the stat prop.
|
|
3
|
+
* Groups by x + fill (primary) or x + color (fallback).
|
|
4
|
+
* fill = box interior color, color = whisker/outline stroke.
|
|
5
|
+
*/
|
|
6
|
+
export class BoxBrewer extends ChartBrewer {
|
|
7
|
+
transform(data: any, channels: any): any;
|
|
8
|
+
boxes: any[];
|
|
9
|
+
}
|
|
10
|
+
import { ChartBrewer } from './brewer.svelte.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brewer for cartesian charts (Bar, Line, Area).
|
|
3
|
+
* Groups by x (and fill/color if set) and applies the given stat.
|
|
4
|
+
*/
|
|
5
|
+
export class CartesianBrewer extends ChartBrewer {
|
|
6
|
+
transform(data: any, channels: any, stat: any): any;
|
|
7
|
+
}
|
|
8
|
+
import { ChartBrewer } from './brewer.svelte.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brewer for pie charts. Always aggregates by the label field.
|
|
3
|
+
* 'identity' is not meaningful for pie charts — falls back to 'sum'.
|
|
4
|
+
*/
|
|
5
|
+
export class PieBrewer extends ChartBrewer {
|
|
6
|
+
transform(data: any, channels: any, stat: any): any;
|
|
7
|
+
}
|
|
8
|
+
import { ChartBrewer } from './brewer.svelte.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brewer for violin plots. Computes the same quartile statistics as BoxBrewer.
|
|
3
|
+
* fill = violin body color, color = outline stroke.
|
|
4
|
+
*/
|
|
5
|
+
export class ViolinBrewer extends ChartBrewer {
|
|
6
|
+
transform(data: any, channels: any): any;
|
|
7
|
+
violins: any[];
|
|
8
|
+
}
|
|
9
|
+
import { ChartBrewer } from './brewer.svelte.js';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates x-axis tick data for rendering
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} scales - Chart scales
|
|
5
|
+
* @param {Function} scales.x - X-axis scale
|
|
6
|
+
* @param {Object} dimensions - Chart dimensions
|
|
7
|
+
* @param {Object} options - Axis options
|
|
8
|
+
* @param {number} [options.tickCount] - Number of ticks to show
|
|
9
|
+
* @param {Function} [options.tickFormat] - Tick formatting function
|
|
10
|
+
* @param {string} [options.label] - Axis label
|
|
11
|
+
* @returns {AxisData} Axis rendering data
|
|
12
|
+
*/
|
|
13
|
+
export function createXAxis(scales: {
|
|
14
|
+
x: Function;
|
|
15
|
+
}, dimensions: Object, options: {
|
|
16
|
+
tickCount?: number | undefined;
|
|
17
|
+
tickFormat?: Function | undefined;
|
|
18
|
+
label?: string | undefined;
|
|
19
|
+
}): AxisData;
|
|
20
|
+
/**
|
|
21
|
+
* Creates y-axis tick data for rendering
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} scales - Chart scales
|
|
24
|
+
* @param {Function} scales.y - Y-axis scale
|
|
25
|
+
* @param {Object} dimensions - Chart dimensions
|
|
26
|
+
* @param {Object} options - Axis options
|
|
27
|
+
* @param {number} [options.tickCount] - Number of ticks to show
|
|
28
|
+
* @param {Function} [options.tickFormat] - Tick formatting function
|
|
29
|
+
* @param {string} [options.label] - Axis label
|
|
30
|
+
* @returns {AxisData} Axis rendering data
|
|
31
|
+
*/
|
|
32
|
+
export function createYAxis(scales: {
|
|
33
|
+
y: Function;
|
|
34
|
+
}, dimensions: Object, options: {
|
|
35
|
+
tickCount?: number | undefined;
|
|
36
|
+
tickFormat?: Function | undefined;
|
|
37
|
+
label?: string | undefined;
|
|
38
|
+
}): AxisData;
|
|
39
|
+
/**
|
|
40
|
+
* Creates grid line data for rendering
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} scales - Chart scales
|
|
43
|
+
* @param {Object} dimensions - Chart dimensions
|
|
44
|
+
* @param {Object} options - Grid options
|
|
45
|
+
* @param {string} [options.direction='both'] - Grid direction ('x', 'y', or 'both')
|
|
46
|
+
* @param {number} [options.xTickCount] - Number of x-axis ticks
|
|
47
|
+
* @param {number} [options.yTickCount] - Number of y-axis ticks
|
|
48
|
+
* @returns {Object} Grid rendering data
|
|
49
|
+
*/
|
|
50
|
+
export function createGrid(scales: Object, dimensions: Object, options: {
|
|
51
|
+
direction?: string | undefined;
|
|
52
|
+
xTickCount?: number | undefined;
|
|
53
|
+
yTickCount?: number | undefined;
|
|
54
|
+
}): Object;
|
|
55
|
+
/**
|
|
56
|
+
* Creates DOM attributes for a tick element
|
|
57
|
+
*
|
|
58
|
+
* @param {TickData} tick - Tick data
|
|
59
|
+
* @param {string} axis - Axis type ('x' or 'y')
|
|
60
|
+
* @returns {Object} Attributes for the tick
|
|
61
|
+
*/
|
|
62
|
+
export function createTickAttributes(tick: TickData, axis: string): Object;
|
|
63
|
+
export type TickData = import("./types").TickData;
|
|
64
|
+
export type AxisData = import("./types").AxisData;
|
|
65
|
+
export type ChartScales = import("./types").ChartScales;
|
|
66
|
+
export type ChartDimensions = import("./types").ChartDimensions;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates bar data for rendering
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} data - Chart data
|
|
5
|
+
* @param {Object} fields - Field mappings
|
|
6
|
+
* @param {string} fields.x - X-axis field
|
|
7
|
+
* @param {string} fields.y - Y-axis field
|
|
8
|
+
* @param {string} fields.color - Color field (optional)
|
|
9
|
+
* @param {Object} scales - Chart scales
|
|
10
|
+
* @param {Function} scales.x - X-axis scale
|
|
11
|
+
* @param {Function} scales.y - Y-axis scale
|
|
12
|
+
* @param {Function} scales.color - Color scale
|
|
13
|
+
* @param {Object} options - Options including dimensions and defaultColor
|
|
14
|
+
* @param {Object} options.dimensions - Chart dimensions
|
|
15
|
+
* @param {string} [options.defaultColor='#4682b4'] - Default color if no color scale
|
|
16
|
+
* @returns {BarData[]} Bar data for rendering
|
|
17
|
+
*/
|
|
18
|
+
export function createBars(data: any[], fields: {
|
|
19
|
+
x: string;
|
|
20
|
+
y: string;
|
|
21
|
+
color: string;
|
|
22
|
+
}, scales: {
|
|
23
|
+
x: Function;
|
|
24
|
+
y: Function;
|
|
25
|
+
color: Function;
|
|
26
|
+
}, options: {
|
|
27
|
+
dimensions: Object;
|
|
28
|
+
defaultColor?: string | undefined;
|
|
29
|
+
}): BarData[];
|
|
30
|
+
/**
|
|
31
|
+
* Filter bars based on a selection criteria
|
|
32
|
+
*
|
|
33
|
+
* @param {BarData[]} bars - Bar data array
|
|
34
|
+
* @param {Object} selection - Selection criteria
|
|
35
|
+
* @returns {BarData[]} Filtered bars
|
|
36
|
+
*/
|
|
37
|
+
export function filterBars(bars: BarData[], selection: Object): BarData[];
|
|
38
|
+
/**
|
|
39
|
+
* Creates a grouped bars layout
|
|
40
|
+
*
|
|
41
|
+
* @param {Array} data - Chart data
|
|
42
|
+
* @param {Object} fields - Field mappings
|
|
43
|
+
* @param {Object} scales - Chart scales
|
|
44
|
+
* @param {Object} options - Options including dimensions and padding
|
|
45
|
+
* @param {Object} options.dimensions - Chart dimensions
|
|
46
|
+
* @param {number} [options.padding=0.1] - Padding between bars in a group
|
|
47
|
+
* @returns {Object} Grouped bar data
|
|
48
|
+
*/
|
|
49
|
+
export function createGroupedBars(data: any[], fields: Object, scales: Object, options: {
|
|
50
|
+
dimensions: Object;
|
|
51
|
+
padding?: number | undefined;
|
|
52
|
+
}): Object;
|
|
53
|
+
export type BarData = import("./types").BarData;
|
|
54
|
+
export type ScaleFields = import("./types").ScaleFields;
|
|
55
|
+
export type ChartScales = import("./types").ChartScales;
|
|
56
|
+
export type ChartDimensions = import("./types").ChartDimensions;
|