@voila.dev/chart 4.0.0
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/README.md +85 -0
- package/dist/brush/brush-layer.d.ts +16 -0
- package/dist/brush/brush-layer.d.ts.map +1 -0
- package/dist/brush/brush-layer.js +137 -0
- package/dist/brush/brush-layer.js.map +7 -0
- package/dist/brush/index.d.ts +10 -0
- package/dist/brush/index.d.ts.map +1 -0
- package/dist/brush/index.js +8 -0
- package/dist/brush/index.js.map +7 -0
- package/dist/canvas/canvas-renderer.d.ts +11 -0
- package/dist/canvas/canvas-renderer.d.ts.map +1 -0
- package/dist/canvas/canvas-renderer.js +49 -0
- package/dist/canvas/canvas-renderer.js.map +7 -0
- package/dist/canvas/index.d.ts +2 -0
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/canvas/index.js +5 -0
- package/dist/canvas/index.js.map +7 -0
- package/dist/canvas/paint-scene.d.ts +4 -0
- package/dist/canvas/paint-scene.d.ts.map +1 -0
- package/dist/canvas/paint-scene.js +130 -0
- package/dist/canvas/paint-scene.js.map +7 -0
- package/dist/canvas/resolve-color.d.ts +18 -0
- package/dist/canvas/resolve-color.d.ts.map +1 -0
- package/dist/canvas/resolve-color.js +52 -0
- package/dist/canvas/resolve-color.js.map +7 -0
- package/dist/contour/density.d.ts +20 -0
- package/dist/contour/density.d.ts.map +1 -0
- package/dist/contour/density.js +59 -0
- package/dist/contour/density.js.map +7 -0
- package/dist/contour/index.d.ts +2 -0
- package/dist/contour/index.d.ts.map +1 -0
- package/dist/contour/index.js +5 -0
- package/dist/contour/index.js.map +7 -0
- package/dist/core/channel.d.ts +11 -0
- package/dist/core/channel.d.ts.map +1 -0
- package/dist/core/channel.js +44 -0
- package/dist/core/channel.js.map +7 -0
- package/dist/core/compile.d.ts +22 -0
- package/dist/core/compile.d.ts.map +1 -0
- package/dist/core/compile.js +295 -0
- package/dist/core/compile.js.map +7 -0
- package/dist/core/define-chart.d.ts +96 -0
- package/dist/core/define-chart.d.ts.map +1 -0
- package/dist/core/define-chart.js +7 -0
- package/dist/core/define-chart.js.map +7 -0
- package/dist/core/facet.d.ts +7 -0
- package/dist/core/facet.d.ts.map +1 -0
- package/dist/core/facet.js +134 -0
- package/dist/core/facet.js.map +7 -0
- package/dist/core/format.d.ts +37 -0
- package/dist/core/format.d.ts.map +1 -0
- package/dist/core/format.js +108 -0
- package/dist/core/format.js.map +7 -0
- package/dist/core/guides/axes.d.ts +25 -0
- package/dist/core/guides/axes.d.ts.map +1 -0
- package/dist/core/guides/axes.js +204 -0
- package/dist/core/guides/axes.js.map +7 -0
- package/dist/core/marks/area.d.ts +23 -0
- package/dist/core/marks/area.d.ts.map +1 -0
- package/dist/core/marks/area.js +187 -0
- package/dist/core/marks/area.js.map +7 -0
- package/dist/core/marks/bar.d.ts +26 -0
- package/dist/core/marks/bar.d.ts.map +1 -0
- package/dist/core/marks/bar.js +200 -0
- package/dist/core/marks/bar.js.map +7 -0
- package/dist/core/marks/cell.d.ts +16 -0
- package/dist/core/marks/cell.d.ts.map +1 -0
- package/dist/core/marks/cell.js +98 -0
- package/dist/core/marks/cell.js.map +7 -0
- package/dist/core/marks/dot.d.ts +17 -0
- package/dist/core/marks/dot.d.ts.map +1 -0
- package/dist/core/marks/dot.js +125 -0
- package/dist/core/marks/dot.js.map +7 -0
- package/dist/core/marks/funnel-layout.d.ts +37 -0
- package/dist/core/marks/funnel-layout.d.ts.map +1 -0
- package/dist/core/marks/funnel-layout.js +61 -0
- package/dist/core/marks/funnel-layout.js.map +7 -0
- package/dist/core/marks/funnel.d.ts +19 -0
- package/dist/core/marks/funnel.d.ts.map +1 -0
- package/dist/core/marks/funnel.js +143 -0
- package/dist/core/marks/funnel.js.map +7 -0
- package/dist/core/marks/line.d.ts +17 -0
- package/dist/core/marks/line.d.ts.map +1 -0
- package/dist/core/marks/line.js +150 -0
- package/dist/core/marks/line.js.map +7 -0
- package/dist/core/marks/polar.d.ts +61 -0
- package/dist/core/marks/polar.d.ts.map +1 -0
- package/dist/core/marks/polar.js +436 -0
- package/dist/core/marks/polar.js.map +7 -0
- package/dist/core/marks/rect.d.ts +22 -0
- package/dist/core/marks/rect.d.ts.map +1 -0
- package/dist/core/marks/rect.js +119 -0
- package/dist/core/marks/rect.js.map +7 -0
- package/dist/core/marks/rule.d.ts +17 -0
- package/dist/core/marks/rule.d.ts.map +1 -0
- package/dist/core/marks/rule.js +73 -0
- package/dist/core/marks/rule.js.map +7 -0
- package/dist/core/marks/shared.d.ts +41 -0
- package/dist/core/marks/shared.d.ts.map +1 -0
- package/dist/core/marks/shared.js +74 -0
- package/dist/core/marks/shared.js.map +7 -0
- package/dist/core/marks/stack.d.ts +13 -0
- package/dist/core/marks/stack.d.ts.map +1 -0
- package/dist/core/marks/stack.js +28 -0
- package/dist/core/marks/stack.js.map +7 -0
- package/dist/core/marks/stats/difference.d.ts +20 -0
- package/dist/core/marks/stats/difference.d.ts.map +1 -0
- package/dist/core/marks/stats/difference.js +168 -0
- package/dist/core/marks/stats/difference.js.map +7 -0
- package/dist/core/marks/stats/distribution.d.ts +41 -0
- package/dist/core/marks/stats/distribution.d.ts.map +1 -0
- package/dist/core/marks/stats/distribution.js +354 -0
- package/dist/core/marks/stats/distribution.js.map +7 -0
- package/dist/core/marks/stats/dodge.d.ts +16 -0
- package/dist/core/marks/stats/dodge.d.ts.map +1 -0
- package/dist/core/marks/stats/dodge.js +104 -0
- package/dist/core/marks/stats/dodge.js.map +7 -0
- package/dist/core/marks/stats/hexbin.d.ts +26 -0
- package/dist/core/marks/stats/hexbin.d.ts.map +1 -0
- package/dist/core/marks/stats/hexbin.js +113 -0
- package/dist/core/marks/stats/hexbin.js.map +7 -0
- package/dist/core/marks/stats/histogram.d.ts +27 -0
- package/dist/core/marks/stats/histogram.d.ts.map +1 -0
- package/dist/core/marks/stats/histogram.js +70 -0
- package/dist/core/marks/stats/histogram.js.map +7 -0
- package/dist/core/marks/stats/regression.d.ts +13 -0
- package/dist/core/marks/stats/regression.d.ts.map +1 -0
- package/dist/core/marks/stats/regression.js +80 -0
- package/dist/core/marks/stats/regression.js.map +7 -0
- package/dist/core/marks/stats/statistics.d.ts +34 -0
- package/dist/core/marks/stats/statistics.d.ts.map +1 -0
- package/dist/core/marks/stats/statistics.js +111 -0
- package/dist/core/marks/stats/statistics.js.map +7 -0
- package/dist/core/marks/stats/waffle.d.ts +18 -0
- package/dist/core/marks/stats/waffle.d.ts.map +1 -0
- package/dist/core/marks/stats/waffle.js +117 -0
- package/dist/core/marks/stats/waffle.js.map +7 -0
- package/dist/core/marks/text.d.ts +19 -0
- package/dist/core/marks/text.d.ts.map +1 -0
- package/dist/core/marks/text.js +60 -0
- package/dist/core/marks/text.js.map +7 -0
- package/dist/core/motion/tween.d.ts +6 -0
- package/dist/core/motion/tween.d.ts.map +1 -0
- package/dist/core/motion/tween.js +98 -0
- package/dist/core/motion/tween.js.map +7 -0
- package/dist/core/nearest.d.ts +25 -0
- package/dist/core/nearest.d.ts.map +1 -0
- package/dist/core/nearest.js +151 -0
- package/dist/core/nearest.js.map +7 -0
- package/dist/core/paths.d.ts +65 -0
- package/dist/core/paths.d.ts.map +1 -0
- package/dist/core/paths.js +192 -0
- package/dist/core/paths.js.map +7 -0
- package/dist/core/scales/color.d.ts +11 -0
- package/dist/core/scales/color.d.ts.map +1 -0
- package/dist/core/scales/color.js +35 -0
- package/dist/core/scales/color.js.map +7 -0
- package/dist/core/scales/continuous.d.ts +18 -0
- package/dist/core/scales/continuous.d.ts.map +1 -0
- package/dist/core/scales/continuous.js +82 -0
- package/dist/core/scales/continuous.js.map +7 -0
- package/dist/core/scales/discrete.d.ts +22 -0
- package/dist/core/scales/discrete.d.ts.map +1 -0
- package/dist/core/scales/discrete.js +103 -0
- package/dist/core/scales/discrete.js.map +7 -0
- package/dist/core/scales/resolve.d.ts +18 -0
- package/dist/core/scales/resolve.d.ts.map +1 -0
- package/dist/core/scales/resolve.js +112 -0
- package/dist/core/scales/resolve.js.map +7 -0
- package/dist/core/scales/time.d.ts +4 -0
- package/dist/core/scales/time.d.ts.map +1 -0
- package/dist/core/scales/time.js +140 -0
- package/dist/core/scales/time.js.map +7 -0
- package/dist/core/text.d.ts +3 -0
- package/dist/core/text.d.ts.map +1 -0
- package/dist/core/text.js +29 -0
- package/dist/core/text.js.map +7 -0
- package/dist/core/theme.d.ts +8 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/theme.js +21 -0
- package/dist/core/theme.js.map +7 -0
- package/dist/core/ticks.d.ts +27 -0
- package/dist/core/ticks.d.ts.map +1 -0
- package/dist/core/ticks.js +76 -0
- package/dist/core/ticks.js.map +7 -0
- package/dist/core/types.d.ts +305 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +1 -0
- package/dist/core/types.js.map +7 -0
- package/dist/force/force.d.ts +30 -0
- package/dist/force/force.d.ts.map +1 -0
- package/dist/force/force.js +143 -0
- package/dist/force/force.js.map +7 -0
- package/dist/force/index.d.ts +2 -0
- package/dist/force/index.d.ts.map +1 -0
- package/dist/force/index.js +7 -0
- package/dist/force/index.js.map +7 -0
- package/dist/geo/geo.d.ts +59 -0
- package/dist/geo/geo.d.ts.map +1 -0
- package/dist/geo/geo.js +231 -0
- package/dist/geo/geo.js.map +7 -0
- package/dist/geo/index.d.ts +2 -0
- package/dist/geo/index.d.ts.map +1 -0
- package/dist/geo/index.js +13 -0
- package/dist/geo/index.js.map +7 -0
- package/dist/hierarchy/hierarchy.d.ts +24 -0
- package/dist/hierarchy/hierarchy.d.ts.map +1 -0
- package/dist/hierarchy/hierarchy.js +279 -0
- package/dist/hierarchy/hierarchy.js.map +7 -0
- package/dist/hierarchy/index.d.ts +2 -0
- package/dist/hierarchy/index.d.ts.map +1 -0
- package/dist/hierarchy/index.js +11 -0
- package/dist/hierarchy/index.js.map +7 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +7 -0
- package/dist/react/brush-contract.d.ts +23 -0
- package/dist/react/brush-contract.d.ts.map +1 -0
- package/dist/react/brush-contract.js +7 -0
- package/dist/react/brush-contract.js.map +7 -0
- package/dist/react/chart-data-table.d.ts +18 -0
- package/dist/react/chart-data-table.d.ts.map +1 -0
- package/dist/react/chart-data-table.js +55 -0
- package/dist/react/chart-data-table.js.map +7 -0
- package/dist/react/chart-legend.d.ts +17 -0
- package/dist/react/chart-legend.d.ts.map +1 -0
- package/dist/react/chart-legend.js +126 -0
- package/dist/react/chart-legend.js.map +7 -0
- package/dist/react/chart-tooltip.d.ts +18 -0
- package/dist/react/chart-tooltip.d.ts.map +1 -0
- package/dist/react/chart-tooltip.js +95 -0
- package/dist/react/chart-tooltip.js.map +7 -0
- package/dist/react/chart.d.ts +45 -0
- package/dist/react/chart.d.ts.map +1 -0
- package/dist/react/chart.js +383 -0
- package/dist/react/chart.js.map +7 -0
- package/dist/react/focus-overlay.d.ts +14 -0
- package/dist/react/focus-overlay.d.ts.map +1 -0
- package/dist/react/focus-overlay.js +147 -0
- package/dist/react/focus-overlay.js.map +7 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +11 -0
- package/dist/react/index.js.map +7 -0
- package/dist/react/messages.d.ts +16 -0
- package/dist/react/messages.d.ts.map +1 -0
- package/dist/react/messages.js +33 -0
- package/dist/react/messages.js.map +7 -0
- package/dist/react/renderer.d.ts +14 -0
- package/dist/react/renderer.d.ts.map +1 -0
- package/dist/react/renderer.js +1 -0
- package/dist/react/renderer.js.map +7 -0
- package/dist/react/sr-only.d.ts +4 -0
- package/dist/react/sr-only.d.ts.map +1 -0
- package/dist/react/sr-only.js +15 -0
- package/dist/react/sr-only.js.map +7 -0
- package/dist/react/svg-renderer.d.ts +4 -0
- package/dist/react/svg-renderer.d.ts.map +1 -0
- package/dist/react/svg-renderer.js +20 -0
- package/dist/react/svg-renderer.js.map +7 -0
- package/dist/react/svg-scene.d.ts +8 -0
- package/dist/react/svg-scene.d.ts.map +1 -0
- package/dist/react/svg-scene.js +121 -0
- package/dist/react/svg-scene.js.map +7 -0
- package/dist/react/use-animated-scene.d.ts +10 -0
- package/dist/react/use-animated-scene.d.ts.map +1 -0
- package/dist/react/use-animated-scene.js +41 -0
- package/dist/react/use-animated-scene.js.map +7 -0
- package/dist/react/use-chart-focus.d.ts +29 -0
- package/dist/react/use-chart-focus.d.ts.map +1 -0
- package/dist/react/use-chart-focus.js +180 -0
- package/dist/react/use-chart-focus.js.map +7 -0
- package/dist/react/use-chart-width.d.ts +12 -0
- package/dist/react/use-chart-width.d.ts.map +1 -0
- package/dist/react/use-chart-width.js +23 -0
- package/dist/react/use-chart-width.js.map +7 -0
- package/dist/react/use-chart-zoom.d.ts +13 -0
- package/dist/react/use-chart-zoom.d.ts.map +1 -0
- package/dist/react/use-chart-zoom.js +52 -0
- package/dist/react/use-chart-zoom.js.map +7 -0
- package/dist/react/use-text-measurer.d.ts +8 -0
- package/dist/react/use-text-measurer.d.ts.map +1 -0
- package/dist/react/use-text-measurer.js +44 -0
- package/dist/react/use-text-measurer.js.map +7 -0
- package/dist/sankey/index.d.ts +2 -0
- package/dist/sankey/index.d.ts.map +1 -0
- package/dist/sankey/index.js +7 -0
- package/dist/sankey/index.js.map +7 -0
- package/dist/sankey/sankey.d.ts +29 -0
- package/dist/sankey/sankey.d.ts.map +1 -0
- package/dist/sankey/sankey.js +127 -0
- package/dist/sankey/sankey.js.map +7 -0
- package/dist/voronoi/index.d.ts +2 -0
- package/dist/voronoi/index.d.ts.map +1 -0
- package/dist/voronoi/index.js +5 -0
- package/dist/voronoi/index.js.map +7 -0
- package/dist/voronoi/voronoi.d.ts +16 -0
- package/dist/voronoi/voronoi.d.ts.map +1 -0
- package/dist/voronoi/voronoi.js +62 -0
- package/dist/voronoi/voronoi.js.map +7 -0
- package/package.json +74 -0
- package/src/brush/brush-layer.tsx +174 -0
- package/src/brush/index.ts +14 -0
- package/src/canvas/canvas-renderer.tsx +56 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/paint-scene.ts +152 -0
- package/src/canvas/resolve-color.ts +65 -0
- package/src/contour/density.ts +90 -0
- package/src/contour/index.ts +1 -0
- package/src/core/channel.ts +53 -0
- package/src/core/compile.ts +436 -0
- package/src/core/define-chart.ts +128 -0
- package/src/core/facet.ts +189 -0
- package/src/core/format.ts +163 -0
- package/src/core/guides/axes.ts +283 -0
- package/src/core/marks/area.ts +238 -0
- package/src/core/marks/bar.ts +278 -0
- package/src/core/marks/cell.ts +123 -0
- package/src/core/marks/dot.ts +157 -0
- package/src/core/marks/funnel-layout.ts +113 -0
- package/src/core/marks/funnel.ts +172 -0
- package/src/core/marks/line.ts +206 -0
- package/src/core/marks/polar.ts +568 -0
- package/src/core/marks/rect.ts +156 -0
- package/src/core/marks/rule.ts +104 -0
- package/src/core/marks/shared.ts +134 -0
- package/src/core/marks/stack.ts +42 -0
- package/src/core/marks/stats/difference.ts +205 -0
- package/src/core/marks/stats/distribution.ts +425 -0
- package/src/core/marks/stats/dodge.ts +136 -0
- package/src/core/marks/stats/hexbin.ts +152 -0
- package/src/core/marks/stats/histogram.ts +108 -0
- package/src/core/marks/stats/regression.ts +108 -0
- package/src/core/marks/stats/statistics.ts +153 -0
- package/src/core/marks/stats/waffle.ts +141 -0
- package/src/core/marks/text.ts +97 -0
- package/src/core/motion/tween.ts +131 -0
- package/src/core/nearest.ts +223 -0
- package/src/core/paths.ts +323 -0
- package/src/core/scales/color.ts +51 -0
- package/src/core/scales/continuous.ts +111 -0
- package/src/core/scales/discrete.ts +156 -0
- package/src/core/scales/resolve.ts +158 -0
- package/src/core/scales/time.ts +180 -0
- package/src/core/text.ts +42 -0
- package/src/core/theme.ts +26 -0
- package/src/core/ticks.ts +118 -0
- package/src/core/types.ts +358 -0
- package/src/force/force.ts +200 -0
- package/src/force/index.ts +6 -0
- package/src/geo/geo.ts +346 -0
- package/src/geo/index.ts +10 -0
- package/src/hierarchy/hierarchy.ts +377 -0
- package/src/hierarchy/index.ts +6 -0
- package/src/index.ts +70 -0
- package/src/react/brush-contract.ts +35 -0
- package/src/react/chart-data-table.tsx +98 -0
- package/src/react/chart-legend.tsx +130 -0
- package/src/react/chart-tooltip.tsx +111 -0
- package/src/react/chart.tsx +489 -0
- package/src/react/focus-overlay.tsx +164 -0
- package/src/react/index.ts +9 -0
- package/src/react/messages.ts +49 -0
- package/src/react/renderer.ts +15 -0
- package/src/react/sr-only.ts +14 -0
- package/src/react/svg-renderer.tsx +18 -0
- package/src/react/svg-scene.tsx +146 -0
- package/src/react/use-animated-scene.ts +57 -0
- package/src/react/use-chart-focus.ts +245 -0
- package/src/react/use-chart-width.ts +27 -0
- package/src/react/use-chart-zoom.ts +67 -0
- package/src/react/use-text-measurer.ts +49 -0
- package/src/sankey/index.ts +6 -0
- package/src/sankey/sankey.ts +179 -0
- package/src/voronoi/index.ts +1 -0
- package/src/voronoi/voronoi.ts +84 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hierarchy/index.ts"],
|
|
4
|
+
"sourcesContent": ["export {\n\ttype HierarchyOptions,\n\tsunburstMark as sunburst,\n\ttreeMark as tree,\n\ttreemapMark as treemap,\n} from \"#/hierarchy/hierarchy.ts\";\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EAEiB;AAAA,EACJ;AAAA,EACG;AAAA,OACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { type CompileOptions, compileChart } from "./core/compile.js";
|
|
2
|
+
export { type ChartAxisOptions, type ChartBuildContext, type ChartColorOptions, type ChartDefinition, type ChartFacet, type ChartFacetOptions, type ChartPositionScaleOptions, type ChartSpec, defineChart, } from "./core/define-chart.js";
|
|
3
|
+
export { facet } from "./core/facet.js";
|
|
4
|
+
export { formatDate, formatNumber, formatValue } from "./core/format.js";
|
|
5
|
+
export { type AreaOptions, areaX, areaY } from "./core/marks/area.js";
|
|
6
|
+
export { type BarOptions, barX, barY } from "./core/marks/bar.js";
|
|
7
|
+
export { type CellOptions, cell } from "./core/marks/cell.js";
|
|
8
|
+
export { type DotOptions, dot } from "./core/marks/dot.js";
|
|
9
|
+
export { type FunnelOptions, funnel } from "./core/marks/funnel.js";
|
|
10
|
+
export { type LineOptions, lineX, lineY } from "./core/marks/line.js";
|
|
11
|
+
export { type ArcOptions, arc, donut, type RadarOptions, type RadialBarOptions, radar, radialBar, } from "./core/marks/polar.js";
|
|
12
|
+
export { type RectOptions, rectY } from "./core/marks/rect.js";
|
|
13
|
+
export { type RuleOptions, ruleX, ruleY } from "./core/marks/rule.js";
|
|
14
|
+
export type { ChartMarkOptions } from "./core/marks/shared.js";
|
|
15
|
+
export { type DifferenceOptions, differenceY, } from "./core/marks/stats/difference.js";
|
|
16
|
+
export { type BoxOptions, boxY, type RidgelineOptions, ridgeline, violinY, } from "./core/marks/stats/distribution.js";
|
|
17
|
+
export { type DodgeOptions, dodgeY } from "./core/marks/stats/dodge.js";
|
|
18
|
+
export { type HexbinOptions, hexbin } from "./core/marks/stats/hexbin.js";
|
|
19
|
+
export { type HistogramOptions, histogram, } from "./core/marks/stats/histogram.js";
|
|
20
|
+
export { type RegressionOptions, regressionY, } from "./core/marks/stats/regression.js";
|
|
21
|
+
export { boxSummary, kernelDensity, linearFit, quantile, } from "./core/marks/stats/statistics.js";
|
|
22
|
+
export { type WaffleOptions, waffleY } from "./core/marks/stats/waffle.js";
|
|
23
|
+
export { type TextOptions, text } from "./core/marks/text.js";
|
|
24
|
+
export { easeOutCubic, tweenScene } from "./core/motion/tween.js";
|
|
25
|
+
export { type ChartFocusStop, findNearest, focusStops, } from "./core/nearest.js";
|
|
26
|
+
export { estimateTextWidth } from "./core/text.js";
|
|
27
|
+
export { DEFAULT_THEME } from "./core/theme.js";
|
|
28
|
+
export type * from "./core/types.js";
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,SAAS,EACd,WAAW,GACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,KAAK,WAAW,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,KAAK,UAAU,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EACN,KAAK,UAAU,EACf,GAAG,EACH,KAAK,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,EACL,SAAS,GACT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACN,KAAK,iBAAiB,EACtB,WAAW,GACX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,KAAK,UAAU,EACf,IAAI,EACJ,KAAK,gBAAgB,EACrB,SAAS,EACT,OAAO,GACP,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EACN,KAAK,gBAAgB,EACrB,SAAS,GACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,KAAK,iBAAiB,EACtB,WAAW,GACX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,UAAU,EACV,aAAa,EACb,SAAS,EACT,QAAQ,GACR,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,KAAK,WAAW,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EACN,KAAK,cAAc,EACnB,WAAW,EACX,UAAU,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,mBAAmB,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { compileChart } from "./core/compile.js";
|
|
2
|
+
import {
|
|
3
|
+
defineChart
|
|
4
|
+
} from "./core/define-chart.js";
|
|
5
|
+
import { facet } from "./core/facet.js";
|
|
6
|
+
import { formatDate, formatNumber, formatValue } from "./core/format.js";
|
|
7
|
+
import { areaX, areaY } from "./core/marks/area.js";
|
|
8
|
+
import { barX, barY } from "./core/marks/bar.js";
|
|
9
|
+
import { cell } from "./core/marks/cell.js";
|
|
10
|
+
import { dot } from "./core/marks/dot.js";
|
|
11
|
+
import { funnel } from "./core/marks/funnel.js";
|
|
12
|
+
import { lineX, lineY } from "./core/marks/line.js";
|
|
13
|
+
import {
|
|
14
|
+
arc,
|
|
15
|
+
donut,
|
|
16
|
+
radar,
|
|
17
|
+
radialBar
|
|
18
|
+
} from "./core/marks/polar.js";
|
|
19
|
+
import { rectY } from "./core/marks/rect.js";
|
|
20
|
+
import { ruleX, ruleY } from "./core/marks/rule.js";
|
|
21
|
+
import {
|
|
22
|
+
differenceY
|
|
23
|
+
} from "./core/marks/stats/difference.js";
|
|
24
|
+
import {
|
|
25
|
+
boxY,
|
|
26
|
+
ridgeline,
|
|
27
|
+
violinY
|
|
28
|
+
} from "./core/marks/stats/distribution.js";
|
|
29
|
+
import { dodgeY } from "./core/marks/stats/dodge.js";
|
|
30
|
+
import { hexbin } from "./core/marks/stats/hexbin.js";
|
|
31
|
+
import {
|
|
32
|
+
histogram
|
|
33
|
+
} from "./core/marks/stats/histogram.js";
|
|
34
|
+
import {
|
|
35
|
+
regressionY
|
|
36
|
+
} from "./core/marks/stats/regression.js";
|
|
37
|
+
import {
|
|
38
|
+
boxSummary,
|
|
39
|
+
kernelDensity,
|
|
40
|
+
linearFit,
|
|
41
|
+
quantile
|
|
42
|
+
} from "./core/marks/stats/statistics.js";
|
|
43
|
+
import { waffleY } from "./core/marks/stats/waffle.js";
|
|
44
|
+
import { text } from "./core/marks/text.js";
|
|
45
|
+
import { easeOutCubic, tweenScene } from "./core/motion/tween.js";
|
|
46
|
+
import {
|
|
47
|
+
findNearest,
|
|
48
|
+
focusStops
|
|
49
|
+
} from "./core/nearest.js";
|
|
50
|
+
import { estimateTextWidth } from "./core/text.js";
|
|
51
|
+
import { DEFAULT_THEME } from "./core/theme.js";
|
|
52
|
+
export {
|
|
53
|
+
DEFAULT_THEME,
|
|
54
|
+
arc,
|
|
55
|
+
areaX,
|
|
56
|
+
areaY,
|
|
57
|
+
barX,
|
|
58
|
+
barY,
|
|
59
|
+
boxSummary,
|
|
60
|
+
boxY,
|
|
61
|
+
cell,
|
|
62
|
+
compileChart,
|
|
63
|
+
defineChart,
|
|
64
|
+
differenceY,
|
|
65
|
+
dodgeY,
|
|
66
|
+
donut,
|
|
67
|
+
dot,
|
|
68
|
+
easeOutCubic,
|
|
69
|
+
estimateTextWidth,
|
|
70
|
+
facet,
|
|
71
|
+
findNearest,
|
|
72
|
+
focusStops,
|
|
73
|
+
formatDate,
|
|
74
|
+
formatNumber,
|
|
75
|
+
formatValue,
|
|
76
|
+
funnel,
|
|
77
|
+
hexbin,
|
|
78
|
+
histogram,
|
|
79
|
+
kernelDensity,
|
|
80
|
+
lineX,
|
|
81
|
+
lineY,
|
|
82
|
+
linearFit,
|
|
83
|
+
quantile,
|
|
84
|
+
radar,
|
|
85
|
+
radialBar,
|
|
86
|
+
rectY,
|
|
87
|
+
regressionY,
|
|
88
|
+
ridgeline,
|
|
89
|
+
ruleX,
|
|
90
|
+
ruleY,
|
|
91
|
+
text,
|
|
92
|
+
tweenScene,
|
|
93
|
+
violinY,
|
|
94
|
+
waffleY
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { type CompileOptions, compileChart } from \"#/core/compile.ts\";\nexport {\n\ttype ChartAxisOptions,\n\ttype ChartBuildContext,\n\ttype ChartColorOptions,\n\ttype ChartDefinition,\n\ttype ChartFacet,\n\ttype ChartFacetOptions,\n\ttype ChartPositionScaleOptions,\n\ttype ChartSpec,\n\tdefineChart,\n} from \"#/core/define-chart.ts\";\nexport { facet } from \"#/core/facet.ts\";\nexport { formatDate, formatNumber, formatValue } from \"#/core/format.ts\";\nexport { type AreaOptions, areaX, areaY } from \"#/core/marks/area.ts\";\nexport { type BarOptions, barX, barY } from \"#/core/marks/bar.ts\";\nexport { type CellOptions, cell } from \"#/core/marks/cell.ts\";\nexport { type DotOptions, dot } from \"#/core/marks/dot.ts\";\nexport { type FunnelOptions, funnel } from \"#/core/marks/funnel.ts\";\nexport { type LineOptions, lineX, lineY } from \"#/core/marks/line.ts\";\nexport {\n\ttype ArcOptions,\n\tarc,\n\tdonut,\n\ttype RadarOptions,\n\ttype RadialBarOptions,\n\tradar,\n\tradialBar,\n} from \"#/core/marks/polar.ts\";\nexport { type RectOptions, rectY } from \"#/core/marks/rect.ts\";\nexport { type RuleOptions, ruleX, ruleY } from \"#/core/marks/rule.ts\";\nexport type { ChartMarkOptions } from \"#/core/marks/shared.ts\";\nexport {\n\ttype DifferenceOptions,\n\tdifferenceY,\n} from \"#/core/marks/stats/difference.ts\";\nexport {\n\ttype BoxOptions,\n\tboxY,\n\ttype RidgelineOptions,\n\tridgeline,\n\tviolinY,\n} from \"#/core/marks/stats/distribution.ts\";\nexport { type DodgeOptions, dodgeY } from \"#/core/marks/stats/dodge.ts\";\nexport { type HexbinOptions, hexbin } from \"#/core/marks/stats/hexbin.ts\";\nexport {\n\ttype HistogramOptions,\n\thistogram,\n} from \"#/core/marks/stats/histogram.ts\";\nexport {\n\ttype RegressionOptions,\n\tregressionY,\n} from \"#/core/marks/stats/regression.ts\";\nexport {\n\tboxSummary,\n\tkernelDensity,\n\tlinearFit,\n\tquantile,\n} from \"#/core/marks/stats/statistics.ts\";\nexport { type WaffleOptions, waffleY } from \"#/core/marks/stats/waffle.ts\";\nexport { type TextOptions, text } from \"#/core/marks/text.ts\";\nexport { easeOutCubic, tweenScene } from \"#/core/motion/tween.ts\";\nexport {\n\ttype ChartFocusStop,\n\tfindNearest,\n\tfocusStops,\n} from \"#/core/nearest.ts\";\nexport { estimateTextWidth } from \"#/core/text.ts\";\nexport { DEFAULT_THEME } from \"#/core/theme.ts\";\nexport type * from \"#/core/types.ts\";\n"],
|
|
5
|
+
"mappings": "AAAA,SAA8B,oBAAoB;AAClD;AAAA,EASC;AAAA,OACM;AACP,SAAS,aAAa;AACtB,SAAS,YAAY,cAAc,mBAAmB;AACtD,SAA2B,OAAO,aAAa;AAC/C,SAA0B,MAAM,YAAY;AAC5C,SAA2B,YAAY;AACvC,SAA0B,WAAW;AACrC,SAA6B,cAAc;AAC3C,SAA2B,OAAO,aAAa;AAC/C;AAAA,EAEC;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,OACM;AACP,SAA2B,aAAa;AACxC,SAA2B,OAAO,aAAa;AAE/C;AAAA,EAEC;AAAA,OACM;AACP;AAAA,EAEC;AAAA,EAEA;AAAA,EACA;AAAA,OACM;AACP,SAA4B,cAAc;AAC1C,SAA6B,cAAc;AAC3C;AAAA,EAEC;AAAA,OACM;AACP;AAAA,EAEC;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAA6B,eAAe;AAC5C,SAA2B,YAAY;AACvC,SAAS,cAAc,kBAAkB;AACzC;AAAA,EAEC;AAAA,EACA;AAAA,OACM;AACP,SAAS,yBAAyB;AAClC,SAAS,qBAAqB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { ChartPositionScale, ChartRect, ChartValue } from "../core/types.js";
|
|
3
|
+
import type { ChartMessages } from "./messages.js";
|
|
4
|
+
export type ChartBrushRange = readonly [ChartValue, ChartValue];
|
|
5
|
+
export interface ChartBrushLayerProps {
|
|
6
|
+
readonly scale: ChartPositionScale;
|
|
7
|
+
readonly plot: ChartRect;
|
|
8
|
+
readonly range: ChartBrushRange | null;
|
|
9
|
+
readonly messages: ChartMessages;
|
|
10
|
+
readonly onChange: (range: ChartBrushRange | null) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What `brushX(…)` from `@voila.dev/chart/brush` returns. The chart only
|
|
14
|
+
* knows this shape, so the brush's selection layer and sliders ship only
|
|
15
|
+
* with the charts that use them.
|
|
16
|
+
*/
|
|
17
|
+
export interface ChartBrush {
|
|
18
|
+
readonly onBrush: (range: ChartBrushRange | null) => void;
|
|
19
|
+
readonly Layer: React.ComponentType<ChartBrushLayerProps>;
|
|
20
|
+
}
|
|
21
|
+
/** The two ends in the scale's own order. */
|
|
22
|
+
export declare function ordered(scale: ChartPositionScale, [a, b]: ChartBrushRange): ChartBrushRange;
|
|
23
|
+
//# sourceMappingURL=brush-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brush-contract.d.ts","sourceRoot":"","sources":["../../src/react/brush-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EACX,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3D;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1D,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC1D;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CACtB,KAAK,EAAE,kBAAkB,EACzB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,GACrB,eAAe,CAEjB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/react/brush-contract.ts"],
|
|
4
|
+
"sourcesContent": ["import type * as React from \"react\";\nimport type {\n\tChartPositionScale,\n\tChartRect,\n\tChartValue,\n} from \"#/core/types.ts\";\nimport type { ChartMessages } from \"#/react/messages.ts\";\n\nexport type ChartBrushRange = readonly [ChartValue, ChartValue];\n\nexport interface ChartBrushLayerProps {\n\treadonly scale: ChartPositionScale;\n\treadonly plot: ChartRect;\n\treadonly range: ChartBrushRange | null;\n\treadonly messages: ChartMessages;\n\treadonly onChange: (range: ChartBrushRange | null) => void;\n}\n\n/**\n * What `brushX(\u2026)` from `@voila.dev/chart/brush` returns. The chart only\n * knows this shape, so the brush's selection layer and sliders ship only\n * with the charts that use them.\n */\nexport interface ChartBrush {\n\treadonly onBrush: (range: ChartBrushRange | null) => void;\n\treadonly Layer: React.ComponentType<ChartBrushLayerProps>;\n}\n\n/** The two ends in the scale's own order. */\nexport function ordered(\n\tscale: ChartPositionScale,\n\t[a, b]: ChartBrushRange,\n): ChartBrushRange {\n\treturn scale.map(a) <= scale.map(b) ? [a, b] : [b, a];\n}\n"],
|
|
5
|
+
"mappings": "AA6BO,SAAS,QACf,OACA,CAAC,GAAG,CAAC,GACa;AAClB,SAAO,MAAM,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AACrD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChartFocusStop } from "../core/nearest.js";
|
|
2
|
+
import type { ChartScene } from "../core/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The chart's content as a table, for anyone who cannot read the picture: a
|
|
5
|
+
* screen reader gets the actual numbers, not a one-line summary of them. One
|
|
6
|
+
* row per focus stop, one column per series, the same values the tooltip
|
|
7
|
+
* shows.
|
|
8
|
+
*
|
|
9
|
+
* The hiding goes on a wrapper: a table box ignores `width: 1px` and lays out
|
|
10
|
+
* at its content width, which widened the page on a phone.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ChartDataTable({ scene, stops, caption, seriesHeading, }: {
|
|
13
|
+
scene: ChartScene;
|
|
14
|
+
stops: ReadonlyArray<ChartFocusStop>;
|
|
15
|
+
caption: string;
|
|
16
|
+
seriesHeading: string;
|
|
17
|
+
}): import("react").JSX.Element | null;
|
|
18
|
+
//# sourceMappingURL=chart-data-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-data-table.d.ts","sourceRoot":"","sources":["../../src/react/chart-data-table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAC9B,KAAK,EACL,KAAK,EACL,OAAO,EACP,aAAa,GACb,EAAE;IACF,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACtB,sCA0EA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SR_ONLY } from "./sr-only.js";
|
|
3
|
+
function ChartDataTable({
|
|
4
|
+
scene,
|
|
5
|
+
stops,
|
|
6
|
+
caption,
|
|
7
|
+
seriesHeading
|
|
8
|
+
}) {
|
|
9
|
+
if (stops.length === 0) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const series = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const point of scene.points) {
|
|
14
|
+
const key = point.series ?? point.markId;
|
|
15
|
+
if (!series.has(key)) {
|
|
16
|
+
series.set(key, point.seriesLabel ?? scene.yLabel);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (scene.focusOrder === "point") {
|
|
20
|
+
const named = scene.points.some(
|
|
21
|
+
(point) => point.seriesLabel !== void 0 && point.seriesLabel !== point.title
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ jsx("div", { style: SR_ONLY, children: /* @__PURE__ */ jsxs("table", { "data-slot": "chart-data-table", children: [
|
|
24
|
+
/* @__PURE__ */ jsx("caption", { children: caption }),
|
|
25
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
26
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: scene.xLabel }),
|
|
27
|
+
named ? /* @__PURE__ */ jsx("th", { scope: "col", children: seriesHeading }) : null,
|
|
28
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: scene.yLabel })
|
|
29
|
+
] }) }),
|
|
30
|
+
/* @__PURE__ */ jsx("tbody", { children: scene.points.map((point) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
31
|
+
/* @__PURE__ */ jsx("th", { scope: "row", children: point.title }),
|
|
32
|
+
named ? /* @__PURE__ */ jsx("td", { children: point.seriesLabel }) : null,
|
|
33
|
+
/* @__PURE__ */ jsx("td", { children: point.value })
|
|
34
|
+
] }, point.key)) })
|
|
35
|
+
] }) });
|
|
36
|
+
}
|
|
37
|
+
const columns = [...series.entries()];
|
|
38
|
+
return /* @__PURE__ */ jsx("div", { style: SR_ONLY, children: /* @__PURE__ */ jsxs("table", { "data-slot": "chart-data-table", children: [
|
|
39
|
+
/* @__PURE__ */ jsx("caption", { children: caption }),
|
|
40
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
41
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: scene.xLabel }),
|
|
42
|
+
columns.map(([key, label]) => /* @__PURE__ */ jsx("th", { scope: "col", children: label }, key))
|
|
43
|
+
] }) }),
|
|
44
|
+
/* @__PURE__ */ jsx("tbody", { children: stops.map((stop) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
45
|
+
/* @__PURE__ */ jsx("th", { scope: "row", children: stop.points[0].title }),
|
|
46
|
+
columns.map(([key]) => /* @__PURE__ */ jsx("td", { children: stop.points.find(
|
|
47
|
+
(point) => (point.series ?? point.markId) === key
|
|
48
|
+
)?.value ?? "" }, key))
|
|
49
|
+
] }, stop.key)) })
|
|
50
|
+
] }) });
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
ChartDataTable
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=chart-data-table.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/react/chart-data-table.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { ChartFocusStop } from \"#/core/nearest.ts\";\nimport type { ChartScene } from \"#/core/types.ts\";\nimport { SR_ONLY } from \"#/react/sr-only.ts\";\n\n/**\n * The chart's content as a table, for anyone who cannot read the picture: a\n * screen reader gets the actual numbers, not a one-line summary of them. One\n * row per focus stop, one column per series, the same values the tooltip\n * shows.\n *\n * The hiding goes on a wrapper: a table box ignores `width: 1px` and lays out\n * at its content width, which widened the page on a phone.\n */\nexport function ChartDataTable({\n\tscene,\n\tstops,\n\tcaption,\n\tseriesHeading,\n}: {\n\tscene: ChartScene;\n\tstops: ReadonlyArray<ChartFocusStop>;\n\tcaption: string;\n\tseriesHeading: string;\n}) {\n\tif (stops.length === 0) {\n\t\treturn null;\n\t}\n\tconst series = new Map<string, string>();\n\tfor (const point of scene.points) {\n\t\tconst key = point.series ?? point.markId;\n\t\tif (!series.has(key)) {\n\t\t\tseries.set(key, point.seriesLabel ?? scene.yLabel);\n\t\t}\n\t}\n\t// A pie or a scatter: one row per point, the series only when it says\n\t// something the row heading does not.\n\tif (scene.focusOrder === \"point\") {\n\t\tconst named = scene.points.some(\n\t\t\t(point) =>\n\t\t\t\tpoint.seriesLabel !== undefined && point.seriesLabel !== point.title,\n\t\t);\n\t\treturn (\n\t\t\t<div style={SR_ONLY}>\n\t\t\t\t<table data-slot=\"chart-data-table\">\n\t\t\t\t\t<caption>{caption}</caption>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th scope=\"col\">{scene.xLabel}</th>\n\t\t\t\t\t\t\t{named ? <th scope=\"col\">{seriesHeading}</th> : null}\n\t\t\t\t\t\t\t<th scope=\"col\">{scene.yLabel}</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{scene.points.map((point) => (\n\t\t\t\t\t\t\t<tr key={point.key}>\n\t\t\t\t\t\t\t\t<th scope=\"row\">{point.title}</th>\n\t\t\t\t\t\t\t\t{named ? <td>{point.seriesLabel}</td> : null}\n\t\t\t\t\t\t\t\t<td>{point.value}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t);\n\t}\n\tconst columns = [...series.entries()];\n\treturn (\n\t\t<div style={SR_ONLY}>\n\t\t\t<table data-slot=\"chart-data-table\">\n\t\t\t\t<caption>{caption}</caption>\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th scope=\"col\">{scene.xLabel}</th>\n\t\t\t\t\t\t{columns.map(([key, label]) => (\n\t\t\t\t\t\t\t<th key={key} scope=\"col\">\n\t\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>\n\t\t\t\t\t{stops.map((stop) => (\n\t\t\t\t\t\t<tr key={stop.key}>\n\t\t\t\t\t\t\t<th scope=\"row\">{stop.points[0].title}</th>\n\t\t\t\t\t\t\t{columns.map(([key]) => (\n\t\t\t\t\t\t\t\t<td key={key}>\n\t\t\t\t\t\t\t\t\t{stop.points.find(\n\t\t\t\t\t\t\t\t\t\t(point) => (point.series ?? point.markId) === key,\n\t\t\t\t\t\t\t\t\t)?.value ?? \"\"}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t))}\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AA4CK,cAEC,YAFD;AA1CL,SAAS,eAAe;AAWjB,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAKG;AACF,MAAI,MAAM,WAAW,GAAG;AACvB,WAAO;AAAA,EACR;AACA,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,SAAS,MAAM,QAAQ;AACjC,UAAM,MAAM,MAAM,UAAU,MAAM;AAClC,QAAI,CAAC,OAAO,IAAI,GAAG,GAAG;AACrB,aAAO,IAAI,KAAK,MAAM,eAAe,MAAM,MAAM;AAAA,IAClD;AAAA,EACD;AAGA,MAAI,MAAM,eAAe,SAAS;AACjC,UAAM,QAAQ,MAAM,OAAO;AAAA,MAC1B,CAAC,UACA,MAAM,gBAAgB,UAAa,MAAM,gBAAgB,MAAM;AAAA,IACjE;AACA,WACC,oBAAC,SAAI,OAAO,SACX,+BAAC,WAAM,aAAU,oBAChB;AAAA,0BAAC,aAAS,mBAAQ;AAAA,MAClB,oBAAC,WACA,+BAAC,QACA;AAAA,4BAAC,QAAG,OAAM,OAAO,gBAAM,QAAO;AAAA,QAC7B,QAAQ,oBAAC,QAAG,OAAM,OAAO,yBAAc,IAAQ;AAAA,QAChD,oBAAC,QAAG,OAAM,OAAO,gBAAM,QAAO;AAAA,SAC/B,GACD;AAAA,MACA,oBAAC,WACC,gBAAM,OAAO,IAAI,CAAC,UAClB,qBAAC,QACA;AAAA,4BAAC,QAAG,OAAM,OAAO,gBAAM,OAAM;AAAA,QAC5B,QAAQ,oBAAC,QAAI,gBAAM,aAAY,IAAQ;AAAA,QACxC,oBAAC,QAAI,gBAAM,OAAM;AAAA,WAHT,MAAM,GAIf,CACA,GACF;AAAA,OACD,GACD;AAAA,EAEF;AACA,QAAM,UAAU,CAAC,GAAG,OAAO,QAAQ,CAAC;AACpC,SACC,oBAAC,SAAI,OAAO,SACX,+BAAC,WAAM,aAAU,oBAChB;AAAA,wBAAC,aAAS,mBAAQ;AAAA,IAClB,oBAAC,WACA,+BAAC,QACA;AAAA,0BAAC,QAAG,OAAM,OAAO,gBAAM,QAAO;AAAA,MAC7B,QAAQ,IAAI,CAAC,CAAC,KAAK,KAAK,MACxB,oBAAC,QAAa,OAAM,OAClB,mBADO,GAET,CACA;AAAA,OACF,GACD;AAAA,IACA,oBAAC,WACC,gBAAM,IAAI,CAAC,SACX,qBAAC,QACA;AAAA,0BAAC,QAAG,OAAM,OAAO,eAAK,OAAO,CAAC,EAAE,OAAM;AAAA,MACrC,QAAQ,IAAI,CAAC,CAAC,GAAG,MACjB,oBAAC,QACC,eAAK,OAAO;AAAA,QACZ,CAAC,WAAW,MAAM,UAAU,MAAM,YAAY;AAAA,MAC/C,GAAG,SAAS,MAHJ,GAIT,CACA;AAAA,SARO,KAAK,GASd,CACA,GACF;AAAA,KACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChartLegendItem, ChartScene } from "../core/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* One toggle button per series. Turning a series off redraws without it but
|
|
4
|
+
* keeps the axes where they were, so the other series do not jump.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ChartLegend({ items, hidden, label, onToggle, }: {
|
|
7
|
+
items: ReadonlyArray<ChartLegendItem>;
|
|
8
|
+
hidden: ReadonlySet<string>;
|
|
9
|
+
label: string;
|
|
10
|
+
onToggle: (key: string) => void;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
/** The ramp of a sequential colour scale: a gradient bar between its two ends. */
|
|
13
|
+
export declare function ChartColorRamp({ ramp, label, }: {
|
|
14
|
+
ramp: NonNullable<ChartScene["colorRamp"]>;
|
|
15
|
+
label: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=chart-legend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-legend.d.ts","sourceRoot":"","sources":["../../src/react/chart-legend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA+BnE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,KAAK,EACL,QAAQ,GACR,EAAE;IACF,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACtC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC,+BAgDA;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,EAC9B,IAAI,EACJ,KAAK,GACL,EAAE;IACF,IAAI,EAAE,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;CACd,+BA2BA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
function Swatch({ item }) {
|
|
3
|
+
const base = { flex: "none", display: "inline-block" };
|
|
4
|
+
if (item.shape === "line" || item.shape === "dashed") {
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
"span",
|
|
7
|
+
{
|
|
8
|
+
"aria-hidden": "true",
|
|
9
|
+
style: {
|
|
10
|
+
...base,
|
|
11
|
+
width: 14,
|
|
12
|
+
height: 0,
|
|
13
|
+
borderTop: `2px ${item.shape === "dashed" ? "dashed" : "solid"} ${item.color}`
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
"span",
|
|
20
|
+
{
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
style: {
|
|
23
|
+
...base,
|
|
24
|
+
width: 10,
|
|
25
|
+
height: 10,
|
|
26
|
+
borderRadius: item.shape === "dot" ? "50%" : 2,
|
|
27
|
+
background: item.color
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
function ChartLegend({
|
|
33
|
+
items,
|
|
34
|
+
hidden,
|
|
35
|
+
label,
|
|
36
|
+
onToggle
|
|
37
|
+
}) {
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
"ul",
|
|
40
|
+
{
|
|
41
|
+
"aria-label": label,
|
|
42
|
+
"data-slot": "chart-legend",
|
|
43
|
+
style: {
|
|
44
|
+
display: "flex",
|
|
45
|
+
flexWrap: "wrap",
|
|
46
|
+
justifyContent: "center",
|
|
47
|
+
gap: 4,
|
|
48
|
+
margin: 0,
|
|
49
|
+
padding: 0,
|
|
50
|
+
listStyle: "none",
|
|
51
|
+
fontSize: 12
|
|
52
|
+
},
|
|
53
|
+
children: items.map((item) => {
|
|
54
|
+
const visible = !hidden.has(item.key);
|
|
55
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
type: "button",
|
|
59
|
+
"aria-pressed": visible,
|
|
60
|
+
onClick: () => onToggle(item.key),
|
|
61
|
+
style: {
|
|
62
|
+
display: "inline-flex",
|
|
63
|
+
alignItems: "center",
|
|
64
|
+
gap: 6,
|
|
65
|
+
minHeight: 24,
|
|
66
|
+
padding: "2px 8px",
|
|
67
|
+
border: 0,
|
|
68
|
+
borderRadius: 6,
|
|
69
|
+
background: "transparent",
|
|
70
|
+
color: "inherit",
|
|
71
|
+
font: "inherit",
|
|
72
|
+
cursor: "pointer",
|
|
73
|
+
opacity: visible ? 1 : 0.45,
|
|
74
|
+
textDecoration: visible ? void 0 : "line-through"
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsx(Swatch, { item }),
|
|
78
|
+
item.label
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
) }, item.key);
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
function ChartColorRamp({
|
|
87
|
+
ramp,
|
|
88
|
+
label
|
|
89
|
+
}) {
|
|
90
|
+
return /* @__PURE__ */ jsxs(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
role: "img",
|
|
94
|
+
"aria-label": `${label} : ${ramp.low} \u2013 ${ramp.high}`,
|
|
95
|
+
"data-slot": "chart-color-ramp",
|
|
96
|
+
style: {
|
|
97
|
+
display: "flex",
|
|
98
|
+
alignItems: "center",
|
|
99
|
+
justifyContent: "center",
|
|
100
|
+
gap: 8,
|
|
101
|
+
fontSize: 12
|
|
102
|
+
},
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsx("span", { children: ramp.low }),
|
|
105
|
+
/* @__PURE__ */ jsx(
|
|
106
|
+
"span",
|
|
107
|
+
{
|
|
108
|
+
"aria-hidden": "true",
|
|
109
|
+
style: {
|
|
110
|
+
width: 120,
|
|
111
|
+
height: 8,
|
|
112
|
+
borderRadius: 4,
|
|
113
|
+
background: `linear-gradient(to right, ${ramp.stops.join(", ")})`
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ jsx("span", { children: ramp.high })
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
ChartColorRamp,
|
|
124
|
+
ChartLegend
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=chart-legend.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/react/chart-legend.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { ChartLegendItem, ChartScene } from \"#/core/types.ts\";\n\nfunction Swatch({ item }: { item: ChartLegendItem }) {\n\tconst base = { flex: \"none\" as const, display: \"inline-block\" };\n\tif (item.shape === \"line\" || item.shape === \"dashed\") {\n\t\treturn (\n\t\t\t<span\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tstyle={{\n\t\t\t\t\t...base,\n\t\t\t\t\twidth: 14,\n\t\t\t\t\theight: 0,\n\t\t\t\t\tborderTop: `2px ${item.shape === \"dashed\" ? \"dashed\" : \"solid\"} ${item.color}`,\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<span\n\t\t\taria-hidden=\"true\"\n\t\t\tstyle={{\n\t\t\t\t...base,\n\t\t\t\twidth: 10,\n\t\t\t\theight: 10,\n\t\t\t\tborderRadius: item.shape === \"dot\" ? \"50%\" : 2,\n\t\t\t\tbackground: item.color,\n\t\t\t}}\n\t\t/>\n\t);\n}\n\n/**\n * One toggle button per series. Turning a series off redraws without it but\n * keeps the axes where they were, so the other series do not jump.\n */\nexport function ChartLegend({\n\titems,\n\thidden,\n\tlabel,\n\tonToggle,\n}: {\n\titems: ReadonlyArray<ChartLegendItem>;\n\thidden: ReadonlySet<string>;\n\tlabel: string;\n\tonToggle: (key: string) => void;\n}) {\n\treturn (\n\t\t<ul\n\t\t\taria-label={label}\n\t\t\tdata-slot=\"chart-legend\"\n\t\t\tstyle={{\n\t\t\t\tdisplay: \"flex\",\n\t\t\t\tflexWrap: \"wrap\",\n\t\t\t\tjustifyContent: \"center\",\n\t\t\t\tgap: 4,\n\t\t\t\tmargin: 0,\n\t\t\t\tpadding: 0,\n\t\t\t\tlistStyle: \"none\",\n\t\t\t\tfontSize: 12,\n\t\t\t}}\n\t\t>\n\t\t\t{items.map((item) => {\n\t\t\t\tconst visible = !hidden.has(item.key);\n\t\t\t\treturn (\n\t\t\t\t\t<li key={item.key}>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\taria-pressed={visible}\n\t\t\t\t\t\t\tonClick={() => onToggle(item.key)}\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\tdisplay: \"inline-flex\",\n\t\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\t\tgap: 6,\n\t\t\t\t\t\t\t\tminHeight: 24,\n\t\t\t\t\t\t\t\tpadding: \"2px 8px\",\n\t\t\t\t\t\t\t\tborder: 0,\n\t\t\t\t\t\t\t\tborderRadius: 6,\n\t\t\t\t\t\t\t\tbackground: \"transparent\",\n\t\t\t\t\t\t\t\tcolor: \"inherit\",\n\t\t\t\t\t\t\t\tfont: \"inherit\",\n\t\t\t\t\t\t\t\tcursor: \"pointer\",\n\t\t\t\t\t\t\t\topacity: visible ? 1 : 0.45,\n\t\t\t\t\t\t\t\ttextDecoration: visible ? undefined : \"line-through\",\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Swatch item={item} />\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</li>\n\t\t\t\t);\n\t\t\t})}\n\t\t</ul>\n\t);\n}\n\n/** The ramp of a sequential colour scale: a gradient bar between its two ends. */\nexport function ChartColorRamp({\n\tramp,\n\tlabel,\n}: {\n\tramp: NonNullable<ChartScene[\"colorRamp\"]>;\n\tlabel: string;\n}) {\n\treturn (\n\t\t<div\n\t\t\trole=\"img\"\n\t\t\taria-label={`${label} : ${ramp.low} \u2013 ${ramp.high}`}\n\t\t\tdata-slot=\"chart-color-ramp\"\n\t\t\tstyle={{\n\t\t\t\tdisplay: \"flex\",\n\t\t\t\talignItems: \"center\",\n\t\t\t\tjustifyContent: \"center\",\n\t\t\t\tgap: 8,\n\t\t\t\tfontSize: 12,\n\t\t\t}}\n\t\t>\n\t\t\t<span>{ramp.low}</span>\n\t\t\t<span\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tstyle={{\n\t\t\t\t\twidth: 120,\n\t\t\t\t\theight: 8,\n\t\t\t\t\tborderRadius: 4,\n\t\t\t\t\tbackground: `linear-gradient(to right, ${ramp.stops.join(\", \")})`,\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t<span>{ramp.high}</span>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAMG,cA2DG,YA3DH;AAJH,SAAS,OAAO,EAAE,KAAK,GAA8B;AACpD,QAAM,OAAO,EAAE,MAAM,QAAiB,SAAS,eAAe;AAC9D,MAAI,KAAK,UAAU,UAAU,KAAK,UAAU,UAAU;AACrD,WACC;AAAA,MAAC;AAAA;AAAA,QACA,eAAY;AAAA,QACZ,OAAO;AAAA,UACN,GAAG;AAAA,UACH,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,WAAW,OAAO,KAAK,UAAU,WAAW,WAAW,OAAO,IAAI,KAAK,KAAK;AAAA,QAC7E;AAAA;AAAA,IACD;AAAA,EAEF;AACA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,eAAY;AAAA,MACZ,OAAO;AAAA,QACN,GAAG;AAAA,QACH,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,cAAc,KAAK,UAAU,QAAQ,QAAQ;AAAA,QAC7C,YAAY,KAAK;AAAA,MAClB;AAAA;AAAA,EACD;AAEF;AAMO,SAAS,YAAY;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAKG;AACF,SACC;AAAA,IAAC;AAAA;AAAA,MACA,cAAY;AAAA,MACZ,aAAU;AAAA,MACV,OAAO;AAAA,QACN,SAAS;AAAA,QACT,UAAU;AAAA,QACV,gBAAgB;AAAA,QAChB,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,WAAW;AAAA,QACX,UAAU;AAAA,MACX;AAAA,MAEC,gBAAM,IAAI,CAAC,SAAS;AACpB,cAAM,UAAU,CAAC,OAAO,IAAI,KAAK,GAAG;AACpC,eACC,oBAAC,QACA;AAAA,UAAC;AAAA;AAAA,YACA,MAAK;AAAA,YACL,gBAAc;AAAA,YACd,SAAS,MAAM,SAAS,KAAK,GAAG;AAAA,YAChC,OAAO;AAAA,cACN,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,KAAK;AAAA,cACL,WAAW;AAAA,cACX,SAAS;AAAA,cACT,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,MAAM;AAAA,cACN,QAAQ;AAAA,cACR,SAAS,UAAU,IAAI;AAAA,cACvB,gBAAgB,UAAU,SAAY;AAAA,YACvC;AAAA,YAEA;AAAA,kCAAC,UAAO,MAAY;AAAA,cACnB,KAAK;AAAA;AAAA;AAAA,QACP,KAvBQ,KAAK,GAwBd;AAAA,MAEF,CAAC;AAAA;AAAA,EACF;AAEF;AAGO,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AACD,GAGG;AACF,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,cAAY,GAAG,KAAK,MAAM,KAAK,GAAG,WAAM,KAAK,IAAI;AAAA,MACjD,aAAU;AAAA,MACV,OAAO;AAAA,QACN,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,KAAK;AAAA,QACL,UAAU;AAAA,MACX;AAAA,MAEA;AAAA,4BAAC,UAAM,eAAK,KAAI;AAAA,QAChB;AAAA,UAAC;AAAA;AAAA,YACA,eAAY;AAAA,YACZ,OAAO;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,YAAY,6BAA6B,KAAK,MAAM,KAAK,IAAI,CAAC;AAAA,YAC/D;AAAA;AAAA,QACD;AAAA,QACA,oBAAC,UAAM,eAAK,MAAK;AAAA;AAAA;AAAA,EAClB;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { ChartScene } from "../core/types.js";
|
|
3
|
+
import type { ActiveFocus } from "./use-chart-focus.js";
|
|
4
|
+
export interface ChartTooltipRenderProps {
|
|
5
|
+
readonly active: ActiveFocus;
|
|
6
|
+
readonly scene: ChartScene;
|
|
7
|
+
}
|
|
8
|
+
/** The default content: the stop's title, then one row per series with its swatch. */
|
|
9
|
+
export declare function ChartTooltipContent({ active, scene, }: ChartTooltipRenderProps): React.JSX.Element;
|
|
10
|
+
/**
|
|
11
|
+
* Follows the focused stop, on the side with room. Hidden from assistive
|
|
12
|
+
* tech: the live region already says the same thing once, where this would
|
|
13
|
+
* say it on every pointer move.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ChartTooltip({ active, scene, render, }: ChartTooltipRenderProps & {
|
|
16
|
+
render: (props: ChartTooltipRenderProps) => React.ReactNode;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
//# sourceMappingURL=chart-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-tooltip.d.ts","sourceRoot":"","sources":["../../src/react/chart-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAK9D,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC3B;AAqBD,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,EACnC,MAAM,EACN,KAAK,GACL,EAAE,uBAAuB,qBA6CzB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,MAAM,GACN,EAAE,uBAAuB,GAAG;IAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC5D,qBAiBA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
const OFFSET = 12;
|
|
3
|
+
const MAX_WIDTH = 280;
|
|
4
|
+
const SURFACE = {
|
|
5
|
+
position: "absolute",
|
|
6
|
+
top: 0,
|
|
7
|
+
left: 0,
|
|
8
|
+
pointerEvents: "none",
|
|
9
|
+
zIndex: 1,
|
|
10
|
+
maxWidth: MAX_WIDTH,
|
|
11
|
+
padding: "6px 10px",
|
|
12
|
+
borderRadius: 8,
|
|
13
|
+
border: "1px solid var(--border, color-mix(in oklab, currentColor 15%, transparent))",
|
|
14
|
+
background: "var(--popover, Canvas)",
|
|
15
|
+
color: "var(--popover-foreground, CanvasText)",
|
|
16
|
+
boxShadow: "0 4px 16px rgb(0 0 0 / 0.08)",
|
|
17
|
+
fontSize: 12,
|
|
18
|
+
lineHeight: 1.4,
|
|
19
|
+
whiteSpace: "nowrap"
|
|
20
|
+
};
|
|
21
|
+
function ChartTooltipContent({
|
|
22
|
+
active,
|
|
23
|
+
scene
|
|
24
|
+
}) {
|
|
25
|
+
const rows = active.stop.points.length > 1 ? active.stop.points : [active.point];
|
|
26
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx("div", { style: { fontWeight: 600, marginBottom: 2 }, children: active.point.title }),
|
|
28
|
+
rows.map((point) => /* @__PURE__ */ jsxs(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
style: {
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
gap: 6,
|
|
35
|
+
fontWeight: point.key === active.point.key && rows.length > 1 ? 600 : 400
|
|
36
|
+
},
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
"span",
|
|
40
|
+
{
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
style: {
|
|
43
|
+
width: 8,
|
|
44
|
+
height: 8,
|
|
45
|
+
borderRadius: 2,
|
|
46
|
+
background: point.color,
|
|
47
|
+
flex: "none"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--muted-foreground, inherit)" }, children: point.seriesLabel ?? scene.yLabel }),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
"span",
|
|
54
|
+
{
|
|
55
|
+
style: {
|
|
56
|
+
marginLeft: "auto",
|
|
57
|
+
paddingLeft: 12,
|
|
58
|
+
fontVariantNumeric: "tabular-nums"
|
|
59
|
+
},
|
|
60
|
+
children: point.value
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
point.key
|
|
66
|
+
))
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
function ChartTooltip({
|
|
70
|
+
active,
|
|
71
|
+
scene,
|
|
72
|
+
render
|
|
73
|
+
}) {
|
|
74
|
+
const anchorX = scene.focusOrder === "x" ? active.stop.at : active.point.x;
|
|
75
|
+
const anchorY = Math.min(...active.stop.points.map((point) => point.y));
|
|
76
|
+
const flip = anchorX > scene.width / 2;
|
|
77
|
+
return /* @__PURE__ */ jsx(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
"aria-hidden": "true",
|
|
81
|
+
"data-slot": "chart-tooltip",
|
|
82
|
+
"data-pinned": active.pinned ? "" : void 0,
|
|
83
|
+
style: {
|
|
84
|
+
...SURFACE,
|
|
85
|
+
transform: `translate(${flip ? `calc(${anchorX - OFFSET}px - 100%)` : `${anchorX + OFFSET}px`}, ${Math.max(0, anchorY - OFFSET)}px)`
|
|
86
|
+
},
|
|
87
|
+
children: render({ active, scene })
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
ChartTooltip,
|
|
93
|
+
ChartTooltipContent
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=chart-tooltip.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/react/chart-tooltip.tsx"],
|
|
4
|
+
"sourcesContent": ["import type * as React from \"react\";\nimport type { ChartScene } from \"#/core/types.ts\";\nimport type { ActiveFocus } from \"#/react/use-chart-focus.ts\";\n\nconst OFFSET = 12;\nconst MAX_WIDTH = 280;\n\nexport interface ChartTooltipRenderProps {\n\treadonly active: ActiveFocus;\n\treadonly scene: ChartScene;\n}\n\nconst SURFACE: React.CSSProperties = {\n\tposition: \"absolute\",\n\ttop: 0,\n\tleft: 0,\n\tpointerEvents: \"none\",\n\tzIndex: 1,\n\tmaxWidth: MAX_WIDTH,\n\tpadding: \"6px 10px\",\n\tborderRadius: 8,\n\tborder:\n\t\t\"1px solid var(--border, color-mix(in oklab, currentColor 15%, transparent))\",\n\tbackground: \"var(--popover, Canvas)\",\n\tcolor: \"var(--popover-foreground, CanvasText)\",\n\tboxShadow: \"0 4px 16px rgb(0 0 0 / 0.08)\",\n\tfontSize: 12,\n\tlineHeight: 1.4,\n\twhiteSpace: \"nowrap\",\n};\n\n/** The default content: the stop's title, then one row per series with its swatch. */\nexport function ChartTooltipContent({\n\tactive,\n\tscene,\n}: ChartTooltipRenderProps) {\n\tconst rows =\n\t\tactive.stop.points.length > 1 ? active.stop.points : [active.point];\n\treturn (\n\t\t<>\n\t\t\t<div style={{ fontWeight: 600, marginBottom: 2 }}>\n\t\t\t\t{active.point.title}\n\t\t\t</div>\n\t\t\t{rows.map((point) => (\n\t\t\t\t<div\n\t\t\t\t\tkey={point.key}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\tgap: 6,\n\t\t\t\t\t\tfontWeight:\n\t\t\t\t\t\t\tpoint.key === active.point.key && rows.length > 1 ? 600 : 400,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\twidth: 8,\n\t\t\t\t\t\t\theight: 8,\n\t\t\t\t\t\t\tborderRadius: 2,\n\t\t\t\t\t\t\tbackground: point.color,\n\t\t\t\t\t\t\tflex: \"none\",\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t<span style={{ color: \"var(--muted-foreground, inherit)\" }}>\n\t\t\t\t\t\t{point.seriesLabel ?? scene.yLabel}\n\t\t\t\t\t</span>\n\t\t\t\t\t<span\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tmarginLeft: \"auto\",\n\t\t\t\t\t\t\tpaddingLeft: 12,\n\t\t\t\t\t\t\tfontVariantNumeric: \"tabular-nums\",\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{point.value}\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t))}\n\t\t</>\n\t);\n}\n\n/**\n * Follows the focused stop, on the side with room. Hidden from assistive\n * tech: the live region already says the same thing once, where this would\n * say it on every pointer move.\n */\nexport function ChartTooltip({\n\tactive,\n\tscene,\n\trender,\n}: ChartTooltipRenderProps & {\n\trender: (props: ChartTooltipRenderProps) => React.ReactNode;\n}) {\n\tconst anchorX = scene.focusOrder === \"x\" ? active.stop.at : active.point.x;\n\tconst anchorY = Math.min(...active.stop.points.map((point) => point.y));\n\tconst flip = anchorX > scene.width / 2;\n\treturn (\n\t\t<div\n\t\t\taria-hidden=\"true\"\n\t\t\tdata-slot=\"chart-tooltip\"\n\t\t\tdata-pinned={active.pinned ? \"\" : undefined}\n\t\t\tstyle={{\n\t\t\t\t...SURFACE,\n\t\t\t\ttransform: `translate(${flip ? `calc(${anchorX - OFFSET}px - 100%)` : `${anchorX + OFFSET}px`}, ${Math.max(0, anchorY - OFFSET)}px)`,\n\t\t\t}}\n\t\t>\n\t\t\t{render({ active, scene })}\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAuCE,mBACC,KAIC,YALF;AAnCF,MAAM,SAAS;AACf,MAAM,YAAY;AAOlB,MAAM,UAA+B;AAAA,EACpC,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AAAA,EACT,cAAc;AAAA,EACd,QACC;AAAA,EACD,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AACb;AAGO,SAAS,oBAAoB;AAAA,EACnC;AAAA,EACA;AACD,GAA4B;AAC3B,QAAM,OACL,OAAO,KAAK,OAAO,SAAS,IAAI,OAAO,KAAK,SAAS,CAAC,OAAO,KAAK;AACnE,SACC,iCACC;AAAA,wBAAC,SAAI,OAAO,EAAE,YAAY,KAAK,cAAc,EAAE,GAC7C,iBAAO,MAAM,OACf;AAAA,IACC,KAAK,IAAI,CAAC,UACV;AAAA,MAAC;AAAA;AAAA,QAEA,OAAO;AAAA,UACN,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,KAAK;AAAA,UACL,YACC,MAAM,QAAQ,OAAO,MAAM,OAAO,KAAK,SAAS,IAAI,MAAM;AAAA,QAC5D;AAAA,QAEA;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,eAAY;AAAA,cACZ,OAAO;AAAA,gBACN,OAAO;AAAA,gBACP,QAAQ;AAAA,gBACR,cAAc;AAAA,gBACd,YAAY,MAAM;AAAA,gBAClB,MAAM;AAAA,cACP;AAAA;AAAA,UACD;AAAA,UACA,oBAAC,UAAK,OAAO,EAAE,OAAO,mCAAmC,GACvD,gBAAM,eAAe,MAAM,QAC7B;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,OAAO;AAAA,gBACN,YAAY;AAAA,gBACZ,aAAa;AAAA,gBACb,oBAAoB;AAAA,cACrB;AAAA,cAEC,gBAAM;AAAA;AAAA,UACR;AAAA;AAAA;AAAA,MA9BK,MAAM;AAAA,IA+BZ,CACA;AAAA,KACF;AAEF;AAOO,SAAS,aAAa;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACD,GAEG;AACF,QAAM,UAAU,MAAM,eAAe,MAAM,OAAO,KAAK,KAAK,OAAO,MAAM;AACzE,QAAM,UAAU,KAAK,IAAI,GAAG,OAAO,KAAK,OAAO,IAAI,CAAC,UAAU,MAAM,CAAC,CAAC;AACtE,QAAM,OAAO,UAAU,MAAM,QAAQ;AACrC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,eAAY;AAAA,MACZ,aAAU;AAAA,MACV,eAAa,OAAO,SAAS,KAAK;AAAA,MAClC,OAAO;AAAA,QACN,GAAG;AAAA,QACH,WAAW,aAAa,OAAO,QAAQ,UAAU,MAAM,eAAe,GAAG,UAAU,MAAM,IAAI,KAAK,KAAK,IAAI,GAAG,UAAU,MAAM,CAAC;AAAA,MAChI;AAAA,MAEC,iBAAO,EAAE,QAAQ,MAAM,CAAC;AAAA;AAAA,EAC1B;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|