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":"overlay.cjs","names":["toCss","require_color","font","theme","weight","size","crisp","v","rectOf","s","xa","a","xb","ya","yb","left","plot","right","top","bottom","drawBackground","input","scales","ctx","r","y","yTicks","py","x","xTicks","px","line","base","lastRight","order","i","b","w","text","overlaps","inside","haloText","halo","color","placeLabels","placed","label","labels","measure","gap","box","height","c","occupied","o","drawForeground","labelHeight","pos","tx","ty","textColor","t"],"sources":["../../../../charts/src/engine/overlay.ts"],"sourcesContent":["// Canvas2D layers around the data: background (areas, grid, axes, tick\n// labels) and foreground (reference lines, annotation and point labels).\n\nimport { toCss, type Rgba } from \"./color\";\nimport type { AxisTicks } from \"./axis\";\nimport type { Rect, Scales } from \"./layout\";\nimport type { AxisModel } from \"./model\";\nimport type { ChartTheme } from \"./theme\";\nimport type { ChartLabelPosition } from \"./types\";\n\nexport interface ResolvedRect {\n type: \"rect\";\n x0?: number;\n x1?: number;\n y0?: number;\n y1?: number;\n color: Rgba;\n opacity: number;\n label?: string;\n labelPosition: ChartLabelPosition;\n labelColor: Rgba;\n}\n\nexport interface ResolvedLine {\n type: \"line\";\n axis: \"x\" | \"y\";\n value: number;\n color: Rgba;\n width: number;\n dash: number[];\n label?: string;\n}\n\nexport type ResolvedAnnotation = ResolvedRect | ResolvedLine;\n\nexport interface PointLabel {\n x: number;\n y: number;\n /** Radius of the dot */\n r: number;\n text: string;\n}\n\nexport const font = (theme: ChartTheme, size = theme.fontSize, weight = 400) =>\n `${weight} ${size}px ${theme.fontFamily}`;\n\nconst crisp = (v: number) => Math.round(v) + 0.5;\n\nconst rectOf = (a: ResolvedRect, s: Scales): Rect => {\n const { plot } = s;\n const xa = a.x0 === undefined ? -Infinity : s.xToPx(a.x0);\n const xb = a.x1 === undefined ? Infinity : s.xToPx(a.x1);\n const ya = a.y0 === undefined ? Infinity : s.yToPx(a.y0);\n const yb = a.y1 === undefined ? -Infinity : s.yToPx(a.y1);\n const left = Math.max(plot.x, Math.min(xa, xb));\n const right = Math.min(plot.x + plot.width, Math.max(xa, xb));\n const top = Math.max(plot.y, Math.min(ya, yb));\n const bottom = Math.min(plot.y + plot.height, Math.max(ya, yb));\n return { x: left, y: top, width: right - left, height: bottom - top };\n};\n\nexport interface BackgroundInput {\n width: number;\n height: number;\n scales: Scales;\n x: AxisModel;\n y: AxisModel;\n xTicks: AxisTicks;\n yTicks: AxisTicks;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n}\n\nexport const drawBackground = (\n ctx: CanvasRenderingContext2D,\n input: BackgroundInput,\n) => {\n const { scales, theme, x, y, xTicks, yTicks } = input;\n const { plot } = scales;\n ctx.clearRect(0, 0, input.width, input.height);\n\n // areas\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n for (const a of input.annotations) {\n if (a.type !== \"rect\") continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n ctx.fillStyle = toCss(a.color, a.opacity);\n ctx.fillRect(r.x, r.y, r.width, r.height);\n }\n ctx.restore();\n\n // grid\n ctx.lineWidth = 1;\n ctx.strokeStyle = toCss(theme.grid);\n ctx.beginPath();\n if (y.grid) {\n for (const v of yTicks.values) {\n const py = crisp(scales.yToPx(v));\n if (py < plot.y - 1 || py > plot.y + plot.height + 1) continue;\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n }\n }\n if (x.grid) {\n for (const v of xTicks.values) {\n const px = crisp(scales.xToPx(v));\n if (px < plot.x - 1 || px > plot.x + plot.width + 1) continue;\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n }\n }\n ctx.stroke();\n\n const line = Math.ceil(theme.fontSize * 1.4);\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n\n // x axis\n if (x.visible) {\n ctx.strokeStyle = toCss(theme.axis);\n ctx.beginPath();\n const base = crisp(plot.y + plot.height);\n ctx.moveTo(plot.x, base);\n ctx.lineTo(plot.x + plot.width, base);\n ctx.stroke();\n ctx.textBaseline = \"top\";\n ctx.textAlign = \"center\";\n let lastRight = -Infinity;\n // left to right (reversed axes list their ticks right to left)\n const order = xTicks.values\n .map((v, i) => ({ px: scales.xToPx(v), text: xTicks.labels[i] }))\n .sort((a, b) => a.px - b.px);\n for (const { px, text } of order) {\n if (px < plot.x - 0.5 || px > plot.x + plot.width + 0.5) continue;\n const w = ctx.measureText(text).width;\n const left = Math.max(0, Math.min(input.width - w, px - w / 2));\n if (left < lastRight + 6) continue;\n lastRight = left + w;\n ctx.fillText(text, left + w / 2, plot.y + plot.height + 7);\n }\n if (x.title) {\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.fillText(\n x.title,\n plot.x + plot.width / 2,\n plot.y + plot.height + line + 10,\n );\n }\n }\n\n // y axis\n if (y.visible) {\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"middle\";\n yTicks.values.forEach((v, i) => {\n const py = scales.yToPx(v);\n if (py < plot.y - 0.5 || py > plot.y + plot.height + 0.5) return;\n ctx.fillText(yTicks.labels[i], plot.x - 8, py);\n });\n if (y.title) {\n ctx.save();\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.translate(line / 2 + 4, plot.y + plot.height / 2);\n ctx.rotate(-Math.PI / 2);\n ctx.textAlign = \"center\";\n ctx.fillText(y.title, 0, 0);\n ctx.restore();\n }\n }\n};\n\nconst overlaps = (a: Rect, b: Rect) =>\n a.x < b.x + b.width &&\n b.x < a.x + a.width &&\n a.y < b.y + b.height &&\n b.y < a.y + a.height;\n\nconst inside = (r: Rect, plot: Rect) =>\n r.x >= plot.x &&\n r.y >= plot.y &&\n r.x + r.width <= plot.x + plot.width &&\n r.y + r.height <= plot.y + plot.height;\n\n/** Text with a halo in the background color (readable over data) */\nconst haloText = (\n ctx: CanvasRenderingContext2D,\n text: string,\n x: number,\n y: number,\n color: string,\n halo: string,\n) => {\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = halo;\n ctx.strokeText(text, x, y);\n ctx.fillStyle = color;\n ctx.fillText(text, x, y);\n};\n\n/** Greedy placement: right, left, above, below the dot; skipped when no slot is free */\nexport const placeLabels = (\n labels: readonly PointLabel[],\n plot: Rect,\n measure: (text: string) => number,\n height: number,\n occupied: Rect[] = [],\n): { label: PointLabel; box: Rect }[] => {\n const placed: { label: PointLabel; box: Rect }[] = [];\n for (const label of labels) {\n const w = measure(label.text);\n const gap = label.r + 4;\n const candidates: Rect[] = [\n { x: label.x + gap, y: label.y - height / 2, width: w, height },\n { x: label.x - gap - w, y: label.y - height / 2, width: w, height },\n { x: label.x - w / 2, y: label.y - gap - height, width: w, height },\n { x: label.x - w / 2, y: label.y + gap, width: w, height },\n ];\n const box = candidates.find(\n (c) => inside(c, plot) && !occupied.some((o) => overlaps(o, c)),\n );\n if (!box) continue;\n occupied.push(box);\n placed.push({ label, box });\n }\n return placed;\n};\n\nexport interface ForegroundInput {\n width: number;\n height: number;\n scales: Scales;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n pointLabels: readonly PointLabel[];\n}\n\nexport const drawForeground = (\n ctx: CanvasRenderingContext2D,\n input: ForegroundInput,\n) => {\n const { scales, theme } = input;\n const { plot } = scales;\n ctx.clearRect(0, 0, input.width, input.height);\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n\n const halo = toCss(theme.background, 0.9);\n const occupied: Rect[] = [];\n const labelHeight = theme.fontSize + 4;\n\n for (const a of input.annotations) {\n if (a.type !== \"line\") continue;\n const color = toCss(a.color);\n ctx.strokeStyle = color;\n ctx.lineWidth = a.width;\n ctx.setLineDash(a.dash);\n ctx.beginPath();\n if (a.axis === \"y\") {\n const py = crisp(scales.yToPx(a.value));\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"bottom\";\n haloText(ctx, a.label, plot.x + plot.width - 6, py - 3, color, halo);\n }\n } else {\n const px = crisp(scales.xToPx(a.value));\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n haloText(ctx, a.label, px + 5, plot.y + 5, color, halo);\n }\n }\n }\n ctx.setLineDash([]);\n\n // labels of areas\n ctx.font = font(theme, theme.fontSize + 1, 600);\n for (const a of input.annotations) {\n if (a.type !== \"rect\" || !a.label) continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n const pad = 10;\n const w = ctx.measureText(a.label).width;\n const pos = a.labelPosition;\n const tx = pos.endsWith(\"left\")\n ? r.x + pad\n : pos.endsWith(\"right\")\n ? r.x + r.width - pad - w\n : r.x + (r.width - w) / 2;\n const ty = pos.startsWith(\"top\")\n ? r.y + pad\n : pos.startsWith(\"bottom\")\n ? r.y + r.height - pad - labelHeight\n : r.y + (r.height - labelHeight) / 2;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n ctx.fillStyle = toCss(a.labelColor);\n ctx.fillText(a.label, tx, ty);\n occupied.push({ x: tx, y: ty, width: w, height: labelHeight });\n }\n\n // point labels\n if (input.pointLabels.length) {\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n const textColor = toCss(theme.text, 0.85);\n const placed = placeLabels(\n input.pointLabels,\n plot,\n (t) => ctx.measureText(t).width,\n labelHeight - 2,\n occupied,\n );\n for (const { label, box } of placed) {\n haloText(ctx, label.text, box.x, box.y + box.height / 2, textColor, halo);\n }\n }\n ctx.restore();\n};\n"],"mappings":"+BA2CA,IAAaE,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AKA,EAAE,MAAQa,GAAK,EACtBsB,EAAKF,EAAI,WAAW,KAAK,EAC3BjC,EAAE,EAAI,GACNiC,EAAI,WAAW,QAAQ,EACrBjC,EAAE,EAAIA,EAAE,OAAS,GAAMgC,EACvBhC,EAAE,GAAKA,EAAE,OAASgC,GAAe,EACvC,EAAI,UAAY,OAChB,EAAI,aAAe,MACnB,EAAI,UAAYxD,EAAAA,MAAMW,EAAE,UAAU,EAClCY,EAAI,SAASZ,EAAE,MAAO+C,EAAIC,CAAE,EAC5BN,EAAS,KAAK,CAAE,EAAGK,EAAI,EAAGC,EAAI,MAAOtB,EAAG,OAAQmB,CAAY,CAAC,CAC/D,CAGA,GAAInC,EAAM,YAAY,OAAQ,CAC5B,EAAI,KAAOnB,EAAKC,CAAK,EACrB,EAAI,UAAY,OAChB,EAAI,aAAe,SACnB,IAAMyD,EAAY5D,EAAAA,MAAMG,EAAM,KAAM,GAAI,EAClC0C,EAASD,EACbvB,EAAM,YACNL,EACC,GAAMO,EAAI,YAAYsC,CAAC,CAAC,CAAC,MAC1BL,EAAc,EACdH,CACF,EACA,IAAK,GAAM,CAAE,QAAO,SAASR,EAC3BJ,EAASlB,EAAKuB,EAAM,KAAMI,EAAI,EAAGA,EAAI,EAAIA,EAAI,OAAS,EAAGU,EAAWlB,CAAI,CAE5E,CACAnB,EAAI,QAAQ,CACd"}
|
|
1
|
+
{"version":3,"file":"overlay.cjs","names":["toCss","require_color","font","theme","weight","size","crisp","v","textBox","s","px","a","plot","py","x","width","y","height","rectOf","xa","xb","ya","yb","left","right","top","bottom","drawBackground","input","scales","ctx","r","yTicks","xTicks","line","base","lastRight","order","i","b","w","text","overlaps","inside","haloText","halo","color","placeLabels","placed","label","labels","measure","gap","above","below","box","c","occupied","o","drawForeground","labelHeight","pos","tx","ty","textColor","t"],"sources":["../../../../charts/src/engine/overlay.ts"],"sourcesContent":["// Canvas2D layers around the data: background (areas, grid, axes, tick\n// labels) and foreground (reference lines, annotation and point labels).\n\nimport { toCss, type Rgba } from \"./color\";\nimport type { AxisTicks } from \"./axis\";\nimport type { Rect, Scales } from \"./layout\";\nimport type { AxisModel } from \"./model\";\nimport type { ChartTheme } from \"./theme\";\nimport type { ChartLabelPosition } from \"./types\";\n\nexport interface ResolvedRect {\n type: \"rect\";\n x0?: number;\n x1?: number;\n y0?: number;\n y1?: number;\n color: Rgba;\n opacity: number;\n label?: string;\n labelPosition: ChartLabelPosition;\n labelColor: Rgba;\n}\n\nexport interface ResolvedLine {\n type: \"line\";\n axis: \"x\" | \"y\";\n value: number;\n color: Rgba;\n width: number;\n dash: number[];\n label?: string;\n}\n\nexport interface ResolvedText {\n type: \"text\";\n x?: number;\n y?: number;\n text: string;\n anchor: \"center\" | \"top\" | \"bottom\" | \"left\" | \"right\";\n color: Rgba;\n weight: number;\n}\n\nexport type ResolvedAnnotation = ResolvedRect | ResolvedLine | ResolvedText;\n\nexport interface PointLabel {\n x: number;\n y: number;\n /** Radius of the dot */\n r: number;\n text: string;\n /** Fixed side (bar values); any free side around the dot otherwise */\n placement?: \"above\" | \"below\";\n}\n\nexport const font = (theme: ChartTheme, size = theme.fontSize, weight = 400) =>\n `${weight} ${size}px ${theme.fontFamily}`;\n\nconst crisp = (v: number) => Math.round(v) + 0.5;\n\n/** Box of a text annotation, kept inside the plot */\nexport const textBox = (\n a: ResolvedText,\n s: Scales,\n width: number,\n height: number,\n): Rect => {\n const { plot } = s;\n const px = a.x === undefined ? plot.x + plot.width / 2 : s.xToPx(a.x);\n const py = a.y === undefined ? plot.y + plot.height / 2 : s.yToPx(a.y);\n const gap = 6;\n let x = px - width / 2;\n let y = py - height / 2;\n if (a.anchor === \"top\") y = py + gap;\n else if (a.anchor === \"bottom\") y = py - gap - height;\n else if (a.anchor === \"left\") x = px + gap;\n else if (a.anchor === \"right\") x = px - gap - width;\n x = Math.max(plot.x + gap, Math.min(x, plot.x + plot.width - gap - width));\n y = Math.max(plot.y + 2, Math.min(y, plot.y + plot.height - 2 - height));\n return { x, y, width, height };\n};\n\nconst rectOf = (a: ResolvedRect, s: Scales): Rect => {\n const { plot } = s;\n const xa = a.x0 === undefined ? -Infinity : s.xToPx(a.x0);\n const xb = a.x1 === undefined ? Infinity : s.xToPx(a.x1);\n const ya = a.y0 === undefined ? Infinity : s.yToPx(a.y0);\n const yb = a.y1 === undefined ? -Infinity : s.yToPx(a.y1);\n const left = Math.max(plot.x, Math.min(xa, xb));\n const right = Math.min(plot.x + plot.width, Math.max(xa, xb));\n const top = Math.max(plot.y, Math.min(ya, yb));\n const bottom = Math.min(plot.y + plot.height, Math.max(ya, yb));\n return { x: left, y: top, width: right - left, height: bottom - top };\n};\n\nexport interface BackgroundInput {\n width: number;\n height: number;\n scales: Scales;\n x: AxisModel;\n y: AxisModel;\n xTicks: AxisTicks;\n yTicks: AxisTicks;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n}\n\nexport const drawBackground = (\n ctx: CanvasRenderingContext2D,\n input: BackgroundInput,\n) => {\n const { scales, theme, x, y, xTicks, yTicks } = input;\n const { plot } = scales;\n ctx.clearRect(0, 0, input.width, input.height);\n\n // areas\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n for (const a of input.annotations) {\n if (a.type !== \"rect\") continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n ctx.fillStyle = toCss(a.color, a.opacity);\n ctx.fillRect(r.x, r.y, r.width, r.height);\n }\n ctx.restore();\n\n // grid\n ctx.lineWidth = 1;\n ctx.strokeStyle = toCss(theme.grid);\n ctx.beginPath();\n if (y.grid) {\n for (const v of yTicks.values) {\n const py = crisp(scales.yToPx(v));\n if (py < plot.y - 1 || py > plot.y + plot.height + 1) continue;\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n }\n }\n if (x.grid) {\n for (const v of xTicks.values) {\n const px = crisp(scales.xToPx(v));\n if (px < plot.x - 1 || px > plot.x + plot.width + 1) continue;\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n }\n }\n ctx.stroke();\n\n const line = Math.ceil(theme.fontSize * 1.4);\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n\n // x axis\n if (x.visible) {\n ctx.strokeStyle = toCss(theme.axis);\n ctx.beginPath();\n const base = crisp(plot.y + plot.height);\n ctx.moveTo(plot.x, base);\n ctx.lineTo(plot.x + plot.width, base);\n ctx.stroke();\n ctx.textBaseline = \"top\";\n ctx.textAlign = \"center\";\n let lastRight = -Infinity;\n // left to right (reversed axes list their ticks right to left)\n const order = xTicks.values\n .map((v, i) => ({ px: scales.xToPx(v), text: xTicks.labels[i] }))\n .sort((a, b) => a.px - b.px);\n for (const { px, text } of order) {\n if (px < plot.x - 0.5 || px > plot.x + plot.width + 0.5) continue;\n const w = ctx.measureText(text).width;\n const left = Math.max(0, Math.min(input.width - w, px - w / 2));\n if (left < lastRight + 6) continue;\n lastRight = left + w;\n ctx.fillText(text, left + w / 2, plot.y + plot.height + 7);\n }\n if (x.title) {\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.fillText(\n x.title,\n plot.x + plot.width / 2,\n plot.y + plot.height + line + 10,\n );\n }\n }\n\n // y axis\n if (y.visible) {\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"middle\";\n yTicks.values.forEach((v, i) => {\n const py = scales.yToPx(v);\n if (py < plot.y - 0.5 || py > plot.y + plot.height + 0.5) return;\n ctx.fillText(yTicks.labels[i], plot.x - 8, py);\n });\n if (y.title) {\n ctx.save();\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.translate(line / 2 + 4, plot.y + plot.height / 2);\n ctx.rotate(-Math.PI / 2);\n ctx.textAlign = \"center\";\n ctx.fillText(y.title, 0, 0);\n ctx.restore();\n }\n }\n};\n\nconst overlaps = (a: Rect, b: Rect) =>\n a.x < b.x + b.width &&\n b.x < a.x + a.width &&\n a.y < b.y + b.height &&\n b.y < a.y + a.height;\n\nconst inside = (r: Rect, plot: Rect) =>\n r.x >= plot.x &&\n r.y >= plot.y &&\n r.x + r.width <= plot.x + plot.width &&\n r.y + r.height <= plot.y + plot.height;\n\n/** Text with a halo in the background color (readable over data) */\nconst haloText = (\n ctx: CanvasRenderingContext2D,\n text: string,\n x: number,\n y: number,\n color: string,\n halo: string,\n) => {\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = halo;\n ctx.strokeText(text, x, y);\n ctx.fillStyle = color;\n ctx.fillText(text, x, y);\n};\n\n/** Greedy placement: right, left, above, below the dot; skipped when no slot is free */\nexport const placeLabels = (\n labels: readonly PointLabel[],\n plot: Rect,\n measure: (text: string) => number,\n height: number,\n occupied: Rect[] = [],\n): { label: PointLabel; box: Rect }[] => {\n const placed: { label: PointLabel; box: Rect }[] = [];\n for (const label of labels) {\n const w = measure(label.text);\n const gap = label.r + 4;\n const above = {\n x: label.x - w / 2,\n y: label.y - gap - height,\n width: w,\n height,\n };\n const below = { x: label.x - w / 2, y: label.y + gap, width: w, height };\n const candidates: Rect[] =\n label.placement === \"above\"\n ? [above]\n : label.placement === \"below\"\n ? [below]\n : [\n { x: label.x + gap, y: label.y - height / 2, width: w, height },\n {\n x: label.x - gap - w,\n y: label.y - height / 2,\n width: w,\n height,\n },\n above,\n below,\n ];\n const box = candidates.find(\n (c) => inside(c, plot) && !occupied.some((o) => overlaps(o, c)),\n );\n if (!box) continue;\n occupied.push(box);\n placed.push({ label, box });\n }\n return placed;\n};\n\nexport interface ForegroundInput {\n width: number;\n height: number;\n scales: Scales;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n pointLabels: readonly PointLabel[];\n /**\n * Clears the canvas first (off when the layers share one canvas)\n * @default true\n */\n clear?: boolean;\n}\n\nexport const drawForeground = (\n ctx: CanvasRenderingContext2D,\n input: ForegroundInput,\n) => {\n const { scales, theme } = input;\n const { plot } = scales;\n if (input.clear !== false) ctx.clearRect(0, 0, input.width, input.height);\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n\n const halo = toCss(theme.background, 0.9);\n const occupied: Rect[] = [];\n const labelHeight = theme.fontSize + 4;\n\n for (const a of input.annotations) {\n if (a.type !== \"line\") continue;\n const color = toCss(a.color);\n ctx.strokeStyle = color;\n ctx.lineWidth = a.width;\n ctx.setLineDash(a.dash);\n ctx.beginPath();\n if (a.axis === \"y\") {\n const py = crisp(scales.yToPx(a.value));\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"bottom\";\n haloText(ctx, a.label, plot.x + plot.width - 6, py - 3, color, halo);\n }\n } else {\n const px = crisp(scales.xToPx(a.value));\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n haloText(ctx, a.label, px + 5, plot.y + 5, color, halo);\n }\n }\n }\n ctx.setLineDash([]);\n\n // labels of areas\n ctx.font = font(theme, theme.fontSize + 1, 600);\n for (const a of input.annotations) {\n if (a.type !== \"rect\" || !a.label) continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n const pad = 10;\n const w = ctx.measureText(a.label).width;\n const pos = a.labelPosition;\n const tx = pos.endsWith(\"left\")\n ? r.x + pad\n : pos.endsWith(\"right\")\n ? r.x + r.width - pad - w\n : r.x + (r.width - w) / 2;\n const ty = pos.startsWith(\"top\")\n ? r.y + pad\n : pos.startsWith(\"bottom\")\n ? r.y + r.height - pad - labelHeight\n : r.y + (r.height - labelHeight) / 2;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n ctx.fillStyle = toCss(a.labelColor);\n ctx.fillText(a.label, tx, ty);\n occupied.push({ x: tx, y: ty, width: w, height: labelHeight });\n }\n\n // free texts\n for (const a of input.annotations) {\n if (a.type !== \"text\" || !a.text) continue;\n ctx.font = font(theme, theme.fontSize, a.weight);\n const box = textBox(a, scales, ctx.measureText(a.text).width, labelHeight);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n haloText(ctx, a.text, box.x, box.y + box.height / 2, toCss(a.color), halo);\n occupied.push(box);\n }\n\n // point labels\n if (input.pointLabels.length) {\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n const textColor = toCss(theme.text, 0.85);\n const placed = placeLabels(\n input.pointLabels,\n plot,\n (t) => ctx.measureText(t).width,\n labelHeight - 2,\n occupied,\n );\n for (const { label, box } of placed) {\n haloText(ctx, label.text, box.x, box.y + box.height / 2, textColor, halo);\n }\n }\n ctx.restore();\n};\n"],"mappings":"+BAuDA,IAAaE,GAAQ,EAAmB,EAAOC,EAAM,SAAU,EAAS,MACtE,GAAGC,EAAO,GAAGC,EAAK,KAAKF,EAAM,aAEzBG,EAAS,GAAc,KAAK,MAAMC,CAAC,EAAI,GAGhCC,GACX,EACA,EACA,EACA,IACS,CACT,GAAM,CAAE,QAASC,EACXC,EAAKC,EAAE,IAAM,IAAA,GAAYC,EAAK,EAAIA,EAAK,MAAQ,EAAIH,EAAE,MAAME,EAAE,CAAC,EAC9DE,EAAKF,EAAE,IAAM,IAAA,GAAYC,EAAK,EAAIA,EAAK,OAAS,EAAIH,EAAE,MAAME,EAAE,CAAC,EAEjEG,EAAIJ,EAAKK,EAAQ,EACjBC,EAAIH,EAAKI,EAAS,EAOtB,OANIN,EAAE,SAAW,MAAO,EAAIE,EAAK,EACxBF,EAAE,SAAW,SAAU,EAAIE,EAAK,EAAMI,EACtCN,EAAE,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ACnB,CAGA,GAAI3B,EAAM,YAAY,OAAQ,CAC5B,EAAI,KAAO1B,EAAKC,CAAK,EACrB,EAAI,UAAY,OAChB,EAAI,aAAe,SACnB,IAAM6D,EAAYhE,EAAAA,MAAMG,EAAM,KAAM,GAAI,EAClC6C,EAASD,EACbnB,EAAM,YACNhB,EACC,GAAMkB,EAAI,YAAYmC,CAAC,CAAC,CAAC,MAC1BL,EAAc,EACdH,CACF,EACA,IAAK,GAAM,CAAE,QAAO,SAAST,EAC3BJ,EAASd,EAAKmB,EAAM,KAAMM,EAAI,EAAGA,EAAI,EAAIA,EAAI,OAAS,EAAGS,EAAWnB,CAAI,CAE5E,CACAf,EAAI,QAAQ,CACd"}
|
|
@@ -25,15 +25,28 @@ export interface ResolvedLine {
|
|
|
25
25
|
dash: number[];
|
|
26
26
|
label?: string;
|
|
27
27
|
}
|
|
28
|
-
export
|
|
28
|
+
export interface ResolvedText {
|
|
29
|
+
type: "text";
|
|
30
|
+
x?: number;
|
|
31
|
+
y?: number;
|
|
32
|
+
text: string;
|
|
33
|
+
anchor: "center" | "top" | "bottom" | "left" | "right";
|
|
34
|
+
color: Rgba;
|
|
35
|
+
weight: number;
|
|
36
|
+
}
|
|
37
|
+
export type ResolvedAnnotation = ResolvedRect | ResolvedLine | ResolvedText;
|
|
29
38
|
export interface PointLabel {
|
|
30
39
|
x: number;
|
|
31
40
|
y: number;
|
|
32
41
|
/** Radius of the dot */
|
|
33
42
|
r: number;
|
|
34
43
|
text: string;
|
|
44
|
+
/** Fixed side (bar values); any free side around the dot otherwise */
|
|
45
|
+
placement?: "above" | "below";
|
|
35
46
|
}
|
|
36
47
|
export declare const font: (theme: ChartTheme, size?: number, weight?: number) => string;
|
|
48
|
+
/** Box of a text annotation, kept inside the plot */
|
|
49
|
+
export declare const textBox: (a: ResolvedText, s: Scales, width: number, height: number) => Rect;
|
|
37
50
|
export interface BackgroundInput {
|
|
38
51
|
width: number;
|
|
39
52
|
height: number;
|
|
@@ -58,5 +71,10 @@ export interface ForegroundInput {
|
|
|
58
71
|
theme: ChartTheme;
|
|
59
72
|
annotations: readonly ResolvedAnnotation[];
|
|
60
73
|
pointLabels: readonly PointLabel[];
|
|
74
|
+
/**
|
|
75
|
+
* Clears the canvas first (off when the layers share one canvas)
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
clear?: boolean;
|
|
61
79
|
}
|
|
62
80
|
export declare const drawForeground: (ctx: CanvasRenderingContext2D, input: ForegroundInput) => void;
|
|
@@ -25,15 +25,28 @@ export interface ResolvedLine {
|
|
|
25
25
|
dash: number[];
|
|
26
26
|
label?: string;
|
|
27
27
|
}
|
|
28
|
-
export
|
|
28
|
+
export interface ResolvedText {
|
|
29
|
+
type: "text";
|
|
30
|
+
x?: number;
|
|
31
|
+
y?: number;
|
|
32
|
+
text: string;
|
|
33
|
+
anchor: "center" | "top" | "bottom" | "left" | "right";
|
|
34
|
+
color: Rgba;
|
|
35
|
+
weight: number;
|
|
36
|
+
}
|
|
37
|
+
export type ResolvedAnnotation = ResolvedRect | ResolvedLine | ResolvedText;
|
|
29
38
|
export interface PointLabel {
|
|
30
39
|
x: number;
|
|
31
40
|
y: number;
|
|
32
41
|
/** Radius of the dot */
|
|
33
42
|
r: number;
|
|
34
43
|
text: string;
|
|
44
|
+
/** Fixed side (bar values); any free side around the dot otherwise */
|
|
45
|
+
placement?: "above" | "below";
|
|
35
46
|
}
|
|
36
47
|
export declare const font: (theme: ChartTheme, size?: number, weight?: number) => string;
|
|
48
|
+
/** Box of a text annotation, kept inside the plot */
|
|
49
|
+
export declare const textBox: (a: ResolvedText, s: Scales, width: number, height: number) => Rect;
|
|
37
50
|
export interface BackgroundInput {
|
|
38
51
|
width: number;
|
|
39
52
|
height: number;
|
|
@@ -58,5 +71,10 @@ export interface ForegroundInput {
|
|
|
58
71
|
theme: ChartTheme;
|
|
59
72
|
annotations: readonly ResolvedAnnotation[];
|
|
60
73
|
pointLabels: readonly PointLabel[];
|
|
74
|
+
/**
|
|
75
|
+
* Clears the canvas first (off when the layers share one canvas)
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
clear?: boolean;
|
|
61
79
|
}
|
|
62
80
|
export declare const drawForeground: (ctx: CanvasRenderingContext2D, input: ForegroundInput) => void;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { toCss as e } from "./color.js";
|
|
2
2
|
//#region src/engine/overlay.ts
|
|
3
|
-
var t = (e, t = e.fontSize, n = 400) => `${n} ${t}px ${e.fontFamily}`, n = (e) => Math.round(e) + .5, r = (e, t) => {
|
|
3
|
+
var t = (e, t = e.fontSize, n = 400) => `${n} ${t}px ${e.fontFamily}`, n = (e) => Math.round(e) + .5, r = (e, t, n, r) => {
|
|
4
|
+
let { plot: i } = t, a = e.x === void 0 ? i.x + i.width / 2 : t.xToPx(e.x), o = e.y === void 0 ? i.y + i.height / 2 : t.yToPx(e.y), s = a - n / 2, c = o - r / 2;
|
|
5
|
+
return e.anchor === "top" ? c = o + 6 : e.anchor === "bottom" ? c = o - 6 - r : e.anchor === "left" ? s = a + 6 : e.anchor === "right" && (s = a - 6 - n), s = Math.max(i.x + 6, Math.min(s, i.x + i.width - 6 - n)), c = Math.max(i.y + 2, Math.min(c, i.y + i.height - 2 - r)), {
|
|
6
|
+
x: s,
|
|
7
|
+
y: c,
|
|
8
|
+
width: n,
|
|
9
|
+
height: r
|
|
10
|
+
};
|
|
11
|
+
}, i = (e, t) => {
|
|
4
12
|
let { plot: n } = t, r = e.x0 === void 0 ? -Infinity : t.xToPx(e.x0), i = e.x1 === void 0 ? Infinity : t.xToPx(e.x1), a = e.y0 === void 0 ? Infinity : t.yToPx(e.y0), o = e.y1 === void 0 ? -Infinity : t.yToPx(e.y1), s = Math.max(n.x, Math.min(r, i)), c = Math.min(n.x + n.width, Math.max(r, i)), l = Math.max(n.y, Math.min(a, o)), u = Math.min(n.y + n.height, Math.max(a, o));
|
|
5
13
|
return {
|
|
6
14
|
x: s,
|
|
@@ -8,49 +16,59 @@ var t = (e, t = e.fontSize, n = 400) => `${n} ${t}px ${e.fontFamily}`, n = (e) =
|
|
|
8
16
|
width: c - s,
|
|
9
17
|
height: u - l
|
|
10
18
|
};
|
|
11
|
-
},
|
|
19
|
+
}, a = (r, a) => {
|
|
12
20
|
let { scales: o, theme: s, x: c, y: l, xTicks: u, yTicks: d } = a, { plot: f } = o;
|
|
13
|
-
|
|
21
|
+
r.clearRect(0, 0, a.width, a.height), r.save(), r.beginPath(), r.rect(f.x, f.y, f.width, f.height), r.clip();
|
|
14
22
|
for (let t of a.annotations) {
|
|
15
23
|
if (t.type !== "rect") continue;
|
|
16
|
-
let n =
|
|
17
|
-
n.width <= 0 || n.height <= 0 || (
|
|
24
|
+
let n = i(t, o);
|
|
25
|
+
n.width <= 0 || n.height <= 0 || (r.fillStyle = e(t.color, t.opacity), r.fillRect(n.x, n.y, n.width, n.height));
|
|
18
26
|
}
|
|
19
|
-
if (
|
|
27
|
+
if (r.restore(), r.lineWidth = 1, r.strokeStyle = e(s.grid), r.beginPath(), l.grid) for (let e of d.values) {
|
|
20
28
|
let t = n(o.yToPx(e));
|
|
21
|
-
t < f.y - 1 || t > f.y + f.height + 1 || (
|
|
29
|
+
t < f.y - 1 || t > f.y + f.height + 1 || (r.moveTo(f.x, t), r.lineTo(f.x + f.width, t));
|
|
22
30
|
}
|
|
23
31
|
if (c.grid) for (let e of u.values) {
|
|
24
32
|
let t = n(o.xToPx(e));
|
|
25
|
-
t < f.x - 1 || t > f.x + f.width + 1 || (
|
|
33
|
+
t < f.x - 1 || t > f.x + f.width + 1 || (r.moveTo(t, f.y), r.lineTo(t, f.y + f.height));
|
|
26
34
|
}
|
|
27
|
-
|
|
35
|
+
r.stroke();
|
|
28
36
|
let p = Math.ceil(s.fontSize * 1.4);
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
37
|
+
if (r.font = t(s), r.fillStyle = e(s.textMuted), c.visible) {
|
|
38
|
+
r.strokeStyle = e(s.axis), r.beginPath();
|
|
39
|
+
let i = n(f.y + f.height);
|
|
40
|
+
r.moveTo(f.x, i), r.lineTo(f.x + f.width, i), r.stroke(), r.textBaseline = "top", r.textAlign = "center";
|
|
33
41
|
let l = -Infinity, d = u.values.map((e, t) => ({
|
|
34
42
|
px: o.xToPx(e),
|
|
35
43
|
text: u.labels[t]
|
|
36
44
|
})).sort((e, t) => e.px - t.px);
|
|
37
45
|
for (let { px: e, text: t } of d) {
|
|
38
46
|
if (e < f.x - .5 || e > f.x + f.width + .5) continue;
|
|
39
|
-
let n =
|
|
40
|
-
|
|
47
|
+
let n = r.measureText(t).width, i = Math.max(0, Math.min(a.width - n, e - n / 2));
|
|
48
|
+
i < l + 6 || (l = i + n, r.fillText(t, i + n / 2, f.y + f.height + 7));
|
|
41
49
|
}
|
|
42
|
-
c.title && (
|
|
50
|
+
c.title && (r.font = t(s, s.fontSize + 1, 500), r.fillStyle = e(s.text, .8), r.fillText(c.title, f.x + f.width / 2, f.y + f.height + p + 10));
|
|
43
51
|
}
|
|
44
|
-
l.visible && (
|
|
52
|
+
l.visible && (r.font = t(s), r.fillStyle = e(s.textMuted), r.textAlign = "right", r.textBaseline = "middle", d.values.forEach((e, t) => {
|
|
45
53
|
let n = o.yToPx(e);
|
|
46
|
-
n < f.y - .5 || n > f.y + f.height + .5 ||
|
|
47
|
-
}), l.title && (
|
|
48
|
-
},
|
|
54
|
+
n < f.y - .5 || n > f.y + f.height + .5 || r.fillText(d.labels[t], f.x - 8, n);
|
|
55
|
+
}), l.title && (r.save(), r.font = t(s, s.fontSize + 1, 500), r.fillStyle = e(s.text, .8), r.translate(p / 2 + 4, f.y + f.height / 2), r.rotate(-Math.PI / 2), r.textAlign = "center", r.fillText(l.title, 0, 0), r.restore()));
|
|
56
|
+
}, o = (e, t) => e.x < t.x + t.width && t.x < e.x + e.width && e.y < t.y + t.height && t.y < e.y + e.height, s = (e, t) => e.x >= t.x && e.y >= t.y && e.x + e.width <= t.x + t.width && e.y + e.height <= t.y + t.height, c = (e, t, n, r, i, a) => {
|
|
49
57
|
e.lineWidth = 3, e.lineJoin = "round", e.strokeStyle = a, e.strokeText(t, n, r), e.fillStyle = i, e.fillText(t, n, r);
|
|
50
|
-
},
|
|
51
|
-
let
|
|
58
|
+
}, l = (e, t, n, r, i = []) => {
|
|
59
|
+
let a = [];
|
|
52
60
|
for (let c of e) {
|
|
53
|
-
let e = n(c.text), l = c.r + 4, u =
|
|
61
|
+
let e = n(c.text), l = c.r + 4, u = {
|
|
62
|
+
x: c.x - e / 2,
|
|
63
|
+
y: c.y - l - r,
|
|
64
|
+
width: e,
|
|
65
|
+
height: r
|
|
66
|
+
}, d = {
|
|
67
|
+
x: c.x - e / 2,
|
|
68
|
+
y: c.y + l,
|
|
69
|
+
width: e,
|
|
70
|
+
height: r
|
|
71
|
+
}, f = (c.placement === "above" ? [u] : c.placement === "below" ? [d] : [
|
|
54
72
|
{
|
|
55
73
|
x: c.x + l,
|
|
56
74
|
y: c.y - r / 2,
|
|
@@ -63,61 +81,57 @@ var t = (e, t = e.fontSize, n = 400) => `${n} ${t}px ${e.fontFamily}`, n = (e) =
|
|
|
63
81
|
width: e,
|
|
64
82
|
height: r
|
|
65
83
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
height: r
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
x: c.x - e / 2,
|
|
74
|
-
y: c.y + l,
|
|
75
|
-
width: e,
|
|
76
|
-
height: r
|
|
77
|
-
}
|
|
78
|
-
].find((e) => o(e, t) && !i.some((t) => a(t, e)));
|
|
79
|
-
u && (i.push(u), s.push({
|
|
84
|
+
u,
|
|
85
|
+
d
|
|
86
|
+
]).find((e) => s(e, t) && !i.some((t) => o(t, e)));
|
|
87
|
+
f && (i.push(f), a.push({
|
|
80
88
|
label: c,
|
|
81
|
-
box:
|
|
89
|
+
box: f
|
|
82
90
|
}));
|
|
83
91
|
}
|
|
84
|
-
return
|
|
85
|
-
},
|
|
86
|
-
let { scales:
|
|
87
|
-
|
|
88
|
-
let
|
|
89
|
-
for (let r of
|
|
92
|
+
return a;
|
|
93
|
+
}, u = (a, o) => {
|
|
94
|
+
let { scales: s, theme: u } = o, { plot: d } = s;
|
|
95
|
+
o.clear !== !1 && a.clearRect(0, 0, o.width, o.height), a.save(), a.beginPath(), a.rect(d.x, d.y, d.width, d.height), a.clip();
|
|
96
|
+
let f = e(u.background, .9), p = [], m = u.fontSize + 4;
|
|
97
|
+
for (let r of o.annotations) {
|
|
90
98
|
if (r.type !== "line") continue;
|
|
91
|
-
let
|
|
92
|
-
if (
|
|
93
|
-
let e = n(
|
|
94
|
-
|
|
99
|
+
let i = e(r.color);
|
|
100
|
+
if (a.strokeStyle = i, a.lineWidth = r.width, a.setLineDash(r.dash), a.beginPath(), r.axis === "y") {
|
|
101
|
+
let e = n(s.yToPx(r.value));
|
|
102
|
+
a.moveTo(d.x, e), a.lineTo(d.x + d.width, e), a.stroke(), r.label && (a.setLineDash([]), a.font = t(u, u.fontSize, 500), a.textAlign = "right", a.textBaseline = "bottom", c(a, r.label, d.x + d.width - 6, e - 3, i, f));
|
|
95
103
|
} else {
|
|
96
|
-
let e = n(
|
|
97
|
-
|
|
104
|
+
let e = n(s.xToPx(r.value));
|
|
105
|
+
a.moveTo(e, d.y), a.lineTo(e, d.y + d.height), a.stroke(), r.label && (a.setLineDash([]), a.font = t(u, u.fontSize, 500), a.textAlign = "left", a.textBaseline = "top", c(a, r.label, e + 5, d.y + 5, i, f));
|
|
98
106
|
}
|
|
99
107
|
}
|
|
100
|
-
|
|
101
|
-
for (let t of
|
|
108
|
+
a.setLineDash([]), a.font = t(u, u.fontSize + 1, 600);
|
|
109
|
+
for (let t of o.annotations) {
|
|
102
110
|
if (t.type !== "rect" || !t.label) continue;
|
|
103
|
-
let n =
|
|
111
|
+
let n = i(t, s);
|
|
104
112
|
if (n.width <= 0 || n.height <= 0) continue;
|
|
105
|
-
let
|
|
106
|
-
|
|
113
|
+
let r = a.measureText(t.label).width, o = t.labelPosition, c = o.endsWith("left") ? n.x + 10 : o.endsWith("right") ? n.x + n.width - 10 - r : n.x + (n.width - r) / 2, l = o.startsWith("top") ? n.y + 10 : o.startsWith("bottom") ? n.y + n.height - 10 - m : n.y + (n.height - m) / 2;
|
|
114
|
+
a.textAlign = "left", a.textBaseline = "top", a.fillStyle = e(t.labelColor), a.fillText(t.label, c, l), p.push({
|
|
107
115
|
x: c,
|
|
108
116
|
y: l,
|
|
109
|
-
width:
|
|
110
|
-
height:
|
|
117
|
+
width: r,
|
|
118
|
+
height: m
|
|
111
119
|
});
|
|
112
120
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
for (let n of o.annotations) {
|
|
122
|
+
if (n.type !== "text" || !n.text) continue;
|
|
123
|
+
a.font = t(u, u.fontSize, n.weight);
|
|
124
|
+
let i = r(n, s, a.measureText(n.text).width, m);
|
|
125
|
+
a.textAlign = "left", a.textBaseline = "middle", c(a, n.text, i.x, i.y + i.height / 2, e(n.color), f), p.push(i);
|
|
126
|
+
}
|
|
127
|
+
if (o.pointLabels.length) {
|
|
128
|
+
a.font = t(u), a.textAlign = "left", a.textBaseline = "middle";
|
|
129
|
+
let n = e(u.text, .85), r = l(o.pointLabels, d, (e) => a.measureText(e).width, m - 2, p);
|
|
130
|
+
for (let { label: e, box: t } of r) c(a, e.text, t.x, t.y + t.height / 2, n, f);
|
|
117
131
|
}
|
|
118
|
-
|
|
132
|
+
a.restore();
|
|
119
133
|
};
|
|
120
134
|
//#endregion
|
|
121
|
-
export {
|
|
135
|
+
export { a as drawBackground, u as drawForeground, t as font, l as placeLabels, r as textBox };
|
|
122
136
|
|
|
123
137
|
//# sourceMappingURL=overlay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.js","names":["font","theme","weight","size","crisp","v","rectOf","s","xa","a","xb","ya","yb","left","plot","right","top","bottom","drawBackground","input","scales","ctx","r","toCss","y","yTicks","py","x","xTicks","px","line","base","lastRight","order","i","b","w","text","overlaps","inside","haloText","halo","color","placeLabels","placed","label","labels","measure","gap","box","height","c","occupied","o","drawForeground","labelHeight","pos","tx","ty","textColor","t"],"sources":["../../../../charts/src/engine/overlay.ts"],"sourcesContent":["// Canvas2D layers around the data: background (areas, grid, axes, tick\n// labels) and foreground (reference lines, annotation and point labels).\n\nimport { toCss, type Rgba } from \"./color\";\nimport type { AxisTicks } from \"./axis\";\nimport type { Rect, Scales } from \"./layout\";\nimport type { AxisModel } from \"./model\";\nimport type { ChartTheme } from \"./theme\";\nimport type { ChartLabelPosition } from \"./types\";\n\nexport interface ResolvedRect {\n type: \"rect\";\n x0?: number;\n x1?: number;\n y0?: number;\n y1?: number;\n color: Rgba;\n opacity: number;\n label?: string;\n labelPosition: ChartLabelPosition;\n labelColor: Rgba;\n}\n\nexport interface ResolvedLine {\n type: \"line\";\n axis: \"x\" | \"y\";\n value: number;\n color: Rgba;\n width: number;\n dash: number[];\n label?: string;\n}\n\nexport type ResolvedAnnotation = ResolvedRect | ResolvedLine;\n\nexport interface PointLabel {\n x: number;\n y: number;\n /** Radius of the dot */\n r: number;\n text: string;\n}\n\nexport const font = (theme: ChartTheme, size = theme.fontSize, weight = 400) =>\n `${weight} ${size}px ${theme.fontFamily}`;\n\nconst crisp = (v: number) => Math.round(v) + 0.5;\n\nconst rectOf = (a: ResolvedRect, s: Scales): Rect => {\n const { plot } = s;\n const xa = a.x0 === undefined ? -Infinity : s.xToPx(a.x0);\n const xb = a.x1 === undefined ? Infinity : s.xToPx(a.x1);\n const ya = a.y0 === undefined ? Infinity : s.yToPx(a.y0);\n const yb = a.y1 === undefined ? -Infinity : s.yToPx(a.y1);\n const left = Math.max(plot.x, Math.min(xa, xb));\n const right = Math.min(plot.x + plot.width, Math.max(xa, xb));\n const top = Math.max(plot.y, Math.min(ya, yb));\n const bottom = Math.min(plot.y + plot.height, Math.max(ya, yb));\n return { x: left, y: top, width: right - left, height: bottom - top };\n};\n\nexport interface BackgroundInput {\n width: number;\n height: number;\n scales: Scales;\n x: AxisModel;\n y: AxisModel;\n xTicks: AxisTicks;\n yTicks: AxisTicks;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n}\n\nexport const drawBackground = (\n ctx: CanvasRenderingContext2D,\n input: BackgroundInput,\n) => {\n const { scales, theme, x, y, xTicks, yTicks } = input;\n const { plot } = scales;\n ctx.clearRect(0, 0, input.width, input.height);\n\n // areas\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n for (const a of input.annotations) {\n if (a.type !== \"rect\") continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n ctx.fillStyle = toCss(a.color, a.opacity);\n ctx.fillRect(r.x, r.y, r.width, r.height);\n }\n ctx.restore();\n\n // grid\n ctx.lineWidth = 1;\n ctx.strokeStyle = toCss(theme.grid);\n ctx.beginPath();\n if (y.grid) {\n for (const v of yTicks.values) {\n const py = crisp(scales.yToPx(v));\n if (py < plot.y - 1 || py > plot.y + plot.height + 1) continue;\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n }\n }\n if (x.grid) {\n for (const v of xTicks.values) {\n const px = crisp(scales.xToPx(v));\n if (px < plot.x - 1 || px > plot.x + plot.width + 1) continue;\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n }\n }\n ctx.stroke();\n\n const line = Math.ceil(theme.fontSize * 1.4);\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n\n // x axis\n if (x.visible) {\n ctx.strokeStyle = toCss(theme.axis);\n ctx.beginPath();\n const base = crisp(plot.y + plot.height);\n ctx.moveTo(plot.x, base);\n ctx.lineTo(plot.x + plot.width, base);\n ctx.stroke();\n ctx.textBaseline = \"top\";\n ctx.textAlign = \"center\";\n let lastRight = -Infinity;\n // left to right (reversed axes list their ticks right to left)\n const order = xTicks.values\n .map((v, i) => ({ px: scales.xToPx(v), text: xTicks.labels[i] }))\n .sort((a, b) => a.px - b.px);\n for (const { px, text } of order) {\n if (px < plot.x - 0.5 || px > plot.x + plot.width + 0.5) continue;\n const w = ctx.measureText(text).width;\n const left = Math.max(0, Math.min(input.width - w, px - w / 2));\n if (left < lastRight + 6) continue;\n lastRight = left + w;\n ctx.fillText(text, left + w / 2, plot.y + plot.height + 7);\n }\n if (x.title) {\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.fillText(\n x.title,\n plot.x + plot.width / 2,\n plot.y + plot.height + line + 10,\n );\n }\n }\n\n // y axis\n if (y.visible) {\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"middle\";\n yTicks.values.forEach((v, i) => {\n const py = scales.yToPx(v);\n if (py < plot.y - 0.5 || py > plot.y + plot.height + 0.5) return;\n ctx.fillText(yTicks.labels[i], plot.x - 8, py);\n });\n if (y.title) {\n ctx.save();\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.translate(line / 2 + 4, plot.y + plot.height / 2);\n ctx.rotate(-Math.PI / 2);\n ctx.textAlign = \"center\";\n ctx.fillText(y.title, 0, 0);\n ctx.restore();\n }\n }\n};\n\nconst overlaps = (a: Rect, b: Rect) =>\n a.x < b.x + b.width &&\n b.x < a.x + a.width &&\n a.y < b.y + b.height &&\n b.y < a.y + a.height;\n\nconst inside = (r: Rect, plot: Rect) =>\n r.x >= plot.x &&\n r.y >= plot.y &&\n r.x + r.width <= plot.x + plot.width &&\n r.y + r.height <= plot.y + plot.height;\n\n/** Text with a halo in the background color (readable over data) */\nconst haloText = (\n ctx: CanvasRenderingContext2D,\n text: string,\n x: number,\n y: number,\n color: string,\n halo: string,\n) => {\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = halo;\n ctx.strokeText(text, x, y);\n ctx.fillStyle = color;\n ctx.fillText(text, x, y);\n};\n\n/** Greedy placement: right, left, above, below the dot; skipped when no slot is free */\nexport const placeLabels = (\n labels: readonly PointLabel[],\n plot: Rect,\n measure: (text: string) => number,\n height: number,\n occupied: Rect[] = [],\n): { label: PointLabel; box: Rect }[] => {\n const placed: { label: PointLabel; box: Rect }[] = [];\n for (const label of labels) {\n const w = measure(label.text);\n const gap = label.r + 4;\n const candidates: Rect[] = [\n { x: label.x + gap, y: label.y - height / 2, width: w, height },\n { x: label.x - gap - w, y: label.y - height / 2, width: w, height },\n { x: label.x - w / 2, y: label.y - gap - height, width: w, height },\n { x: label.x - w / 2, y: label.y + gap, width: w, height },\n ];\n const box = candidates.find(\n (c) => inside(c, plot) && !occupied.some((o) => overlaps(o, c)),\n );\n if (!box) continue;\n occupied.push(box);\n placed.push({ label, box });\n }\n return placed;\n};\n\nexport interface ForegroundInput {\n width: number;\n height: number;\n scales: Scales;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n pointLabels: readonly PointLabel[];\n}\n\nexport const drawForeground = (\n ctx: CanvasRenderingContext2D,\n input: ForegroundInput,\n) => {\n const { scales, theme } = input;\n const { plot } = scales;\n ctx.clearRect(0, 0, input.width, input.height);\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n\n const halo = toCss(theme.background, 0.9);\n const occupied: Rect[] = [];\n const labelHeight = theme.fontSize + 4;\n\n for (const a of input.annotations) {\n if (a.type !== \"line\") continue;\n const color = toCss(a.color);\n ctx.strokeStyle = color;\n ctx.lineWidth = a.width;\n ctx.setLineDash(a.dash);\n ctx.beginPath();\n if (a.axis === \"y\") {\n const py = crisp(scales.yToPx(a.value));\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"bottom\";\n haloText(ctx, a.label, plot.x + plot.width - 6, py - 3, color, halo);\n }\n } else {\n const px = crisp(scales.xToPx(a.value));\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n haloText(ctx, a.label, px + 5, plot.y + 5, color, halo);\n }\n }\n }\n ctx.setLineDash([]);\n\n // labels of areas\n ctx.font = font(theme, theme.fontSize + 1, 600);\n for (const a of input.annotations) {\n if (a.type !== \"rect\" || !a.label) continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n const pad = 10;\n const w = ctx.measureText(a.label).width;\n const pos = a.labelPosition;\n const tx = pos.endsWith(\"left\")\n ? r.x + pad\n : pos.endsWith(\"right\")\n ? r.x + r.width - pad - w\n : r.x + (r.width - w) / 2;\n const ty = pos.startsWith(\"top\")\n ? r.y + pad\n : pos.startsWith(\"bottom\")\n ? r.y + r.height - pad - labelHeight\n : r.y + (r.height - labelHeight) / 2;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n ctx.fillStyle = toCss(a.labelColor);\n ctx.fillText(a.label, tx, ty);\n occupied.push({ x: tx, y: ty, width: w, height: labelHeight });\n }\n\n // point labels\n if (input.pointLabels.length) {\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n const textColor = toCss(theme.text, 0.85);\n const placed = placeLabels(\n input.pointLabels,\n plot,\n (t) => ctx.measureText(t).width,\n labelHeight - 2,\n occupied,\n );\n for (const { label, box } of placed) {\n haloText(ctx, label.text, box.x, box.y + box.height / 2, textColor, halo);\n }\n }\n ctx.restore();\n};\n"],"mappings":";;AA2CA,IAAaA,KAAQ,GAAmB,IAAOC,EAAM,UAAU,IAAS,QACtE,GAAGC,EAAO,GAAGC,EAAK,KAAKF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K,GACtBsB,IAAKF,EAAI,WAAW,KAAK,IAC3BlC,EAAE,IAAI,KACNkC,EAAI,WAAW,QAAQ,IACrBlC,EAAE,IAAIA,EAAE,SAAS,KAAMiC,IACvBjC,EAAE,KAAKA,EAAE,SAASiC,KAAe;EAKvC,AAJA,EAAI,YAAY,QAChB,EAAI,eAAe,OACnB,EAAI,YAAYhC,EAAMd,EAAE,UAAU,GAClCY,EAAI,SAASZ,EAAE,OAAOgD,GAAIC,CAAE,GAC5BN,EAAS,KAAK;GAAE,GAAGK;GAAI,GAAGC;GAAI,OAAOtB;GAAG,QAAQmB;EAAY,CAAC;CAC/D;CAGA,IAAIpC,EAAM,YAAY,QAAQ;EAG5B,AAFA,EAAI,OAAOnB,EAAKC,CAAK,GACrB,EAAI,YAAY,QAChB,EAAI,eAAe;EACnB,IAAM0D,IAAYpC,EAAMtB,EAAM,MAAM,GAAI,GAClC2C,IAASD,EACbxB,EAAM,aACNL,IACC,MAAMO,EAAI,YAAYuC,CAAC,CAAC,CAAC,OAC1BL,IAAc,GACdH,CACF;EACA,KAAK,IAAM,EAAE,UAAO,YAASR,GAC3B,EAASvB,GAAKwB,EAAM,MAAMI,EAAI,GAAGA,EAAI,IAAIA,EAAI,SAAS,GAAGU,GAAWlB,CAAI;CAE5E;CACA,EAAI,QAAQ;AACd"}
|
|
1
|
+
{"version":3,"file":"overlay.js","names":["font","theme","weight","size","crisp","v","textBox","s","px","a","plot","py","x","width","y","height","rectOf","xa","xb","ya","yb","left","right","top","bottom","drawBackground","input","scales","ctx","r","toCss","yTicks","xTicks","line","base","lastRight","order","i","b","w","text","overlaps","inside","haloText","halo","color","placeLabels","placed","label","labels","measure","gap","above","below","box","c","occupied","o","drawForeground","labelHeight","pos","tx","ty","textColor","t"],"sources":["../../../../charts/src/engine/overlay.ts"],"sourcesContent":["// Canvas2D layers around the data: background (areas, grid, axes, tick\n// labels) and foreground (reference lines, annotation and point labels).\n\nimport { toCss, type Rgba } from \"./color\";\nimport type { AxisTicks } from \"./axis\";\nimport type { Rect, Scales } from \"./layout\";\nimport type { AxisModel } from \"./model\";\nimport type { ChartTheme } from \"./theme\";\nimport type { ChartLabelPosition } from \"./types\";\n\nexport interface ResolvedRect {\n type: \"rect\";\n x0?: number;\n x1?: number;\n y0?: number;\n y1?: number;\n color: Rgba;\n opacity: number;\n label?: string;\n labelPosition: ChartLabelPosition;\n labelColor: Rgba;\n}\n\nexport interface ResolvedLine {\n type: \"line\";\n axis: \"x\" | \"y\";\n value: number;\n color: Rgba;\n width: number;\n dash: number[];\n label?: string;\n}\n\nexport interface ResolvedText {\n type: \"text\";\n x?: number;\n y?: number;\n text: string;\n anchor: \"center\" | \"top\" | \"bottom\" | \"left\" | \"right\";\n color: Rgba;\n weight: number;\n}\n\nexport type ResolvedAnnotation = ResolvedRect | ResolvedLine | ResolvedText;\n\nexport interface PointLabel {\n x: number;\n y: number;\n /** Radius of the dot */\n r: number;\n text: string;\n /** Fixed side (bar values); any free side around the dot otherwise */\n placement?: \"above\" | \"below\";\n}\n\nexport const font = (theme: ChartTheme, size = theme.fontSize, weight = 400) =>\n `${weight} ${size}px ${theme.fontFamily}`;\n\nconst crisp = (v: number) => Math.round(v) + 0.5;\n\n/** Box of a text annotation, kept inside the plot */\nexport const textBox = (\n a: ResolvedText,\n s: Scales,\n width: number,\n height: number,\n): Rect => {\n const { plot } = s;\n const px = a.x === undefined ? plot.x + plot.width / 2 : s.xToPx(a.x);\n const py = a.y === undefined ? plot.y + plot.height / 2 : s.yToPx(a.y);\n const gap = 6;\n let x = px - width / 2;\n let y = py - height / 2;\n if (a.anchor === \"top\") y = py + gap;\n else if (a.anchor === \"bottom\") y = py - gap - height;\n else if (a.anchor === \"left\") x = px + gap;\n else if (a.anchor === \"right\") x = px - gap - width;\n x = Math.max(plot.x + gap, Math.min(x, plot.x + plot.width - gap - width));\n y = Math.max(plot.y + 2, Math.min(y, plot.y + plot.height - 2 - height));\n return { x, y, width, height };\n};\n\nconst rectOf = (a: ResolvedRect, s: Scales): Rect => {\n const { plot } = s;\n const xa = a.x0 === undefined ? -Infinity : s.xToPx(a.x0);\n const xb = a.x1 === undefined ? Infinity : s.xToPx(a.x1);\n const ya = a.y0 === undefined ? Infinity : s.yToPx(a.y0);\n const yb = a.y1 === undefined ? -Infinity : s.yToPx(a.y1);\n const left = Math.max(plot.x, Math.min(xa, xb));\n const right = Math.min(plot.x + plot.width, Math.max(xa, xb));\n const top = Math.max(plot.y, Math.min(ya, yb));\n const bottom = Math.min(plot.y + plot.height, Math.max(ya, yb));\n return { x: left, y: top, width: right - left, height: bottom - top };\n};\n\nexport interface BackgroundInput {\n width: number;\n height: number;\n scales: Scales;\n x: AxisModel;\n y: AxisModel;\n xTicks: AxisTicks;\n yTicks: AxisTicks;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n}\n\nexport const drawBackground = (\n ctx: CanvasRenderingContext2D,\n input: BackgroundInput,\n) => {\n const { scales, theme, x, y, xTicks, yTicks } = input;\n const { plot } = scales;\n ctx.clearRect(0, 0, input.width, input.height);\n\n // areas\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n for (const a of input.annotations) {\n if (a.type !== \"rect\") continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n ctx.fillStyle = toCss(a.color, a.opacity);\n ctx.fillRect(r.x, r.y, r.width, r.height);\n }\n ctx.restore();\n\n // grid\n ctx.lineWidth = 1;\n ctx.strokeStyle = toCss(theme.grid);\n ctx.beginPath();\n if (y.grid) {\n for (const v of yTicks.values) {\n const py = crisp(scales.yToPx(v));\n if (py < plot.y - 1 || py > plot.y + plot.height + 1) continue;\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n }\n }\n if (x.grid) {\n for (const v of xTicks.values) {\n const px = crisp(scales.xToPx(v));\n if (px < plot.x - 1 || px > plot.x + plot.width + 1) continue;\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n }\n }\n ctx.stroke();\n\n const line = Math.ceil(theme.fontSize * 1.4);\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n\n // x axis\n if (x.visible) {\n ctx.strokeStyle = toCss(theme.axis);\n ctx.beginPath();\n const base = crisp(plot.y + plot.height);\n ctx.moveTo(plot.x, base);\n ctx.lineTo(plot.x + plot.width, base);\n ctx.stroke();\n ctx.textBaseline = \"top\";\n ctx.textAlign = \"center\";\n let lastRight = -Infinity;\n // left to right (reversed axes list their ticks right to left)\n const order = xTicks.values\n .map((v, i) => ({ px: scales.xToPx(v), text: xTicks.labels[i] }))\n .sort((a, b) => a.px - b.px);\n for (const { px, text } of order) {\n if (px < plot.x - 0.5 || px > plot.x + plot.width + 0.5) continue;\n const w = ctx.measureText(text).width;\n const left = Math.max(0, Math.min(input.width - w, px - w / 2));\n if (left < lastRight + 6) continue;\n lastRight = left + w;\n ctx.fillText(text, left + w / 2, plot.y + plot.height + 7);\n }\n if (x.title) {\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.fillText(\n x.title,\n plot.x + plot.width / 2,\n plot.y + plot.height + line + 10,\n );\n }\n }\n\n // y axis\n if (y.visible) {\n ctx.font = font(theme);\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"middle\";\n yTicks.values.forEach((v, i) => {\n const py = scales.yToPx(v);\n if (py < plot.y - 0.5 || py > plot.y + plot.height + 0.5) return;\n ctx.fillText(yTicks.labels[i], plot.x - 8, py);\n });\n if (y.title) {\n ctx.save();\n ctx.font = font(theme, theme.fontSize + 1, 500);\n ctx.fillStyle = toCss(theme.text, 0.8);\n ctx.translate(line / 2 + 4, plot.y + plot.height / 2);\n ctx.rotate(-Math.PI / 2);\n ctx.textAlign = \"center\";\n ctx.fillText(y.title, 0, 0);\n ctx.restore();\n }\n }\n};\n\nconst overlaps = (a: Rect, b: Rect) =>\n a.x < b.x + b.width &&\n b.x < a.x + a.width &&\n a.y < b.y + b.height &&\n b.y < a.y + a.height;\n\nconst inside = (r: Rect, plot: Rect) =>\n r.x >= plot.x &&\n r.y >= plot.y &&\n r.x + r.width <= plot.x + plot.width &&\n r.y + r.height <= plot.y + plot.height;\n\n/** Text with a halo in the background color (readable over data) */\nconst haloText = (\n ctx: CanvasRenderingContext2D,\n text: string,\n x: number,\n y: number,\n color: string,\n halo: string,\n) => {\n ctx.lineWidth = 3;\n ctx.lineJoin = \"round\";\n ctx.strokeStyle = halo;\n ctx.strokeText(text, x, y);\n ctx.fillStyle = color;\n ctx.fillText(text, x, y);\n};\n\n/** Greedy placement: right, left, above, below the dot; skipped when no slot is free */\nexport const placeLabels = (\n labels: readonly PointLabel[],\n plot: Rect,\n measure: (text: string) => number,\n height: number,\n occupied: Rect[] = [],\n): { label: PointLabel; box: Rect }[] => {\n const placed: { label: PointLabel; box: Rect }[] = [];\n for (const label of labels) {\n const w = measure(label.text);\n const gap = label.r + 4;\n const above = {\n x: label.x - w / 2,\n y: label.y - gap - height,\n width: w,\n height,\n };\n const below = { x: label.x - w / 2, y: label.y + gap, width: w, height };\n const candidates: Rect[] =\n label.placement === \"above\"\n ? [above]\n : label.placement === \"below\"\n ? [below]\n : [\n { x: label.x + gap, y: label.y - height / 2, width: w, height },\n {\n x: label.x - gap - w,\n y: label.y - height / 2,\n width: w,\n height,\n },\n above,\n below,\n ];\n const box = candidates.find(\n (c) => inside(c, plot) && !occupied.some((o) => overlaps(o, c)),\n );\n if (!box) continue;\n occupied.push(box);\n placed.push({ label, box });\n }\n return placed;\n};\n\nexport interface ForegroundInput {\n width: number;\n height: number;\n scales: Scales;\n theme: ChartTheme;\n annotations: readonly ResolvedAnnotation[];\n pointLabels: readonly PointLabel[];\n /**\n * Clears the canvas first (off when the layers share one canvas)\n * @default true\n */\n clear?: boolean;\n}\n\nexport const drawForeground = (\n ctx: CanvasRenderingContext2D,\n input: ForegroundInput,\n) => {\n const { scales, theme } = input;\n const { plot } = scales;\n if (input.clear !== false) ctx.clearRect(0, 0, input.width, input.height);\n ctx.save();\n ctx.beginPath();\n ctx.rect(plot.x, plot.y, plot.width, plot.height);\n ctx.clip();\n\n const halo = toCss(theme.background, 0.9);\n const occupied: Rect[] = [];\n const labelHeight = theme.fontSize + 4;\n\n for (const a of input.annotations) {\n if (a.type !== \"line\") continue;\n const color = toCss(a.color);\n ctx.strokeStyle = color;\n ctx.lineWidth = a.width;\n ctx.setLineDash(a.dash);\n ctx.beginPath();\n if (a.axis === \"y\") {\n const py = crisp(scales.yToPx(a.value));\n ctx.moveTo(plot.x, py);\n ctx.lineTo(plot.x + plot.width, py);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"right\";\n ctx.textBaseline = \"bottom\";\n haloText(ctx, a.label, plot.x + plot.width - 6, py - 3, color, halo);\n }\n } else {\n const px = crisp(scales.xToPx(a.value));\n ctx.moveTo(px, plot.y);\n ctx.lineTo(px, plot.y + plot.height);\n ctx.stroke();\n if (a.label) {\n ctx.setLineDash([]);\n ctx.font = font(theme, theme.fontSize, 500);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n haloText(ctx, a.label, px + 5, plot.y + 5, color, halo);\n }\n }\n }\n ctx.setLineDash([]);\n\n // labels of areas\n ctx.font = font(theme, theme.fontSize + 1, 600);\n for (const a of input.annotations) {\n if (a.type !== \"rect\" || !a.label) continue;\n const r = rectOf(a, scales);\n if (r.width <= 0 || r.height <= 0) continue;\n const pad = 10;\n const w = ctx.measureText(a.label).width;\n const pos = a.labelPosition;\n const tx = pos.endsWith(\"left\")\n ? r.x + pad\n : pos.endsWith(\"right\")\n ? r.x + r.width - pad - w\n : r.x + (r.width - w) / 2;\n const ty = pos.startsWith(\"top\")\n ? r.y + pad\n : pos.startsWith(\"bottom\")\n ? r.y + r.height - pad - labelHeight\n : r.y + (r.height - labelHeight) / 2;\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"top\";\n ctx.fillStyle = toCss(a.labelColor);\n ctx.fillText(a.label, tx, ty);\n occupied.push({ x: tx, y: ty, width: w, height: labelHeight });\n }\n\n // free texts\n for (const a of input.annotations) {\n if (a.type !== \"text\" || !a.text) continue;\n ctx.font = font(theme, theme.fontSize, a.weight);\n const box = textBox(a, scales, ctx.measureText(a.text).width, labelHeight);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n haloText(ctx, a.text, box.x, box.y + box.height / 2, toCss(a.color), halo);\n occupied.push(box);\n }\n\n // point labels\n if (input.pointLabels.length) {\n ctx.font = font(theme);\n ctx.textAlign = \"left\";\n ctx.textBaseline = \"middle\";\n const textColor = toCss(theme.text, 0.85);\n const placed = placeLabels(\n input.pointLabels,\n plot,\n (t) => ctx.measureText(t).width,\n labelHeight - 2,\n occupied,\n );\n for (const { label, box } of placed) {\n haloText(ctx, label.text, box.x, box.y + box.height / 2, textColor, halo);\n }\n }\n ctx.restore();\n};\n"],"mappings":";;AAuDA,IAAaA,KAAQ,GAAmB,IAAOC,EAAM,UAAU,IAAS,QACtE,GAAGC,EAAO,GAAGC,EAAK,KAAKF,EAAM,cAEzBG,KAAS,MAAc,KAAK,MAAMC,CAAC,IAAI,IAGhCC,KACX,GACA,GACA,GACA,MACS;CACT,IAAM,EAAE,YAASC,GACXC,IAAKC,EAAE,MAAM,KAAA,IAAYC,EAAK,IAAIA,EAAK,QAAQ,IAAIH,EAAE,MAAME,EAAE,CAAC,GAC9DE,IAAKF,EAAE,MAAM,KAAA,IAAYC,EAAK,IAAIA,EAAK,SAAS,IAAIH,EAAE,MAAME,EAAE,CAAC,GAEjEG,IAAIJ,IAAKK,IAAQ,GACjBC,IAAIH,IAAKI,IAAS;CAOtB,OANIN,EAAE,WAAW,QAAO,IAAIE,IAAK,IACxBF,EAAE,WAAW,WAAU,IAAIE,IAAK,IAAMI,IACtCN,EAAE,WAAW,SAAQ,IAAID,IAAK,IAC9BC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AAKF,CAAG;CACnB;CAGA,IAAI5B,EAAM,YAAY,QAAQ;EAG5B,AAFA,EAAI,OAAO1B,EAAKC,CAAK,GACrB,EAAI,YAAY,QAChB,EAAI,eAAe;EACnB,IAAM8D,IAAYjC,EAAM7B,EAAM,MAAM,GAAI,GAClC8C,IAASD,EACbpB,EAAM,aACNhB,IACC,MAAMkB,EAAI,YAAYoC,CAAC,CAAC,CAAC,OAC1BL,IAAc,GACdH,CACF;EACA,KAAK,IAAM,EAAE,UAAO,YAAST,GAC3B,EAASnB,GAAKoB,EAAM,MAAMM,EAAI,GAAGA,EAAI,IAAIA,EAAI,SAAS,GAAGS,GAAWnB,CAAI;CAE5E;CACA,EAAI,QAAQ;AACd"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var e=(e,t,n,r)=>e.map(e=>{let i=e.type??t;return{...e,type:i,...n!==void 0&&i===t?{stack:e.stack??n}:{},...r!==void 0&&(i===`line`||i===`area`)?{curve:e.curve??r}:{}}}),t=(t,n=!1,r={})=>e(t,n?`area`:`line`,r.stacked?`stack`:void 0,r.curve),n=(e,n={})=>t(e,!0,n),r=(t,n=!1,r=!1)=>e(t,`bar`,n?`stack`:void 0).map(e=>r&&e.type===`bar`?{...e,showLabels:e.showLabels??!0}:e),i=t=>e(t,`scatter`),a=t=>e(t,`candlestick`),o=(e,t={})=>{let n=e.data.some(e=>typeof e.x==`number`),r=e.data.some(e=>typeof e.y==`number`);return{...t,series:[{id:`heatmap`,name:e.name??`Value`,type:`heatmap`,data:e.data.map(e=>({x:e.x,y:e.y,value:e.value})),colorScale:e.colorScale,valueRange:e.valueRange,radius:e.radius,format:e.format}],xAxis:{...n?{}:{type:`category`,categories:e.xCategories},grid:!1,...t.xAxis},yAxis:{...r?{}:{type:`category`,categories:e.yCategories},grid:!1,...t.yAxis},legend:t.legend??!1,interaction:t.interaction??{zoom:!1},tooltip:t.tooltip??{mode:`nearest`}}},s=(e,t={})=>{let n=e.type??`line`;return{...t,series:[{id:`sparkline`,name:e.name??`Value`,type:n,data:e.data,color:e.color,curve:n===`bar`?void 0:e.curve??`smooth`,lineWidth:1.5,opacity:n===`area`?.22:void 0,radius:n===`bar`?1.5:void 0,format:e.format}],xAxis:{visible:!1,grid:!1,...t.xAxis},yAxis:{visible:!1,grid:!1,nice:!1,...t.yAxis},legend:!1,padding:t.padding??{top:4,right:4,bottom:4,left:4},interaction:t.interaction??{zoom:!1},annotations:e.reference===void 0?t.annotations:[...t.annotations??[],{type:`line`,axis:`y`,value:e.reference,dash:[2,3]}]}},c={topLeft:`var(--danger-color, #ef4444)`,topRight:`var(--primary-color, #4f46e5)`,bottomLeft:`var(--warning-color, #f59e0b)`,bottomRight:`var(--text-secondary-color, #64748b)`},l=`var(--border-strong-color, var(--border-color, #cbd5e1))`,u=e=>{let[t,n]=e.xDomain??[0,10],[r,i]=e.yDomain??[0,10];return{x0:t,x1:n,y0:r,y1:i,xs:e.xSplit??(t+n)/2,ys:e.ySplit??(r+i)/2}},d=(e,t,n)=>{let{xs:r,ys:i}=u(e),a=e.reverseX?t<r:t>=r;return n>=i?a?`topRight`:`topLeft`:a?`bottomRight`:`bottomLeft`},f=(e,t)=>{let{x0:n,x1:r,y0:i,y1:a,xs:o,ys:s}=u(e),c=t.endsWith(`Right`);return{x:(e.reverseX?!c:c)?(o+r)/2:(n+o)/2,y:t.startsWith(`top`)?(s+a)/2:(i+s)/2}},p=(e,t={})=>{let{x0:n,x1:r,y0:i,y1:a,xs:o,ys:s}=u(e),f=!!e.reverseX,p=t=>e.quadrants?.[t]?.color??c[t],m=[{type:`scatter`,name:e.name??``,pointSize:e.pointSize??12,showLabels:e.showLabels??!0,opacity:.9,data:e.points.map(t=>({x:t.x,y:t.y,label:t.label,size:t.size,color:t.color??p(d(e,t.x,t.y))}))}],h=f?[o,r]:[n,o],g=f?[n,o]:[o,r],_=(t,[n,r],[i,a],o)=>({type:`rect`,x0:n,x1:r,y0:i,y1:a,color:p(t),opacity:.07,label:e.quadrants?.[t]?.label,labelPosition:o}),v=e.axisLabels??{},y=f?r:n,b=f?n:r,x=[...v.top?[{type:`text`,x:o,y:a,text:v.top,anchor:`top`}]:[],...v.bottom?[{type:`text`,x:o,y:i,text:v.bottom,anchor:`bottom`}]:[],...v.left?[{type:`text`,x:y,y:s,text:v.left,anchor:`left`}]:[],...v.right?[{type:`text`,x:b,y:s,text:v.right,anchor:`right`}]:[]],S=[_(`topLeft`,h,[s,a],`top-left`),_(`topRight`,g,[s,a],`top-right`),_(`bottomLeft`,h,[i,s],`bottom-left`),_(`bottomRight`,g,[i,s],`bottom-right`),{type:`line`,axis:`x`,value:o,dash:[],color:l},{type:`line`,axis:`y`,value:s,dash:[],color:l},...x,...t.annotations??[]],C=e.showTicks??!0,w=t.interaction!==!1&&{zoom:!1,...typeof t.interaction==`object`?t.interaction:{},...e.draggable?{dragPoints:!0}:{}};return{...t,series:m,annotations:S,tooltip:t.tooltip??(C?void 0:{render:t=>{let n=t.items[0];if(!n)return null;let r=e.quadrants?.[d(e,n.x,n.y)]?.label;return[n.label??e.name??``,r??``].filter(Boolean).join(`
|
|
2
|
+
`)}}),xAxis:{min:n,max:r,title:e.xLabel,reverse:f,nice:!1,grid:!1,tickCount:4,visible:C||!!e.xLabel,...C?{}:{format:()=>``}},yAxis:{min:i,max:a,title:e.yLabel,nice:!1,grid:!1,tickCount:4,visible:C||!!e.yLabel,...C?{}:{format:()=>``}},legend:t.legend??!1,padding:t.padding??(C?void 0:{top:4,right:4,bottom:4,left:4}),interaction:w}};exports.DEFAULT_QUADRANT_COLORS=c,exports.areaSeries=n,exports.barSeries=r,exports.candlestickSeries=a,exports.heatmapChartOptions=o,exports.lineSeries=t,exports.quadrantCenter=f,exports.quadrantChartOptions=p,exports.quadrantOf=d,exports.scatterSeries=i,exports.sparklineOptions=s,exports.withSeriesType=e;
|
|
3
|
+
//# sourceMappingURL=presets.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.cjs","names":["withSeriesType","series","t","s","type","stack","curve","lineSeries","area","extra","areaSeries","barSeries","stacked","labels","scatterSeries","candlestickSeries","heatmapChartOptions","numericX","config","c","numericY","base","sparklineOptions","DEFAULT_QUADRANT_COLORS","DIVIDER","splits","x0","x1","y0","y1","quadrantOf","right","x","xs","y","ys","quadrantCenter","visualRight","corner","quadrantChartOptions","reverseX","color","p","left","rect","xa","xb","ya","yb","position","ends","visualLeft","texts","annotations","showTicks","interaction","item","event","region"],"sources":["../../../../charts/src/engine/presets.ts"],"sourcesContent":["// Option presets of the chart components, shared by every platform (React,\n// mini-programs, React Native): they turn component props into engine\n// options.\n\nimport type {\n ChartAnnotation,\n ChartCurve,\n ChartInteractionOptions,\n ChartOptions,\n ChartSeries,\n ChartSeriesType,\n} from \"./types\";\n\n/** Gives the series without a `type` the type of the component */\nexport const withSeriesType = (\n series: readonly ChartSeries[],\n type: ChartSeriesType,\n stack?: string,\n curve?: ChartCurve,\n): ChartSeries[] =>\n series.map((s) => {\n const t = s.type ?? type;\n return {\n ...s,\n type: t,\n ...(stack !== undefined && t === type ? { stack: s.stack ?? stack } : {}),\n ...(curve !== undefined && (t === \"line\" || t === \"area\")\n ? { curve: s.curve ?? curve }\n : {}),\n };\n });\n\n/** Options of the line-like components */\nexport interface LineSeriesOptions {\n /** Stacks the series on top of each other */\n stacked?: boolean;\n /** Shape of the lines */\n curve?: ChartCurve;\n}\n\n/** Series of a LineChart (`area` fills them) */\nexport const lineSeries = (\n series: readonly ChartSeries[],\n area = false,\n extra: LineSeriesOptions = {},\n) =>\n withSeriesType(\n series,\n area ? \"area\" : \"line\",\n extra.stacked ? \"stack\" : undefined,\n extra.curve,\n );\n\n/** Series of an AreaChart */\nexport const areaSeries = (\n series: readonly ChartSeries[],\n extra: LineSeriesOptions = {},\n) => lineSeries(series, true, extra);\n\n/** Series of a BarChart (`stacked` stacks them, `labels` shows the values) */\nexport const barSeries = (\n series: readonly ChartSeries[],\n stacked = false,\n labels = false,\n) =>\n withSeriesType(series, \"bar\", stacked ? \"stack\" : undefined).map((s) =>\n labels && s.type === \"bar\" ? { ...s, showLabels: s.showLabels ?? true } : s,\n );\n\n/** Series of a ScatterChart */\nexport const scatterSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"scatter\");\n\n/** Series of a CandlestickChart */\nexport const candlestickSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"candlestick\");\n\n/** A cell of a HeatmapChart */\nexport interface HeatmapCell {\n /** Column: a category name (or a number on a numeric axis) */\n x: string | number;\n /** Row: a category name (or a number on a numeric axis) */\n y: string | number;\n /** Value mapped to the color scale; `null` leaves the cell empty */\n value: number | null;\n}\n\n/** Settings of a heatmap (the props of HeatmapChart) */\nexport interface HeatmapConfig {\n /** Cells */\n data: readonly HeatmapCell[];\n /** Column names in order (collected from the data when omitted) */\n xCategories?: readonly string[];\n /** Row names from bottom to top (collected from the data when omitted) */\n yCategories?: readonly string[];\n /** Colors from the lowest to the highest value; a ramp of the first palette color by default */\n colorScale?: readonly string[];\n /** Values at the ends of the color scale; the data range by default */\n valueRange?: readonly [number, number];\n /** Name of the value in the tooltip */\n name?: string;\n /** Corner radius of the cells, in pixels */\n radius?: number;\n /** Formats the values in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a heatmap */\nexport const heatmapChartOptions = (\n config: HeatmapConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const numericX = config.data.some((c) => typeof c.x === \"number\");\n const numericY = config.data.some((c) => typeof c.y === \"number\");\n return {\n ...base,\n series: [\n {\n id: \"heatmap\",\n name: config.name ?? \"Value\",\n type: \"heatmap\",\n data: config.data.map((c) => ({ x: c.x, y: c.y, value: c.value })),\n colorScale: config.colorScale,\n valueRange: config.valueRange,\n radius: config.radius,\n format: config.format,\n },\n ],\n xAxis: {\n ...(numericX\n ? {}\n : { type: \"category\" as const, categories: config.xCategories }),\n grid: false,\n ...base.xAxis,\n },\n yAxis: {\n ...(numericY\n ? {}\n : { type: \"category\" as const, categories: config.yCategories }),\n grid: false,\n ...base.yAxis,\n },\n legend: base.legend ?? false,\n interaction: base.interaction ?? { zoom: false },\n tooltip: base.tooltip ?? { mode: \"nearest\" },\n };\n};\n\n/** Settings of a sparkline (the props of Sparkline) */\nexport interface SparklineConfig {\n /** Values (or `[x, y]` pairs, typed arrays, ...) */\n data: ChartSeries[\"data\"];\n /**\n * How the values are drawn\n * @default \"line\"\n */\n type?: \"line\" | \"area\" | \"bar\";\n /** Color (any CSS color); the first palette color by default */\n color?: string;\n /**\n * Shape of the line\n * @default \"smooth\"\n */\n curve?: ChartCurve;\n /** Name shown in the tooltip */\n name?: string;\n /** Draws a reference line at this value (e.g. a target or the average) */\n reference?: number;\n /** Formats the value in the tooltip */\n format?: (value: number) => string;\n}\n\n/** Engine options of a sparkline: no axes, no legend, a tooltip only */\nexport const sparklineOptions = (\n config: SparklineConfig,\n base: Partial<ChartOptions> = {},\n): ChartOptions => {\n const type = config.type ?? \"line\";\n return {\n ...base,\n series: [\n {\n id: \"sparkline\",\n name: config.name ?? \"Value\",\n type,\n data: config.data,\n color: config.color,\n curve: type === \"bar\" ? undefined : (config.curve ?? \"smooth\"),\n lineWidth: 1.5,\n opacity: type === \"area\" ? 0.22 : undefined,\n radius: type === \"bar\" ? 1.5 : undefined,\n format: config.format,\n },\n ],\n xAxis: { visible: false, grid: false, ...base.xAxis },\n yAxis: { visible: false, grid: false, nice: false, ...base.yAxis },\n legend: false,\n padding: base.padding ?? { top: 4, right: 4, bottom: 4, left: 4 },\n interaction: base.interaction ?? { zoom: false },\n annotations:\n config.reference !== undefined\n ? [\n ...(base.annotations ?? []),\n {\n type: \"line\",\n axis: \"y\",\n value: config.reference,\n dash: [2, 3],\n },\n ]\n : base.annotations,\n };\n};\n\n/** A point of a QuadrantChart */\nexport interface QuadrantPoint {\n /** Position on the horizontal axis */\n x: number;\n /** Position on the vertical axis */\n y: number;\n /** Text drawn next to the dot and shown in the tooltip */\n label?: string;\n /** Dot color (any CSS color); the color of its quadrant by default */\n color?: string;\n /** Dot diameter in pixels */\n size?: number;\n}\n\n/** Title and color of a quadrant */\nexport interface QuadrantRegion {\n /** Title drawn in the outer corner of the quadrant */\n label?: string;\n /** Background tint and default dot color (any CSS color) */\n color?: string;\n}\n\n/** The four quadrants of a QuadrantChart */\nexport interface QuadrantRegions {\n topLeft?: QuadrantRegion;\n topRight?: QuadrantRegion;\n bottomLeft?: QuadrantRegion;\n bottomRight?: QuadrantRegion;\n}\n\n/** A quadrant, as seen on screen */\nexport type QuadrantCorner = keyof QuadrantRegions;\n\n/** Texts at the four ends of the dividers, inside the plot */\nexport interface QuadrantAxisLabels {\n top?: string;\n bottom?: string;\n left?: string;\n right?: string;\n}\n\n/** Settings of a quadrant matrix (the props of QuadrantChart) */\nexport interface QuadrantConfig {\n /** Points to place */\n points: readonly QuadrantPoint[];\n /**\n * Range of the horizontal axis\n * @default [0, 10]\n */\n xDomain?: [number, number];\n /**\n * Range of the vertical axis\n * @default [0, 10]\n */\n yDomain?: [number, number];\n /** X value of the vertical divider (the middle of `xDomain` by default) */\n xSplit?: number;\n /** Y value of the horizontal divider (the middle of `yDomain` by default) */\n ySplit?: number;\n /** Titles and colors of the quadrants */\n quadrants?: QuadrantRegions;\n /** Title of the horizontal axis */\n xLabel?: string;\n /** Title of the vertical axis */\n yLabel?: string;\n /** Texts at the ends of the dividers, drawn inside the plot (e.g. \"Important\" at the top) */\n axisLabels?: QuadrantAxisLabels;\n /**\n * Shows the numeric ticks of the axes; `false` keeps only the matrix\n * @default true\n */\n showTicks?: boolean;\n /** Reverses the horizontal axis (e.g. \"urgent\" on the left) */\n reverseX?: boolean;\n /**\n * Draws the labels next to the dots (overlapping labels are skipped)\n * @default true\n */\n showLabels?: boolean;\n /**\n * Dot diameter in pixels\n * @default 12\n */\n pointSize?: number;\n /** Name of the points in the tooltip */\n name?: string;\n /** Lets the user drag the dots (`drag` / `drop` events) */\n draggable?: boolean;\n}\n\nexport const DEFAULT_QUADRANT_COLORS: Required<Record<QuadrantCorner, string>> =\n {\n topLeft: \"var(--danger-color, #ef4444)\",\n topRight: \"var(--primary-color, #4f46e5)\",\n bottomLeft: \"var(--warning-color, #f59e0b)\",\n bottomRight: \"var(--text-secondary-color, #64748b)\",\n };\n\nconst DIVIDER = \"var(--border-strong-color, var(--border-color, #cbd5e1))\";\n\nconst splits = (config: QuadrantConfig) => {\n const [x0, x1] = config.xDomain ?? [0, 10];\n const [y0, y1] = config.yDomain ?? [0, 10];\n return {\n x0,\n x1,\n y0,\n y1,\n xs: config.xSplit ?? (x0 + x1) / 2,\n ys: config.ySplit ?? (y0 + y1) / 2,\n };\n};\n\n/** Quadrant of a data position, as seen on screen */\nexport const quadrantOf = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n x: number,\n y: number,\n): QuadrantCorner => {\n const { xs, ys } = splits(config as QuadrantConfig);\n const right = config.reverseX ? x < xs : x >= xs;\n const top = y >= ys;\n return top\n ? right\n ? \"topRight\"\n : \"topLeft\"\n : right\n ? \"bottomRight\"\n : \"bottomLeft\";\n};\n\n/** Center of a quadrant in data coordinates */\nexport const quadrantCenter = (\n config: Pick<\n QuadrantConfig,\n \"xDomain\" | \"yDomain\" | \"xSplit\" | \"ySplit\" | \"reverseX\"\n >,\n corner: QuadrantCorner,\n): { x: number; y: number } => {\n const { x0, x1, y0, y1, xs, ys } = splits(config as QuadrantConfig);\n const visualRight = corner.endsWith(\"Right\");\n const dataHigh = config.reverseX ? !visualRight : visualRight;\n return {\n x: dataHigh ? (xs + x1) / 2 : (x0 + xs) / 2,\n y: corner.startsWith(\"top\") ? (ys + y1) / 2 : (y0 + ys) / 2,\n };\n};\n\n/** Engine options of a quadrant matrix */\nexport const quadrantChartOptions = (\n config: QuadrantConfig,\n base: Omit<ChartOptions, \"series\"> = {},\n): ChartOptions => {\n const { x0, x1, y0, y1, xs, ys } = splits(config);\n const reverseX = !!config.reverseX;\n const color = (corner: QuadrantCorner) =>\n config.quadrants?.[corner]?.color ?? DEFAULT_QUADRANT_COLORS[corner];\n\n const series: ChartSeries[] = [\n {\n type: \"scatter\",\n name: config.name ?? \"\",\n pointSize: config.pointSize ?? 12,\n showLabels: config.showLabels ?? true,\n opacity: 0.9,\n data: config.points.map((p) => ({\n x: p.x,\n y: p.y,\n label: p.label,\n size: p.size,\n color: p.color ?? color(quadrantOf(config, p.x, p.y)),\n })),\n },\n ];\n\n // visual left / right -> data ranges\n const left: [number, number] = reverseX ? [xs, x1] : [x0, xs];\n const right: [number, number] = reverseX ? [x0, xs] : [xs, x1];\n const rect = (\n corner: QuadrantCorner,\n [xa, xb]: [number, number],\n [ya, yb]: [number, number],\n position: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\",\n ): ChartAnnotation => ({\n type: \"rect\",\n x0: xa,\n x1: xb,\n y0: ya,\n y1: yb,\n color: color(corner),\n opacity: 0.07,\n label: config.quadrants?.[corner]?.label,\n labelPosition: position,\n });\n const ends = config.axisLabels ?? {};\n const visualLeft = reverseX ? x1 : x0;\n const visualRight = reverseX ? x0 : x1;\n const texts: ChartAnnotation[] = [\n ...(ends.top\n ? [{ type: \"text\", x: xs, y: y1, text: ends.top, anchor: \"top\" } as const]\n : []),\n ...(ends.bottom\n ? [\n {\n type: \"text\",\n x: xs,\n y: y0,\n text: ends.bottom,\n anchor: \"bottom\",\n } as const,\n ]\n : []),\n ...(ends.left\n ? [\n {\n type: \"text\",\n x: visualLeft,\n y: ys,\n text: ends.left,\n anchor: \"left\",\n } as const,\n ]\n : []),\n ...(ends.right\n ? [\n {\n type: \"text\",\n x: visualRight,\n y: ys,\n text: ends.right,\n anchor: \"right\",\n } as const,\n ]\n : []),\n ];\n\n const annotations: ChartAnnotation[] = [\n rect(\"topLeft\", left, [ys, y1], \"top-left\"),\n rect(\"topRight\", right, [ys, y1], \"top-right\"),\n rect(\"bottomLeft\", left, [y0, ys], \"bottom-left\"),\n rect(\"bottomRight\", right, [y0, ys], \"bottom-right\"),\n { type: \"line\", axis: \"x\", value: xs, dash: [], color: DIVIDER },\n { type: \"line\", axis: \"y\", value: ys, dash: [], color: DIVIDER },\n ...texts,\n ...(base.annotations ?? []),\n ];\n\n const showTicks = config.showTicks ?? true;\n const interaction: boolean | ChartInteractionOptions =\n base.interaction === false\n ? false\n : {\n zoom: false,\n ...(typeof base.interaction === \"object\" ? base.interaction : {}),\n ...(config.draggable ? { dragPoints: true } : {}),\n };\n\n return {\n ...base,\n series,\n annotations,\n tooltip:\n base.tooltip ??\n (showTicks\n ? undefined\n : {\n render: (event) => {\n const item = event.items[0];\n if (!item) return null;\n const region =\n config.quadrants?.[quadrantOf(config, item.x, item.y)]?.label;\n return [item.label ?? config.name ?? \"\", region ?? \"\"]\n .filter(Boolean)\n .join(\"\\n\");\n },\n }),\n xAxis: {\n min: x0,\n max: x1,\n title: config.xLabel,\n reverse: reverseX,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.xLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n yAxis: {\n min: y0,\n max: y1,\n title: config.yLabel,\n nice: false,\n grid: false,\n tickCount: 4,\n visible: showTicks || !!config.yLabel,\n ...(showTicks ? {} : { format: () => \"\" }),\n },\n legend: base.legend ?? false,\n padding:\n base.padding ??\n (showTicks ? undefined : { top: 4, right: 4, bottom: 4, left: 4 }),\n interaction,\n };\n};\n"],"mappings":"AAcA,IAAaA,GACX,EACA,EACA,EACA,IAEAC,EAAO,IAAK,GAAM,CAChB,IAAMC,EAAIC,EAAE,MAAQC,EACpB,MAAO,CACL,GAAGD,EACH,KAAMD,EACN,GAAIG,IAAU,IAAA,IAAaH,IAAME,EAAO,CAAE,MAAOD,EAAE,OAASE,CAAM,EAAI,CAAC,EACvE,GAAIC,IAAU,IAAA,KAAcJ,IAAM,QAAUA,IAAM,QAC9C,CAAE,MAAOC,EAAE,OAASG,CAAM,EAC1B,CAAC,CACP,CACF,CAAC,EAWUC,GACX,EACA,EA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