minerva-design 1.1.0 → 1.3.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/CHANGELOG.md +15 -0
- package/dist/charts/canvas.d.cts +10 -0
- package/dist/charts/canvas.d.ts +10 -0
- package/dist/charts/core.cjs +1 -1
- package/dist/charts/core.d.cts +8 -1
- package/dist/charts/core.d.ts +8 -1
- package/dist/charts/core.js +6 -1
- package/dist/charts/engine/canvas.cjs +2 -0
- package/dist/charts/engine/canvas.cjs.map +1 -0
- package/dist/charts/engine/canvas.d.cts +85 -0
- package/dist/charts/engine/canvas.d.ts +85 -0
- package/dist/charts/engine/canvas.js +177 -0
- package/dist/charts/engine/canvas.js.map +1 -0
- package/dist/charts/engine/chart.cjs +1 -2
- package/dist/charts/engine/chart.cjs.map +1 -1
- package/dist/charts/engine/chart.js +450 -489
- package/dist/charts/engine/chart.js.map +1 -1
- package/dist/charts/engine/color.cjs +1 -1
- package/dist/charts/engine/color.cjs.map +1 -1
- package/dist/charts/engine/color.d.cts +27 -0
- package/dist/charts/engine/color.d.ts +27 -0
- package/dist/charts/engine/color.js +100 -4
- package/dist/charts/engine/color.js.map +1 -1
- package/dist/charts/engine/controller.cjs +3 -0
- package/dist/charts/engine/controller.cjs.map +1 -0
- package/dist/charts/engine/controller.d.cts +188 -0
- package/dist/charts/engine/controller.d.ts +188 -0
- package/dist/charts/engine/controller.js +592 -0
- package/dist/charts/engine/controller.js.map +1 -0
- package/dist/charts/engine/curve.cjs +2 -0
- package/dist/charts/engine/curve.cjs.map +1 -0
- package/dist/charts/engine/curve.d.cts +15 -0
- package/dist/charts/engine/curve.d.ts +15 -0
- package/dist/charts/engine/curve.js +56 -0
- package/dist/charts/engine/curve.js.map +1 -0
- package/dist/charts/engine/data.cjs +1 -1
- package/dist/charts/engine/data.cjs.map +1 -1
- package/dist/charts/engine/data.d.cts +15 -2
- package/dist/charts/engine/data.d.ts +15 -2
- package/dist/charts/engine/data.js +98 -38
- package/dist/charts/engine/data.js.map +1 -1
- package/dist/charts/engine/dom.cjs +1 -1
- package/dist/charts/engine/dom.cjs.map +1 -1
- package/dist/charts/engine/dom.d.cts +5 -3
- package/dist/charts/engine/dom.d.ts +5 -3
- package/dist/charts/engine/dom.js +27 -22
- package/dist/charts/engine/dom.js.map +1 -1
- package/dist/charts/engine/items.cjs +1 -1
- package/dist/charts/engine/items.cjs.map +1 -1
- package/dist/charts/engine/items.js +132 -61
- package/dist/charts/engine/items.js.map +1 -1
- package/dist/charts/engine/model.cjs +1 -1
- package/dist/charts/engine/model.cjs.map +1 -1
- package/dist/charts/engine/model.d.cts +32 -5
- package/dist/charts/engine/model.d.ts +32 -5
- package/dist/charts/engine/model.js +226 -109
- package/dist/charts/engine/model.js.map +1 -1
- package/dist/charts/engine/overlay.cjs +1 -1
- package/dist/charts/engine/overlay.cjs.map +1 -1
- package/dist/charts/engine/overlay.d.cts +19 -1
- package/dist/charts/engine/overlay.d.ts +19 -1
- package/dist/charts/engine/overlay.js +77 -63
- package/dist/charts/engine/overlay.js.map +1 -1
- package/dist/charts/engine/presets.cjs +3 -0
- package/dist/charts/engine/presets.cjs.map +1 -0
- package/dist/charts/engine/presets.d.cts +169 -0
- package/dist/charts/engine/presets.d.ts +169 -0
- package/dist/charts/engine/presets.js +240 -0
- package/dist/charts/engine/presets.js.map +1 -0
- package/dist/charts/engine/renderers/canvas2d.cjs +1 -1
- package/dist/charts/engine/renderers/canvas2d.cjs.map +1 -1
- package/dist/charts/engine/renderers/canvas2d.d.cts +17 -1
- package/dist/charts/engine/renderers/canvas2d.d.ts +17 -1
- package/dist/charts/engine/renderers/canvas2d.js +176 -101
- package/dist/charts/engine/renderers/canvas2d.js.map +1 -1
- package/dist/charts/engine/renderers/range.cjs +1 -1
- package/dist/charts/engine/renderers/range.cjs.map +1 -1
- package/dist/charts/engine/renderers/range.js +4 -4
- package/dist/charts/engine/renderers/range.js.map +1 -1
- package/dist/charts/engine/renderers/shaders.cjs +37 -19
- package/dist/charts/engine/renderers/shaders.cjs.map +1 -1
- package/dist/charts/engine/renderers/shaders.d.cts +2 -2
- package/dist/charts/engine/renderers/shaders.d.ts +2 -2
- package/dist/charts/engine/renderers/shaders.js +37 -19
- package/dist/charts/engine/renderers/shaders.js.map +1 -1
- package/dist/charts/engine/renderers/types.cjs.map +1 -1
- package/dist/charts/engine/renderers/types.d.cts +11 -4
- package/dist/charts/engine/renderers/types.d.ts +11 -4
- package/dist/charts/engine/renderers/types.js.map +1 -1
- package/dist/charts/engine/renderers/webgl2.cjs +1 -1
- package/dist/charts/engine/renderers/webgl2.cjs.map +1 -1
- package/dist/charts/engine/renderers/webgl2.js +33 -12
- package/dist/charts/engine/renderers/webgl2.js.map +1 -1
- package/dist/charts/engine/renderers/webgpu.cjs +1 -1
- package/dist/charts/engine/renderers/webgpu.cjs.map +1 -1
- package/dist/charts/engine/renderers/webgpu.js +18 -15
- package/dist/charts/engine/renderers/webgpu.js.map +1 -1
- package/dist/charts/engine/scene.cjs +2 -0
- package/dist/charts/engine/scene.cjs.map +1 -0
- package/dist/charts/engine/scene.d.cts +102 -0
- package/dist/charts/engine/scene.d.ts +102 -0
- package/dist/charts/engine/scene.js +353 -0
- package/dist/charts/engine/scene.js.map +1 -0
- package/dist/charts/engine/shapes/canvas.cjs +2 -0
- package/dist/charts/engine/shapes/canvas.cjs.map +1 -0
- package/dist/charts/engine/shapes/canvas.d.cts +58 -0
- package/dist/charts/engine/shapes/canvas.d.ts +58 -0
- package/dist/charts/engine/shapes/canvas.js +159 -0
- package/dist/charts/engine/shapes/canvas.js.map +1 -0
- package/dist/charts/engine/shapes/chart.cjs +2 -0
- package/dist/charts/engine/shapes/chart.cjs.map +1 -0
- package/dist/charts/engine/shapes/chart.d.cts +6 -0
- package/dist/charts/engine/shapes/chart.d.ts +6 -0
- package/dist/charts/engine/shapes/chart.js +273 -0
- package/dist/charts/engine/shapes/chart.js.map +1 -0
- package/dist/charts/engine/shapes/draw.cjs +2 -0
- package/dist/charts/engine/shapes/draw.cjs.map +1 -0
- package/dist/charts/engine/shapes/draw.d.cts +20 -0
- package/dist/charts/engine/shapes/draw.d.ts +20 -0
- package/dist/charts/engine/shapes/draw.js +152 -0
- package/dist/charts/engine/shapes/draw.js.map +1 -0
- package/dist/charts/engine/shapes/funnel.cjs +2 -0
- package/dist/charts/engine/shapes/funnel.cjs.map +1 -0
- package/dist/charts/engine/shapes/funnel.d.cts +6 -0
- package/dist/charts/engine/shapes/funnel.d.ts +6 -0
- package/dist/charts/engine/shapes/funnel.js +149 -0
- package/dist/charts/engine/shapes/funnel.js.map +1 -0
- package/dist/charts/engine/shapes/gauge.cjs +2 -0
- package/dist/charts/engine/shapes/gauge.cjs.map +1 -0
- package/dist/charts/engine/shapes/gauge.d.cts +7 -0
- package/dist/charts/engine/shapes/gauge.d.ts +7 -0
- package/dist/charts/engine/shapes/gauge.js +173 -0
- package/dist/charts/engine/shapes/gauge.js.map +1 -0
- package/dist/charts/engine/shapes/hit.cjs +2 -0
- package/dist/charts/engine/shapes/hit.cjs.map +1 -0
- package/dist/charts/engine/shapes/hit.d.cts +28 -0
- package/dist/charts/engine/shapes/hit.d.ts +28 -0
- package/dist/charts/engine/shapes/hit.js +124 -0
- package/dist/charts/engine/shapes/hit.js.map +1 -0
- package/dist/charts/engine/shapes/index.d.cts +9 -0
- package/dist/charts/engine/shapes/index.d.ts +9 -0
- package/dist/charts/engine/shapes/layout.cjs +3 -0
- package/dist/charts/engine/shapes/layout.cjs.map +1 -0
- package/dist/charts/engine/shapes/layout.d.cts +88 -0
- package/dist/charts/engine/shapes/layout.d.ts +88 -0
- package/dist/charts/engine/shapes/layout.js +266 -0
- package/dist/charts/engine/shapes/layout.js.map +1 -0
- package/dist/charts/engine/shapes/pie.cjs +2 -0
- package/dist/charts/engine/shapes/pie.cjs.map +1 -0
- package/dist/charts/engine/shapes/pie.d.cts +20 -0
- package/dist/charts/engine/shapes/pie.d.ts +20 -0
- package/dist/charts/engine/shapes/pie.js +302 -0
- package/dist/charts/engine/shapes/pie.js.map +1 -0
- package/dist/charts/engine/shapes/radar.cjs +2 -0
- package/dist/charts/engine/shapes/radar.cjs.map +1 -0
- package/dist/charts/engine/shapes/radar.d.cts +8 -0
- package/dist/charts/engine/shapes/radar.d.ts +8 -0
- package/dist/charts/engine/shapes/radar.js +197 -0
- package/dist/charts/engine/shapes/radar.js.map +1 -0
- package/dist/charts/engine/shapes/runtime.cjs +2 -0
- package/dist/charts/engine/shapes/runtime.cjs.map +1 -0
- package/dist/charts/engine/shapes/runtime.d.cts +29 -0
- package/dist/charts/engine/shapes/runtime.d.ts +29 -0
- package/dist/charts/engine/shapes/runtime.js +97 -0
- package/dist/charts/engine/shapes/runtime.js.map +1 -0
- package/dist/charts/engine/shapes/scene.cjs +2 -0
- package/dist/charts/engine/shapes/scene.cjs.map +1 -0
- package/dist/charts/engine/shapes/scene.d.cts +257 -0
- package/dist/charts/engine/shapes/scene.d.ts +257 -0
- package/dist/charts/engine/shapes/scene.js +123 -0
- package/dist/charts/engine/shapes/scene.js.map +1 -0
- package/dist/charts/engine/shapes/treemap.cjs +2 -0
- package/dist/charts/engine/shapes/treemap.cjs.map +1 -0
- package/dist/charts/engine/shapes/treemap.d.cts +14 -0
- package/dist/charts/engine/shapes/treemap.d.ts +14 -0
- package/dist/charts/engine/shapes/treemap.js +213 -0
- package/dist/charts/engine/shapes/treemap.js.map +1 -0
- package/dist/charts/engine/shapes/types.d.cts +292 -0
- package/dist/charts/engine/shapes/types.d.ts +292 -0
- package/dist/charts/engine/signature.cjs +2 -0
- package/dist/charts/engine/signature.cjs.map +1 -0
- package/dist/charts/engine/signature.d.cts +9 -0
- package/dist/charts/engine/signature.d.ts +9 -0
- package/dist/charts/engine/signature.js +13 -0
- package/dist/charts/engine/signature.js.map +1 -0
- package/dist/charts/engine/theme.cjs +1 -1
- package/dist/charts/engine/theme.cjs.map +1 -1
- package/dist/charts/engine/theme.d.cts +35 -2
- package/dist/charts/engine/theme.d.ts +35 -2
- package/dist/charts/engine/theme.js +66 -26
- package/dist/charts/engine/theme.js.map +1 -1
- package/dist/charts/engine/types.d.cts +139 -11
- package/dist/charts/engine/types.d.ts +139 -11
- package/dist/charts/index.cjs +1 -1
- package/dist/charts/index.d.cts +4 -2
- package/dist/charts/index.d.ts +4 -2
- package/dist/charts/index.js +8 -2
- package/dist/charts/react/Chart.cjs +1 -1
- package/dist/charts/react/Chart.cjs.map +1 -1
- package/dist/charts/react/Chart.d.cts +18 -4
- package/dist/charts/react/Chart.d.ts +18 -4
- package/dist/charts/react/Chart.js +102 -41
- package/dist/charts/react/Chart.js.map +1 -1
- package/dist/charts/react/charts.cjs +1 -1
- package/dist/charts/react/charts.cjs.map +1 -1
- package/dist/charts/react/charts.d.cts +11 -3
- package/dist/charts/react/charts.d.ts +11 -3
- package/dist/charts/react/charts.js +221 -144
- package/dist/charts/react/charts.js.map +1 -1
- package/dist/charts/react/shapes.cjs +2 -0
- package/dist/charts/react/shapes.cjs.map +1 -0
- package/dist/charts/react/shapes.d.cts +255 -0
- package/dist/charts/react/shapes.d.ts +255 -0
- package/dist/charts/react/shapes.js +242 -0
- package/dist/charts/react/shapes.js.map +1 -0
- package/dist/charts/react/types.d.cts +100 -63
- package/dist/charts/react/types.d.ts +100 -63
- package/dist/native/charts/src/canvas.cjs +1 -0
- package/dist/native/charts/src/canvas.js +6 -0
- package/dist/native/charts/src/engine/axis.cjs +2 -0
- package/dist/native/charts/src/engine/axis.cjs.map +1 -0
- package/dist/native/charts/src/engine/axis.js +38 -0
- package/dist/native/charts/src/engine/axis.js.map +1 -0
- package/dist/native/charts/src/engine/canvas.cjs +1 -0
- package/dist/native/charts/src/engine/canvas.js +1 -0
- package/dist/native/charts/src/engine/color.cjs +2 -0
- package/dist/native/charts/src/engine/color.cjs.map +1 -0
- package/dist/native/charts/src/engine/color.js +139 -0
- package/dist/native/charts/src/engine/color.js.map +1 -0
- package/dist/native/charts/src/engine/controller.cjs +3 -0
- package/dist/native/charts/src/engine/controller.cjs.map +1 -0
- package/dist/native/charts/src/engine/controller.js +592 -0
- package/dist/native/charts/src/engine/controller.js.map +1 -0
- package/dist/native/charts/src/engine/curve.cjs +2 -0
- package/dist/native/charts/src/engine/curve.cjs.map +1 -0
- package/dist/native/charts/src/engine/curve.js +56 -0
- package/dist/native/charts/src/engine/curve.js.map +1 -0
- package/dist/native/charts/src/engine/data.cjs +2 -0
- package/dist/native/charts/src/engine/data.cjs.map +1 -0
- package/dist/native/charts/src/engine/data.js +164 -0
- package/dist/native/charts/src/engine/data.js.map +1 -0
- package/dist/native/charts/src/engine/decimate.cjs +2 -0
- package/dist/native/charts/src/engine/decimate.cjs.map +1 -0
- package/dist/native/charts/src/engine/decimate.js +28 -0
- package/dist/native/charts/src/engine/decimate.js.map +1 -0
- package/dist/native/charts/src/engine/format.cjs +2 -0
- package/dist/native/charts/src/engine/format.cjs.map +1 -0
- package/dist/native/charts/src/engine/format.js +34 -0
- package/dist/native/charts/src/engine/format.js.map +1 -0
- package/dist/native/charts/src/engine/layout.cjs +2 -0
- package/dist/native/charts/src/engine/layout.cjs.map +1 -0
- package/dist/native/charts/src/engine/layout.js +26 -0
- package/dist/native/charts/src/engine/layout.js.map +1 -0
- package/dist/native/charts/src/engine/model.cjs +2 -0
- package/dist/native/charts/src/engine/model.cjs.map +1 -0
- package/dist/native/charts/src/engine/model.js +292 -0
- package/dist/native/charts/src/engine/model.js.map +1 -0
- package/dist/native/charts/src/engine/overlay.cjs +2 -0
- package/dist/native/charts/src/engine/overlay.cjs.map +1 -0
- package/dist/native/charts/src/engine/overlay.js +49 -0
- package/dist/native/charts/src/engine/overlay.js.map +1 -0
- package/dist/native/charts/src/engine/presets.cjs +3 -0
- package/dist/native/charts/src/engine/presets.cjs.map +1 -0
- package/dist/native/charts/src/engine/presets.js +154 -0
- package/dist/native/charts/src/engine/presets.js.map +1 -0
- package/dist/native/charts/src/engine/scale.cjs +2 -0
- package/dist/native/charts/src/engine/scale.cjs.map +1 -0
- package/dist/native/charts/src/engine/scale.js +37 -0
- package/dist/native/charts/src/engine/scale.js.map +1 -0
- package/dist/native/charts/src/engine/scene.cjs +2 -0
- package/dist/native/charts/src/engine/scene.cjs.map +1 -0
- package/dist/native/charts/src/engine/scene.js +353 -0
- package/dist/native/charts/src/engine/scene.js.map +1 -0
- package/dist/native/charts/src/engine/spatial.cjs +2 -0
- package/dist/native/charts/src/engine/spatial.cjs.map +1 -0
- package/dist/native/charts/src/engine/spatial.js +53 -0
- package/dist/native/charts/src/engine/spatial.js.map +1 -0
- package/dist/native/charts/src/engine/theme.cjs +2 -0
- package/dist/native/charts/src/engine/theme.cjs.map +1 -0
- package/dist/native/charts/src/engine/theme.js +62 -0
- package/dist/native/charts/src/engine/theme.js.map +1 -0
- package/dist/native/charts/src/engine/time.cjs +2 -0
- package/dist/native/charts/src/engine/time.cjs.map +1 -0
- package/dist/native/charts/src/engine/time.js +189 -0
- package/dist/native/charts/src/engine/time.js.map +1 -0
- package/dist/native/charts/src/engine/viewport.cjs +2 -0
- package/dist/native/charts/src/engine/viewport.cjs.map +1 -0
- package/dist/native/charts/src/engine/viewport.js +12 -0
- package/dist/native/charts/src/engine/viewport.js.map +1 -0
- package/dist/native/components/Chart/ChartBase.cjs +2 -0
- package/dist/native/components/Chart/ChartBase.cjs.map +1 -0
- package/dist/native/components/Chart/ChartBase.d.cts +29 -0
- package/dist/native/components/Chart/ChartBase.d.ts +29 -0
- package/dist/native/components/Chart/ChartBase.js +287 -0
- package/dist/native/components/Chart/ChartBase.js.map +1 -0
- package/dist/native/components/Chart/charts.cjs +2 -0
- package/dist/native/components/Chart/charts.cjs.map +1 -0
- package/dist/native/components/Chart/charts.d.cts +19 -0
- package/dist/native/components/Chart/charts.d.ts +19 -0
- package/dist/native/components/Chart/charts.js +173 -0
- package/dist/native/components/Chart/charts.js.map +1 -0
- package/dist/native/components/Chart/index.cjs +1 -0
- package/dist/native/components/Chart/index.d.cts +2 -0
- package/dist/native/components/Chart/index.d.ts +2 -0
- package/dist/native/components/Chart/index.js +2 -0
- package/dist/native/components/Chart/measure.cjs +2 -0
- package/dist/native/components/Chart/measure.cjs.map +1 -0
- package/dist/native/components/Chart/measure.d.cts +5 -0
- package/dist/native/components/Chart/measure.d.ts +5 -0
- package/dist/native/components/Chart/measure.js +11 -0
- package/dist/native/components/Chart/measure.js.map +1 -0
- package/dist/native/components/Chart/scene.cjs +2 -0
- package/dist/native/components/Chart/scene.cjs.map +1 -0
- package/dist/native/components/Chart/scene.d.cts +41 -0
- package/dist/native/components/Chart/scene.d.ts +41 -0
- package/dist/native/components/Chart/scene.js +431 -0
- package/dist/native/components/Chart/scene.js.map +1 -0
- package/dist/native/components/Chart/theme.cjs +2 -0
- package/dist/native/components/Chart/theme.cjs.map +1 -0
- package/dist/native/components/Chart/theme.d.cts +10 -0
- package/dist/native/components/Chart/theme.d.ts +10 -0
- package/dist/native/components/Chart/theme.js +10 -0
- package/dist/native/components/Chart/theme.js.map +1 -0
- package/dist/native/components/Chart/types.d.cts +129 -0
- package/dist/native/components/Chart/types.d.ts +129 -0
- package/dist/native/index.cjs +1 -1
- package/dist/native/index.d.cts +1 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.js +6 -4
- package/dist/native/manifest.d.cts +7 -0
- package/dist/native/manifest.d.ts +7 -0
- package/dist/native/source/components/Chart/ChartBase.tsx +545 -0
- package/dist/native/source/components/Chart/charts.tsx +291 -0
- package/dist/native/source/components/Chart/index.ts +8 -0
- package/dist/native/source/components/Chart/measure.ts +50 -0
- package/dist/native/source/components/Chart/scene.tsx +1021 -0
- package/dist/native/source/components/Chart/theme.ts +16 -0
- package/dist/native/source/components/Chart/types.ts +194 -0
- package/dist/native/source/index.ts +1 -0
- package/dist/native/source/manifest.ts +14 -0
- package/dist/taro/charts.d.ts +144 -0
- package/dist/taro/index.d.ts +1 -0
- package/dist/taro/index.js +3544 -618
- package/dist/uni/BarChart.vue +75 -0
- package/dist/uni/BarChart.vue.d.ts +111 -0
- package/dist/uni/Chart.vue +68 -0
- package/dist/uni/Chart.vue.d.ts +100 -0
- package/dist/uni/LineChart.vue +75 -0
- package/dist/uni/LineChart.vue.d.ts +111 -0
- package/dist/uni/ProgressIndicator.vue.d.ts +1 -1
- package/dist/uni/QuadrantChart.vue +184 -0
- package/dist/uni/QuadrantChart.vue.d.ts +173 -0
- package/dist/uni/ScatterChart.vue +69 -0
- package/dist/uni/ScatterChart.vue.d.ts +100 -0
- package/dist/uni/chart-canvas.d.ts +68 -0
- package/dist/uni/chart-canvas.js +363 -0
- package/dist/uni/chart-types.d.ts +135 -0
- package/dist/uni/chart-types.js +84 -0
- package/dist/uni/charts-canvas.d.ts +1 -0
- package/dist/uni/charts-canvas.js +10 -0
- package/dist/uni/index.d.ts +6 -0
- package/dist/uni/index.js +6 -0
- package/dist/weapp/bar-chart/index.js +1 -0
- package/dist/weapp/bar-chart/index.json +1 -0
- package/dist/weapp/bar-chart/index.wxml +1 -0
- package/dist/weapp/bar-chart/index.wxss +1 -0
- package/dist/weapp/chart/index.js +1 -0
- package/dist/weapp/chart/index.json +1 -0
- package/dist/weapp/chart/index.wxml +1 -0
- package/dist/weapp/chart/index.wxss +1 -0
- package/dist/weapp/controls.js +4760 -266
- package/dist/weapp/line-chart/index.js +1 -0
- package/dist/weapp/line-chart/index.json +1 -0
- package/dist/weapp/line-chart/index.wxml +1 -0
- package/dist/weapp/line-chart/index.wxss +1 -0
- package/dist/weapp/quadrant-chart/index.js +1 -0
- package/dist/weapp/quadrant-chart/index.json +1 -0
- package/dist/weapp/quadrant-chart/index.wxml +1 -0
- package/dist/weapp/quadrant-chart/index.wxss +1 -0
- package/dist/weapp/scatter-chart/index.js +1 -0
- package/dist/weapp/scatter-chart/index.json +1 -0
- package/dist/weapp/scatter-chart/index.wxml +1 -0
- package/dist/weapp/scatter-chart/index.wxss +1 -0
- package/dist/weapp/types.d.ts +295 -0
- package/package.json +21 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":["DEFAULT_PALETTE","readVar","style","name","readTheme","element","color","names","resolveColor","fallback","background","text","textMuted","border","colors","palette","c","custom","i","fontFamily","mix","watchTheme","cleanups","observer","onChange","node","query","fn"],"sources":["../../../../charts/src/engine/theme.ts"],"sourcesContent":["// Chart colors and fonts read from the Minerva CSS variables.\n\nimport { mix, resolveColor, type Rgba } from \"./color\";\n\nexport interface ChartTheme {\n palette: Rgba[];\n text: Rgba;\n textMuted: Rgba;\n grid: Rgba;\n axis: Rgba;\n background: Rgba;\n surface: Rgba;\n primary: Rgba;\n fontFamily: string;\n /** Tick label font size in CSS pixels */\n fontSize: number;\n}\n\n/** Used when no CSS variable is defined (e.g. without the Minerva stylesheet) */\nconst DEFAULT_PALETTE = [\n \"#4f46e5\",\n \"#10b981\",\n \"#f59e0b\",\n \"#ef4444\",\n \"#0ea5e9\",\n \"#8b5cf6\",\n \"#14b8a6\",\n \"#f97316\",\n];\n\nconst readVar = (style: CSSStyleDeclaration | null, name: string) =>\n style?.getPropertyValue(name).trim() ?? \"\";\n\n/** Reads the theme from the computed style of `element` */\nexport const readTheme = (\n element: Element | null,\n palette?: readonly string[],\n): ChartTheme => {\n const style =\n element && typeof getComputedStyle === \"function\"\n ? getComputedStyle(element)\n : null;\n const color = (names: string[], fallback: string): Rgba => {\n for (const name of names) {\n if (readVar(style, name)) return resolveColor(`var(${name})`, element);\n }\n return resolveColor(fallback, element);\n };\n\n const background = color(\n [\"--surface-color\", \"--background-color\"],\n \"#ffffff\",\n );\n const text = color([\"--text-color\"], \"#1f2937\");\n const textMuted = color(\n [\"--text-secondary-color\", \"--text-muted-color\"],\n \"#6b7280\",\n );\n const border = color([\"--border-color\"], \"#e5e7eb\");\n\n let colors: Rgba[];\n if (palette && palette.length) {\n colors = palette.map((c) => resolveColor(c, element));\n } else {\n const custom: Rgba[] = [];\n for (let i = 1; i <= 8; i++) {\n const name = `--chart-series-${i}`;\n if (readVar(style, name))\n custom.push(resolveColor(`var(${name})`, element));\n }\n if (custom.length) {\n colors = custom;\n } else {\n const themed = [\n \"--primary-color\",\n \"--success-color\",\n \"--warning-color\",\n \"--danger-color\",\n \"--info-color\",\n ].map((name, i) =>\n readVar(style, name)\n ? resolveColor(`var(${name})`, element)\n : resolveColor(DEFAULT_PALETTE[i], element),\n );\n colors = [\n ...themed,\n ...DEFAULT_PALETTE.slice(5).map((c) => resolveColor(c, element)),\n ];\n }\n }\n\n const fontFamily =\n readVar(style, \"--font-family-sans\") ||\n (style?.fontFamily ?? \"\") ||\n \"system-ui, -apple-system, 'Segoe UI', sans-serif\";\n\n return {\n palette: colors,\n text,\n textMuted,\n grid: mix(background, border, 0.75),\n axis: border,\n background,\n surface: background,\n primary: colors[0],\n fontFamily,\n fontSize: 11,\n };\n};\n\n/**\n * Calls `onChange` when the theme may have changed: attributes of `<html>` /\n * `<body>` (class, style, data-theme) and the color scheme.\n */\nexport const watchTheme = (onChange: () => void): (() => void) => {\n if (typeof document === \"undefined\") return () => {};\n const cleanups: (() => void)[] = [];\n if (typeof MutationObserver === \"function\") {\n const observer = new MutationObserver(onChange);\n for (const node of [document.documentElement, document.body]) {\n if (node) {\n observer.observe(node, {\n attributes: true,\n attributeFilter: [\"class\", \"style\", \"data-theme\", \"data-mode\"],\n });\n }\n }\n cleanups.push(() => observer.disconnect());\n }\n if (typeof matchMedia === \"function\") {\n const query = matchMedia(\"(prefers-color-scheme: dark)\");\n query.addEventListener?.(\"change\", onChange);\n cleanups.push(() => query.removeEventListener?.(\"change\", onChange));\n }\n return () => cleanups.forEach((fn) => fn());\n};\n"],"mappings":";;AAmBA,IAAMA,IAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,KAAW,GAAmC,MAClDC,GAAO,iBAAiBC,CAAI,CAAC,CAAC,KAAK,KAAK,IAG7BC,KACX,GACA,MACe;CACf,IAAMF,IACJG,KAAW,OAAO,oBAAqB,aACnC,iBAAiBA,CAAO,IACxB,MACAC,KAAS,GAAiB,MAA2B;EACzD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CAAC;CACnD,IAAMC,IAA2B,CAAC;CAClC,IAAI,OAAO,oBAAqB,YAAY;EAC1C,IAAMC,IAAW,IAAI,iBAAiBC,CAAQ;EAC9C,KAAK,IAAMC,KAAQ,CAAC,SAAS,iBAAiB,SAAS,IAAI,GACzD,AAAIA,KACFF,EAAS,QAAQE,GAAM;GACrB,YAAY;GACZ,iBAAiB;IAAC;IAAS;IAAS;IAAc;GAAW;EAC/D,CAAC;EAGL,EAAS,WAAWF,EAAS,WAAW,CAAC;CAC3C;CACA,IAAI,OAAO,cAAe,YAAY;EACpC,IAAMG,IAAQ,WAAW,8BAA8B;EAEvD,AADAA,EAAM,mBAAmB,UAAUF,CAAQ,GAC3CF,EAAS,WAAWI,EAAM,sBAAsB,UAAUF,CAAQ,CAAC;CACrE;CACA,aAAaF,EAAS,SAAS,MAAOK,EAAG,CAAC;AAC5C"}
|
|
1
|
+
{"version":3,"file":"theme.js","names":["DEFAULT_PALETTE","readVar","style","name","readTheme","element","buildTheme","memoizeColorResolver","domColorResolver","palette","THEME_COLORS","themeColorsChanged","previous","next","sameColor","c","i","key","cache","probe","value","color","resolved","createTheme","variables","input","staticColorResolver","resolveStaticColor","fallback","fallbackGray","resolveColor","resolve","names","readVariable","background","text","textMuted","border","colors","custom","fontFamily","inheritedFont","mix","watchTheme","cleanups","observer","onChange","node","query","fn"],"sources":["../../../../charts/src/engine/theme.ts"],"sourcesContent":["// Chart colors and fonts read from the Minerva CSS variables.\n\nimport {\n domColorResolver,\n memoizeColorResolver,\n mix,\n resolveStaticColor,\n sameColor,\n type ColorResolver,\n type MemoizedColorResolver,\n type Rgba,\n} from \"./color\";\n\nexport interface ChartTheme {\n palette: Rgba[];\n text: Rgba;\n textMuted: Rgba;\n grid: Rgba;\n axis: Rgba;\n background: Rgba;\n surface: Rgba;\n primary: Rgba;\n fontFamily: string;\n /** Tick label font size in CSS pixels */\n fontSize: number;\n /** Resolves the colors of the options (`var(--x)` included); static colors only when omitted */\n resolve?: ColorResolver;\n}\n\n/** Used when no CSS variable is defined (e.g. without the Minerva stylesheet) */\nconst DEFAULT_PALETTE = [\n \"#4f46e5\",\n \"#10b981\",\n \"#f59e0b\",\n \"#ef4444\",\n \"#0ea5e9\",\n \"#8b5cf6\",\n \"#14b8a6\",\n \"#f97316\",\n];\n\nconst readVar = (style: CSSStyleDeclaration | null, name: string) =>\n style?.getPropertyValue(name).trim() ?? \"\";\n\n/**\n * Reads the theme from the computed style of `element`. Its resolver caches\n * the colors (DOM probes are costly): read the theme again to see new values.\n */\nexport const readTheme = (\n element: Element | null,\n palette?: readonly string[],\n): ChartTheme => {\n const style =\n element && typeof getComputedStyle === \"function\"\n ? getComputedStyle(element)\n : null;\n return buildTheme(\n (name) => readVar(style, name),\n memoizeColorResolver(domColorResolver(element)),\n palette,\n style?.fontFamily ?? \"\",\n );\n};\n\nconst THEME_COLORS = [\n \"text\",\n \"textMuted\",\n \"grid\",\n \"axis\",\n \"background\",\n \"surface\",\n \"primary\",\n] as const;\n\n/**\n * Whether `next` (a re-read of `previous`) resolves any color differently:\n * the theme colors, the palette and every color `previous` has resolved so\n * far (series, points, annotations...). `true` when it cannot tell.\n */\nexport const themeColorsChanged = (\n previous: ChartTheme,\n next: ChartTheme,\n): boolean => {\n if (previous === next) return false;\n if (previous.palette.length !== next.palette.length) return true;\n if (previous.palette.some((c, i) => !sameColor(c, next.palette[i])))\n return true;\n if (THEME_COLORS.some((key) => !sameColor(previous[key], next[key])))\n return true;\n const cache = (previous.resolve as Partial<MemoizedColorResolver> | undefined)\n ?.cache;\n if (!cache || !next.resolve) return true;\n const probe: Rgba = [NaN, NaN, NaN, NaN];\n for (const [value, color] of cache) {\n const resolved = next.resolve(value, probe);\n if (!sameColor(color, resolved === probe ? null : resolved)) return true;\n }\n return false;\n};\n\n/** Theme of the charts drawn without a DOM (mini-programs, React Native) */\nexport interface ChartThemeInput {\n /**\n * Values of the Minerva CSS variables (`--primary-color`, `--text-color`,\n * `--chart-series-1`, ...) used for the theme colors and to resolve\n * `var(--name)` colors of the options\n */\n variables?: Readonly<Record<string, string>>;\n /** Series colors (hex / rgb) */\n palette?: readonly string[];\n /** Font family of the labels */\n fontFamily?: string;\n /**\n * Font size of the tick labels, in pixels\n * @default 11\n */\n fontSize?: number;\n}\n\n/** Builds a theme from plain values (no DOM) */\nexport const createTheme = (\n input: ChartThemeInput = {},\n palette?: readonly string[],\n): ChartTheme => {\n const variables = input.variables ?? {};\n const theme = buildTheme(\n (name) => variables[name]?.trim() ?? \"\",\n staticColorResolver(variables),\n palette?.length ? palette : input.palette,\n \"\",\n );\n return {\n ...theme,\n ...(input.fontFamily ? { fontFamily: input.fontFamily } : {}),\n ...(input.fontSize ? { fontSize: input.fontSize } : {}),\n };\n};\n\n/** Resolver of `var(--name, fallback)` colors against plain variables */\nexport const staticColorResolver =\n (variables: Readonly<Record<string, string>>): ColorResolver =>\n (value, fallback) =>\n resolveStaticColor(value, variables, fallback);\n\nconst buildTheme = (\n readVariable: (name: string) => string,\n resolve: ColorResolver,\n palette: readonly string[] | undefined,\n inheritedFont: string,\n): ChartTheme => {\n const fallbackGray: Rgba = [0.4, 0.4, 0.4, 1];\n const resolveColor = (value: string) => resolve(value, fallbackGray);\n const color = (names: string[], fallback: string): Rgba => {\n for (const name of names) {\n if (readVariable(name)) return resolveColor(`var(${name})`);\n }\n return resolveColor(fallback);\n };\n\n const background = color(\n [\"--surface-color\", \"--background-color\"],\n \"#ffffff\",\n );\n const text = color([\"--text-color\"], \"#1f2937\");\n const textMuted = color(\n [\"--text-secondary-color\", \"--text-muted-color\"],\n \"#6b7280\",\n );\n const border = color([\"--border-color\"], \"#e5e7eb\");\n\n let colors: Rgba[];\n if (palette && palette.length) {\n colors = palette.map((c) => resolveColor(c));\n } else {\n const custom: Rgba[] = [];\n for (let i = 1; i <= 8; i++) {\n const name = `--chart-series-${i}`;\n if (readVariable(name)) custom.push(resolveColor(`var(${name})`));\n }\n if (custom.length) {\n colors = custom;\n } else {\n const themed = [\n \"--primary-color\",\n \"--success-color\",\n \"--warning-color\",\n \"--danger-color\",\n \"--info-color\",\n ].map((name, i) =>\n readVariable(name)\n ? resolveColor(`var(${name})`)\n : resolveColor(DEFAULT_PALETTE[i]),\n );\n colors = [\n ...themed,\n ...DEFAULT_PALETTE.slice(5).map((c) => resolveColor(c)),\n ];\n }\n }\n\n const fontFamily =\n readVariable(\"--font-family-sans\") ||\n inheritedFont ||\n \"system-ui, -apple-system, 'Segoe UI', sans-serif\";\n\n return {\n palette: colors,\n text,\n textMuted,\n grid: mix(background, border, 0.75),\n axis: border,\n background,\n surface: background,\n primary: colors[0],\n fontFamily,\n fontSize: 11,\n resolve,\n };\n};\n\n/**\n * Calls `onChange` when the theme may have changed: attributes of `<html>` /\n * `<body>` (class, style, data-theme) and the color scheme.\n */\nexport const watchTheme = (onChange: () => void): (() => void) => {\n if (typeof document === \"undefined\") return () => {};\n const cleanups: (() => void)[] = [];\n if (typeof MutationObserver === \"function\") {\n const observer = new MutationObserver(onChange);\n for (const node of [document.documentElement, document.body]) {\n if (node) {\n observer.observe(node, {\n attributes: true,\n attributeFilter: [\"class\", \"style\", \"data-theme\", \"data-mode\"],\n });\n }\n }\n cleanups.push(() => observer.disconnect());\n }\n if (typeof matchMedia === \"function\") {\n const query = matchMedia(\"(prefers-color-scheme: dark)\");\n query.addEventListener?.(\"change\", onChange);\n cleanups.push(() => query.removeEventListener?.(\"change\", onChange));\n }\n return () => cleanups.forEach((fn) => fn());\n};\n"],"mappings":";;AA8BA,IAAMA,IAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,KAAW,GAAmC,MAClDC,GAAO,iBAAiBC,CAAI,CAAC,CAAC,KAAK,KAAK,IAM7BC,KACX,GACA,MACe;CACf,IAAMF,IACJG,KAAW,OAAO,oBAAqB,aACnC,iBAAiBA,CAAO,IACxB;CACN,OAAOC,GACJ,MAASL,EAAQC,GAAOC,CAAI,GAC7BI,EAAqBC,EAAiBH,CAAO,CAAC,GA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OAAO,oBAAqB,YAAY;EAC1C,IAAMC,IAAW,IAAI,iBAAiBC,CAAQ;EAC9C,KAAK,IAAMC,KAAQ,CAAC,SAAS,iBAAiB,SAAS,IAAI,GACzD,AAAIA,KACFF,EAAS,QAAQE,GAAM;GACrB,YAAY;GACZ,iBAAiB;IAAC;IAAS;IAAS;IAAc;GAAW;EAC/D,CAAC;EAGL,EAAS,WAAWF,EAAS,WAAW,CAAC;CAC3C;CACA,IAAI,OAAO,cAAe,YAAY;EACpC,IAAMG,IAAQ,WAAW,8BAA8B;EAEvD,AADAA,EAAM,mBAAmB,UAAUF,CAAQ,GAC3CF,EAAS,WAAWI,EAAM,sBAAsB,UAAUF,CAAQ,CAAC;CACrE;CACA,aAAaF,EAAS,SAAS,MAAOK,EAAG,CAAC;AAC5C"}
|
|
@@ -8,30 +8,51 @@ export type ChartRendererPreference = "auto" | ChartRendererKind;
|
|
|
8
8
|
/** Scale of an axis */
|
|
9
9
|
export type ChartAxisType = "linear" | "time" | "category";
|
|
10
10
|
/** How a series is drawn */
|
|
11
|
-
export type ChartSeriesType = "line" | "area" | "bar" | "scatter";
|
|
11
|
+
export type ChartSeriesType = "line" | "area" | "bar" | "scatter" | "candlestick" | "heatmap";
|
|
12
|
+
/** Shape of a line (and of the edge of an area) between its points */
|
|
13
|
+
export type ChartCurve = "linear" | "smooth" | "step";
|
|
12
14
|
/** X value of a datum: a number, a `Date` (time axis) or a category name */
|
|
13
15
|
export type ChartXValue = number | Date | string;
|
|
14
16
|
/** One datum written as an object */
|
|
15
17
|
export interface ChartPointDatum {
|
|
16
18
|
/** X value; the datum index when omitted */
|
|
17
19
|
x?: ChartXValue;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Y value; `null` leaves a gap. Candlesticks: the close. Heatmaps: the
|
|
22
|
+
* row (a number, or a category name of a `category` y axis)
|
|
23
|
+
*/
|
|
24
|
+
y: number | string | null;
|
|
20
25
|
/** Diameter of the dot in CSS pixels (scatter) */
|
|
21
26
|
size?: number;
|
|
22
|
-
/** Color of the dot (scatter); any CSS color */
|
|
27
|
+
/** Color of the dot or bar (scatter, bar); any CSS color */
|
|
23
28
|
color?: string;
|
|
24
29
|
/** Text drawn next to the dot (scatter with `showLabels`) and shown in the tooltip */
|
|
25
30
|
label?: string;
|
|
31
|
+
/** Candlestick: opening value */
|
|
32
|
+
open?: number;
|
|
33
|
+
/** Candlestick: highest value */
|
|
34
|
+
high?: number;
|
|
35
|
+
/** Candlestick: lowest value */
|
|
36
|
+
low?: number;
|
|
37
|
+
/** Heatmap: value of the cell, mapped to `colorScale` */
|
|
38
|
+
value?: number | null;
|
|
26
39
|
}
|
|
27
40
|
/** Column-oriented data: the fastest form for large data sets (typed arrays are used as is) */
|
|
28
41
|
export interface ChartColumnData {
|
|
29
42
|
/** X values; the index when omitted */
|
|
30
43
|
x?: ArrayLike<number> | readonly ChartXValue[];
|
|
31
|
-
/** Y values (`NaN` / `null` leave a gap) */
|
|
32
|
-
y: ArrayLike<number> | readonly (number | null)[];
|
|
44
|
+
/** Y values (`NaN` / `null` leave a gap); candlesticks: the closes; heatmaps: the rows */
|
|
45
|
+
y: ArrayLike<number> | readonly (number | string | null)[];
|
|
33
46
|
/** Per-point diameters in CSS pixels (scatter) */
|
|
34
47
|
size?: ArrayLike<number>;
|
|
48
|
+
/** Candlestick: opening values */
|
|
49
|
+
open?: ArrayLike<number>;
|
|
50
|
+
/** Candlestick: highest values */
|
|
51
|
+
high?: ArrayLike<number>;
|
|
52
|
+
/** Candlestick: lowest values */
|
|
53
|
+
low?: ArrayLike<number>;
|
|
54
|
+
/** Heatmap: values of the cells */
|
|
55
|
+
value?: ArrayLike<number> | readonly (number | null)[];
|
|
35
56
|
}
|
|
36
57
|
/**
|
|
37
58
|
* Data of a series: y values only (`[3, 5, 2]`, typed arrays included),
|
|
@@ -65,17 +86,45 @@ export interface ChartSeries {
|
|
|
65
86
|
pointSize?: number;
|
|
66
87
|
/** Fill opacity (area, scatter), 0-1 */
|
|
67
88
|
opacity?: number;
|
|
68
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Series with the same stack id are stacked (bars, areas and lines; see
|
|
91
|
+
* `stackMode` for 100% stacks)
|
|
92
|
+
*/
|
|
69
93
|
stack?: string;
|
|
70
94
|
/** Hides the series (it stays in the legend) */
|
|
71
95
|
hidden?: boolean;
|
|
72
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Draws the `label` of each point next to it (scatter) or the value above
|
|
98
|
+
* each bar (bar)
|
|
99
|
+
*/
|
|
73
100
|
showLabels?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Shape of the line between the points: straight, smooth (monotone, never
|
|
103
|
+
* overshoots the data) or steps (line / area)
|
|
104
|
+
* @default "linear"
|
|
105
|
+
*/
|
|
106
|
+
curve?: ChartCurve;
|
|
107
|
+
/** Candlestick: color of the rising candles (close >= open); `--success-color` by default */
|
|
108
|
+
upColor?: string;
|
|
109
|
+
/** Candlestick: color of the falling candles; `--danger-color` by default */
|
|
110
|
+
downColor?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Heatmap: colors from the lowest to the highest value (two or more)
|
|
113
|
+
* @default a ramp from the background to the series color
|
|
114
|
+
*/
|
|
115
|
+
colorScale?: readonly string[];
|
|
116
|
+
/** Heatmap: values mapped to the ends of `colorScale`; the data range by default */
|
|
117
|
+
valueRange?: readonly [number, number];
|
|
118
|
+
/** Bar / heatmap: corner radius in CSS pixels (bars: 3, heatmap cells: 2) */
|
|
119
|
+
radius?: number;
|
|
120
|
+
/** Formats the values of this series in the tooltip (the y axis format by default) */
|
|
121
|
+
format?: (value: number) => string;
|
|
74
122
|
}
|
|
75
123
|
/** Options of an axis */
|
|
76
124
|
export interface ChartAxisOptions {
|
|
77
125
|
/**
|
|
78
|
-
* Scale of the axis: `linear` numbers, `time` timestamps / dates, `category`
|
|
126
|
+
* Scale of the axis: `linear` numbers, `time` timestamps / dates, `category`
|
|
127
|
+
* names (x axis, and y axis of heatmaps)
|
|
79
128
|
* @default "linear"
|
|
80
129
|
*/
|
|
81
130
|
type?: ChartAxisType;
|
|
@@ -145,8 +194,28 @@ export interface ChartLineAnnotation {
|
|
|
145
194
|
/** Text drawn at the end of the line */
|
|
146
195
|
label?: string;
|
|
147
196
|
}
|
|
148
|
-
/**
|
|
149
|
-
export
|
|
197
|
+
/** Text placed at a data position (omitted coordinates center it on the plot) */
|
|
198
|
+
export interface ChartTextAnnotation {
|
|
199
|
+
type: "text";
|
|
200
|
+
x?: number;
|
|
201
|
+
y?: number;
|
|
202
|
+
text: string;
|
|
203
|
+
/**
|
|
204
|
+
* Side of the text that touches the position: `top` hangs the text below
|
|
205
|
+
* it, `left` starts it there, ...; the text always stays inside the plot
|
|
206
|
+
* @default "center"
|
|
207
|
+
*/
|
|
208
|
+
anchor?: "center" | "top" | "bottom" | "left" | "right";
|
|
209
|
+
/** Text color (defaults to the secondary text color) */
|
|
210
|
+
color?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Font weight
|
|
213
|
+
* @default 500
|
|
214
|
+
*/
|
|
215
|
+
weight?: number;
|
|
216
|
+
}
|
|
217
|
+
/** Background area, reference line or text */
|
|
218
|
+
export type ChartAnnotation = ChartRectAnnotation | ChartLineAnnotation | ChartTextAnnotation;
|
|
150
219
|
/** Zoom / pan / keyboard options */
|
|
151
220
|
export interface ChartInteractionOptions {
|
|
152
221
|
/**
|
|
@@ -169,6 +238,12 @@ export interface ChartInteractionOptions {
|
|
|
169
238
|
* @default true
|
|
170
239
|
*/
|
|
171
240
|
keyboard?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Scatter points can be dragged: `drag` events follow the pointer and a
|
|
243
|
+
* `drop` event ends the gesture (the data is not changed by the chart)
|
|
244
|
+
* @default false
|
|
245
|
+
*/
|
|
246
|
+
dragPoints?: boolean;
|
|
172
247
|
}
|
|
173
248
|
/** Tooltip options */
|
|
174
249
|
export interface ChartTooltipOptions {
|
|
@@ -229,6 +304,12 @@ export interface ChartOptions {
|
|
|
229
304
|
palette?: readonly string[];
|
|
230
305
|
/** Accessible name of the chart */
|
|
231
306
|
ariaLabel?: string;
|
|
307
|
+
/**
|
|
308
|
+
* `percent` scales every stack to 100% at each x (the axis shows percents,
|
|
309
|
+
* the tooltip the actual values)
|
|
310
|
+
* @default "normal"
|
|
311
|
+
*/
|
|
312
|
+
stackMode?: "normal" | "percent";
|
|
232
313
|
}
|
|
233
314
|
/** A point under the pointer */
|
|
234
315
|
export interface ChartHoverItem {
|
|
@@ -242,6 +323,12 @@ export interface ChartHoverItem {
|
|
|
242
323
|
/** Resolved color of the point */
|
|
243
324
|
color: string;
|
|
244
325
|
label?: string;
|
|
326
|
+
/** Candlestick: open / high / low (`y` is the close) */
|
|
327
|
+
open?: number;
|
|
328
|
+
high?: number;
|
|
329
|
+
low?: number;
|
|
330
|
+
/** Heatmap: value of the cell */
|
|
331
|
+
value?: number;
|
|
245
332
|
}
|
|
246
333
|
/** Hover / click payload */
|
|
247
334
|
export interface ChartHoverEvent {
|
|
@@ -257,12 +344,41 @@ export interface ChartView {
|
|
|
257
344
|
x: [number, number];
|
|
258
345
|
y: [number, number];
|
|
259
346
|
}
|
|
347
|
+
/** Rectangle in CSS pixels, relative to the chart's container */
|
|
348
|
+
export interface ChartRect {
|
|
349
|
+
x: number;
|
|
350
|
+
y: number;
|
|
351
|
+
width: number;
|
|
352
|
+
height: number;
|
|
353
|
+
}
|
|
354
|
+
/** A dragged point (`drag` / `drop` events) */
|
|
355
|
+
export interface ChartDragEvent {
|
|
356
|
+
/** The point being dragged */
|
|
357
|
+
item: ChartHoverItem;
|
|
358
|
+
/** Data coordinates under the pointer */
|
|
359
|
+
x: number;
|
|
360
|
+
y: number;
|
|
361
|
+
}
|
|
362
|
+
/** A click (or tap) on the plot area outside the points */
|
|
363
|
+
export interface ChartPlotClickEvent {
|
|
364
|
+
/** Data coordinates of the click */
|
|
365
|
+
x: number;
|
|
366
|
+
y: number;
|
|
367
|
+
}
|
|
260
368
|
/** Events of a chart instance */
|
|
261
369
|
export interface ChartEventMap {
|
|
262
370
|
hover: ChartHoverEvent | null;
|
|
263
371
|
click: ChartHoverEvent;
|
|
372
|
+
/** Click on the plot area where there is no point */
|
|
373
|
+
plotClick: ChartPlotClickEvent;
|
|
264
374
|
zoom: ChartView;
|
|
265
375
|
renderer: ChartRendererKind;
|
|
376
|
+
/** The plot area moved or was resized */
|
|
377
|
+
layout: ChartRect;
|
|
378
|
+
/** A point is dragged (`interaction.dragPoints`) */
|
|
379
|
+
drag: ChartDragEvent;
|
|
380
|
+
/** A dragged point was released */
|
|
381
|
+
drop: ChartDragEvent;
|
|
266
382
|
}
|
|
267
383
|
/** Chart created by `createChart` */
|
|
268
384
|
export interface ChartInstance {
|
|
@@ -276,6 +392,18 @@ export interface ChartInstance {
|
|
|
276
392
|
getView(): ChartView;
|
|
277
393
|
/** Sets the visible range */
|
|
278
394
|
setView(view: Partial<ChartView>): void;
|
|
395
|
+
/** Plot area in CSS pixels of the container (`null` before the first frame) */
|
|
396
|
+
getPlotRect(): ChartRect | null;
|
|
397
|
+
/** Data coordinates -> CSS pixels of the container (`null` before the first frame) */
|
|
398
|
+
toPixel(x: number, y: number): {
|
|
399
|
+
x: number;
|
|
400
|
+
y: number;
|
|
401
|
+
} | null;
|
|
402
|
+
/** CSS pixels of the container -> data coordinates (`null` before the first frame) */
|
|
403
|
+
fromPixel(x: number, y: number): {
|
|
404
|
+
x: number;
|
|
405
|
+
y: number;
|
|
406
|
+
} | null;
|
|
279
407
|
/** Backend in use, `null` until ready */
|
|
280
408
|
getRenderer(): ChartRendererKind | null;
|
|
281
409
|
/** Resolves with the backend once the first frame can be drawn (`null` when the browser has no canvas support) */
|
|
@@ -8,30 +8,51 @@ export type ChartRendererPreference = "auto" | ChartRendererKind;
|
|
|
8
8
|
/** Scale of an axis */
|
|
9
9
|
export type ChartAxisType = "linear" | "time" | "category";
|
|
10
10
|
/** How a series is drawn */
|
|
11
|
-
export type ChartSeriesType = "line" | "area" | "bar" | "scatter";
|
|
11
|
+
export type ChartSeriesType = "line" | "area" | "bar" | "scatter" | "candlestick" | "heatmap";
|
|
12
|
+
/** Shape of a line (and of the edge of an area) between its points */
|
|
13
|
+
export type ChartCurve = "linear" | "smooth" | "step";
|
|
12
14
|
/** X value of a datum: a number, a `Date` (time axis) or a category name */
|
|
13
15
|
export type ChartXValue = number | Date | string;
|
|
14
16
|
/** One datum written as an object */
|
|
15
17
|
export interface ChartPointDatum {
|
|
16
18
|
/** X value; the datum index when omitted */
|
|
17
19
|
x?: ChartXValue;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Y value; `null` leaves a gap. Candlesticks: the close. Heatmaps: the
|
|
22
|
+
* row (a number, or a category name of a `category` y axis)
|
|
23
|
+
*/
|
|
24
|
+
y: number | string | null;
|
|
20
25
|
/** Diameter of the dot in CSS pixels (scatter) */
|
|
21
26
|
size?: number;
|
|
22
|
-
/** Color of the dot (scatter); any CSS color */
|
|
27
|
+
/** Color of the dot or bar (scatter, bar); any CSS color */
|
|
23
28
|
color?: string;
|
|
24
29
|
/** Text drawn next to the dot (scatter with `showLabels`) and shown in the tooltip */
|
|
25
30
|
label?: string;
|
|
31
|
+
/** Candlestick: opening value */
|
|
32
|
+
open?: number;
|
|
33
|
+
/** Candlestick: highest value */
|
|
34
|
+
high?: number;
|
|
35
|
+
/** Candlestick: lowest value */
|
|
36
|
+
low?: number;
|
|
37
|
+
/** Heatmap: value of the cell, mapped to `colorScale` */
|
|
38
|
+
value?: number | null;
|
|
26
39
|
}
|
|
27
40
|
/** Column-oriented data: the fastest form for large data sets (typed arrays are used as is) */
|
|
28
41
|
export interface ChartColumnData {
|
|
29
42
|
/** X values; the index when omitted */
|
|
30
43
|
x?: ArrayLike<number> | readonly ChartXValue[];
|
|
31
|
-
/** Y values (`NaN` / `null` leave a gap) */
|
|
32
|
-
y: ArrayLike<number> | readonly (number | null)[];
|
|
44
|
+
/** Y values (`NaN` / `null` leave a gap); candlesticks: the closes; heatmaps: the rows */
|
|
45
|
+
y: ArrayLike<number> | readonly (number | string | null)[];
|
|
33
46
|
/** Per-point diameters in CSS pixels (scatter) */
|
|
34
47
|
size?: ArrayLike<number>;
|
|
48
|
+
/** Candlestick: opening values */
|
|
49
|
+
open?: ArrayLike<number>;
|
|
50
|
+
/** Candlestick: highest values */
|
|
51
|
+
high?: ArrayLike<number>;
|
|
52
|
+
/** Candlestick: lowest values */
|
|
53
|
+
low?: ArrayLike<number>;
|
|
54
|
+
/** Heatmap: values of the cells */
|
|
55
|
+
value?: ArrayLike<number> | readonly (number | null)[];
|
|
35
56
|
}
|
|
36
57
|
/**
|
|
37
58
|
* Data of a series: y values only (`[3, 5, 2]`, typed arrays included),
|
|
@@ -65,17 +86,45 @@ export interface ChartSeries {
|
|
|
65
86
|
pointSize?: number;
|
|
66
87
|
/** Fill opacity (area, scatter), 0-1 */
|
|
67
88
|
opacity?: number;
|
|
68
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Series with the same stack id are stacked (bars, areas and lines; see
|
|
91
|
+
* `stackMode` for 100% stacks)
|
|
92
|
+
*/
|
|
69
93
|
stack?: string;
|
|
70
94
|
/** Hides the series (it stays in the legend) */
|
|
71
95
|
hidden?: boolean;
|
|
72
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Draws the `label` of each point next to it (scatter) or the value above
|
|
98
|
+
* each bar (bar)
|
|
99
|
+
*/
|
|
73
100
|
showLabels?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Shape of the line between the points: straight, smooth (monotone, never
|
|
103
|
+
* overshoots the data) or steps (line / area)
|
|
104
|
+
* @default "linear"
|
|
105
|
+
*/
|
|
106
|
+
curve?: ChartCurve;
|
|
107
|
+
/** Candlestick: color of the rising candles (close >= open); `--success-color` by default */
|
|
108
|
+
upColor?: string;
|
|
109
|
+
/** Candlestick: color of the falling candles; `--danger-color` by default */
|
|
110
|
+
downColor?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Heatmap: colors from the lowest to the highest value (two or more)
|
|
113
|
+
* @default a ramp from the background to the series color
|
|
114
|
+
*/
|
|
115
|
+
colorScale?: readonly string[];
|
|
116
|
+
/** Heatmap: values mapped to the ends of `colorScale`; the data range by default */
|
|
117
|
+
valueRange?: readonly [number, number];
|
|
118
|
+
/** Bar / heatmap: corner radius in CSS pixels (bars: 3, heatmap cells: 2) */
|
|
119
|
+
radius?: number;
|
|
120
|
+
/** Formats the values of this series in the tooltip (the y axis format by default) */
|
|
121
|
+
format?: (value: number) => string;
|
|
74
122
|
}
|
|
75
123
|
/** Options of an axis */
|
|
76
124
|
export interface ChartAxisOptions {
|
|
77
125
|
/**
|
|
78
|
-
* Scale of the axis: `linear` numbers, `time` timestamps / dates, `category`
|
|
126
|
+
* Scale of the axis: `linear` numbers, `time` timestamps / dates, `category`
|
|
127
|
+
* names (x axis, and y axis of heatmaps)
|
|
79
128
|
* @default "linear"
|
|
80
129
|
*/
|
|
81
130
|
type?: ChartAxisType;
|
|
@@ -145,8 +194,28 @@ export interface ChartLineAnnotation {
|
|
|
145
194
|
/** Text drawn at the end of the line */
|
|
146
195
|
label?: string;
|
|
147
196
|
}
|
|
148
|
-
/**
|
|
149
|
-
export
|
|
197
|
+
/** Text placed at a data position (omitted coordinates center it on the plot) */
|
|
198
|
+
export interface ChartTextAnnotation {
|
|
199
|
+
type: "text";
|
|
200
|
+
x?: number;
|
|
201
|
+
y?: number;
|
|
202
|
+
text: string;
|
|
203
|
+
/**
|
|
204
|
+
* Side of the text that touches the position: `top` hangs the text below
|
|
205
|
+
* it, `left` starts it there, ...; the text always stays inside the plot
|
|
206
|
+
* @default "center"
|
|
207
|
+
*/
|
|
208
|
+
anchor?: "center" | "top" | "bottom" | "left" | "right";
|
|
209
|
+
/** Text color (defaults to the secondary text color) */
|
|
210
|
+
color?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Font weight
|
|
213
|
+
* @default 500
|
|
214
|
+
*/
|
|
215
|
+
weight?: number;
|
|
216
|
+
}
|
|
217
|
+
/** Background area, reference line or text */
|
|
218
|
+
export type ChartAnnotation = ChartRectAnnotation | ChartLineAnnotation | ChartTextAnnotation;
|
|
150
219
|
/** Zoom / pan / keyboard options */
|
|
151
220
|
export interface ChartInteractionOptions {
|
|
152
221
|
/**
|
|
@@ -169,6 +238,12 @@ export interface ChartInteractionOptions {
|
|
|
169
238
|
* @default true
|
|
170
239
|
*/
|
|
171
240
|
keyboard?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Scatter points can be dragged: `drag` events follow the pointer and a
|
|
243
|
+
* `drop` event ends the gesture (the data is not changed by the chart)
|
|
244
|
+
* @default false
|
|
245
|
+
*/
|
|
246
|
+
dragPoints?: boolean;
|
|
172
247
|
}
|
|
173
248
|
/** Tooltip options */
|
|
174
249
|
export interface ChartTooltipOptions {
|
|
@@ -229,6 +304,12 @@ export interface ChartOptions {
|
|
|
229
304
|
palette?: readonly string[];
|
|
230
305
|
/** Accessible name of the chart */
|
|
231
306
|
ariaLabel?: string;
|
|
307
|
+
/**
|
|
308
|
+
* `percent` scales every stack to 100% at each x (the axis shows percents,
|
|
309
|
+
* the tooltip the actual values)
|
|
310
|
+
* @default "normal"
|
|
311
|
+
*/
|
|
312
|
+
stackMode?: "normal" | "percent";
|
|
232
313
|
}
|
|
233
314
|
/** A point under the pointer */
|
|
234
315
|
export interface ChartHoverItem {
|
|
@@ -242,6 +323,12 @@ export interface ChartHoverItem {
|
|
|
242
323
|
/** Resolved color of the point */
|
|
243
324
|
color: string;
|
|
244
325
|
label?: string;
|
|
326
|
+
/** Candlestick: open / high / low (`y` is the close) */
|
|
327
|
+
open?: number;
|
|
328
|
+
high?: number;
|
|
329
|
+
low?: number;
|
|
330
|
+
/** Heatmap: value of the cell */
|
|
331
|
+
value?: number;
|
|
245
332
|
}
|
|
246
333
|
/** Hover / click payload */
|
|
247
334
|
export interface ChartHoverEvent {
|
|
@@ -257,12 +344,41 @@ export interface ChartView {
|
|
|
257
344
|
x: [number, number];
|
|
258
345
|
y: [number, number];
|
|
259
346
|
}
|
|
347
|
+
/** Rectangle in CSS pixels, relative to the chart's container */
|
|
348
|
+
export interface ChartRect {
|
|
349
|
+
x: number;
|
|
350
|
+
y: number;
|
|
351
|
+
width: number;
|
|
352
|
+
height: number;
|
|
353
|
+
}
|
|
354
|
+
/** A dragged point (`drag` / `drop` events) */
|
|
355
|
+
export interface ChartDragEvent {
|
|
356
|
+
/** The point being dragged */
|
|
357
|
+
item: ChartHoverItem;
|
|
358
|
+
/** Data coordinates under the pointer */
|
|
359
|
+
x: number;
|
|
360
|
+
y: number;
|
|
361
|
+
}
|
|
362
|
+
/** A click (or tap) on the plot area outside the points */
|
|
363
|
+
export interface ChartPlotClickEvent {
|
|
364
|
+
/** Data coordinates of the click */
|
|
365
|
+
x: number;
|
|
366
|
+
y: number;
|
|
367
|
+
}
|
|
260
368
|
/** Events of a chart instance */
|
|
261
369
|
export interface ChartEventMap {
|
|
262
370
|
hover: ChartHoverEvent | null;
|
|
263
371
|
click: ChartHoverEvent;
|
|
372
|
+
/** Click on the plot area where there is no point */
|
|
373
|
+
plotClick: ChartPlotClickEvent;
|
|
264
374
|
zoom: ChartView;
|
|
265
375
|
renderer: ChartRendererKind;
|
|
376
|
+
/** The plot area moved or was resized */
|
|
377
|
+
layout: ChartRect;
|
|
378
|
+
/** A point is dragged (`interaction.dragPoints`) */
|
|
379
|
+
drag: ChartDragEvent;
|
|
380
|
+
/** A dragged point was released */
|
|
381
|
+
drop: ChartDragEvent;
|
|
266
382
|
}
|
|
267
383
|
/** Chart created by `createChart` */
|
|
268
384
|
export interface ChartInstance {
|
|
@@ -276,6 +392,18 @@ export interface ChartInstance {
|
|
|
276
392
|
getView(): ChartView;
|
|
277
393
|
/** Sets the visible range */
|
|
278
394
|
setView(view: Partial<ChartView>): void;
|
|
395
|
+
/** Plot area in CSS pixels of the container (`null` before the first frame) */
|
|
396
|
+
getPlotRect(): ChartRect | null;
|
|
397
|
+
/** Data coordinates -> CSS pixels of the container (`null` before the first frame) */
|
|
398
|
+
toPixel(x: number, y: number): {
|
|
399
|
+
x: number;
|
|
400
|
+
y: number;
|
|
401
|
+
} | null;
|
|
402
|
+
/** CSS pixels of the container -> data coordinates (`null` before the first frame) */
|
|
403
|
+
fromPixel(x: number, y: number): {
|
|
404
|
+
x: number;
|
|
405
|
+
y: number;
|
|
406
|
+
} | null;
|
|
279
407
|
/** Backend in use, `null` until ready */
|
|
280
408
|
getRenderer(): ChartRendererKind | null;
|
|
281
409
|
/** Resolves with the backend once the first frame can be drawn (`null` when the browser has no canvas support) */
|
package/dist/charts/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./engine/format.cjs"),t=require("./engine/chart.cjs"),n=require("./react/Chart.cjs"),r=require("./react/charts.cjs");require("./core.cjs"),exports.BarChart=
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./engine/format.cjs"),t=require("./engine/chart.cjs"),n=require("./react/Chart.cjs"),r=require("./engine/presets.cjs"),i=require("./react/charts.cjs"),a=require("./engine/shapes/chart.cjs"),o=require("./react/shapes.cjs"),s=require("./engine/shapes/canvas.cjs"),c=require("./engine/controller.cjs"),l=require("./engine/canvas.cjs");require("./core.cjs"),exports.AreaChart=i.AreaChart,exports.BarChart=i.BarChart,exports.CandlestickChart=i.CandlestickChart,exports.Chart=n.Chart,exports.DonutChart=o.DonutChart,exports.FunnelChart=o.FunnelChart,exports.GaugeChart=o.GaugeChart,exports.HeatmapChart=i.HeatmapChart,exports.LineChart=i.LineChart,exports.PieChart=o.PieChart,exports.QuadrantChart=i.QuadrantChart,exports.RadarChart=o.RadarChart,exports.ScatterChart=i.ScatterChart,exports.Sparkline=i.Sparkline,exports.TreemapChart=o.TreemapChart,exports.createCanvasChart=l.createCanvasChart,exports.createCanvasShapeChart=s.createCanvasShapeChart,exports.createChart=t.createChart,exports.createChartController=c.createChartController,exports.createShapeChart=a.createShapeChart,exports.formatCompact=e.formatCompact,exports.heatmapChartOptions=r.heatmapChartOptions,exports.quadrantCenter=r.quadrantCenter,exports.quadrantChartOptions=r.quadrantChartOptions,exports.quadrantOf=r.quadrantOf,exports.scenePrimitives=c.scenePrimitives,exports.sparklineOptions=r.sparklineOptions;
|
package/dist/charts/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { Chart } from './react/Chart.cjs';
|
|
2
|
-
export { BarChart, LineChart, QuadrantChart, ScatterChart, } from './react/charts.cjs';
|
|
3
|
-
export
|
|
2
|
+
export { AreaChart, BarChart, CandlestickChart, HeatmapChart, LineChart, QuadrantChart, ScatterChart, Sparkline, } from './react/charts.cjs';
|
|
3
|
+
export { DonutChart, FunnelChart, GaugeChart, PieChart, RadarChart, TreemapChart, } from './react/shapes.cjs';
|
|
4
|
+
export type { AreaChartProps, BarChartProps, CandlestickChartProps, ChartCommonProps, ChartHandle, ChartProps, HeatmapChartProps, LineChartProps, QuadrantChartProps, QuadrantDropTarget, ScatterChartProps, SparklineProps, } from './react/types.cjs';
|
|
5
|
+
export type { DonutChartProps, FunnelChartProps, GaugeChartProps, PieChartProps, RadarChartProps, ShapeChartCommonProps, ShapeChartHandle, TreemapChartProps, } from './react/shapes.cjs';
|
|
4
6
|
export * from './core.cjs';
|
package/dist/charts/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { Chart } from './react/Chart.js';
|
|
2
|
-
export { BarChart, LineChart, QuadrantChart, ScatterChart, } from './react/charts.js';
|
|
3
|
-
export
|
|
2
|
+
export { AreaChart, BarChart, CandlestickChart, HeatmapChart, LineChart, QuadrantChart, ScatterChart, Sparkline, } from './react/charts.js';
|
|
3
|
+
export { DonutChart, FunnelChart, GaugeChart, PieChart, RadarChart, TreemapChart, } from './react/shapes.js';
|
|
4
|
+
export type { AreaChartProps, BarChartProps, CandlestickChartProps, ChartCommonProps, ChartHandle, ChartProps, HeatmapChartProps, LineChartProps, QuadrantChartProps, QuadrantDropTarget, ScatterChartProps, SparklineProps, } from './react/types.js';
|
|
5
|
+
export type { DonutChartProps, FunnelChartProps, GaugeChartProps, PieChartProps, RadarChartProps, ShapeChartCommonProps, ShapeChartHandle, TreemapChartProps, } from './react/shapes.js';
|
|
4
6
|
export * from './core.js';
|
package/dist/charts/index.js
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
import { formatCompact as e } from "./engine/format.js";
|
|
3
3
|
import { createChart as t } from "./engine/chart.js";
|
|
4
4
|
import { Chart as n } from "./react/Chart.js";
|
|
5
|
-
import {
|
|
5
|
+
import { heatmapChartOptions as r, quadrantCenter as i, quadrantChartOptions as a, quadrantOf as o, sparklineOptions as s } from "./engine/presets.js";
|
|
6
|
+
import { AreaChart as c, BarChart as l, CandlestickChart as u, HeatmapChart as d, LineChart as f, QuadrantChart as p, ScatterChart as m, Sparkline as h } from "./react/charts.js";
|
|
7
|
+
import { createShapeChart as g } from "./engine/shapes/chart.js";
|
|
8
|
+
import { DonutChart as _, FunnelChart as v, GaugeChart as y, PieChart as b, RadarChart as x, TreemapChart as S } from "./react/shapes.js";
|
|
9
|
+
import { createCanvasShapeChart as C } from "./engine/shapes/canvas.js";
|
|
10
|
+
import { createChartController as w, scenePrimitives as T } from "./engine/controller.js";
|
|
11
|
+
import { createCanvasChart as E } from "./engine/canvas.js";
|
|
6
12
|
import "./core.js";
|
|
7
|
-
export {
|
|
13
|
+
export { c as AreaChart, l as BarChart, u as CandlestickChart, n as Chart, _ as DonutChart, v as FunnelChart, y as GaugeChart, d as HeatmapChart, f as LineChart, b as PieChart, p as QuadrantChart, x as RadarChart, m as ScatterChart, h as Sparkline, S as TreemapChart, E as createCanvasChart, C as createCanvasShapeChart, t as createChart, w as createChartController, g as createShapeChart, e as formatCompact, r as heatmapChartOptions, i as quadrantCenter, a as quadrantChartOptions, o as quadrantOf, T as scenePrimitives, s as sparklineOptions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../engine/chart.cjs");let t=require("react"),n=require("react/jsx-runtime");var
|
|
1
|
+
"use client";const e=require("../engine/chart.cjs");let t=require("react"),n=require("react-dom"),r=require("react/jsx-runtime");var i=(e,t)=>e===void 0?t:typeof e==`number`?`${e}px`:e,a=e=>({series:e.series,xAxis:e.xAxis,yAxis:e.yAxis,renderer:e.renderer,legend:e.legend,tooltip:e.tooltip,crosshair:e.crosshair,annotations:e.annotations,interaction:e.interaction,padding:e.padding,palette:e.palette,ariaLabel:e.ariaLabel,stackMode:e.stackMode}),o=e=>{if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},s=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n]&&Object.prototype.hasOwnProperty.call(t,n))},c=(e,t)=>e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):o(e)&&o(t)&&s(e,t),l=(e,t)=>{if(e===t)return!0;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>{if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(n!==`series`)return c(e[n],t[n]);let r=e.series,i=t.series;return r===i||r.length===i.length&&r.every((e,t)=>e===i[t]||s(e,i[t]))})},u=(e,t)=>!!e&&e.x===t.x&&e.xLabel===t.xLabel&&e.items.length===t.items.length&&e.items.every((e,n)=>s(e,t.items[n]));function d({options:a,height:o,width:s,className:c,style:d,handleRef:f,renderTooltip:p,overlay:m,...h}){let g=(0,t.useRef)(null),_=(0,t.useRef)(null),v=(0,t.useRef)(h),y=(0,t.useRef)(p),b=(0,t.useRef)(null),[x,S]=(0,t.useState)(null),[C,w]=(0,t.useState)(null),T=(0,t.useMemo)(()=>typeof document>`u`?null:document.createElement(`div`),[]),[E,D]=(0,t.useState)(a);E!==a&&!l(E,a)&&D(a);let O=!!p,k=(0,t.useMemo)(()=>{if(!O||!T||E.tooltip===!1)return E;let e=typeof E.tooltip==`object`?E.tooltip:{};return{...E,tooltip:{...e,render:e=>y.current?(u(b.current,e)||(b.current=e,(0,n.flushSync)(()=>S(e))),T):null}}},[E,O,T]),A=(0,t.useRef)(k);return(0,t.useEffect)(()=>{v.current=h,y.current=p}),(0,t.useEffect)(()=>{let t=g.current;if(!t)return;let n=e.createChart(t,A.current);_.current=n;let r=[n.on(`hover`,e=>v.current.onHover?.(e)),n.on(`click`,e=>v.current.onPointClick?.(e)),n.on(`plotClick`,e=>v.current.onPlotClick?.(e)),n.on(`zoom`,e=>v.current.onZoom?.(e)),n.on(`renderer`,e=>v.current.onRendererChange?.(e)),n.on(`drag`,e=>v.current.onDrag?.(e)),n.on(`drop`,e=>v.current.onDrop?.(e)),n.on(`layout`,e=>w(e))];return()=>{r.forEach(e=>e()),n.destroy(),_.current=null}},[]),(0,t.useEffect)(()=>{A.current!==k&&(A.current=k,_.current?.setOptions(k))},[k]),(0,t.useImperativeHandle)(f,()=>({resetZoom:()=>_.current?.resetZoom(),getView:()=>_.current?.getView()??null,setView:e=>_.current?.setView(e),getRenderer:()=>_.current?.getRenderer()??null,getInstance:()=>_.current}),[]),(0,r.jsxs)(`div`,{className:c,style:{position:`relative`,width:i(s,`100%`),height:i(o,`320px`),...d},children:[(0,r.jsx)(`div`,{ref:g,style:{position:`absolute`,inset:0}}),m&&C&&(0,r.jsx)(`div`,{className:`minerva-chart-overlay`,style:{position:`absolute`,left:C.x,top:C.y,width:C.width,height:C.height,pointerEvents:`none`},children:m(C)}),T&&x&&p&&(0,n.createPortal)(p(x),T)]})}function f(e){let{height:t,width:n,className:i,style:o,ref:s,onHover:c,onPointClick:l,onPlotClick:u,onZoom:f,onRendererChange:p,renderTooltip:m}=e;return(0,r.jsx)(d,{options:a(e),height:t,width:n,className:i,style:o,handleRef:s,onHover:c,onPointClick:l,onPlotClick:u,onZoom:f,onRendererChange:p,renderTooltip:m})}exports.Chart=f,exports.ChartBase=d,exports.engineOptions=a,exports.sameOptions=l;
|
|
2
2
|
//# sourceMappingURL=Chart.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.cjs","names":["useRef","createChart","require_chart","react","react_jsx_runtime","size","value","fallback","engineOptions","props","ChartBase","handlers","containerRef","chartRef","handlersRef","optionsRef","options","container","chart","offs","v","r","off","handleRef","view","width","height","style","Chart","ref"],"sources":["../../../../charts/src/react/Chart.tsx"],"sourcesContent":["import {\n useEffect,\n useImperativeHandle,\n useRef,\n type CSSProperties,\n} from \"react\";\nimport { createChart } from \"../engine/chart\";\nimport type {\n ChartHoverEvent,\n ChartInstance,\n ChartOptions,\n ChartRendererKind,\n ChartView,\n} from \"../engine/types\";\nimport type { ChartCommonProps, ChartProps } from \"./types\";\n\ninterface Handlers {\n onHover?: (event: ChartHoverEvent | null) => void;\n onPointClick?: (event: ChartHoverEvent) => void;\n onZoom?: (view: ChartView) => void;\n onRendererChange?: (renderer: ChartRendererKind) => void;\n}\n\nconst size = (value: number | string | undefined, fallback: string) =>\n value === undefined\n ? fallback\n : typeof value === \"number\"\n ? `${value}px`\n : value;\n\n/** Engine options of the common props */\nexport const engineOptions = (\n props: Omit<ChartCommonProps, \"onPointClick\"> & Pick<ChartOptions, \"series\">,\n): ChartOptions => ({\n series: props.series,\n xAxis: props.xAxis,\n yAxis: props.yAxis,\n renderer: props.renderer,\n legend: props.legend,\n tooltip: props.tooltip,\n crosshair: props.crosshair,\n annotations: props.annotations,\n interaction: props.interaction,\n padding: props.padding,\n palette: props.palette,\n ariaLabel: props.ariaLabel,\n});\n\ninterface ChartBaseProps extends Handlers {\n options: ChartOptions;\n height?: number | string;\n width?: number | string;\n className?: string;\n style?: CSSProperties;\n handleRef?: ChartCommonProps[\"ref\"];\n}\n\n/** Mounts the engine in a sized <div> and forwards option / handler changes */\nexport function ChartBase({\n options,\n height,\n width,\n className,\n style,\n handleRef,\n ...handlers\n}: ChartBaseProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const chartRef = useRef<ChartInstance | null>(null);\n const handlersRef = useRef<Handlers>(handlers);\n const optionsRef = useRef(options);\n\n useEffect(() => {\n handlersRef.current = handlers;\n });\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n const chart = createChart(container, optionsRef.current);\n chartRef.current = chart;\n const offs = [\n chart.on(\"hover\", (e) => handlersRef.current.onHover?.(e)),\n chart.on(\"click\", (e) => handlersRef.current.onPointClick?.(e)),\n chart.on(\"zoom\", (v) => handlersRef.current.onZoom?.(v)),\n chart.on(\"renderer\", (r) => handlersRef.current.onRendererChange?.(r)),\n ];\n return () => {\n offs.forEach((off) => off());\n chart.destroy();\n chartRef.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (optionsRef.current === options) return;\n optionsRef.current = options;\n chartRef.current?.setOptions(options);\n }, [options]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n resetZoom: () => chartRef.current?.resetZoom(),\n getView: () => chartRef.current?.getView() ?? null,\n setView: (view) => chartRef.current?.setView(view),\n getRenderer: () => chartRef.current?.getRenderer() ?? null,\n getInstance: () => chartRef.current,\n }),\n [],\n );\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={{\n position: \"relative\",\n width: size(width, \"100%\"),\n height: size(height, \"320px\"),\n ...style,\n }}\n />\n );\n}\n\n/**\n * GPU chart (WebGPU, then WebGL2, then Canvas2D) mixing line, area, bar and\n * scatter series; zoomable, keyboard accessible and themed by the Minerva\n * CSS variables.\n */\nexport function Chart(props: ChartProps) {\n const {\n height,\n width,\n className,\n style,\n ref,\n onHover,\n onPointClick,\n onZoom,\n onRendererChange,\n } = props;\n return (\n <ChartBase\n options={engineOptions(props)}\n height={height}\n width={width}\n className={className}\n style={style}\n handleRef={ref}\n onHover={onHover}\n onPointClick={onPointClick}\n onZoom={onZoom}\n onRendererChange={onRendererChange}\n />\n );\n}\n"],"mappings":"0GAuBA,IAAMK,GAAQ,EAAoC,IAChDC,IAAU,IAAA,GACNC,EACA,OAAOD,GAAU,SACf,G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EAAW,QAAUA,EACrBH,EAAS,SAAS,WAAWG,CAAO,EACtC,EAAG,CAACA,CAAO,CAAC,GAEZ,EAAAb,EAAA,oBAAA,CACEoB,OACO,CACL,cAAiBV,EAAS,SAAS,UAAU,EAC7C,YAAeA,EAAS,SAAS,QAAQ,GAAK,KAC9C,QAAU,GAASA,EAAS,SAAS,QAAQW,CAAI,EACjD,gBAAmBX,EAAS,SAAS,YAAY,GAAK,KACtD,gBAAmBA,EAAS,OAC9B,GACA,CAAC,CACH,GAGE,EAAAT,EAAA,IAAA,CAAC,MAAD,CACE,IAAKQ,EACM,YACX,MAAO,CACL,SAAU,WACV,MAAOP,EAAKoB,EAAO,MAAM,EACzB,OAAQpB,EAAKqB,EAAQ,OAAO,EAC5B,GAAGC,CACL,CACD,CAAA,CAEL,CAOA,SAAgBC,EAAM,EAAmB,CACvC,GAAM,CACJ,SACA,QACA,YACA,QACA,MACA,UACA,eACA,SACA,oBACEnB,EACJ,OACE,EAAAL,EAAA,IAAA,CAACM,EAAD,CACE,QAASF,EAAcC,CAAK,EACpB,SACD,QACI,YACJ,QACP,UAAWoB,EACF,UACK,eACN,SACU,kBACnB,CAAA,CAEL"}
|
|
1
|
+
{"version":3,"file":"Chart.cjs","names":["useRef","useState","useMemo","createChart","createPortal","require_chart","react","react_dom","react_jsx_runtime","size","value","fallback","engineOptions","props","isPlainObject","proto","shallowEqual","keys","a","b","key","sameValue","v","i","sameOptions","sa","sb","s","sameTooltipEvent","item","ChartBase","handlers","containerRef","chartRef","handlersRef","tooltipRef","renderTooltip","tipEventRef","tipEvent","setTipEvent","plot","setPlot","tipHost","stable","setStable","options","hasTooltip","resolved","base","event","optionsRef","container","chart","offs","r","rect","off","handleRef","view","width","height","style","overlay","Chart","ref"],"sources":["../../../../charts/src/react/Chart.tsx"],"sourcesContent":["import {\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { createChart } from \"../engine/chart\";\nimport type {\n ChartDragEvent,\n ChartHoverEvent,\n ChartInstance,\n ChartOptions,\n ChartPlotClickEvent,\n ChartRect,\n ChartRendererKind,\n ChartView,\n} from \"../engine/types\";\nimport type { ChartCommonProps, ChartProps } from \"./types\";\n\ninterface Handlers {\n onHover?: (event: ChartHoverEvent | null) => void;\n onPointClick?: (event: ChartHoverEvent) => void;\n onPlotClick?: (event: ChartPlotClickEvent) => void;\n onZoom?: (view: ChartView) => void;\n onRendererChange?: (renderer: ChartRendererKind) => void;\n onDrag?: (event: ChartDragEvent) => void;\n onDrop?: (event: ChartDragEvent) => void;\n}\n\nconst size = (value: number | string | undefined, fallback: string) =>\n value === undefined\n ? fallback\n : typeof value === \"number\"\n ? `${value}px`\n : value;\n\n/** Engine options of the common props */\nexport const engineOptions = (\n props: Pick<\n ChartCommonProps,\n | \"xAxis\"\n | \"yAxis\"\n | \"renderer\"\n | \"legend\"\n | \"tooltip\"\n | \"crosshair\"\n | \"annotations\"\n | \"interaction\"\n | \"padding\"\n | \"palette\"\n | \"ariaLabel\"\n > &\n Pick<ChartOptions, \"series\" | \"stackMode\">,\n): ChartOptions => ({\n series: props.series,\n xAxis: props.xAxis,\n yAxis: props.yAxis,\n renderer: props.renderer,\n legend: props.legend,\n tooltip: props.tooltip,\n crosshair: props.crosshair,\n annotations: props.annotations,\n interaction: props.interaction,\n padding: props.padding,\n palette: props.palette,\n ariaLabel: props.ariaLabel,\n stackMode: props.stackMode,\n});\n\ninterface ChartBaseProps extends Handlers {\n options: ChartOptions;\n height?: number | string;\n width?: number | string;\n className?: string;\n style?: CSSProperties;\n handleRef?: ChartCommonProps[\"ref\"];\n /** React content of the tooltip (replaces the engine's content) */\n renderTooltip?: (event: ChartHoverEvent) => ReactNode;\n /** React content placed over the chart, given the plot area */\n overlay?: (plot: ChartRect) => ReactNode;\n}\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== \"object\" || value === null) return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n};\n\n/** Same keys with identical values */\nconst shallowEqual = (\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n): boolean => {\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every(\n (key) => a[key] === b[key] && Object.prototype.hasOwnProperty.call(b, key),\n );\n};\n\n/**\n * Identical values, or plain arrays / objects whose items are identical\n * (`[\"#f00\"]`, `{ title: \"x\" }` written inline)\n */\nconst sameValue = (a: unknown, b: unknown): boolean => {\n if (a === b) return true;\n if (Array.isArray(a) && Array.isArray(b))\n return a.length === b.length && a.every((v, i) => v === b[i]);\n return isPlainObject(a) && isPlainObject(b) && shallowEqual(a, b);\n};\n\n/**\n * Whether `b` describes the same chart as `a`: top-level options compared by\n * identity (or one level deep for inline arrays / objects), series compared\n * one by one, each series shallowly (inline `series={[{ name, data }]}`\n * with a stable `data` stays equal). Data is never compared by content.\n */\nexport const sameOptions = (a: ChartOptions, b: ChartOptions): boolean => {\n if (a === b) return true;\n const keys = Object.keys(a) as (keyof ChartOptions)[];\n if (keys.length !== Object.keys(b).length) return false;\n return keys.every((key) => {\n if (!Object.prototype.hasOwnProperty.call(b, key)) return false;\n if (key !== \"series\") return sameValue(a[key], b[key]);\n const sa = a.series;\n const sb = b.series;\n return (\n sa === sb ||\n (sa.length === sb.length &&\n sa.every(\n (s, i) =>\n s === sb[i] ||\n shallowEqual(\n s as unknown as Record<string, unknown>,\n sb[i] as unknown as Record<string, unknown>,\n ),\n ))\n );\n });\n};\n\n/** Same hovered points with the same values (same tooltip content) */\nconst sameTooltipEvent = (\n a: ChartHoverEvent | null,\n b: ChartHoverEvent,\n): boolean =>\n !!a &&\n a.x === b.x &&\n a.xLabel === b.xLabel &&\n a.items.length === b.items.length &&\n a.items.every((item, i) =>\n shallowEqual(\n item as unknown as Record<string, unknown>,\n b.items[i] as unknown as Record<string, unknown>,\n ),\n );\n\n/** Mounts the engine in a sized <div> and forwards option / handler changes */\nexport function ChartBase({\n options,\n height,\n width,\n className,\n style,\n handleRef,\n renderTooltip,\n overlay,\n ...handlers\n}: ChartBaseProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const chartRef = useRef<ChartInstance | null>(null);\n const handlersRef = useRef<Handlers>(handlers);\n const tooltipRef = useRef(renderTooltip);\n const tipEventRef = useRef<ChartHoverEvent | null>(null);\n const [tipEvent, setTipEvent] = useState<ChartHoverEvent | null>(null);\n const [plot, setPlot] = useState<ChartRect | null>(null);\n const tipHost = useMemo(\n () =>\n typeof document === \"undefined\" ? null : document.createElement(\"div\"),\n [],\n );\n\n // Parents pass a new options object on every render: keep the previous\n // one while it describes the same chart, so the engine isn't rebuilt\n // (state derived during render, the pattern React documents for it)\n const [stable, setStable] = useState(options);\n if (stable !== options && !sameOptions(stable, options)) setStable(options);\n // the render callback reads the latest `renderTooltip` through a ref: only\n // its presence matters here (inline callbacks change on every render)\n const hasTooltip = !!renderTooltip;\n\n const resolved = useMemo((): ChartOptions => {\n if (!hasTooltip || !tipHost || stable.tooltip === false) return stable;\n const base = typeof stable.tooltip === \"object\" ? stable.tooltip : {};\n return {\n ...stable,\n tooltip: {\n ...base,\n render: (event) => {\n if (!tooltipRef.current) return null;\n // render synchronously so the engine measures the final size;\n // pointer moves over the same points keep the rendered content\n if (!sameTooltipEvent(tipEventRef.current, event)) {\n tipEventRef.current = event;\n flushSync(() => setTipEvent(event));\n }\n return tipHost;\n },\n },\n };\n }, [stable, hasTooltip, tipHost]);\n const optionsRef = useRef(resolved);\n\n useEffect(() => {\n handlersRef.current = handlers;\n tooltipRef.current = renderTooltip;\n });\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n const chart = createChart(container, optionsRef.current);\n chartRef.current = chart;\n const offs = [\n chart.on(\"hover\", (e) => handlersRef.current.onHover?.(e)),\n chart.on(\"click\", (e) => handlersRef.current.onPointClick?.(e)),\n chart.on(\"plotClick\", (e) => handlersRef.current.onPlotClick?.(e)),\n chart.on(\"zoom\", (v) => handlersRef.current.onZoom?.(v)),\n chart.on(\"renderer\", (r) => handlersRef.current.onRendererChange?.(r)),\n chart.on(\"drag\", (e) => handlersRef.current.onDrag?.(e)),\n chart.on(\"drop\", (e) => handlersRef.current.onDrop?.(e)),\n chart.on(\"layout\", (rect) => setPlot(rect)),\n ];\n return () => {\n offs.forEach((off) => off());\n chart.destroy();\n chartRef.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (optionsRef.current === resolved) return;\n optionsRef.current = resolved;\n chartRef.current?.setOptions(resolved);\n }, [resolved]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n resetZoom: () => chartRef.current?.resetZoom(),\n getView: () => chartRef.current?.getView() ?? null,\n setView: (view) => chartRef.current?.setView(view),\n getRenderer: () => chartRef.current?.getRenderer() ?? null,\n getInstance: () => chartRef.current,\n }),\n [],\n );\n\n return (\n <div\n className={className}\n style={{\n position: \"relative\",\n width: size(width, \"100%\"),\n height: size(height, \"320px\"),\n ...style,\n }}\n >\n <div ref={containerRef} style={{ position: \"absolute\", inset: 0 }} />\n {overlay && plot && (\n <div\n className=\"minerva-chart-overlay\"\n style={{\n position: \"absolute\",\n left: plot.x,\n top: plot.y,\n width: plot.width,\n height: plot.height,\n pointerEvents: \"none\",\n }}\n >\n {overlay(plot)}\n </div>\n )}\n {tipHost &&\n tipEvent &&\n renderTooltip &&\n createPortal(renderTooltip(tipEvent), tipHost)}\n </div>\n );\n}\n\n/**\n * GPU chart (WebGPU, then WebGL2, then Canvas2D) mixing line, area, bar and\n * scatter series; zoomable, keyboard accessible and themed by the Minerva\n * CSS variables.\n */\nexport function Chart(props: ChartProps) {\n const {\n height,\n width,\n className,\n style,\n ref,\n onHover,\n onPointClick,\n onPlotClick,\n onZoom,\n onRendererChange,\n renderTooltip,\n } = props;\n return (\n <ChartBase\n options={engineOptions(props)}\n height={height}\n width={width}\n className={className}\n style={style}\n handleRef={ref}\n onHover={onHover}\n onPointClick={onPointClick}\n onPlotClick={onPlotCl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