@salmonui/charts 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/barcode/Barcode.d.ts +51 -0
- package/dist/barcode/Barcode.d.ts.map +1 -0
- package/dist/barcode/Barcode.js +30 -0
- package/dist/barcode/Barcode.js.map +1 -0
- package/dist/barcode/DotCode.d.ts +12 -0
- package/dist/barcode/DotCode.d.ts.map +1 -0
- package/dist/barcode/DotCode.js +20 -0
- package/dist/barcode/DotCode.js.map +1 -0
- package/dist/barcode/Gs1DataBar.d.ts +16 -0
- package/dist/barcode/Gs1DataBar.d.ts.map +1 -0
- package/dist/barcode/Gs1DataBar.js +26 -0
- package/dist/barcode/Gs1DataBar.js.map +1 -0
- package/dist/barcode/Pdf417.d.ts +24 -0
- package/dist/barcode/Pdf417.d.ts.map +1 -0
- package/dist/barcode/Pdf417.js +20 -0
- package/dist/barcode/Pdf417.js.map +1 -0
- package/dist/barcode/QRCode.d.ts +41 -0
- package/dist/barcode/QRCode.d.ts.map +1 -0
- package/dist/barcode/QRCode.js +23 -0
- package/dist/barcode/QRCode.js.map +1 -0
- package/dist/barcode/SymbolSvg.d.ts +44 -0
- package/dist/barcode/SymbolSvg.d.ts.map +1 -0
- package/dist/barcode/SymbolSvg.js +62 -0
- package/dist/barcode/SymbolSvg.js.map +1 -0
- package/dist/barcode/encode/databar.d.ts +17 -0
- package/dist/barcode/encode/databar.d.ts.map +1 -0
- package/dist/barcode/encode/databar.js +506 -0
- package/dist/barcode/encode/databar.js.map +1 -0
- package/dist/barcode/encode/datamatrix.d.ts +41 -0
- package/dist/barcode/encode/datamatrix.d.ts.map +1 -0
- package/dist/barcode/encode/datamatrix.js +299 -0
- package/dist/barcode/encode/datamatrix.js.map +1 -0
- package/dist/barcode/encode/dotcode.d.ts +31 -0
- package/dist/barcode/encode/dotcode.d.ts.map +1 -0
- package/dist/barcode/encode/dotcode.js +469 -0
- package/dist/barcode/encode/dotcode.js.map +1 -0
- package/dist/barcode/encode/index.d.ts +15 -0
- package/dist/barcode/encode/index.d.ts.map +1 -0
- package/dist/barcode/encode/index.js +30 -0
- package/dist/barcode/encode/index.js.map +1 -0
- package/dist/barcode/encode/linear.d.ts +87 -0
- package/dist/barcode/encode/linear.d.ts.map +1 -0
- package/dist/barcode/encode/linear.js +516 -0
- package/dist/barcode/encode/linear.js.map +1 -0
- package/dist/barcode/encode/pdf417.d.ts +25 -0
- package/dist/barcode/encode/pdf417.d.ts.map +1 -0
- package/dist/barcode/encode/pdf417.js +370 -0
- package/dist/barcode/encode/pdf417.js.map +1 -0
- package/dist/barcode/encode/qr.d.ts +53 -0
- package/dist/barcode/encode/qr.d.ts.map +1 -0
- package/dist/barcode/encode/qr.js +452 -0
- package/dist/barcode/encode/qr.js.map +1 -0
- package/dist/barcode/encode/svg.d.ts +5 -0
- package/dist/barcode/encode/svg.d.ts.map +1 -0
- package/dist/barcode/encode/svg.js +40 -0
- package/dist/barcode/encode/svg.js.map +1 -0
- package/dist/barcode/props.d.ts +30 -0
- package/dist/barcode/props.d.ts.map +1 -0
- package/dist/barcode/props.js +8 -0
- package/dist/barcode/props.js.map +1 -0
- package/dist/barcode/render.d.ts +60 -0
- package/dist/barcode/render.d.ts.map +1 -0
- package/dist/barcode/render.js +95 -0
- package/dist/barcode/render.js.map +1 -0
- package/dist/barcode/rows.d.ts +27 -0
- package/dist/barcode/rows.d.ts.map +1 -0
- package/dist/barcode/rows.js +31 -0
- package/dist/barcode/rows.js.map +1 -0
- package/dist/barcode-dotcode.d.ts +6 -0
- package/dist/barcode-dotcode.d.ts.map +1 -0
- package/dist/barcode-dotcode.js +8 -0
- package/dist/barcode-dotcode.js.map +1 -0
- package/dist/barcode-gs1-databar.d.ts +6 -0
- package/dist/barcode-gs1-databar.d.ts.map +1 -0
- package/dist/barcode-gs1-databar.js +7 -0
- package/dist/barcode-gs1-databar.js.map +1 -0
- package/dist/barcode-pdf417.d.ts +6 -0
- package/dist/barcode-pdf417.d.ts.map +1 -0
- package/dist/barcode-pdf417.js +8 -0
- package/dist/barcode-pdf417.js.map +1 -0
- package/dist/barcode.css +30 -0
- package/dist/barcode.d.ts +9 -0
- package/dist/barcode.d.ts.map +1 -0
- package/dist/barcode.js +13 -0
- package/dist/barcode.js.map +1 -0
- package/dist/chart/BulletChart.d.ts +53 -0
- package/dist/chart/BulletChart.d.ts.map +1 -0
- package/dist/chart/BulletChart.js +107 -0
- package/dist/chart/BulletChart.js.map +1 -0
- package/dist/chart/Chart.d.ts +41 -0
- package/dist/chart/Chart.d.ts.map +1 -0
- package/dist/chart/Chart.js +571 -0
- package/dist/chart/Chart.js.map +1 -0
- package/dist/chart/ChartSeries.d.ts +14 -0
- package/dist/chart/ChartSeries.d.ts.map +1 -0
- package/dist/chart/ChartSeries.js +13 -0
- package/dist/chart/ChartSeries.js.map +1 -0
- package/dist/chart/ChartSyncGroup.d.ts +37 -0
- package/dist/chart/ChartSyncGroup.d.ts.map +1 -0
- package/dist/chart/ChartSyncGroup.js +19 -0
- package/dist/chart/ChartSyncGroup.js.map +1 -0
- package/dist/chart/features.d.ts +11 -0
- package/dist/chart/features.d.ts.map +1 -0
- package/dist/chart/features.js +10 -0
- package/dist/chart/features.js.map +1 -0
- package/dist/chart/indicators.d.ts +17 -0
- package/dist/chart/indicators.d.ts.map +1 -0
- package/dist/chart/indicators.js +119 -0
- package/dist/chart/indicators.js.map +1 -0
- package/dist/chart/interact.d.ts +65 -0
- package/dist/chart/interact.d.ts.map +1 -0
- package/dist/chart/interact.js +249 -0
- package/dist/chart/interact.js.map +1 -0
- package/dist/chart/model.d.ts +193 -0
- package/dist/chart/model.d.ts.map +1 -0
- package/dist/chart/model.js +1280 -0
- package/dist/chart/model.js.map +1 -0
- package/dist/chart/overlay.d.ts +50 -0
- package/dist/chart/overlay.d.ts.map +1 -0
- package/dist/chart/overlay.js +221 -0
- package/dist/chart/overlay.js.map +1 -0
- package/dist/chart/polar.d.ts +5 -0
- package/dist/chart/polar.d.ts.map +1 -0
- package/dist/chart/polar.js +164 -0
- package/dist/chart/polar.js.map +1 -0
- package/dist/chart/render.d.ts +23 -0
- package/dist/chart/render.d.ts.map +1 -0
- package/dist/chart/render.js +81 -0
- package/dist/chart/render.js.map +1 -0
- package/dist/chart/types.d.ts +567 -0
- package/dist/chart/types.d.ts.map +1 -0
- package/dist/chart/types.js +5 -0
- package/dist/chart/types.js.map +1 -0
- package/dist/chart/zoom-toolbar.d.ts +14 -0
- package/dist/chart/zoom-toolbar.d.ts.map +1 -0
- package/dist/chart/zoom-toolbar.js +11 -0
- package/dist/chart/zoom-toolbar.js.map +1 -0
- package/dist/chart-bullet.d.ts +3 -0
- package/dist/chart-bullet.d.ts.map +1 -0
- package/dist/chart-bullet.js +9 -0
- package/dist/chart-bullet.js.map +1 -0
- package/dist/chart-export.d.ts +3 -0
- package/dist/chart-export.d.ts.map +1 -0
- package/dist/chart-export.js +6 -0
- package/dist/chart-export.js.map +1 -0
- package/dist/chart.css +552 -0
- package/dist/chart.d.ts +7 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +12 -0
- package/dist/chart.js.map +1 -0
- package/dist/gauge/Gauge.d.ts +114 -0
- package/dist/gauge/Gauge.d.ts.map +1 -0
- package/dist/gauge/Gauge.js +252 -0
- package/dist/gauge/Gauge.js.map +1 -0
- package/dist/gauge/animate.d.ts +4 -0
- package/dist/gauge/animate.d.ts.map +1 -0
- package/dist/gauge/animate.js +41 -0
- package/dist/gauge/animate.js.map +1 -0
- package/dist/gauge/drag.d.ts +9 -0
- package/dist/gauge/drag.d.ts.map +1 -0
- package/dist/gauge/drag.js +28 -0
- package/dist/gauge/drag.js.map +1 -0
- package/dist/gauge/layout.d.ts +257 -0
- package/dist/gauge/layout.d.ts.map +1 -0
- package/dist/gauge/layout.js +399 -0
- package/dist/gauge/layout.js.map +1 -0
- package/dist/gauge/tooltip.d.ts +20 -0
- package/dist/gauge/tooltip.d.ts.map +1 -0
- package/dist/gauge/tooltip.js +19 -0
- package/dist/gauge/tooltip.js.map +1 -0
- package/dist/gauge.css +379 -0
- package/dist/gauge.d.ts +5 -0
- package/dist/gauge.d.ts.map +1 -0
- package/dist/gauge.js +9 -0
- package/dist/gauge.js.map +1 -0
- package/dist/geo-map/GeoMap.d.ts +175 -0
- package/dist/geo-map/GeoMap.d.ts.map +1 -0
- package/dist/geo-map/GeoMap.js +619 -0
- package/dist/geo-map/GeoMap.js.map +1 -0
- package/dist/geo-map/model.d.ts +270 -0
- package/dist/geo-map/model.d.ts.map +1 -0
- package/dist/geo-map/model.js +265 -0
- package/dist/geo-map/model.js.map +1 -0
- package/dist/geo-map/tiles.d.ts +13 -0
- package/dist/geo-map/tiles.d.ts.map +1 -0
- package/dist/geo-map/tiles.js +13 -0
- package/dist/geo-map/tiles.js.map +1 -0
- package/dist/geo-map.css +522 -0
- package/dist/geo-map.d.ts +6 -0
- package/dist/geo-map.d.ts.map +1 -0
- package/dist/geo-map.js +11 -0
- package/dist/geo-map.js.map +1 -0
- package/dist/heat-map/HeatMap.d.ts +6 -0
- package/dist/heat-map/HeatMap.d.ts.map +1 -0
- package/dist/heat-map/HeatMap.js +328 -0
- package/dist/heat-map/HeatMap.js.map +1 -0
- package/dist/heat-map/canvas.d.ts +12 -0
- package/dist/heat-map/canvas.d.ts.map +1 -0
- package/dist/heat-map/canvas.js +71 -0
- package/dist/heat-map/canvas.js.map +1 -0
- package/dist/heat-map/model.d.ts +41 -0
- package/dist/heat-map/model.d.ts.map +1 -0
- package/dist/heat-map/model.js +194 -0
- package/dist/heat-map/model.js.map +1 -0
- package/dist/heat-map/types.d.ts +152 -0
- package/dist/heat-map/types.d.ts.map +1 -0
- package/dist/heat-map/types.js +2 -0
- package/dist/heat-map/types.js.map +1 -0
- package/dist/heat-map.css +362 -0
- package/dist/heat-map.d.ts +5 -0
- package/dist/heat-map.d.ts.map +1 -0
- package/dist/heat-map.js +11 -0
- package/dist/heat-map.js.map +1 -0
- package/dist/internal/data-colors.d.ts +11 -0
- package/dist/internal/data-colors.d.ts.map +1 -0
- package/dist/internal/data-colors.js +60 -0
- package/dist/internal/data-colors.js.map +1 -0
- package/dist/internal/viz/animate.d.ts +10 -0
- package/dist/internal/viz/animate.d.ts.map +1 -0
- package/dist/internal/viz/animate.js +21 -0
- package/dist/internal/viz/animate.js.map +1 -0
- package/dist/internal/viz/canvas.d.ts +14 -0
- package/dist/internal/viz/canvas.d.ts.map +1 -0
- package/dist/internal/viz/canvas.js +34 -0
- package/dist/internal/viz/canvas.js.map +1 -0
- package/dist/internal/viz/children.d.ts +4 -0
- package/dist/internal/viz/children.d.ts.map +1 -0
- package/dist/internal/viz/children.js +11 -0
- package/dist/internal/viz/children.js.map +1 -0
- package/dist/internal/viz/export-all.d.ts +27 -0
- package/dist/internal/viz/export-all.d.ts.map +1 -0
- package/dist/internal/viz/export-all.js +8 -0
- package/dist/internal/viz/export-all.js.map +1 -0
- package/dist/internal/viz/export-data.d.ts +32 -0
- package/dist/internal/viz/export-data.d.ts.map +1 -0
- package/dist/internal/viz/export-data.js +100 -0
- package/dist/internal/viz/export-data.js.map +1 -0
- package/dist/internal/viz/export.d.ts +48 -0
- package/dist/internal/viz/export.d.ts.map +1 -0
- package/dist/internal/viz/export.js +199 -0
- package/dist/internal/viz/export.js.map +1 -0
- package/dist/internal/viz/fields.d.ts +2 -0
- package/dist/internal/viz/fields.d.ts.map +1 -0
- package/dist/internal/viz/fields.js +5 -0
- package/dist/internal/viz/fields.js.map +1 -0
- package/dist/internal/viz/figure.d.ts +45 -0
- package/dist/internal/viz/figure.d.ts.map +1 -0
- package/dist/internal/viz/figure.js +26 -0
- package/dist/internal/viz/figure.js.map +1 -0
- package/dist/internal/viz/format.d.ts +21 -0
- package/dist/internal/viz/format.d.ts.map +1 -0
- package/dist/internal/viz/format.js +77 -0
- package/dist/internal/viz/format.js.map +1 -0
- package/dist/internal/viz/frame.d.ts +81 -0
- package/dist/internal/viz/frame.d.ts.map +1 -0
- package/dist/internal/viz/frame.js +78 -0
- package/dist/internal/viz/frame.js.map +1 -0
- package/dist/internal/viz/instance-run.d.ts +6 -0
- package/dist/internal/viz/instance-run.d.ts.map +1 -0
- package/dist/internal/viz/instance-run.js +43 -0
- package/dist/internal/viz/instance-run.js.map +1 -0
- package/dist/internal/viz/instance.d.ts +59 -0
- package/dist/internal/viz/instance.d.ts.map +1 -0
- package/dist/internal/viz/instance.js +23 -0
- package/dist/internal/viz/instance.js.map +1 -0
- package/dist/internal/viz/keyboard.d.ts +21 -0
- package/dist/internal/viz/keyboard.d.ts.map +1 -0
- package/dist/internal/viz/keyboard.js +78 -0
- package/dist/internal/viz/keyboard.js.map +1 -0
- package/dist/internal/viz/legend.d.ts +63 -0
- package/dist/internal/viz/legend.d.ts.map +1 -0
- package/dist/internal/viz/legend.js +76 -0
- package/dist/internal/viz/legend.js.map +1 -0
- package/dist/internal/viz/plot-canvas.d.ts +16 -0
- package/dist/internal/viz/plot-canvas.d.ts.map +1 -0
- package/dist/internal/viz/plot-canvas.js +62 -0
- package/dist/internal/viz/plot-canvas.js.map +1 -0
- package/dist/internal/viz/size.d.ts +20 -0
- package/dist/internal/viz/size.d.ts.map +1 -0
- package/dist/internal/viz/size.js +61 -0
- package/dist/internal/viz/size.js.map +1 -0
- package/dist/internal/viz/store.d.ts +20 -0
- package/dist/internal/viz/store.d.ts.map +1 -0
- package/dist/internal/viz/store.js +74 -0
- package/dist/internal/viz/store.js.map +1 -0
- package/dist/internal/viz/svg-server.d.ts +15 -0
- package/dist/internal/viz/svg-server.d.ts.map +1 -0
- package/dist/internal/viz/svg-server.js +105 -0
- package/dist/internal/viz/svg-server.js.map +1 -0
- package/dist/internal/viz/tooltip.d.ts +14 -0
- package/dist/internal/viz/tooltip.d.ts.map +1 -0
- package/dist/internal/viz/tooltip.js +34 -0
- package/dist/internal/viz/tooltip.js.map +1 -0
- package/dist/pie-chart/Accumulation.d.ts +78 -0
- package/dist/pie-chart/Accumulation.d.ts.map +1 -0
- package/dist/pie-chart/Accumulation.js +227 -0
- package/dist/pie-chart/Accumulation.js.map +1 -0
- package/dist/pie-chart/FunnelChart.d.ts +4 -0
- package/dist/pie-chart/FunnelChart.d.ts.map +1 -0
- package/dist/pie-chart/FunnelChart.js +47 -0
- package/dist/pie-chart/FunnelChart.js.map +1 -0
- package/dist/pie-chart/PieChart.d.ts +4 -0
- package/dist/pie-chart/PieChart.d.ts.map +1 -0
- package/dist/pie-chart/PieChart.js +87 -0
- package/dist/pie-chart/PieChart.js.map +1 -0
- package/dist/pie-chart/types.d.ts +199 -0
- package/dist/pie-chart/types.d.ts.map +1 -0
- package/dist/pie-chart/types.js +2 -0
- package/dist/pie-chart/types.js.map +1 -0
- package/dist/pie-chart.css +389 -0
- package/dist/pie-chart.d.ts +6 -0
- package/dist/pie-chart.d.ts.map +1 -0
- package/dist/pie-chart.js +12 -0
- package/dist/pie-chart.js.map +1 -0
- package/dist/range-selector/PeriodSelector.d.ts +19 -0
- package/dist/range-selector/PeriodSelector.d.ts.map +1 -0
- package/dist/range-selector/PeriodSelector.js +9 -0
- package/dist/range-selector/PeriodSelector.js.map +1 -0
- package/dist/range-selector/RangeSelector.d.ts +62 -0
- package/dist/range-selector/RangeSelector.d.ts.map +1 -0
- package/dist/range-selector/RangeSelector.js +220 -0
- package/dist/range-selector/RangeSelector.js.map +1 -0
- package/dist/range-selector/model.d.ts +77 -0
- package/dist/range-selector/model.d.ts.map +1 -0
- package/dist/range-selector/model.js +162 -0
- package/dist/range-selector/model.js.map +1 -0
- package/dist/range-selector/period.d.ts +17 -0
- package/dist/range-selector/period.d.ts.map +1 -0
- package/dist/range-selector/period.js +31 -0
- package/dist/range-selector/period.js.map +1 -0
- package/dist/range-selector.css +407 -0
- package/dist/range-selector.d.ts +8 -0
- package/dist/range-selector.d.ts.map +1 -0
- package/dist/range-selector.js +11 -0
- package/dist/range-selector.js.map +1 -0
- package/dist/sankey-chart/SankeyChart.d.ts +4 -0
- package/dist/sankey-chart/SankeyChart.d.ts.map +1 -0
- package/dist/sankey-chart/SankeyChart.js +304 -0
- package/dist/sankey-chart/SankeyChart.js.map +1 -0
- package/dist/sankey-chart/types.d.ts +107 -0
- package/dist/sankey-chart/types.d.ts.map +1 -0
- package/dist/sankey-chart/types.js +2 -0
- package/dist/sankey-chart/types.js.map +1 -0
- package/dist/sankey-chart.css +344 -0
- package/dist/sankey-chart.d.ts +5 -0
- package/dist/sankey-chart.d.ts.map +1 -0
- package/dist/sankey-chart.js +10 -0
- package/dist/sankey-chart.js.map +1 -0
- package/dist/server-visualization.d.ts +3 -0
- package/dist/server-visualization.d.ts.map +1 -0
- package/dist/server-visualization.js +7 -0
- package/dist/server-visualization.js.map +1 -0
- package/dist/sparkline/Sparkline.d.ts +4 -0
- package/dist/sparkline/Sparkline.d.ts.map +1 -0
- package/dist/sparkline/Sparkline.js +101 -0
- package/dist/sparkline/Sparkline.js.map +1 -0
- package/dist/sparkline/canvas.d.ts +4 -0
- package/dist/sparkline/canvas.d.ts.map +1 -0
- package/dist/sparkline/canvas.js +68 -0
- package/dist/sparkline/canvas.js.map +1 -0
- package/dist/sparkline/model.d.ts +29 -0
- package/dist/sparkline/model.d.ts.map +1 -0
- package/dist/sparkline/model.js +112 -0
- package/dist/sparkline/model.js.map +1 -0
- package/dist/sparkline/tooltip.d.ts +15 -0
- package/dist/sparkline/tooltip.d.ts.map +1 -0
- package/dist/sparkline/tooltip.js +138 -0
- package/dist/sparkline/tooltip.js.map +1 -0
- package/dist/sparkline/types.d.ts +99 -0
- package/dist/sparkline/types.d.ts.map +1 -0
- package/dist/sparkline/types.js +2 -0
- package/dist/sparkline/types.js.map +1 -0
- package/dist/sparkline.css +70 -0
- package/dist/sparkline.d.ts +3 -0
- package/dist/sparkline.d.ts.map +1 -0
- package/dist/sparkline.js +10 -0
- package/dist/sparkline.js.map +1 -0
- package/dist/stock-chart/StockChart.d.ts +84 -0
- package/dist/stock-chart/StockChart.d.ts.map +1 -0
- package/dist/stock-chart/StockChart.js +192 -0
- package/dist/stock-chart/StockChart.js.map +1 -0
- package/dist/stock-chart.css +54 -0
- package/dist/stock-chart.d.ts +3 -0
- package/dist/stock-chart.d.ts.map +1 -0
- package/dist/stock-chart.js +10 -0
- package/dist/stock-chart.js.map +1 -0
- package/dist/styles.css +1284 -0
- package/dist/tree-map/TreeMap.d.ts +4 -0
- package/dist/tree-map/TreeMap.d.ts.map +1 -0
- package/dist/tree-map/TreeMap.js +307 -0
- package/dist/tree-map/TreeMap.js.map +1 -0
- package/dist/tree-map/types.d.ts +139 -0
- package/dist/tree-map/types.d.ts.map +1 -0
- package/dist/tree-map/types.js +2 -0
- package/dist/tree-map/types.js.map +1 -0
- package/dist/tree-map.css +425 -0
- package/dist/tree-map.d.ts +5 -0
- package/dist/tree-map.d.ts.map +1 -0
- package/dist/tree-map.js +10 -0
- package/dist/tree-map.js.map +1 -0
- package/dist/viz/accumulation.d.ts +135 -0
- package/dist/viz/accumulation.d.ts.map +1 -0
- package/dist/viz/accumulation.js +233 -0
- package/dist/viz/accumulation.js.map +1 -0
- package/dist/viz/cluster.d.ts +13 -0
- package/dist/viz/cluster.d.ts.map +1 -0
- package/dist/viz/cluster.js +26 -0
- package/dist/viz/cluster.js.map +1 -0
- package/dist/viz/color.d.ts +33 -0
- package/dist/viz/color.d.ts.map +1 -0
- package/dist/viz/color.js +77 -0
- package/dist/viz/color.js.map +1 -0
- package/dist/viz/decimate.d.ts +41 -0
- package/dist/viz/decimate.d.ts.map +1 -0
- package/dist/viz/decimate.js +205 -0
- package/dist/viz/decimate.js.map +1 -0
- package/dist/viz/field.d.ts +5 -0
- package/dist/viz/field.d.ts.map +1 -0
- package/dist/viz/field.js +23 -0
- package/dist/viz/field.js.map +1 -0
- package/dist/viz/format.d.ts +11 -0
- package/dist/viz/format.d.ts.map +1 -0
- package/dist/viz/format.js +45 -0
- package/dist/viz/format.js.map +1 -0
- package/dist/viz/geometry.d.ts +36 -0
- package/dist/viz/geometry.d.ts.map +1 -0
- package/dist/viz/geometry.js +290 -0
- package/dist/viz/geometry.js.map +1 -0
- package/dist/viz/heatmap.d.ts +37 -0
- package/dist/viz/heatmap.d.ts.map +1 -0
- package/dist/viz/heatmap.js +131 -0
- package/dist/viz/heatmap.js.map +1 -0
- package/dist/viz/hit-test.d.ts +30 -0
- package/dist/viz/hit-test.d.ts.map +1 -0
- package/dist/viz/hit-test.js +116 -0
- package/dist/viz/hit-test.js.map +1 -0
- package/dist/viz/index.d.ts +27 -0
- package/dist/viz/index.d.ts.map +1 -0
- package/dist/viz/index.js +32 -0
- package/dist/viz/index.js.map +1 -0
- package/dist/viz/indicators.d.ts +26 -0
- package/dist/viz/indicators.d.ts.map +1 -0
- package/dist/viz/indicators.js +166 -0
- package/dist/viz/indicators.js.map +1 -0
- package/dist/viz/labels.d.ts +48 -0
- package/dist/viz/labels.d.ts.map +1 -0
- package/dist/viz/labels.js +136 -0
- package/dist/viz/labels.js.map +1 -0
- package/dist/viz/layout.d.ts +134 -0
- package/dist/viz/layout.d.ts.map +1 -0
- package/dist/viz/layout.js +243 -0
- package/dist/viz/layout.js.map +1 -0
- package/dist/viz/palette.d.ts +40 -0
- package/dist/viz/palette.d.ts.map +1 -0
- package/dist/viz/palette.js +89 -0
- package/dist/viz/palette.js.map +1 -0
- package/dist/viz/polygon.d.ts +3 -0
- package/dist/viz/polygon.d.ts.map +1 -0
- package/dist/viz/polygon.js +18 -0
- package/dist/viz/polygon.js.map +1 -0
- package/dist/viz/polyline.d.ts +21 -0
- package/dist/viz/polyline.d.ts.map +1 -0
- package/dist/viz/polyline.js +52 -0
- package/dist/viz/polyline.js.map +1 -0
- package/dist/viz/projection.d.ts +63 -0
- package/dist/viz/projection.d.ts.map +1 -0
- package/dist/viz/projection.js +252 -0
- package/dist/viz/projection.js.map +1 -0
- package/dist/viz/sankey.d.ts +75 -0
- package/dist/viz/sankey.d.ts.map +1 -0
- package/dist/viz/sankey.js +292 -0
- package/dist/viz/sankey.js.map +1 -0
- package/dist/viz/scale.d.ts +95 -0
- package/dist/viz/scale.d.ts.map +1 -0
- package/dist/viz/scale.js +157 -0
- package/dist/viz/scale.js.map +1 -0
- package/dist/viz/stack.d.ts +25 -0
- package/dist/viz/stack.d.ts.map +1 -0
- package/dist/viz/stack.js +62 -0
- package/dist/viz/stack.js.map +1 -0
- package/dist/viz/stats.d.ts +52 -0
- package/dist/viz/stats.d.ts.map +1 -0
- package/dist/viz/stats.js +198 -0
- package/dist/viz/stats.js.map +1 -0
- package/dist/viz/summary.d.ts +60 -0
- package/dist/viz/summary.d.ts.map +1 -0
- package/dist/viz/summary.js +89 -0
- package/dist/viz/summary.js.map +1 -0
- package/dist/viz/text.d.ts +21 -0
- package/dist/viz/text.d.ts.map +1 -0
- package/dist/viz/text.js +99 -0
- package/dist/viz/text.js.map +1 -0
- package/dist/viz/ticks.d.ts +23 -0
- package/dist/viz/ticks.d.ts.map +1 -0
- package/dist/viz/ticks.js +146 -0
- package/dist/viz/ticks.js.map +1 -0
- package/dist/viz/time-ticks.d.ts +44 -0
- package/dist/viz/time-ticks.d.ts.map +1 -0
- package/dist/viz/time-ticks.js +246 -0
- package/dist/viz/time-ticks.js.map +1 -0
- package/dist/viz/treemap.d.ts +61 -0
- package/dist/viz/treemap.d.ts.map +1 -0
- package/dist/viz/treemap.js +171 -0
- package/dist/viz/treemap.js.map +1 -0
- package/dist/viz/trend.d.ts +31 -0
- package/dist/viz/trend.d.ts.map +1 -0
- package/dist/viz/trend.js +130 -0
- package/dist/viz/trend.js.map +1 -0
- package/dist/viz-animations.css +40 -0
- package/dist/viz-rtl.css +31 -0
- package/package.json +146 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/chart/Chart.tsx"],"names":[],"mappings":"AASA,OAAO,EAAsK,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQ3M,OAAO,EAAiC,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAa9F,OAAO,KAAK,EAAmG,UAAU,EAAgE,cAAc,EAAE,MAAM,YAAY,CAAC;AAM5N,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC;IAC7D,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACpE,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACnJ,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACnG,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAgCD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CA6iBlD"}
|
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// `Chart`: props compile to
|
|
4
|
+
// an id-keyed spec, the pure model lays it out for the stored size and zoom
|
|
5
|
+
// frame, `ChartSvg` draws it (or the lazy canvas layer draws the marks), and
|
|
6
|
+
// a store-driven overlay shows the tooltip, crosshair, focus ring and zoom
|
|
7
|
+
// selection. Pointer, wheel and drag transients live in the store and refs,
|
|
8
|
+
// never React state; committed changes go through the controlled triads.
|
|
9
|
+
import { Children, isValidElement, lazy, Suspense, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
10
|
+
import { lineHeight, nearestSorted, pct, textWidth } from '#viz';
|
|
11
|
+
import { useControllableState } from '@salmonui/core/internal/controllable';
|
|
12
|
+
import { useLocale, useLocaleText } from '@salmonui/core/internal/locale';
|
|
13
|
+
import { warnOnce } from '@salmonui/core/internal/dev';
|
|
14
|
+
import { useHydrated } from '@salmonui/core/internal/hydrated';
|
|
15
|
+
import { VizCanvas } from '../internal/viz/canvas.js';
|
|
16
|
+
import { NamedVizFigure } from '../internal/viz/figure.js';
|
|
17
|
+
import { movePointFocus, plotKeyAction } from '../internal/viz/keyboard.js';
|
|
18
|
+
import { LegendButtons, LegendPager } from '../internal/viz/legend.js';
|
|
19
|
+
import { svgMarkup } from '../internal/viz/instance.js';
|
|
20
|
+
import { initialSize, useMeasuredSize } from '../internal/viz/size.js';
|
|
21
|
+
import { useVizSelector, useVizStore } from '../internal/viz/store.js';
|
|
22
|
+
import { ChartAxis, ChartSeries } from './ChartSeries.js';
|
|
23
|
+
import { useChartSync } from './ChartSyncGroup.js';
|
|
24
|
+
import { buildModel, compileSpec, currentZoom, DEFAULT_TEXT, hideAxes, readField, seriesId } from './model.js';
|
|
25
|
+
import { ChartSvg } from './render.js';
|
|
26
|
+
const ZoomToolbar = lazy(() => import('./zoom-toolbar.js'));
|
|
27
|
+
const ChartOverlay = lazy(() => import('./overlay.js'));
|
|
28
|
+
const OVERLAY_TOOLS = { pointContext, nearestSorted, textWidth, lineHeight };
|
|
29
|
+
const ALL_TOOLS = ['zoom', 'zoomIn', 'zoomOut', 'pan', 'reset'];
|
|
30
|
+
const EMPTY = [];
|
|
31
|
+
const EMPTY_POINTS = [];
|
|
32
|
+
const EMPTY_ZOOM = {};
|
|
33
|
+
function collectChildren(children) {
|
|
34
|
+
const series = [];
|
|
35
|
+
const axes = [];
|
|
36
|
+
// Reading direct children's props is pure, so JSX series render on the server like the array form.
|
|
37
|
+
for (const child of Children.toArray(children)) {
|
|
38
|
+
if (!isValidElement(child))
|
|
39
|
+
continue;
|
|
40
|
+
if (child.type === ChartSeries)
|
|
41
|
+
series.push(child.props);
|
|
42
|
+
else if (child.type === ChartAxis) {
|
|
43
|
+
const p = child.props;
|
|
44
|
+
axes.push({ ...p, id: p.id ?? p.direction });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { series, axes };
|
|
48
|
+
}
|
|
49
|
+
const toggle = (list, id) => (list.includes(id) ? list.filter((x) => x !== id) : [...list, id]);
|
|
50
|
+
function pointContext(m, index, datum, xField) {
|
|
51
|
+
return { seriesId: m.id, seriesName: m.name, index, datum: datum ?? {}, x: readField(datum, xField), y: m.yValue(index), xText: m.xText(index), yText: m.yText(index), color: m.color };
|
|
52
|
+
}
|
|
53
|
+
export function Chart(props) {
|
|
54
|
+
const uid = useId().replace(/:/g, '');
|
|
55
|
+
const store = useVizStore(() => ({
|
|
56
|
+
...initialSize({ width: props.width, height: props.height ?? 300 }),
|
|
57
|
+
active: null,
|
|
58
|
+
activeSource: null,
|
|
59
|
+
pointer: null,
|
|
60
|
+
frame: null,
|
|
61
|
+
selecting: null,
|
|
62
|
+
lasso: null,
|
|
63
|
+
dragPoint: null,
|
|
64
|
+
tool: 'zoom',
|
|
65
|
+
legendPage: 0,
|
|
66
|
+
highlight: null,
|
|
67
|
+
version: 0,
|
|
68
|
+
}));
|
|
69
|
+
const surfaceRef = useRef(null);
|
|
70
|
+
const rootRef = useRef(null);
|
|
71
|
+
const plotRef = useRef(null);
|
|
72
|
+
const svgHost = useRef(null);
|
|
73
|
+
// without `height` the surface is a flex item of the root (300 px basis, filling a root whose height CSS
|
|
74
|
+
// fixes); the measured height relays out.
|
|
75
|
+
useMeasuredSize(surfaceRef, store, { width: props.width, height: props.height }, props.onResize);
|
|
76
|
+
const width = useVizSelector(store, (s) => s.width);
|
|
77
|
+
const height = useVizSelector(store, (s) => s.height);
|
|
78
|
+
const frameZoom = useVizSelector(store, (s) => s.frame);
|
|
79
|
+
const legendPage = useVizSelector(store, (s) => s.legendPage);
|
|
80
|
+
const highlightId = useVizSelector(store, (s) => s.highlight);
|
|
81
|
+
const tool = useVizSelector(store, (s) => s.tool);
|
|
82
|
+
const hydrated = useHydrated();
|
|
83
|
+
const version = useVizSelector(store, (s) => s.version);
|
|
84
|
+
const sync = useChartSync();
|
|
85
|
+
const ownSync = useVizStore(() => ({ x: null, source: null, zoom: null }));
|
|
86
|
+
const syncStore = sync?.store ?? ownSync;
|
|
87
|
+
const syncZoom = useVizSelector(syncStore, (s) => s.zoom);
|
|
88
|
+
const [hidden, setHidden] = useControllableState(props.hiddenSeries, props.defaultHiddenSeries ?? EMPTY, props.onHiddenSeriesChange, 'Chart hiddenSeries');
|
|
89
|
+
const [zoomRange, setZoomRange] = useControllableState(props.zoomRange, props.defaultZoomRange ?? EMPTY_ZOOM, props.onZoomRangeChange, 'Chart zoomRange');
|
|
90
|
+
const [selected, setSelected] = useControllableState(props.selectedPoints, props.defaultSelectedPoints ?? EMPTY_POINTS, props.onSelectedPointsChange, 'Chart selectedPoints');
|
|
91
|
+
// Streamed points (api.appendPoints) per series id, kept outside React state.
|
|
92
|
+
const appended = useRef(new Map());
|
|
93
|
+
// The chart's own text and locale over the nearest LocaleProvider's (the model reads them from the props).
|
|
94
|
+
const ownText = useLocaleText('chart', props.text);
|
|
95
|
+
const locale = useLocale(props.locale);
|
|
96
|
+
const children = useMemo(() => collectChildren(props.children), [props.children]);
|
|
97
|
+
const seriesList = useMemo(() => {
|
|
98
|
+
const list = [...(props.series ?? []), ...children.series];
|
|
99
|
+
if (version === 0 || appended.current.size === 0)
|
|
100
|
+
return list;
|
|
101
|
+
return list.map((s, i) => {
|
|
102
|
+
const id = seriesId(s, i);
|
|
103
|
+
const extra = appended.current.get(id);
|
|
104
|
+
if (!extra)
|
|
105
|
+
return s;
|
|
106
|
+
let data = [...(s.data ?? props.data ?? []), ...extra.points];
|
|
107
|
+
if (extra.maxPoints && data.length > extra.maxPoints)
|
|
108
|
+
data = data.slice(data.length - extra.maxPoints);
|
|
109
|
+
return { ...s, data };
|
|
110
|
+
});
|
|
111
|
+
}, [props.series, props.data, children.series, version]);
|
|
112
|
+
// One object per props, text, locale and child axes, so the model memo holds across store-only renders.
|
|
113
|
+
const effectiveProps = useMemo(() => {
|
|
114
|
+
const own = { ...props, text: ownText, locale };
|
|
115
|
+
return children.axes.length ? { ...own, xAxis: { ...props.xAxis, ...children.axes.find((a) => a.id === 'x') }, yAxis: { ...props.yAxis, ...children.axes.find((a) => a.id === 'y') }, axes: [...(props.axes ?? []), ...children.axes.filter((a) => a.id !== 'x' && a.id !== 'y')] } : own;
|
|
116
|
+
}, [props, ownText, locale, children.axes]);
|
|
117
|
+
const hiddenSet = useMemo(() => new Set(hidden), [hidden]);
|
|
118
|
+
const spec = useMemo(() => compileSpec(effectiveProps, seriesList, hiddenSet), [effectiveProps.data, effectiveProps.xAxis, effectiveProps.yAxis, effectiveProps.axes, effectiveProps.orientation, effectiveProps.palette, seriesList, hiddenSet]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
119
|
+
const zoom = frameZoom ?? (sync?.zoom && syncZoom ? { ...zoomRange, x: syncZoom } : zoomRange);
|
|
120
|
+
// Polar and radar: the opt-in `polar` feature of `@salmonui/charts/chart/features`.
|
|
121
|
+
const polarOn = props.coordinate === 'polar' || props.coordinate === 'radar';
|
|
122
|
+
const polar = polarOn ? (props.features?.find((f) => f.name === 'polar')?.layout ?? null) : null;
|
|
123
|
+
// Technical indicators: the opt-in `@salmonui/charts/chart/indicators` feature.
|
|
124
|
+
const indicatorLayout = props.features?.find((f) => f.name === 'indicators')?.layout ?? null;
|
|
125
|
+
const model = useMemo(() => (polar ? polar(effectiveProps, spec, { width, height, zoom }) : buildModel(effectiveProps, polarOn ? hideAxes(spec, []) : spec, { width, height, zoom }, indicatorLayout)), [spec, width, height, zoom, effectiveProps, polar, polarOn, indicatorLayout]);
|
|
126
|
+
const tooltipOpt = props.tooltip === false ? null : typeof props.tooltip === 'object' ? props.tooltip : {};
|
|
127
|
+
const sharedTooltip = tooltipOpt?.mode === 'shared' || tooltipOpt?.mode === 'split' || Boolean(props.crosshair && typeof props.crosshair === 'object' && props.crosshair.snap);
|
|
128
|
+
const zoomOpt = props.zoom ? (typeof props.zoom === 'object' ? props.zoom : { wheel: true, selection: true, pan: true }) : null;
|
|
129
|
+
const legendOpt = typeof props.legend === 'object' ? props.legend : {};
|
|
130
|
+
// Point, range and gradient legends are keys: only series items toggle.
|
|
131
|
+
const legendToggle = legendOpt.toggle !== false && (legendOpt.mode ?? 'series') === 'series';
|
|
132
|
+
const text = { ...DEFAULT_TEXT, ...ownText };
|
|
133
|
+
const renderer = props.renderer ?? 'svg';
|
|
134
|
+
const canvas = renderer === 'canvas' || (renderer === 'auto' && model.drawnPoints > 20_000);
|
|
135
|
+
const selectedKeys = useMemo(() => new Set(selected.map((p) => `${p.seriesId}:${p.index}`)), [selected]);
|
|
136
|
+
const dimmed = useMemo(() => {
|
|
137
|
+
const out = new Set();
|
|
138
|
+
if (highlightId && (legendOpt.highlight !== false || props.highlight === 'series'))
|
|
139
|
+
for (const s of model.series)
|
|
140
|
+
if (s.id !== highlightId)
|
|
141
|
+
out.add(s.id);
|
|
142
|
+
return out;
|
|
143
|
+
}, [highlightId, model, legendOpt.highlight, props.highlight]);
|
|
144
|
+
// Custom markers and labels: SVG content from the series options, per drawn point.
|
|
145
|
+
const customPoints = seriesList.some((s) => s.renderMarker || (typeof s.labels === 'object' && s.labels.render));
|
|
146
|
+
const pointContent = customPoints
|
|
147
|
+
? (kind, id, index) => {
|
|
148
|
+
const opt = spec.series.find((c) => c.id === id)?.options;
|
|
149
|
+
const fn = kind === 'marker' ? opt?.renderMarker : typeof opt?.labels === 'object' ? opt.labels.render : undefined;
|
|
150
|
+
const m = model.series.find((x) => x.id === id);
|
|
151
|
+
return fn && m ? fn(pointContext(m, index, datumOf(m, index), opt?.xField)) : undefined;
|
|
152
|
+
}
|
|
153
|
+
: undefined;
|
|
154
|
+
const legendItems = model.legend.map((l) => ({ id: l.id, label: l.label, color: l.color, shape: l.shape === 'gradient' ? 'rectangle' : l.shape, hidden: l.hidden, lineStyle: l.lineStyle }));
|
|
155
|
+
// Custom legend content and the gradient key: HTML over the item boxes, in place of the drawn item.
|
|
156
|
+
const legendContent = model.legend.map((l) => legendOpt.renderItem ? (legendOpt.renderItem({ id: l.id, label: l.label, color: l.color, hidden: l.hidden, seriesId: l.seriesId, index: l.index })) : l.shape === 'gradient' ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "salmon-chart-gradient-key", style: { background: `linear-gradient(to right, ${(l.stops ?? []).join(', ')})` } }), l.label] })) : undefined);
|
|
157
|
+
const customLegend = new Set(legendContent.flatMap((x, i) => (x === undefined ? [] : [i])));
|
|
158
|
+
const xFieldOf = (m) => seriesList.find((s, i) => seriesId(s, i) === m.id)?.xField;
|
|
159
|
+
const datumOf = (m, index) => spec.series.find((s) => s.id === m.id)?.data[index];
|
|
160
|
+
// --- latest values for event handlers (no stale closures, no re-subscription) ---
|
|
161
|
+
const latest = useRef({ model, props, zoomRange, selected, hidden, syncSelection: null });
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
latest.current = { ...latest.current, model, props, zoomRange, selected, hidden };
|
|
164
|
+
// Development checks of the opt-in features (production drops them, leaving no empty effect).
|
|
165
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
166
|
+
if (polarOn && !polar)
|
|
167
|
+
warnOnce('chart-polar', 'Chart coordinate="polar" or "radar" needs features={[polar]} from @salmonui/charts/chart/features.');
|
|
168
|
+
if (effectiveProps.indicators?.length && !indicatorLayout)
|
|
169
|
+
warnOnce('chart-indicators', 'Chart indicators need features={[technicalIndicators]} from @salmonui/charts/chart/indicators.');
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
// Hit-testing lives in the overlay chunk (pointer events only arrive after hydration, when it loads).
|
|
173
|
+
const hover = useRef(null);
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (hydrated && !hover.current)
|
|
176
|
+
void import('./overlay.js').then((m) => {
|
|
177
|
+
hover.current = m;
|
|
178
|
+
});
|
|
179
|
+
}, [hydrated]);
|
|
180
|
+
const hitPoint = (m, x, y, shared) => hover.current?.hitPoint(m, x, y, shared, nearestSorted) ?? null;
|
|
181
|
+
// Entrance and update transitions: CSS keyed on `data-animate`, set after hydration only, so the server
|
|
182
|
+
// markup and the first client render match and reduced motion turns them off in CSS.
|
|
183
|
+
// Path transitions start once the entrance is over, so the first measured relayout does not slide.
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
const el = rootRef.current;
|
|
186
|
+
if (!el || props.animated === false)
|
|
187
|
+
return el?.removeAttribute('data-animate');
|
|
188
|
+
el.setAttribute('data-animate', '');
|
|
189
|
+
const t = setTimeout(() => el.setAttribute('data-animate', 'update'), 700);
|
|
190
|
+
return () => clearTimeout(t);
|
|
191
|
+
}, [props.animated]);
|
|
192
|
+
// Committed visible ranges: reported after the commit, never per drag frame.
|
|
193
|
+
const visibleRanges = useRef(null);
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (!props.onVisibleRangeChange || frameZoom)
|
|
196
|
+
return;
|
|
197
|
+
const prev = visibleRanges.current;
|
|
198
|
+
const next = {};
|
|
199
|
+
for (const [axisId, range] of Object.entries(currentZoom(model))) {
|
|
200
|
+
next[axisId] = `${range[0]}:${range[1]}`;
|
|
201
|
+
if (prev && prev[axisId] !== next[axisId])
|
|
202
|
+
props.onVisibleRangeChange({ axisId, range });
|
|
203
|
+
}
|
|
204
|
+
visibleRanges.current = next;
|
|
205
|
+
});
|
|
206
|
+
// Point and cluster highlight: fades the other marks through a DOM attribute, no React render.
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
if (props.highlight !== 'point' && props.highlight !== 'cluster')
|
|
209
|
+
return;
|
|
210
|
+
return store.subscribe(() => {
|
|
211
|
+
const a = store.get().active;
|
|
212
|
+
const m = latest.current.model;
|
|
213
|
+
const id = a ? m.series[a.series]?.id : undefined;
|
|
214
|
+
for (const el of svgHost.current?.querySelectorAll('.salmon-viz-mark[data-index]') ?? []) {
|
|
215
|
+
const keep = !a || (Number(el.dataset['index']) === a.index && (props.highlight === 'cluster' || el.closest('[data-series]')?.getAttribute('data-series') === id));
|
|
216
|
+
if (keep)
|
|
217
|
+
el.removeAttribute('data-faded');
|
|
218
|
+
else
|
|
219
|
+
el.setAttribute('data-faded', '');
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}, [store, props.highlight]);
|
|
223
|
+
const toDrawing = (clientX, clientY) => {
|
|
224
|
+
const el = surfaceRef.current;
|
|
225
|
+
if (!el)
|
|
226
|
+
return null;
|
|
227
|
+
const r = el.getBoundingClientRect();
|
|
228
|
+
if (r.width === 0)
|
|
229
|
+
return null;
|
|
230
|
+
const k = latest.current.model.width / r.width;
|
|
231
|
+
return { x: (clientX - r.left) * k, y: (clientY - r.top) * k };
|
|
232
|
+
};
|
|
233
|
+
const setActive = (target, source) => {
|
|
234
|
+
const prev = store.get().active;
|
|
235
|
+
if (prev?.series === target?.series && prev?.index === target?.index && store.get().activeSource === source)
|
|
236
|
+
return;
|
|
237
|
+
store.set({ active: target, activeSource: target ? source : null });
|
|
238
|
+
const m = latest.current.model;
|
|
239
|
+
const s = target ? m.series[target.series] : undefined;
|
|
240
|
+
if (sync && s && target) {
|
|
241
|
+
const xValue = m.horizontal ? s.py[target.index] : s.px[target.index];
|
|
242
|
+
sync.store.set({ x: invertX(m, xValue), source: uid });
|
|
243
|
+
}
|
|
244
|
+
else if (sync && !target && sync.store.get().source === uid)
|
|
245
|
+
sync.store.set({ x: null, source: null });
|
|
246
|
+
props.onPointHover?.(s && target ? pointContext(s, target.index, datumOf(s, target.index), xFieldOf(s)) : null);
|
|
247
|
+
};
|
|
248
|
+
// Drag, wheel and pinch interactions live in a lazy chunk, loaded after hydration when a feature needs it.
|
|
249
|
+
const selOpt = typeof props.selection === 'object' ? props.selection : {};
|
|
250
|
+
const dragSel = selOpt.mode === 'range' || selOpt.mode === 'lasso';
|
|
251
|
+
const interactive = Boolean(zoomOpt || dragSel || props.onPointChange);
|
|
252
|
+
const fx = useRef(null);
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
const ready = (create) => {
|
|
255
|
+
fx.current ??= create();
|
|
256
|
+
plotRef.current?.setAttribute('data-interactive', '');
|
|
257
|
+
};
|
|
258
|
+
const pre = props.features?.find((f) => f.name === 'interactions');
|
|
259
|
+
if (interactive && !fx.current) {
|
|
260
|
+
if (pre?.create)
|
|
261
|
+
ready(pre.create);
|
|
262
|
+
else
|
|
263
|
+
void import('./interact.js').then((m) => ready(m.createInteractions));
|
|
264
|
+
}
|
|
265
|
+
}, [interactive]);
|
|
266
|
+
const ctx = () => {
|
|
267
|
+
const l = latest.current;
|
|
268
|
+
return {
|
|
269
|
+
store,
|
|
270
|
+
model: l.model,
|
|
271
|
+
props: l.props,
|
|
272
|
+
series: seriesList,
|
|
273
|
+
yAxisOf: (id) => spec.series.find((c) => c.id === id)?.yAxis,
|
|
274
|
+
zoomed: Object.keys(l.zoomRange).length > 0,
|
|
275
|
+
zoom: zoomOpt,
|
|
276
|
+
host: svgHost.current,
|
|
277
|
+
toDrawing,
|
|
278
|
+
hit: (x, y) => hitPoint(l.model, x, y, false),
|
|
279
|
+
commitZoom,
|
|
280
|
+
select: (points, reason) => commitSelection(points, { source: 'pointer', reason }),
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
const onPointerMove = (event) => {
|
|
284
|
+
if (fx.current?.move(ctx(), event))
|
|
285
|
+
return;
|
|
286
|
+
const p = toDrawing(event.clientX, event.clientY);
|
|
287
|
+
if (!p)
|
|
288
|
+
return;
|
|
289
|
+
// A moving touch cancels a pending long press.
|
|
290
|
+
if (press.current && Math.hypot(p.x - press.current.x, p.y - press.current.y) > 10)
|
|
291
|
+
clearTimeout(press.current.t);
|
|
292
|
+
const m = latest.current.model;
|
|
293
|
+
if (props.onPlotPointerMove)
|
|
294
|
+
props.onPlotPointerMove(hover.current?.plotPoint(m, p) ?? { ...p, xValue: undefined, yValue: undefined }, event);
|
|
295
|
+
if (event.pointerType === 'touch')
|
|
296
|
+
return;
|
|
297
|
+
store.set({ pointer: p });
|
|
298
|
+
if (tooltipOpt || props.crosshair || props.onPointHover || props.highlight === 'point' || props.highlight === 'cluster')
|
|
299
|
+
setActive(hitPoint(latest.current.model, p.x, p.y, sharedTooltip), 'pointer');
|
|
300
|
+
};
|
|
301
|
+
const onPointerLeave = () => {
|
|
302
|
+
if (store.get().selecting || store.get().dragPoint || store.get().lasso || store.get().frame)
|
|
303
|
+
return;
|
|
304
|
+
store.set({ pointer: null });
|
|
305
|
+
if (store.get().activeSource === 'pointer')
|
|
306
|
+
setActive(null, null);
|
|
307
|
+
};
|
|
308
|
+
const commitSelection = (points, event) => {
|
|
309
|
+
setSelected(points, event);
|
|
310
|
+
if (sync?.selection)
|
|
311
|
+
sync.store.set({ selection: { source: uid, indices: [...new Set(points.map((p) => p.index))] } });
|
|
312
|
+
};
|
|
313
|
+
useEffect(() => {
|
|
314
|
+
if (!sync?.selection || !props.selection)
|
|
315
|
+
return;
|
|
316
|
+
return sync.store.subscribe(() => {
|
|
317
|
+
const sel = sync.store.get().selection;
|
|
318
|
+
// Hover writes the same store: act on a new selection object only.
|
|
319
|
+
if (!sel || sel.source === uid || sel === latest.current.syncSelection)
|
|
320
|
+
return;
|
|
321
|
+
latest.current.syncSelection = sel;
|
|
322
|
+
const points = latest.current.model.series.filter((s) => !s.hidden).flatMap((s) => sel.indices.filter((i) => i < s.count).map((index) => ({ seriesId: s.id, index })));
|
|
323
|
+
setSelected(points, { source: 'api', reason: 'sync' });
|
|
324
|
+
});
|
|
325
|
+
}, [sync, props.selection]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
326
|
+
const commitZoom = (range, reason, source) => {
|
|
327
|
+
setZoomRange(range, { source, reason });
|
|
328
|
+
if (sync?.zoom)
|
|
329
|
+
sync.store.set({ zoom: range.x ? [range.x[0], range.x[1]] : null });
|
|
330
|
+
};
|
|
331
|
+
// Wheel zoom needs a non-passive listener to keep the page from scrolling.
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
const el = plotRef.current;
|
|
334
|
+
if (!el || !zoomOpt || zoomOpt.wheel === false)
|
|
335
|
+
return;
|
|
336
|
+
const onWheel = (event) => fx.current?.wheel(ctx(), event);
|
|
337
|
+
el.addEventListener('wheel', onWheel, { passive: false });
|
|
338
|
+
return () => el.removeEventListener('wheel', onWheel);
|
|
339
|
+
});
|
|
340
|
+
// Touch: a long press shows the tooltip of the nearest point; moving the finger cancels it.
|
|
341
|
+
const press = useRef(null);
|
|
342
|
+
const onPointerDown = (event) => {
|
|
343
|
+
fx.current?.down(ctx(), event);
|
|
344
|
+
const p = event.pointerType === 'touch' && toDrawing(event.clientX, event.clientY);
|
|
345
|
+
if (!p || !tooltipOpt)
|
|
346
|
+
return;
|
|
347
|
+
if (press.current)
|
|
348
|
+
clearTimeout(press.current.t);
|
|
349
|
+
press.current = {
|
|
350
|
+
...p,
|
|
351
|
+
t: setTimeout(() => {
|
|
352
|
+
store.set({ pointer: p });
|
|
353
|
+
setActive(hitPoint(latest.current.model, p.x, p.y, sharedTooltip), 'pointer');
|
|
354
|
+
}, 500),
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
const onClick = (event) => {
|
|
358
|
+
const p = toDrawing(event.clientX, event.clientY);
|
|
359
|
+
if (!p)
|
|
360
|
+
return;
|
|
361
|
+
const m = latest.current.model;
|
|
362
|
+
// Plot clicks with data coordinates.
|
|
363
|
+
if (props.onPlotClick)
|
|
364
|
+
props.onPlotClick(hover.current?.plotPoint(m, p) ?? { ...p, xValue: undefined, yValue: undefined }, event);
|
|
365
|
+
const hit = hitPoint(m, p.x, p.y, false);
|
|
366
|
+
if (!hit)
|
|
367
|
+
return;
|
|
368
|
+
const s = m.series[hit.series];
|
|
369
|
+
if (!s)
|
|
370
|
+
return;
|
|
371
|
+
props.onPointClick?.(pointContext(s, hit.index, datumOf(s, hit.index), xFieldOf(s)), event);
|
|
372
|
+
if (props.selection && !dragSel)
|
|
373
|
+
selectPoint(s.id, hit.index, event.ctrlKey || event.metaKey, 'pointer', 'click');
|
|
374
|
+
};
|
|
375
|
+
// Axis label and label-group clicks: the drawn text carries its tick index.
|
|
376
|
+
const onDrawingClick = (event) => {
|
|
377
|
+
const t = event.target;
|
|
378
|
+
const axis = latest.current.model.axes.find((a) => a.id === t.closest('[data-axis]')?.getAttribute('data-axis'));
|
|
379
|
+
const tick = t.closest('[data-tick]');
|
|
380
|
+
const group = t.closest('[data-group]')?.getAttribute('data-group');
|
|
381
|
+
if (!axis)
|
|
382
|
+
return;
|
|
383
|
+
if (tick) {
|
|
384
|
+
const k = Number(tick.getAttribute('data-tick'));
|
|
385
|
+
const at = axis.ticks[k];
|
|
386
|
+
if (at)
|
|
387
|
+
props.onAxisLabelClick?.({ axisId: axis.id, value: axis.scale.kind === 'category' || axis.scale.kind === 'timeCategory' ? axis.scale.domain[at.value] : axis.scale.kind === 'time' ? new Date(at.value) : at.value, text: at.text.join(' '), index: k }, event);
|
|
388
|
+
}
|
|
389
|
+
else if (group) {
|
|
390
|
+
const [g, l] = group.split('-').map(Number);
|
|
391
|
+
props.onAxisLabelGroupClick?.({ axisId: axis.id, group: g, level: l, label: axis.options.labelGroups?.[g]?.levels[l]?.label ?? '' }, event);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
const selectPoint = (seriesIdValue, index, additive, source, reason) => {
|
|
395
|
+
const opt = typeof props.selection === 'object' ? props.selection : {};
|
|
396
|
+
const cur = latest.current.selected;
|
|
397
|
+
const m = latest.current.model;
|
|
398
|
+
let next;
|
|
399
|
+
if (opt.mode === 'cluster') {
|
|
400
|
+
// Every visible series' point at the same index.
|
|
401
|
+
const all = m.series.filter((x) => !x.hidden && index < x.count).map((x) => ({ seriesId: x.id, index }));
|
|
402
|
+
next = cur.some((p) => p.index === index) ? cur.filter((p) => p.index !== index) : opt.multiple || additive ? [...cur, ...all] : all;
|
|
403
|
+
}
|
|
404
|
+
else if (opt.mode === 'series') {
|
|
405
|
+
const s = m.series.find((x) => x.id === seriesIdValue);
|
|
406
|
+
const all = Array.from({ length: s?.count ?? 0 }, (_, i) => ({ seriesId: seriesIdValue, index: i }));
|
|
407
|
+
next = cur.some((p) => p.seriesId === seriesIdValue) ? cur.filter((p) => p.seriesId !== seriesIdValue) : opt.multiple || additive ? [...cur, ...all] : all;
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
const exists = cur.some((p) => p.seriesId === seriesIdValue && p.index === index);
|
|
411
|
+
next = exists ? cur.filter((p) => !(p.seriesId === seriesIdValue && p.index === index)) : opt.multiple || additive ? [...cur, { seriesId: seriesIdValue, index }] : [{ seriesId: seriesIdValue, index }];
|
|
412
|
+
}
|
|
413
|
+
commitSelection(next, { source, reason });
|
|
414
|
+
};
|
|
415
|
+
const onKeyDown = (event) => {
|
|
416
|
+
const m = latest.current.model;
|
|
417
|
+
if (fx.current?.key(ctx(), event))
|
|
418
|
+
return;
|
|
419
|
+
const action = plotKeyAction(event.key, { horizontal: m.horizontal, zoom: Boolean(zoomOpt) });
|
|
420
|
+
if (!action)
|
|
421
|
+
return;
|
|
422
|
+
event.preventDefault();
|
|
423
|
+
const state = store.get();
|
|
424
|
+
if (action === 'escape') {
|
|
425
|
+
setActive(null, null);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (action === 'zoomIn' || action === 'zoomOut') {
|
|
429
|
+
fx.current?.zoomBy(ctx(), action === 'zoomIn' ? 0.8 : 1.25, 'keyboard', 'keyboard');
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (action === 'zoomReset') {
|
|
433
|
+
commitZoom({}, 'reset', 'keyboard');
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
if (action === 'select') {
|
|
437
|
+
const a = state.active;
|
|
438
|
+
const s = a ? m.series[a.series] : undefined;
|
|
439
|
+
if (a && s && props.selection)
|
|
440
|
+
selectPoint(s.id, a.index, event.ctrlKey || event.metaKey, 'keyboard', 'keyboard');
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const counts = m.series.map((s) => (s.hidden || !s.tooltip ? 0 : s.count));
|
|
444
|
+
setActive(movePointFocus(state.active, action, counts), 'keyboard');
|
|
445
|
+
};
|
|
446
|
+
const onLegendToggle = (id, event) => {
|
|
447
|
+
if (!legendToggle)
|
|
448
|
+
return;
|
|
449
|
+
setHidden(toggle(latest.current.hidden, id), { source: event.type === 'click' && event.detail === 0 ? 'keyboard' : 'pointer', reason: 'legend' });
|
|
450
|
+
};
|
|
451
|
+
// Export: one lazy chunk, `export-data.ts`: images and print, CSV through the core writer, XLSX and
|
|
452
|
+
// PDF through `exportWriters`.
|
|
453
|
+
const runExport = (method, arg) => import('../internal/viz/export-data.js').then((m) => m.runImage(rootRef.current, method, arg, latest.current.props.title ?? text.chart));
|
|
454
|
+
const api = {
|
|
455
|
+
get element() {
|
|
456
|
+
return rootRef.current;
|
|
457
|
+
},
|
|
458
|
+
export: (options = {}) => import('../internal/viz/export-data.js').then((m) => m.exportDocument(rootRef.current, latest.current.model.table, latest.current.props.exportWriters, options, latest.current.props.title ?? text.chart, 'chart')),
|
|
459
|
+
toBlob: (format) => runExport('toBlob', format),
|
|
460
|
+
toDataURL: (format) => runExport('toDataURL', format),
|
|
461
|
+
// synchronous on every family.
|
|
462
|
+
toSVGString: () => svgMarkup(svgHost.current?.querySelector('svg')),
|
|
463
|
+
print: () => runExport('print'),
|
|
464
|
+
focus() {
|
|
465
|
+
plotRef.current?.focus();
|
|
466
|
+
},
|
|
467
|
+
resetZoom() {
|
|
468
|
+
commitZoom({}, 'reset', 'api');
|
|
469
|
+
},
|
|
470
|
+
showTooltip(point) {
|
|
471
|
+
const si = latest.current.model.series.findIndex((s) => s.id === point.seriesId);
|
|
472
|
+
if (si >= 0)
|
|
473
|
+
setActive({ series: si, index: point.index }, 'api');
|
|
474
|
+
},
|
|
475
|
+
hideTooltip() {
|
|
476
|
+
setActive(null, null);
|
|
477
|
+
},
|
|
478
|
+
showCrosshair(at) {
|
|
479
|
+
// The overlay chunk resolves the position (it is loaded after hydration, before any API call can show a crosshair).
|
|
480
|
+
const m = latest.current.model;
|
|
481
|
+
const hit = hover.current?.crosshairAt(m, at);
|
|
482
|
+
if (!hit)
|
|
483
|
+
return;
|
|
484
|
+
store.set({ pointer: hit.pointer });
|
|
485
|
+
if (hit.target)
|
|
486
|
+
setActive(hit.target, 'api');
|
|
487
|
+
},
|
|
488
|
+
hideCrosshair() {
|
|
489
|
+
store.set({ pointer: null });
|
|
490
|
+
if (store.get().activeSource === 'api')
|
|
491
|
+
setActive(null, null);
|
|
492
|
+
},
|
|
493
|
+
appendPoints(id, points, options) {
|
|
494
|
+
const cur = appended.current.get(id) ?? { points: [] };
|
|
495
|
+
let next = [...cur.points, ...points];
|
|
496
|
+
if (options?.maxPoints && next.length > options.maxPoints)
|
|
497
|
+
next = next.slice(next.length - options.maxPoints);
|
|
498
|
+
appended.current.set(id, { points: next, maxPoints: options?.maxPoints });
|
|
499
|
+
store.set({ version: store.get().version + 1 });
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
useImperativeHandle(props.ref, () => api);
|
|
503
|
+
// an application name wins over `title` and the summary, on the figure and the focusable plot.
|
|
504
|
+
const labelledBy = props['aria-labelledby'] || undefined;
|
|
505
|
+
const label = labelledBy ? undefined : props['aria-label'] || undefined;
|
|
506
|
+
const plot = model.plot;
|
|
507
|
+
const canvasMarks = canvas
|
|
508
|
+
? model.series.flatMap((s) => (s.hidden ? [] : s.marks.map((m) => ({ d: m.d, fill: m.fill, stroke: m.stroke, strokeWidth: m.strokeWidth, opacity: m.opacity, dash: m.dash ? m.dash.split(' ').map(Number) : undefined }))))
|
|
509
|
+
: [];
|
|
510
|
+
return (_jsxs(NamedVizFigure, { family: "salmon-chart", className: props.className, style: props.style, rootRef: rootRef, surfaceRef: surfaceRef, surfaceStyle: { ...(props.height ? { height, flex: 'none' } : {}), ...(props.width ? { width: props.width } : {}) }, idBase: uid, title: props.title, subtitle: props.subtitle, summary: model.summary, table: model.table, showTable: props.showDataTable, tableSummary: text.moreRows, announcement: _jsx(ChartAnnouncer, { store: store, model: model }), naming: labelledBy || label ? { 'aria-labelledby': labelledBy, 'aria-label': label } : undefined, extra: { onClick: props.onClick, onDoubleClick: props.onDoubleClick, onContextMenu: props.onContextMenu, onPointerDown: props.onPointerDown, onPointerUp: props.onPointerUp, onPointerMove: props.onPointerMove, onPointerLeave: props.onPointerLeave }, children: [_jsx("div", { ref: svgHost, className: "salmon-chart-drawing", onClick: props.onAxisLabelClick || props.onAxisLabelGroupClick ? onDrawingClick : undefined, children: _jsx(ChartSvg, { model: model, clipId: `${uid}-clip`, canvas: canvas, legendItems: legendItems, legendPage: legendPage, selected: selectedKeys, dimmed: dimmed, highlighted: highlightId, emptyText: polarOn && !polar ? '' : text.noData, renderEmpty: props.renderEmpty, pointContent: pointContent, legendCustom: customLegend }) }), canvas ? (_jsx("div", { className: "salmon-viz-canvas", style: { left: pct(plot.x - 1, model.width), top: pct(plot.y - 1, model.height), width: pct(plot.width + 2, model.width), height: pct(plot.height + 2, model.height) }, children: _jsx(VizCanvas, { marks: canvasMarks, originX: plot.x - 1, originY: plot.y - 1, width: Math.ceil(plot.width + 2), height: Math.ceil(plot.height + 2), className: "salmon-chart-canvas" }) })) : null, model.empty && props.renderEmpty ? (_jsx("div", { className: "salmon-chart-empty", style: { left: pct(plot.x, model.width), top: pct(plot.y, model.height), width: pct(plot.width, model.width), height: pct(plot.height, model.height) }, children: props.renderEmpty() })) : null, hydrated ? (_jsx(Suspense, { fallback: null, children: _jsx(ChartOverlay, { store: store, syncStore: syncStore, model: model, tooltip: tooltipOpt, crosshair: props.crosshair, shared: sharedTooltip, sync: sync, uid: uid, datumOf: datumOf, xFieldOf: xFieldOf, tools: OVERLAY_TOOLS }) })) : null, _jsx("div", { ref: plotRef, className: "salmon-viz-plot", role: "group", "aria-roledescription": text.chart.toLowerCase(), "aria-labelledby": labelledBy, "aria-label": labelledBy ? undefined : (label ?? props.title ?? model.summary.split('.')[0]), "aria-describedby": `${uid}-summary`, tabIndex: 0, style: { left: pct(plot.x, model.width), top: pct(plot.y, model.height), width: pct(plot.width, model.width), height: pct(plot.height, model.height), touchAction: interactive ? 'none' : 'pan-y', cursor: zoomOpt || dragSel ? 'crosshair' : undefined }, onPointerMove: onPointerMove, onPointerLeave: onPointerLeave, onPointerDown: onPointerDown, onPointerUp: (event) => {
|
|
511
|
+
if (press.current)
|
|
512
|
+
clearTimeout(press.current.t);
|
|
513
|
+
fx.current?.up(ctx(), event);
|
|
514
|
+
}, onPointerCancel: (event) => fx.current?.up(ctx(), event), onClick: onClick, onDoubleClick: props.onPointDoubleClick
|
|
515
|
+
? (event) => {
|
|
516
|
+
const p = toDrawing(event.clientX, event.clientY);
|
|
517
|
+
const m = latest.current.model;
|
|
518
|
+
const hit = p && hitPoint(m, p.x, p.y, false);
|
|
519
|
+
const s = hit ? m.series[hit.series] : undefined;
|
|
520
|
+
if (hit && s)
|
|
521
|
+
props.onPointDoubleClick?.(pointContext(s, hit.index, datumOf(s, hit.index), xFieldOf(s)), event);
|
|
522
|
+
}
|
|
523
|
+
: undefined, onKeyDown: onKeyDown, onBlur: () => {
|
|
524
|
+
if (store.get().activeSource === 'keyboard')
|
|
525
|
+
setActive(null, null);
|
|
526
|
+
} }), (props.annotations ?? []).map((a, i) => (_jsx(ChartAnnotationView, { model: model, annotation: a }, i))), hydrated && zoomOpt?.toolbar ? (_jsx(Suspense, { fallback: null, children: _jsx(ZoomToolbar, { tools: zoomOpt.toolbar === true ? ALL_TOOLS : zoomOpt.toolbar, tool: tool, zoomed: Object.keys(zoomRange).length > 0, position: zoomOpt.toolbarPosition ?? 'topEnd', text: text, onTool: (t) => store.set({ tool: t }), onZoom: (f) => fx.current?.zoomBy(ctx(), f, 'toolbar', 'pointer'), onReset: () => commitZoom({}, 'reset', 'pointer') }) })) : null, model.frame.legend && customLegend.size
|
|
527
|
+
? model.frame.legend.items.map((b) => customLegend.has(b.index) && b.page === legendPage ? (_jsx("span", { className: "salmon-chart-legend-content", "aria-hidden": "true", style: { left: pct(b.x, model.width), top: pct(b.y, model.height), width: pct(b.width, model.width), height: pct(b.height, model.height) }, children: legendContent[b.index] }, b.index)) : null)
|
|
528
|
+
: null, model.frame.legend ? (_jsx(LegendButtons
|
|
529
|
+
// A one-column top or bottom legend (`orientation: 'vertical'`) takes the vertical keyboard model of a side legend.
|
|
530
|
+
, {
|
|
531
|
+
// A one-column top or bottom legend (`orientation: 'vertical'`) takes the vertical keyboard model of a side legend.
|
|
532
|
+
layout: legendOpt.orientation === 'vertical' ? { ...model.frame.legend, position: 'start' } : model.frame.legend, items: legendItems, width: model.width, height: model.height, page: legendPage, label: legendOpt.title ?? text.legend, toggle: legendToggle, onToggle: onLegendToggle, onHighlight: (id) => store.set({ highlight: id }), children: _jsx(LegendPager, { layout: model.frame.legend, width: model.width, height: model.height, page: legendPage, text: text, onPage: (page) => store.set({ legendPage: page }) }) })) : null] }));
|
|
533
|
+
}
|
|
534
|
+
function invertX(model, pixel) {
|
|
535
|
+
const a = model.axes.find((x) => x.id === model.xAxisId);
|
|
536
|
+
if (!a)
|
|
537
|
+
return pixel;
|
|
538
|
+
return a.scale.invert(pixel);
|
|
539
|
+
}
|
|
540
|
+
/** Live region text for the keyboard-focused point. */
|
|
541
|
+
function ChartAnnouncer({ store, model }) {
|
|
542
|
+
const active = useVizSelector(store, (s) => (s.activeSource === 'keyboard' ? s.active : null));
|
|
543
|
+
if (!active)
|
|
544
|
+
return null;
|
|
545
|
+
const s = model.series[active.series];
|
|
546
|
+
if (!s)
|
|
547
|
+
return null;
|
|
548
|
+
return `${s.name}, ${s.xText(active.index)}: ${s.yText(active.index)}. ${active.index + 1} of ${s.count}.`;
|
|
549
|
+
}
|
|
550
|
+
function ChartAnnotationView({ model, annotation }) {
|
|
551
|
+
let x;
|
|
552
|
+
let y;
|
|
553
|
+
if (annotation.units === 'pixel') {
|
|
554
|
+
x = Number(annotation.x);
|
|
555
|
+
y = annotation.y;
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
const xa = model.axes.find((a) => a.id === (annotation.xAxis ?? 'x'));
|
|
559
|
+
const ya = model.axes.find((a) => a.id === (annotation.yAxis ?? 'y'));
|
|
560
|
+
if (!xa || !ya)
|
|
561
|
+
return null;
|
|
562
|
+
const xv = xa.scale.kind === 'category' || xa.scale.kind === 'timeCategory' ? Math.max(0, xa.scale.domain.indexOf(String(annotation.x))) : annotation.x instanceof Date ? annotation.x.getTime() : Number(annotation.x);
|
|
563
|
+
const px = xa.scale.map(xv);
|
|
564
|
+
const py = ya.scale.map(annotation.y);
|
|
565
|
+
[x, y] = model.horizontal ? [py, px] : [px, py];
|
|
566
|
+
}
|
|
567
|
+
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
568
|
+
return null;
|
|
569
|
+
return (_jsx("div", { className: "salmon-chart-annotation", style: { left: pct(x, model.width), top: pct(y, model.height) }, children: annotation.content }));
|
|
570
|
+
}
|
|
571
|
+
//# sourceMappingURL=Chart.js.map
|