minerva-design 1.0.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +21 -19
- package/dist/charts/canvas.d.cts +7 -0
- package/dist/charts/canvas.d.ts +7 -0
- package/dist/charts/core.cjs +1 -0
- package/dist/charts/core.d.cts +7 -0
- package/dist/charts/core.d.ts +7 -0
- package/dist/charts/core.js +6 -0
- package/dist/charts/engine/axis.cjs +2 -0
- package/dist/charts/engine/axis.cjs.map +1 -0
- package/dist/charts/engine/axis.d.cts +13 -0
- package/dist/charts/engine/axis.d.ts +13 -0
- package/dist/charts/engine/axis.js +38 -0
- package/dist/charts/engine/axis.js.map +1 -0
- 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 +165 -0
- package/dist/charts/engine/canvas.js.map +1 -0
- package/dist/charts/engine/chart.cjs +3 -0
- package/dist/charts/engine/chart.cjs.map +1 -0
- package/dist/charts/engine/chart.d.cts +6 -0
- package/dist/charts/engine/chart.d.ts +6 -0
- package/dist/charts/engine/chart.js +566 -0
- package/dist/charts/engine/chart.js.map +1 -0
- package/dist/charts/engine/color.cjs +2 -0
- package/dist/charts/engine/color.cjs.map +1 -0
- package/dist/charts/engine/color.d.cts +33 -0
- package/dist/charts/engine/color.d.ts +33 -0
- package/dist/charts/engine/color.js +167 -0
- package/dist/charts/engine/color.js.map +1 -0
- package/dist/charts/engine/controller.cjs +3 -0
- package/dist/charts/engine/controller.cjs.map +1 -0
- package/dist/charts/engine/controller.d.cts +182 -0
- package/dist/charts/engine/controller.d.ts +182 -0
- package/dist/charts/engine/controller.js +528 -0
- package/dist/charts/engine/controller.js.map +1 -0
- package/dist/charts/engine/data.cjs +2 -0
- package/dist/charts/engine/data.cjs.map +1 -0
- package/dist/charts/engine/data.d.cts +29 -0
- package/dist/charts/engine/data.d.ts +29 -0
- package/dist/charts/engine/data.js +104 -0
- package/dist/charts/engine/data.js.map +1 -0
- package/dist/charts/engine/decimate.cjs +2 -0
- package/dist/charts/engine/decimate.cjs.map +1 -0
- package/dist/charts/engine/decimate.d.cts +13 -0
- package/dist/charts/engine/decimate.d.ts +13 -0
- package/dist/charts/engine/decimate.js +28 -0
- package/dist/charts/engine/decimate.js.map +1 -0
- package/dist/charts/engine/dom.cjs +2 -0
- package/dist/charts/engine/dom.cjs.map +1 -0
- package/dist/charts/engine/dom.d.cts +21 -0
- package/dist/charts/engine/dom.d.ts +21 -0
- package/dist/charts/engine/dom.js +125 -0
- package/dist/charts/engine/dom.js.map +1 -0
- package/dist/charts/engine/format.cjs +2 -0
- package/dist/charts/engine/format.cjs.map +1 -0
- package/dist/charts/engine/format.d.cts +9 -0
- package/dist/charts/engine/format.d.ts +9 -0
- package/dist/charts/engine/format.js +34 -0
- package/dist/charts/engine/format.js.map +1 -0
- package/dist/charts/engine/items.cjs +2 -0
- package/dist/charts/engine/items.cjs.map +1 -0
- package/dist/charts/engine/items.d.cts +8 -0
- package/dist/charts/engine/items.d.ts +8 -0
- package/dist/charts/engine/items.js +91 -0
- package/dist/charts/engine/items.js.map +1 -0
- package/dist/charts/engine/layout.cjs +2 -0
- package/dist/charts/engine/layout.cjs.map +1 -0
- package/dist/charts/engine/layout.d.cts +37 -0
- package/dist/charts/engine/layout.d.ts +37 -0
- package/dist/charts/engine/layout.js +26 -0
- package/dist/charts/engine/layout.js.map +1 -0
- package/dist/charts/engine/model.cjs +2 -0
- package/dist/charts/engine/model.cjs.map +1 -0
- package/dist/charts/engine/model.d.cts +74 -0
- package/dist/charts/engine/model.d.ts +74 -0
- package/dist/charts/engine/model.js +175 -0
- package/dist/charts/engine/model.js.map +1 -0
- package/dist/charts/engine/overlay.cjs +2 -0
- package/dist/charts/engine/overlay.cjs.map +1 -0
- package/dist/charts/engine/overlay.d.cts +78 -0
- package/dist/charts/engine/overlay.d.ts +78 -0
- package/dist/charts/engine/overlay.js +137 -0
- package/dist/charts/engine/overlay.js.map +1 -0
- package/dist/charts/engine/presets.cjs +3 -0
- package/dist/charts/engine/presets.cjs.map +1 -0
- package/dist/charts/engine/presets.d.cts +103 -0
- package/dist/charts/engine/presets.d.ts +103 -0
- package/dist/charts/engine/presets.js +153 -0
- package/dist/charts/engine/presets.js.map +1 -0
- package/dist/charts/engine/renderers/canvas2d.cjs +2 -0
- package/dist/charts/engine/renderers/canvas2d.cjs.map +1 -0
- package/dist/charts/engine/renderers/canvas2d.d.cts +20 -0
- package/dist/charts/engine/renderers/canvas2d.d.ts +20 -0
- package/dist/charts/engine/renderers/canvas2d.js +193 -0
- package/dist/charts/engine/renderers/canvas2d.js.map +1 -0
- package/dist/charts/engine/renderers/detect.cjs +2 -0
- package/dist/charts/engine/renderers/detect.cjs.map +1 -0
- package/dist/charts/engine/renderers/detect.d.cts +12 -0
- package/dist/charts/engine/renderers/detect.d.ts +12 -0
- package/dist/charts/engine/renderers/detect.js +33 -0
- package/dist/charts/engine/renderers/detect.js.map +1 -0
- package/dist/charts/engine/renderers/range.cjs +2 -0
- package/dist/charts/engine/renderers/range.cjs.map +1 -0
- package/dist/charts/engine/renderers/range.d.cts +5 -0
- package/dist/charts/engine/renderers/range.d.ts +5 -0
- package/dist/charts/engine/renderers/range.js +32 -0
- package/dist/charts/engine/renderers/range.js.map +1 -0
- package/dist/charts/engine/renderers/shaders.cjs +266 -0
- package/dist/charts/engine/renderers/shaders.cjs.map +1 -0
- package/dist/charts/engine/renderers/shaders.d.cts +20 -0
- package/dist/charts/engine/renderers/shaders.d.ts +20 -0
- package/dist/charts/engine/renderers/shaders.js +251 -0
- package/dist/charts/engine/renderers/shaders.js.map +1 -0
- package/dist/charts/engine/renderers/types.cjs +2 -0
- package/dist/charts/engine/renderers/types.cjs.map +1 -0
- package/dist/charts/engine/renderers/types.d.cts +83 -0
- package/dist/charts/engine/renderers/types.d.ts +83 -0
- package/dist/charts/engine/renderers/types.js +6 -0
- package/dist/charts/engine/renderers/types.js.map +1 -0
- package/dist/charts/engine/renderers/webgl2.cjs +2 -0
- package/dist/charts/engine/renderers/webgl2.cjs.map +1 -0
- package/dist/charts/engine/renderers/webgl2.d.cts +5 -0
- package/dist/charts/engine/renderers/webgl2.d.ts +5 -0
- package/dist/charts/engine/renderers/webgl2.js +134 -0
- package/dist/charts/engine/renderers/webgl2.js.map +1 -0
- package/dist/charts/engine/renderers/webgpu.cjs +2 -0
- package/dist/charts/engine/renderers/webgpu.cjs.map +1 -0
- package/dist/charts/engine/renderers/webgpu.d.cts +6 -0
- package/dist/charts/engine/renderers/webgpu.d.ts +6 -0
- package/dist/charts/engine/renderers/webgpu.js +220 -0
- package/dist/charts/engine/renderers/webgpu.js.map +1 -0
- package/dist/charts/engine/scale.cjs +2 -0
- package/dist/charts/engine/scale.cjs.map +1 -0
- package/dist/charts/engine/scale.d.cts +13 -0
- package/dist/charts/engine/scale.d.ts +13 -0
- package/dist/charts/engine/scale.js +37 -0
- package/dist/charts/engine/scale.js.map +1 -0
- package/dist/charts/engine/scene.cjs +2 -0
- package/dist/charts/engine/scene.cjs.map +1 -0
- package/dist/charts/engine/scene.d.cts +89 -0
- package/dist/charts/engine/scene.d.ts +89 -0
- package/dist/charts/engine/scene.js +241 -0
- package/dist/charts/engine/scene.js.map +1 -0
- package/dist/charts/engine/spatial.cjs +2 -0
- package/dist/charts/engine/spatial.cjs.map +1 -0
- package/dist/charts/engine/spatial.d.cts +18 -0
- package/dist/charts/engine/spatial.d.ts +18 -0
- package/dist/charts/engine/spatial.js +53 -0
- package/dist/charts/engine/spatial.js.map +1 -0
- package/dist/charts/engine/theme.cjs +2 -0
- package/dist/charts/engine/theme.cjs.map +1 -0
- package/dist/charts/engine/theme.d.cts +45 -0
- package/dist/charts/engine/theme.d.ts +45 -0
- package/dist/charts/engine/theme.js +86 -0
- package/dist/charts/engine/theme.js.map +1 -0
- package/dist/charts/engine/time.cjs +2 -0
- package/dist/charts/engine/time.cjs.map +1 -0
- package/dist/charts/engine/time.d.cts +10 -0
- package/dist/charts/engine/time.d.ts +10 -0
- package/dist/charts/engine/time.js +189 -0
- package/dist/charts/engine/time.js.map +1 -0
- package/dist/charts/engine/types.d.cts +356 -0
- package/dist/charts/engine/types.d.ts +356 -0
- package/dist/charts/engine/viewport.cjs +2 -0
- package/dist/charts/engine/viewport.cjs.map +1 -0
- package/dist/charts/engine/viewport.d.cts +12 -0
- package/dist/charts/engine/viewport.d.ts +12 -0
- package/dist/charts/engine/viewport.js +15 -0
- package/dist/charts/engine/viewport.js.map +1 -0
- package/dist/charts/index.cjs +1 -0
- package/dist/charts/index.d.cts +4 -0
- package/dist/charts/index.d.ts +4 -0
- package/dist/charts/index.js +10 -0
- package/dist/charts/react/Chart.cjs +2 -0
- package/dist/charts/react/Chart.cjs.map +1 -0
- package/dist/charts/react/Chart.d.cts +35 -0
- package/dist/charts/react/Chart.d.ts +35 -0
- package/dist/charts/react/Chart.js +117 -0
- package/dist/charts/react/Chart.js.map +1 -0
- package/dist/charts/react/charts.cjs +2 -0
- package/dist/charts/react/charts.cjs.map +1 -0
- package/dist/charts/react/charts.d.cts +13 -0
- package/dist/charts/react/charts.d.ts +13 -0
- package/dist/charts/react/charts.js +133 -0
- package/dist/charts/react/charts.js.map +1 -0
- package/dist/charts/react/types.d.cts +136 -0
- package/dist/charts/react/types.d.ts +136 -0
- 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 +130 -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 +528 -0
- package/dist/native/charts/src/engine/controller.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 +104 -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 +175 -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 +147 -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 +241 -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 +419 -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 +987 -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 +3064 -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 +8 -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 +4019 -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 +48 -2
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
// Shared runtime of the uni-app chart components: finds the `<canvas
|
|
2
|
+
// type="2d">` (the inner HTMLCanvasElement on H5, the SelectorQuery node in
|
|
3
|
+
// mini-programs), draws the chart with the DOM-free engine and forwards
|
|
4
|
+
// touches / pointers. Only `@minerva/charts/canvas` is imported so bundles
|
|
5
|
+
// never include the WebGPU / WebGL2 renderers.
|
|
6
|
+
import { computed, getCurrentInstance, inject, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, toRaw, watch, } from "vue";
|
|
7
|
+
import { githubDark, resolveTokens, } from "../core/index.js";
|
|
8
|
+
import { createCanvasChart, } from "./charts-canvas.js";
|
|
9
|
+
import { useNativeId } from "./native-id.js";
|
|
10
|
+
const themeCache = new Map();
|
|
11
|
+
/** Minerva token values (`--name` keys) of the provider configuration */
|
|
12
|
+
export function chartThemeVariables(config) {
|
|
13
|
+
const mode = config?.mode === "dark" ? "dark" : "light";
|
|
14
|
+
const theme = config?.theme;
|
|
15
|
+
const overrides = theme === "github-dark"
|
|
16
|
+
? githubDark
|
|
17
|
+
: theme && typeof theme === "object"
|
|
18
|
+
? theme
|
|
19
|
+
: undefined;
|
|
20
|
+
const key = JSON.stringify([
|
|
21
|
+
mode,
|
|
22
|
+
config?.palette ?? null,
|
|
23
|
+
config?.design ?? null,
|
|
24
|
+
overrides ?? null,
|
|
25
|
+
]);
|
|
26
|
+
let variables = themeCache.get(key);
|
|
27
|
+
if (!variables) {
|
|
28
|
+
const { css } = resolveTokens({
|
|
29
|
+
mode,
|
|
30
|
+
palette: config?.palette,
|
|
31
|
+
design: config?.design,
|
|
32
|
+
overrides,
|
|
33
|
+
});
|
|
34
|
+
variables = Object.fromEntries(Object.entries(css).map(([name, value]) => [`--${name}`, value]));
|
|
35
|
+
if (themeCache.size >= 16)
|
|
36
|
+
themeCache.clear();
|
|
37
|
+
themeCache.set(key, variables);
|
|
38
|
+
}
|
|
39
|
+
return variables;
|
|
40
|
+
}
|
|
41
|
+
const isPlainObject = (value) => {
|
|
42
|
+
if (!value || typeof value !== "object")
|
|
43
|
+
return false;
|
|
44
|
+
const proto = Object.getPrototypeOf(toRaw(value));
|
|
45
|
+
return proto === Object.prototype || proto === null;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Raw copy of a small option value: reading it through the props tracks
|
|
49
|
+
* nested changes, and the engine receives plain objects (functions and
|
|
50
|
+
* typed arrays are kept as is).
|
|
51
|
+
*/
|
|
52
|
+
export function plain(value) {
|
|
53
|
+
if (Array.isArray(value))
|
|
54
|
+
return value.map(plain);
|
|
55
|
+
if (isPlainObject(value)) {
|
|
56
|
+
const out = {};
|
|
57
|
+
for (const key of Object.keys(value))
|
|
58
|
+
out[key] = plain(value[key]);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Series with their `data` untouched (never traversed: large data sets stay
|
|
65
|
+
* cheap, and the engine keeps its cache while the array is the same).
|
|
66
|
+
*/
|
|
67
|
+
export function plainSeries(series) {
|
|
68
|
+
return (series ?? []).map((item) => {
|
|
69
|
+
const { data, ...rest } = item;
|
|
70
|
+
return { ...plain(rest), data: toRaw(data) };
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** Engine options of the props (like `engineOptions` of the web charts) */
|
|
74
|
+
export function chartEngineOptions(props, series) {
|
|
75
|
+
return {
|
|
76
|
+
series,
|
|
77
|
+
xAxis: plain(props.xAxis),
|
|
78
|
+
yAxis: plain(props.yAxis),
|
|
79
|
+
legend: plain(props.legend),
|
|
80
|
+
tooltip: plain(props.tooltip),
|
|
81
|
+
crosshair: props.crosshair,
|
|
82
|
+
annotations: plain(props.annotations),
|
|
83
|
+
interaction: plain(props.interaction),
|
|
84
|
+
padding: plain(props.padding),
|
|
85
|
+
palette: plain(props.palette),
|
|
86
|
+
ariaLabel: props.ariaLabel,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const cssSize = (value) => typeof value === "number" ? `${value}px` : value;
|
|
90
|
+
function pixelRatio() {
|
|
91
|
+
try {
|
|
92
|
+
const ratio = uni.getWindowInfo?.().pixelRatio;
|
|
93
|
+
if (ratio)
|
|
94
|
+
return ratio;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
/* not available on every host */
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const ratio = uni.getSystemInfoSync?.().pixelRatio;
|
|
101
|
+
if (ratio)
|
|
102
|
+
return ratio;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
/* not available on every host */
|
|
106
|
+
}
|
|
107
|
+
return (typeof window !== "undefined" && window.devicePixelRatio) || 1;
|
|
108
|
+
}
|
|
109
|
+
const noop = () => { };
|
|
110
|
+
export function useCanvasChart(frame, options, listeners) {
|
|
111
|
+
const instance = getCurrentInstance();
|
|
112
|
+
const id = `mn-chart-${useNativeId().replace(/[^a-z0-9]/gi, "")}`;
|
|
113
|
+
const root = ref();
|
|
114
|
+
const plot = shallowRef(null);
|
|
115
|
+
const config = inject("minerva:config", null);
|
|
116
|
+
const variables = computed(() => chartThemeVariables(config?.value));
|
|
117
|
+
const engineOptions = computed(options);
|
|
118
|
+
const rootStyle = computed(() => [
|
|
119
|
+
"position: relative",
|
|
120
|
+
`width: ${cssSize(frame().width) ?? "100%"}`,
|
|
121
|
+
`height: ${cssSize(frame().height) ?? "320px"}`,
|
|
122
|
+
].join("; "));
|
|
123
|
+
let chart = null;
|
|
124
|
+
let element = null;
|
|
125
|
+
let observer;
|
|
126
|
+
let retry;
|
|
127
|
+
let disposed = false;
|
|
128
|
+
let size = { width: -1, height: -1, ratio: -1 };
|
|
129
|
+
let offset = { left: 0, top: 0 };
|
|
130
|
+
const offs = [];
|
|
131
|
+
function create(canvas, width, height) {
|
|
132
|
+
if (disposed || chart)
|
|
133
|
+
return;
|
|
134
|
+
const ratio = pixelRatio();
|
|
135
|
+
size = { width, height, ratio };
|
|
136
|
+
const created = createCanvasChart({
|
|
137
|
+
canvas,
|
|
138
|
+
width,
|
|
139
|
+
height,
|
|
140
|
+
pixelRatio: ratio,
|
|
141
|
+
options: engineOptions.value,
|
|
142
|
+
theme: { variables: variables.value },
|
|
143
|
+
});
|
|
144
|
+
chart = created;
|
|
145
|
+
offs.push(created.on("hover", (event) => listeners.hover?.(event)), created.on("click", (event) => listeners.click?.(event)), created.on("plotClick", (event) => listeners.plotClick?.(event)), created.on("zoom", (event) => listeners.zoom?.(event)), created.on("drop", (event) => listeners.drop?.(event)), created.on("layout", (rect) => (plot.value = { ...rect })));
|
|
146
|
+
const rect = created.getPlotRect();
|
|
147
|
+
plot.value = rect ? { ...rect } : null;
|
|
148
|
+
}
|
|
149
|
+
function apply(width, height) {
|
|
150
|
+
const ratio = pixelRatio();
|
|
151
|
+
if (!chart ||
|
|
152
|
+
(width === size.width && height === size.height && ratio === size.ratio))
|
|
153
|
+
return;
|
|
154
|
+
size = { width, height, ratio };
|
|
155
|
+
chart.resize(width, height, ratio);
|
|
156
|
+
}
|
|
157
|
+
function query(fields, done) {
|
|
158
|
+
try {
|
|
159
|
+
uni
|
|
160
|
+
.createSelectorQuery()
|
|
161
|
+
.in(instance?.proxy)
|
|
162
|
+
.select(`#${id}`)
|
|
163
|
+
.fields(fields, noop)
|
|
164
|
+
.exec((result) => done((Array.isArray(result) ? result[0] : null)));
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
done(null);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function remember(info) {
|
|
171
|
+
offset = { left: info.left ?? 0, top: info.top ?? 0 };
|
|
172
|
+
}
|
|
173
|
+
/** Measures the canvas again and resizes the chart */
|
|
174
|
+
function measure() {
|
|
175
|
+
if (!chart || disposed)
|
|
176
|
+
return;
|
|
177
|
+
if (element) {
|
|
178
|
+
const rect = element.getBoundingClientRect();
|
|
179
|
+
apply(rect.width, rect.height);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
query({ size: true, rect: true }, (info) => {
|
|
183
|
+
if (!info || disposed)
|
|
184
|
+
return;
|
|
185
|
+
remember(info);
|
|
186
|
+
apply(info.width ?? 0, info.height ?? 0);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function attachNode(attempt = 0) {
|
|
190
|
+
retry = undefined;
|
|
191
|
+
query({ node: true, size: true, rect: true }, (info) => {
|
|
192
|
+
if (disposed || chart)
|
|
193
|
+
return;
|
|
194
|
+
if (!info?.node) {
|
|
195
|
+
// uni-mp renders <canvas> after the first setData (`r0`): the node
|
|
196
|
+
// may only be queryable a little after mount
|
|
197
|
+
if (attempt < 5)
|
|
198
|
+
retry = setTimeout(() => attachNode(attempt + 1), 50);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
remember(info);
|
|
202
|
+
create(info.node, info.width ?? 0, info.height ?? 0);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/** H5: uni's `<canvas>` wraps a real canvas element */
|
|
206
|
+
function innerCanvas() {
|
|
207
|
+
const value = root.value;
|
|
208
|
+
const host = value && typeof value === "object" && "$el" in value ? value.$el : value;
|
|
209
|
+
const found = host && typeof host.querySelector === "function"
|
|
210
|
+
? host.querySelector("canvas")
|
|
211
|
+
: null;
|
|
212
|
+
return found && typeof found.getContext === "function" ? found : null;
|
|
213
|
+
}
|
|
214
|
+
const pointerAt = (event) => {
|
|
215
|
+
const rect = element.getBoundingClientRect();
|
|
216
|
+
return [event.clientX - rect.left, event.clientY - rect.top];
|
|
217
|
+
};
|
|
218
|
+
// Mouse / pen on H5 (touches arrive through the touch events)
|
|
219
|
+
const pointer = {
|
|
220
|
+
pointerdown(event) {
|
|
221
|
+
if (event.pointerType === "touch" || !chart)
|
|
222
|
+
return;
|
|
223
|
+
try {
|
|
224
|
+
element?.setPointerCapture?.(event.pointerId);
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
/* capture is optional */
|
|
228
|
+
}
|
|
229
|
+
chart.pointerDown(...pointerAt(event), { id: event.pointerId });
|
|
230
|
+
},
|
|
231
|
+
pointermove(event) {
|
|
232
|
+
if (event.pointerType === "touch" || !chart)
|
|
233
|
+
return;
|
|
234
|
+
chart.pointerMove(...pointerAt(event), { id: event.pointerId });
|
|
235
|
+
},
|
|
236
|
+
pointerup(event) {
|
|
237
|
+
if (event.pointerType === "touch" || !chart)
|
|
238
|
+
return;
|
|
239
|
+
chart.pointerUp(...pointerAt(event), { id: event.pointerId });
|
|
240
|
+
},
|
|
241
|
+
pointercancel(event) {
|
|
242
|
+
if (event.pointerType === "touch" || !chart)
|
|
243
|
+
return;
|
|
244
|
+
chart.getController().pointerCancel({ id: event.pointerId });
|
|
245
|
+
},
|
|
246
|
+
pointerleave(event) {
|
|
247
|
+
if (event.pointerType === "touch" || !chart || event.buttons)
|
|
248
|
+
return;
|
|
249
|
+
chart.pointerLeave();
|
|
250
|
+
},
|
|
251
|
+
// Ctrl / ⌘ + wheel (or any wheel with `interaction.wheel: "always"`)
|
|
252
|
+
// zooms, like the web charts
|
|
253
|
+
wheel(event) {
|
|
254
|
+
const interaction = engineOptions.value.interaction;
|
|
255
|
+
const always = typeof interaction === "object" && interaction.wheel === "always";
|
|
256
|
+
if (!chart ||
|
|
257
|
+
interaction === false ||
|
|
258
|
+
!(always || event.ctrlKey || event.metaKey))
|
|
259
|
+
return;
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
const factor = Math.min(2, Math.max(0.5, Math.exp(event.deltaY * 0.002)));
|
|
262
|
+
chart.zoomAt(...pointerAt(event), factor);
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
function attachElement(canvas) {
|
|
266
|
+
element = canvas;
|
|
267
|
+
const rect = canvas.getBoundingClientRect();
|
|
268
|
+
create(canvas, rect.width, rect.height);
|
|
269
|
+
for (const [type, listener] of Object.entries(pointer))
|
|
270
|
+
canvas.addEventListener(type, listener, {
|
|
271
|
+
passive: type !== "wheel",
|
|
272
|
+
});
|
|
273
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
274
|
+
observer = new ResizeObserver(() => measure());
|
|
275
|
+
observer.observe(canvas);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function touches(list) {
|
|
279
|
+
if (!list)
|
|
280
|
+
return [];
|
|
281
|
+
const rect = element?.getBoundingClientRect();
|
|
282
|
+
return Array.from(list, (touch, index) => {
|
|
283
|
+
const client = typeof touch.clientX === "number" && typeof touch.clientY === "number";
|
|
284
|
+
return {
|
|
285
|
+
x: rect && client
|
|
286
|
+
? touch.clientX - rect.left
|
|
287
|
+
: typeof touch.x === "number"
|
|
288
|
+
? touch.x
|
|
289
|
+
: (touch.clientX ?? 0) - offset.left,
|
|
290
|
+
y: rect && client
|
|
291
|
+
? touch.clientY - rect.top
|
|
292
|
+
: typeof touch.y === "number"
|
|
293
|
+
? touch.y
|
|
294
|
+
: (touch.clientY ?? 0) - offset.top,
|
|
295
|
+
identifier: touch.identifier ?? index,
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function onTouchStart(event) {
|
|
300
|
+
chart?.touchStart(touches(event.changedTouches ?? event.touches));
|
|
301
|
+
}
|
|
302
|
+
function onTouchMove(event) {
|
|
303
|
+
chart?.touchMove(touches(event.touches ?? event.changedTouches));
|
|
304
|
+
}
|
|
305
|
+
function onTouchEnd(event) {
|
|
306
|
+
chart?.touchEnd(touches(event.changedTouches ?? event.touches));
|
|
307
|
+
}
|
|
308
|
+
function onTouchCancel(event) {
|
|
309
|
+
const list = touches(event.changedTouches ?? event.touches);
|
|
310
|
+
chart?.touchCancel(list.length ? list : undefined);
|
|
311
|
+
}
|
|
312
|
+
watch(engineOptions, (next) => chart?.setOptions(next));
|
|
313
|
+
watch(variables, (next) => chart?.setTheme({ variables: next }));
|
|
314
|
+
watch(() => [frame().width, frame().height], () => nextTick(measure));
|
|
315
|
+
onMounted(() => {
|
|
316
|
+
nextTick(() => {
|
|
317
|
+
if (disposed)
|
|
318
|
+
return;
|
|
319
|
+
const canvas = innerCanvas();
|
|
320
|
+
if (canvas)
|
|
321
|
+
attachElement(canvas);
|
|
322
|
+
else
|
|
323
|
+
attachNode();
|
|
324
|
+
});
|
|
325
|
+
uni.onWindowResize?.(measure);
|
|
326
|
+
});
|
|
327
|
+
onBeforeUnmount(() => {
|
|
328
|
+
disposed = true;
|
|
329
|
+
if (retry !== undefined)
|
|
330
|
+
clearTimeout(retry);
|
|
331
|
+
observer?.disconnect();
|
|
332
|
+
uni.offWindowResize?.(measure);
|
|
333
|
+
if (element)
|
|
334
|
+
for (const [type, listener] of Object.entries(pointer))
|
|
335
|
+
element.removeEventListener(type, listener);
|
|
336
|
+
offs.splice(0).forEach((off) => off());
|
|
337
|
+
chart?.destroy();
|
|
338
|
+
chart = null;
|
|
339
|
+
element = null;
|
|
340
|
+
});
|
|
341
|
+
const handle = {
|
|
342
|
+
resetZoom: () => chart?.resetZoom(),
|
|
343
|
+
getView: () => chart?.getView() ?? null,
|
|
344
|
+
setView: (view) => chart?.setView(view),
|
|
345
|
+
getRenderer: () => (chart ? "canvas2d" : null),
|
|
346
|
+
getInstance: () => chart,
|
|
347
|
+
resize: () => {
|
|
348
|
+
size = { width: -1, height: -1, ratio: -1 };
|
|
349
|
+
measure();
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
return {
|
|
353
|
+
id,
|
|
354
|
+
root,
|
|
355
|
+
plot,
|
|
356
|
+
rootStyle,
|
|
357
|
+
handle,
|
|
358
|
+
onTouchStart,
|
|
359
|
+
onTouchMove,
|
|
360
|
+
onTouchEnd,
|
|
361
|
+
onTouchCancel,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { PropType } from "vue";
|
|
2
|
+
import type { CanvasChartInstance, ChartAnnotation, ChartAxisOptions, ChartInteractionOptions, ChartLegendOptions, ChartPadding, ChartSeries, ChartTooltipOptions, ChartView, QuadrantAxisLabels, QuadrantCorner, QuadrantPoint, QuadrantRegions } from "./charts-canvas.js";
|
|
3
|
+
export type { CanvasChartInstance, ChartAnnotation, ChartAxisOptions, ChartHoverEvent, ChartHoverItem, ChartInteractionOptions, ChartLegendOptions, ChartPadding, ChartPlotClickEvent, ChartSeries, ChartSeriesData, ChartTooltipOptions, ChartView, QuadrantAxisLabels, QuadrantCorner, QuadrantPoint, QuadrantRegion, QuadrantRegions, } from "./charts-canvas.js";
|
|
4
|
+
/** Imperative handle of the chart components (template `ref`) */
|
|
5
|
+
export interface ChartHandle {
|
|
6
|
+
/** Shows the whole data range */
|
|
7
|
+
resetZoom(): void;
|
|
8
|
+
/** Visible range, `null` until the canvas is ready */
|
|
9
|
+
getView(): ChartView | null;
|
|
10
|
+
/** Sets the visible range */
|
|
11
|
+
setView(view: Partial<ChartView>): void;
|
|
12
|
+
/** Always `canvas2d` once the canvas is ready, `null` before */
|
|
13
|
+
getRenderer(): "canvas2d" | null;
|
|
14
|
+
/** The underlying canvas chart, `null` until the canvas is ready */
|
|
15
|
+
getInstance(): CanvasChartInstance | null;
|
|
16
|
+
/** Measures the canvas again (after a layout change the chart cannot see) */
|
|
17
|
+
resize(): void;
|
|
18
|
+
}
|
|
19
|
+
/** Where a dragged QuadrantChart point was dropped */
|
|
20
|
+
export interface QuadrantDropTarget {
|
|
21
|
+
/** Data coordinates of the drop */
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
/** Quadrant of the drop, as seen on screen */
|
|
25
|
+
quadrant: QuadrantCorner;
|
|
26
|
+
}
|
|
27
|
+
/** Props shared by every chart component */
|
|
28
|
+
export declare const chartCommonProps: {
|
|
29
|
+
/** Height of the chart (the legend included); numbers are pixels, strings any CSS length (rpx included) */
|
|
30
|
+
height: {
|
|
31
|
+
type: PropType<number | string>;
|
|
32
|
+
default: number;
|
|
33
|
+
};
|
|
34
|
+
/** Width of the chart; numbers are pixels */
|
|
35
|
+
width: {
|
|
36
|
+
type: PropType<number | string>;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
/** Legend; shown by default when several series have a name */
|
|
40
|
+
legend: {
|
|
41
|
+
type: PropType<boolean | ChartLegendOptions>;
|
|
42
|
+
default: undefined;
|
|
43
|
+
};
|
|
44
|
+
/** Tooltip; `false` disables it (`render` may return a string) */
|
|
45
|
+
tooltip: {
|
|
46
|
+
type: PropType<boolean | ChartTooltipOptions>;
|
|
47
|
+
default: undefined;
|
|
48
|
+
};
|
|
49
|
+
/** Vertical guide line following the finger */
|
|
50
|
+
crosshair: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
54
|
+
/** Background areas and reference lines */
|
|
55
|
+
annotations: PropType<readonly ChartAnnotation[]>;
|
|
56
|
+
/** Pinch zoom, pan, double tap reset; `false` makes the chart static */
|
|
57
|
+
interaction: {
|
|
58
|
+
type: PropType<boolean | ChartInteractionOptions>;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
61
|
+
/** Space around the plot area, in pixels */
|
|
62
|
+
padding: PropType<ChartPadding>;
|
|
63
|
+
/** Series colors (defaults to the theme colors) */
|
|
64
|
+
palette: PropType<readonly string[]>;
|
|
65
|
+
/** Accessible name of the chart */
|
|
66
|
+
ariaLabel: StringConstructor;
|
|
67
|
+
/** Keeps the page from scrolling while a finger moves on the chart */
|
|
68
|
+
disableScroll: {
|
|
69
|
+
type: BooleanConstructor;
|
|
70
|
+
default: undefined;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/** X / Y axes (every chart but QuadrantChart) */
|
|
74
|
+
export declare const chartAxisProps: {
|
|
75
|
+
/** X axis */
|
|
76
|
+
xAxis: PropType<ChartAxisOptions>;
|
|
77
|
+
/** Y axis */
|
|
78
|
+
yAxis: PropType<ChartAxisOptions>;
|
|
79
|
+
};
|
|
80
|
+
/** Data series */
|
|
81
|
+
export declare const chartSeriesProps: {
|
|
82
|
+
/** Data series (replace the array or a `data` array to update the chart) */
|
|
83
|
+
readonly series: {
|
|
84
|
+
readonly type: PropType<readonly ChartSeries[]>;
|
|
85
|
+
readonly required: true;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** Props of QuadrantChart (besides the common ones) */
|
|
89
|
+
export declare const quadrantChartProps: {
|
|
90
|
+
/** Points to place (replace the array to update the chart) */
|
|
91
|
+
readonly points: {
|
|
92
|
+
readonly type: PropType<readonly QuadrantPoint[]>;
|
|
93
|
+
readonly required: true;
|
|
94
|
+
};
|
|
95
|
+
/** Range of the horizontal axis (default `[0, 10]`) */
|
|
96
|
+
readonly xDomain: PropType<[number, number]>;
|
|
97
|
+
/** Range of the vertical axis (default `[0, 10]`) */
|
|
98
|
+
readonly yDomain: PropType<[number, number]>;
|
|
99
|
+
/** X value of the vertical divider (the middle of `xDomain` by default) */
|
|
100
|
+
readonly xSplit: NumberConstructor;
|
|
101
|
+
/** Y value of the horizontal divider (the middle of `yDomain` by default) */
|
|
102
|
+
readonly ySplit: NumberConstructor;
|
|
103
|
+
/** Titles and colors of the quadrants */
|
|
104
|
+
readonly quadrants: PropType<QuadrantRegions>;
|
|
105
|
+
/** Title of the horizontal axis */
|
|
106
|
+
readonly xLabel: StringConstructor;
|
|
107
|
+
/** Title of the vertical axis */
|
|
108
|
+
readonly yLabel: StringConstructor;
|
|
109
|
+
/** Texts at the ends of the dividers, drawn inside the plot */
|
|
110
|
+
readonly axisLabels: PropType<QuadrantAxisLabels>;
|
|
111
|
+
/** Shows the numeric ticks of the axes (default `true`) */
|
|
112
|
+
readonly showTicks: {
|
|
113
|
+
readonly type: BooleanConstructor;
|
|
114
|
+
readonly default: undefined;
|
|
115
|
+
};
|
|
116
|
+
/** Reverses the horizontal axis */
|
|
117
|
+
readonly reverseX: {
|
|
118
|
+
readonly type: BooleanConstructor;
|
|
119
|
+
readonly default: undefined;
|
|
120
|
+
};
|
|
121
|
+
/** Draws the labels next to the dots (default `true`) */
|
|
122
|
+
readonly showLabels: {
|
|
123
|
+
readonly type: BooleanConstructor;
|
|
124
|
+
readonly default: undefined;
|
|
125
|
+
};
|
|
126
|
+
/** Dot diameter in pixels (default 12) */
|
|
127
|
+
readonly pointSize: NumberConstructor;
|
|
128
|
+
/** Name of the points in the tooltip */
|
|
129
|
+
readonly name: StringConstructor;
|
|
130
|
+
/** Lets the user drag the dots (default: when a `pointDrop` listener is set) */
|
|
131
|
+
readonly draggable: {
|
|
132
|
+
readonly type: BooleanConstructor;
|
|
133
|
+
readonly default: undefined;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Booleans and boolean unions default to `undefined` (not Vue's `false`) so
|
|
2
|
+
// the engine defaults apply when they are omitted.
|
|
3
|
+
/** Props shared by every chart component */
|
|
4
|
+
export const chartCommonProps = {
|
|
5
|
+
/** Height of the chart (the legend included); numbers are pixels, strings any CSS length (rpx included) */
|
|
6
|
+
height: { type: [Number, String], default: 320 },
|
|
7
|
+
/** Width of the chart; numbers are pixels */
|
|
8
|
+
width: {
|
|
9
|
+
type: [Number, String],
|
|
10
|
+
default: "100%",
|
|
11
|
+
},
|
|
12
|
+
/** Legend; shown by default when several series have a name */
|
|
13
|
+
legend: {
|
|
14
|
+
type: [Boolean, Object],
|
|
15
|
+
default: undefined,
|
|
16
|
+
},
|
|
17
|
+
/** Tooltip; `false` disables it (`render` may return a string) */
|
|
18
|
+
tooltip: {
|
|
19
|
+
type: [Boolean, Object],
|
|
20
|
+
default: undefined,
|
|
21
|
+
},
|
|
22
|
+
/** Vertical guide line following the finger */
|
|
23
|
+
crosshair: { type: Boolean, default: undefined },
|
|
24
|
+
/** Background areas and reference lines */
|
|
25
|
+
annotations: Array,
|
|
26
|
+
/** Pinch zoom, pan, double tap reset; `false` makes the chart static */
|
|
27
|
+
interaction: {
|
|
28
|
+
type: [Boolean, Object],
|
|
29
|
+
default: undefined,
|
|
30
|
+
},
|
|
31
|
+
/** Space around the plot area, in pixels */
|
|
32
|
+
padding: Object,
|
|
33
|
+
/** Series colors (defaults to the theme colors) */
|
|
34
|
+
palette: Array,
|
|
35
|
+
/** Accessible name of the chart */
|
|
36
|
+
ariaLabel: String,
|
|
37
|
+
/** Keeps the page from scrolling while a finger moves on the chart */
|
|
38
|
+
disableScroll: { type: Boolean, default: undefined },
|
|
39
|
+
};
|
|
40
|
+
/** X / Y axes (every chart but QuadrantChart) */
|
|
41
|
+
export const chartAxisProps = {
|
|
42
|
+
/** X axis */
|
|
43
|
+
xAxis: Object,
|
|
44
|
+
/** Y axis */
|
|
45
|
+
yAxis: Object,
|
|
46
|
+
};
|
|
47
|
+
/** Data series */
|
|
48
|
+
export const chartSeriesProps = {
|
|
49
|
+
/** Data series (replace the array or a `data` array to update the chart) */
|
|
50
|
+
series: { type: Array, required: true },
|
|
51
|
+
};
|
|
52
|
+
/** Props of QuadrantChart (besides the common ones) */
|
|
53
|
+
export const quadrantChartProps = {
|
|
54
|
+
/** Points to place (replace the array to update the chart) */
|
|
55
|
+
points: { type: Array, required: true },
|
|
56
|
+
/** Range of the horizontal axis (default `[0, 10]`) */
|
|
57
|
+
xDomain: Array,
|
|
58
|
+
/** Range of the vertical axis (default `[0, 10]`) */
|
|
59
|
+
yDomain: Array,
|
|
60
|
+
/** X value of the vertical divider (the middle of `xDomain` by default) */
|
|
61
|
+
xSplit: Number,
|
|
62
|
+
/** Y value of the horizontal divider (the middle of `yDomain` by default) */
|
|
63
|
+
ySplit: Number,
|
|
64
|
+
/** Titles and colors of the quadrants */
|
|
65
|
+
quadrants: Object,
|
|
66
|
+
/** Title of the horizontal axis */
|
|
67
|
+
xLabel: String,
|
|
68
|
+
/** Title of the vertical axis */
|
|
69
|
+
yLabel: String,
|
|
70
|
+
/** Texts at the ends of the dividers, drawn inside the plot */
|
|
71
|
+
axisLabels: Object,
|
|
72
|
+
/** Shows the numeric ticks of the axes (default `true`) */
|
|
73
|
+
showTicks: { type: Boolean, default: undefined },
|
|
74
|
+
/** Reverses the horizontal axis */
|
|
75
|
+
reverseX: { type: Boolean, default: undefined },
|
|
76
|
+
/** Draws the labels next to the dots (default `true`) */
|
|
77
|
+
showLabels: { type: Boolean, default: undefined },
|
|
78
|
+
/** Dot diameter in pixels (default 12) */
|
|
79
|
+
pointSize: Number,
|
|
80
|
+
/** Name of the points in the tooltip */
|
|
81
|
+
name: String,
|
|
82
|
+
/** Lets the user drag the dots (default: when a `pointDrop` listener is set) */
|
|
83
|
+
draggable: { type: Boolean, default: undefined },
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../charts/canvas.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Private entry of the platform packages (Taro, uni-app, WeChat, React
|
|
2
|
+
// Native): the DOM-free part of the engine only, so their bundles never
|
|
3
|
+
// include the WebGPU / WebGL2 renderers nor the DOM chart.
|
|
4
|
+
export { createCanvasChart, drawScene, } from "../charts/engine/canvas.js";
|
|
5
|
+
export { createChartController, scenePrimitives, } from "../charts/engine/controller.js";
|
|
6
|
+
export { formatCompact } from "../charts/engine/format.js";
|
|
7
|
+
export { barSeries, DEFAULT_QUADRANT_COLORS, lineSeries, quadrantCenter, quadrantChartOptions, quadrantOf, scatterSeries, } from "../charts/engine/presets.js";
|
|
8
|
+
export { toCss } from "../charts/engine/color.js";
|
package/dist/uni/index.d.ts
CHANGED
|
@@ -124,3 +124,9 @@ export { default as TooltipProvider } from "./TooltipProvider.vue.js";
|
|
|
124
124
|
export { confirm, toast } from "./feedback-store.js";
|
|
125
125
|
export { useConfirm, useToast } from "./feedback-context.js";
|
|
126
126
|
export { default as DatePicker } from "./DatePicker.vue.js";
|
|
127
|
+
export { default as Chart } from "./Chart.vue.js";
|
|
128
|
+
export { default as LineChart } from "./LineChart.vue.js";
|
|
129
|
+
export { default as BarChart } from "./BarChart.vue.js";
|
|
130
|
+
export { default as ScatterChart } from "./ScatterChart.vue.js";
|
|
131
|
+
export { default as QuadrantChart } from "./QuadrantChart.vue.js";
|
|
132
|
+
export type { ChartAnnotation, ChartAxisOptions, ChartHandle, ChartHoverEvent, ChartHoverItem, ChartInteractionOptions, ChartLegendOptions, ChartPadding, ChartPlotClickEvent, ChartSeries, ChartSeriesData, ChartTooltipOptions, ChartView, QuadrantAxisLabels, QuadrantCorner, QuadrantDropTarget, QuadrantPoint, QuadrantRegion, QuadrantRegions, } from "./chart-types.js";
|
package/dist/uni/index.js
CHANGED
|
@@ -124,3 +124,9 @@ export { default as TooltipProvider } from "./TooltipProvider.vue";
|
|
|
124
124
|
export { confirm, toast } from "./feedback-store.js";
|
|
125
125
|
export { useConfirm, useToast } from "./feedback-context.js";
|
|
126
126
|
export { default as DatePicker } from "./DatePicker.vue";
|
|
127
|
+
// Charts: canvas renderer of the chart engine (outside the component contract matrix)
|
|
128
|
+
export { default as Chart } from "./Chart.vue";
|
|
129
|
+
export { default as LineChart } from "./LineChart.vue";
|
|
130
|
+
export { default as BarChart } from "./BarChart.vue";
|
|
131
|
+
export { default as ScatterChart } from "./ScatterChart.vue";
|
|
132
|
+
export { default as QuadrantChart } from "./QuadrantChart.vue";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Component(require('../controls.js').barChart.definition);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"component":true}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<view class="mn-chart" style="display:block;position:relative;width:{{chartWidth}};height:{{chartHeight}}"><canvas type="2d" class="mn-chart-canvas" style="display:block;width:100%;height:100%" disable-scroll="{{disableScroll}}" aria-role="img" aria-label="{{ariaLabel}}" bindtouchstart="onTouchStart" bindtouchmove="onTouchMove" bindtouchend="onTouchEnd" bindtouchcancel="onTouchCancel"></canvas></view>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "../controls.wxss";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Component(require('../controls.js').chart.definition);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"component":true}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<view class="mn-chart" style="display:block;position:relative;width:{{chartWidth}};height:{{chartHeight}}"><canvas type="2d" class="mn-chart-canvas" style="display:block;width:100%;height:100%" disable-scroll="{{disableScroll}}" aria-role="img" aria-label="{{ariaLabel}}" bindtouchstart="onTouchStart" bindtouchmove="onTouchMove" bindtouchend="onTouchEnd" bindtouchcancel="onTouchCancel"></canvas></view>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "../controls.wxss";
|