minerva-design 1.1.0 → 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 +8 -0
- package/dist/charts/canvas.d.cts +7 -0
- package/dist/charts/canvas.d.ts +7 -0
- package/dist/charts/core.cjs +1 -1
- package/dist/charts/core.d.cts +5 -1
- package/dist/charts/core.d.ts +5 -1
- package/dist/charts/core.js +4 -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 +165 -0
- package/dist/charts/engine/canvas.js.map +1 -0
- package/dist/charts/engine/chart.cjs +2 -2
- package/dist/charts/engine/chart.cjs.map +1 -1
- package/dist/charts/engine/chart.js +382 -440
- 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 +10 -0
- package/dist/charts/engine/color.d.ts +10 -0
- package/dist/charts/engine/color.js +75 -3
- 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 +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/model.cjs +1 -1
- package/dist/charts/engine/model.cjs.map +1 -1
- package/dist/charts/engine/model.d.cts +2 -2
- package/dist/charts/engine/model.d.ts +2 -2
- package/dist/charts/engine/model.js +72 -72
- 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 +17 -1
- package/dist/charts/engine/overlay.d.ts +17 -1
- package/dist/charts/engine/overlay.js +63 -49
- 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 +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 +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 +88 -51
- package/dist/charts/engine/renderers/canvas2d.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 +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/theme.cjs +1 -1
- package/dist/charts/engine/theme.cjs.map +1 -1
- package/dist/charts/engine/theme.d.cts +25 -1
- package/dist/charts/engine/theme.d.ts +25 -1
- package/dist/charts/engine/theme.js +42 -26
- package/dist/charts/engine/theme.js.map +1 -1
- package/dist/charts/engine/types.d.cts +69 -2
- package/dist/charts/engine/types.d.ts +69 -2
- package/dist/charts/index.cjs +1 -1
- package/dist/charts/index.d.cts +1 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.js +5 -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 +11 -4
- package/dist/charts/react/Chart.d.ts +11 -4
- package/dist/charts/react/Chart.js +81 -39
- 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 +1 -1
- package/dist/charts/react/charts.d.ts +1 -1
- package/dist/charts/react/charts.js +99 -145
- package/dist/charts/react/charts.js.map +1 -1
- package/dist/charts/react/types.d.cts +29 -61
- package/dist/charts/react/types.d.ts +29 -61
- 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 +21 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=(e,t=e.fontSize,n=400)=>`${n} ${t}px ${e.fontFamily}`,t=(e,t,n,r)=>{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;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)),{x:s,y:c,width:n,height:r}},n=(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,r=(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,i=(e,t,i,a,o=[])=>{let s=[];for(let c of e){let e=i(c.text),l=c.r+4,u=[{x:c.x+l,y:c.y-a/2,width:e,height:a},{x:c.x-l-e,y:c.y-a/2,width:e,height:a},{x:c.x-e/2,y:c.y-l-a,width:e,height:a},{x:c.x-e/2,y:c.y+l,width:e,height:a}].find(e=>r(e,t)&&!o.some(t=>n(t,e)));u&&(o.push(u),s.push({label:c,box:u}))}return s};exports.font=e,exports.placeLabels=i,exports.textBox=t;
|
|
2
|
+
//# sourceMappingURL=overlay.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.cjs","names":["font","theme","weight","size","textBox","s","px","a","plot","py","x","width","y","height","overlaps","b","inside","r","placeLabels","placed","label","labels","w","measure","gap","box","c","occupied","o"],"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}\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 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 * 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":"AAqDA,IAAaA,GAAQ,EAAmB,EAAOC,EAAM,SAAU,EAAS,MACtE,GAAGC,EAAO,GAAGC,EAAK,KAAKF,EAAM,aAKlBG,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,O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X,EAAQ,MAAOS,EAAG,QAAO,EAClE,CAAE,EAAGF,EAAM,EAAIE,EAAI,EAAG,EAAGF,EAAM,EAAII,EAAK,MAAOF,EAAG,QAAO,CAE/C,CAAA,CAAW,KACpB,GAAMN,EAAOU,EAAGlB,CAAI,GAAK,CAACmB,EAAS,KAAM,GAAMb,EAASc,EAAGF,CAAC,CAAC,CAChE,EACKD,IACLE,EAAS,KAAKF,CAAG,EACjBN,EAAO,KAAK,CAAE,QAAO,KAAI,CAAC,EAC5B,CACA,OAAOA,CACT"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region ../charts/src/engine/overlay.ts
|
|
2
|
+
var e = (e, t = e.fontSize, n = 400) => `${n} ${t}px ${e.fontFamily}`, t = (e, t, n, r) => {
|
|
3
|
+
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;
|
|
4
|
+
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)), {
|
|
5
|
+
x: s,
|
|
6
|
+
y: c,
|
|
7
|
+
width: n,
|
|
8
|
+
height: r
|
|
9
|
+
};
|
|
10
|
+
}, n = (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, r = (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, i = (e, t, i, a, o = []) => {
|
|
11
|
+
let s = [];
|
|
12
|
+
for (let c of e) {
|
|
13
|
+
let e = i(c.text), l = c.r + 4, u = [
|
|
14
|
+
{
|
|
15
|
+
x: c.x + l,
|
|
16
|
+
y: c.y - a / 2,
|
|
17
|
+
width: e,
|
|
18
|
+
height: a
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
x: c.x - l - e,
|
|
22
|
+
y: c.y - a / 2,
|
|
23
|
+
width: e,
|
|
24
|
+
height: a
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
x: c.x - e / 2,
|
|
28
|
+
y: c.y - l - a,
|
|
29
|
+
width: e,
|
|
30
|
+
height: a
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
x: c.x - e / 2,
|
|
34
|
+
y: c.y + l,
|
|
35
|
+
width: e,
|
|
36
|
+
height: a
|
|
37
|
+
}
|
|
38
|
+
].find((e) => r(e, t) && !o.some((t) => n(t, e)));
|
|
39
|
+
u && (o.push(u), s.push({
|
|
40
|
+
label: c,
|
|
41
|
+
box: u
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
return s;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { e as font, i as placeLabels, t as textBox };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.js","names":["font","theme","weight","size","textBox","s","px","a","plot","py","x","width","y","height","overlaps","b","inside","r","placeLabels","placed","label","labels","w","measure","gap","box","c","occupied","o"],"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}\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 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 * 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":";AAqDA,IAAaA,KAAQ,GAAmB,IAAOC,EAAM,UAAU,IAAS,QACtE,GAAGC,EAAO,GAAGC,EAAK,KAAKF,EAAM,cAKlBG,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,EAAE,WAAW,YAAS,IAAID,IAAK,IAAMK,IAC9C,IAAI,KAAK,IAAIH,EAAK,IAAI,GAAK,KAAK,IAAIE,GAAGF,EAAK,IAAIA,EAAK,QAAQ,IAAMG,CAAK,CAAC,GACzE,IAAI,KAAK,IAAIH,EAAK,IAAI,GAAG,KAAK,IAAII,GAAGJ,EAAK,IAAIA,EAAK,SAAS,IAAIK,CAAM,CAAC,GAChE;EAAE;EAAG;EAAG;EAAO;CAAO;AAC/B,GAqIMC,KAAY,GAAS,MACzBP,EAAE,IAAIQ,EAAE,IAAIA,EAAE,SACdA,EAAE,IAAIR,EAAE,IAAIA,EAAE,SACdA,EAAE,IAAIQ,EAAE,IAAIA,EAAE,UACdA,EAAE,IAAIR,EAAE,IAAIA,EAAE,QAEVS,KAAU,GAAS,MACvBC,EAAE,KAAKT,EAAK,KACZS,EAAE,KAAKT,EAAK,KACZS,EAAE,IAAIA,EAAE,SAAST,EAAK,IAAIA,EAAK,SAC/BS,EAAE,IAAIA,EAAE,UAAUT,EAAK,IAAIA,EAAK,QAoBrBU,KACX,GACA,GACA,GACA,GACA,IAAmB,CAAC,MACmB;CACvC,IAAMC,IAA6C,CAAC;CACpD,KAAK,IAAMC,KAASC,GAAQ;EAC1B,IAAMC,IAAIC,EAAQH,EAAM,IAAI,GACtBI,IAAMJ,EAAM,IAAI,GAOhBK,IAAM;GALV;IAAE,GAAGL,EAAM,IAAII;IAAK,GAAGJ,EAAM,IAAIP,IAAS;IAAG,OAAOS;IAAG;GAAO;GAC9D;IAAE,GAAGF,EAAM,IAAII,IAAMF;IAAG,GAAGF,EAAM,IAAIP,IAAS;IAAG,OAAOS;IAAG;GAAO;GAClE;IAAE,GAAGF,EAAM,IAAIE,IAAI;IAAG,GAAGF,EAAM,IAAII,IAAMX;IAAQ,OAAOS;IAAG;GAAO;GAClE;IAAE,GAAGF,EAAM,IAAIE,IAAI;IAAG,GAAGF,EAAM,IAAII;IAAK,OAAOF;IAAG;GAAO;EAE/C,CAAA,CAAW,MACpB,MAAMN,EAAOU,GAAGlB,CAAI,KAAK,CAACmB,EAAS,MAAM,MAAMb,EAASc,GAAGF,CAAC,CAAC,CAChE;EACA,AAAKD,MACLE,EAAS,KAAKF,CAAG,GACjBN,EAAO,KAAK;GAAE;GAAO;EAAI,CAAC;CAC5B;CACA,OAAOA;AACT"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var e=(e,t,n)=>e.map(e=>({...e,type:e.type??t,...n!==void 0&&(e.type??t)===`bar`?{stack:e.stack??n}:{}})),t=(t,n=!1)=>e(t,n?`area`:`line`),n=(t,n=!1)=>e(t,`bar`,n?`stack`:void 0),r=t=>e(t,`scatter`),i={topLeft:`var(--danger-color, #ef4444)`,topRight:`var(--primary-color, #4f46e5)`,bottomLeft:`var(--warning-color, #f59e0b)`,bottomRight:`var(--text-secondary-color, #64748b)`},a=`var(--border-strong-color, var(--border-color, #cbd5e1))`,o=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}},s=(e,t,n)=>{let{xs:r,ys:i}=o(e),a=e.reverseX?t<r:t>=r;return n>=i?a?`topRight`:`topLeft`:a?`bottomRight`:`bottomLeft`},c=(e,t={})=>{let{x0:n,x1:r,y0:c,y1:l,xs:u,ys:d}=o(e),f=!!e.reverseX,p=t=>e.quadrants?.[t]?.color??i[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(s(e,t.x,t.y))}))}],h=f?[u,r]:[n,u],g=f?[n,u]:[u,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:u,y:l,text:v.top,anchor:`top`}]:[],...v.bottom?[{type:`text`,x:u,y:c,text:v.bottom,anchor:`bottom`}]:[],...v.left?[{type:`text`,x:y,y:d,text:v.left,anchor:`left`}]:[],...v.right?[{type:`text`,x:b,y:d,text:v.right,anchor:`right`}]:[]],S=[_(`topLeft`,h,[d,l],`top-left`),_(`topRight`,g,[d,l],`top-right`),_(`bottomLeft`,h,[c,d],`bottom-left`),_(`bottomRight`,g,[c,d],`bottom-right`),{type:`line`,axis:`x`,value:u,dash:[],color:a},{type:`line`,axis:`y`,value:d,dash:[],color:a},...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?.[s(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:c,max:l,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=i,exports.barSeries=n,exports.lineSeries=t,exports.quadrantChartOptions=c,exports.quadrantOf=s,exports.scatterSeries=r,exports.withSeriesType=e;
|
|
3
|
+
//# sourceMappingURL=presets.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.cjs","names":["withSeriesType","series","s","type","stack","lineSeries","area","barSeries","stacked","scatterSeries","DEFAULT_QUADRANT_COLORS","DIVIDER","splits","x0","x1","config","y0","y1","quadrantOf","right","x","xs","y","ys","quadrantChartOptions","reverseX","color","corner","p","left","rect","xa","xb","ya","yb","position","ends","visualLeft","visualRight","texts","annotations","base","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 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): ChartSeries[] =>\n series.map((s) => ({\n ...s,\n type: s.type ?? type,\n ...(stack !== undefined && (s.type ?? type) === \"bar\"\n ? { stack: s.stack ?? stack }\n : {}),\n }));\n\n/** Series of a LineChart (`area` fills them) */\nexport const lineSeries = (series: readonly ChartSeries[], area = false) =>\n withSeriesType(series, area ? \"area\" : \"line\");\n\n/** Series of a BarChart (`stacked` stacks them) */\nexport const barSeries = (series: readonly ChartSeries[], stacked = false) =>\n withSeriesType(series, \"bar\", stacked ? \"stack\" : undefined);\n\n/** Series of a ScatterChart */\nexport const scatterSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"scatter\");\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 (showTic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C,EACA,MAAO,CACL,IAAK1B,EACL,IAAKC,EACL,MAAOF,EAAO,OACd,KAAM,GACN,KAAM,GACN,UAAW,EACX,QAAS2B,GAAa,CAAC,CAAC3B,EAAO,OAC/B,GAAI2B,EAAY,CAAC,EAAI,CAAE,WAAc,EAAG,CAC1C,EACA,OAAQD,EAAK,QAAU,GACvB,QACEA,EAAK,UACJC,EAAY,IAAA,GAAY,CAAE,IAAK,EAAG,MAAO,EAAG,OAAQ,EAAG,KAAM,CAAE,GAClE,aACF,CACF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//#region ../charts/src/engine/presets.ts
|
|
2
|
+
var e = (e, t, n) => e.map((e) => ({
|
|
3
|
+
...e,
|
|
4
|
+
type: e.type ?? t,
|
|
5
|
+
...n !== void 0 && (e.type ?? t) === "bar" ? { stack: e.stack ?? n } : {}
|
|
6
|
+
})), t = (t, n = !1) => e(t, n ? "area" : "line"), n = (t, n = !1) => e(t, "bar", n ? "stack" : void 0), r = (t) => e(t, "scatter"), i = {
|
|
7
|
+
topLeft: "var(--danger-color, #ef4444)",
|
|
8
|
+
topRight: "var(--primary-color, #4f46e5)",
|
|
9
|
+
bottomLeft: "var(--warning-color, #f59e0b)",
|
|
10
|
+
bottomRight: "var(--text-secondary-color, #64748b)"
|
|
11
|
+
}, a = "var(--border-strong-color, var(--border-color, #cbd5e1))", o = (e) => {
|
|
12
|
+
let [t, n] = e.xDomain ?? [0, 10], [r, i] = e.yDomain ?? [0, 10];
|
|
13
|
+
return {
|
|
14
|
+
x0: t,
|
|
15
|
+
x1: n,
|
|
16
|
+
y0: r,
|
|
17
|
+
y1: i,
|
|
18
|
+
xs: e.xSplit ?? (t + n) / 2,
|
|
19
|
+
ys: e.ySplit ?? (r + i) / 2
|
|
20
|
+
};
|
|
21
|
+
}, s = (e, t, n) => {
|
|
22
|
+
let { xs: r, ys: i } = o(e), a = e.reverseX ? t < r : t >= r;
|
|
23
|
+
return n >= i ? a ? "topRight" : "topLeft" : a ? "bottomRight" : "bottomLeft";
|
|
24
|
+
}, c = (e, t = {}) => {
|
|
25
|
+
let { x0: n, x1: r, y0: c, y1: l, xs: u, ys: d } = o(e), f = !!e.reverseX, p = (t) => e.quadrants?.[t]?.color ?? i[t], m = [{
|
|
26
|
+
type: "scatter",
|
|
27
|
+
name: e.name ?? "",
|
|
28
|
+
pointSize: e.pointSize ?? 12,
|
|
29
|
+
showLabels: e.showLabels ?? !0,
|
|
30
|
+
opacity: .9,
|
|
31
|
+
data: e.points.map((t) => ({
|
|
32
|
+
x: t.x,
|
|
33
|
+
y: t.y,
|
|
34
|
+
label: t.label,
|
|
35
|
+
size: t.size,
|
|
36
|
+
color: t.color ?? p(s(e, t.x, t.y))
|
|
37
|
+
}))
|
|
38
|
+
}], h = f ? [u, r] : [n, u], g = f ? [n, u] : [u, r], _ = (t, [n, r], [i, a], o) => ({
|
|
39
|
+
type: "rect",
|
|
40
|
+
x0: n,
|
|
41
|
+
x1: r,
|
|
42
|
+
y0: i,
|
|
43
|
+
y1: a,
|
|
44
|
+
color: p(t),
|
|
45
|
+
opacity: .07,
|
|
46
|
+
label: e.quadrants?.[t]?.label,
|
|
47
|
+
labelPosition: o
|
|
48
|
+
}), v = e.axisLabels ?? {}, y = f ? r : n, b = f ? n : r, x = [
|
|
49
|
+
...v.top ? [{
|
|
50
|
+
type: "text",
|
|
51
|
+
x: u,
|
|
52
|
+
y: l,
|
|
53
|
+
text: v.top,
|
|
54
|
+
anchor: "top"
|
|
55
|
+
}] : [],
|
|
56
|
+
...v.bottom ? [{
|
|
57
|
+
type: "text",
|
|
58
|
+
x: u,
|
|
59
|
+
y: c,
|
|
60
|
+
text: v.bottom,
|
|
61
|
+
anchor: "bottom"
|
|
62
|
+
}] : [],
|
|
63
|
+
...v.left ? [{
|
|
64
|
+
type: "text",
|
|
65
|
+
x: y,
|
|
66
|
+
y: d,
|
|
67
|
+
text: v.left,
|
|
68
|
+
anchor: "left"
|
|
69
|
+
}] : [],
|
|
70
|
+
...v.right ? [{
|
|
71
|
+
type: "text",
|
|
72
|
+
x: b,
|
|
73
|
+
y: d,
|
|
74
|
+
text: v.right,
|
|
75
|
+
anchor: "right"
|
|
76
|
+
}] : []
|
|
77
|
+
], S = [
|
|
78
|
+
_("topLeft", h, [d, l], "top-left"),
|
|
79
|
+
_("topRight", g, [d, l], "top-right"),
|
|
80
|
+
_("bottomLeft", h, [c, d], "bottom-left"),
|
|
81
|
+
_("bottomRight", g, [c, d], "bottom-right"),
|
|
82
|
+
{
|
|
83
|
+
type: "line",
|
|
84
|
+
axis: "x",
|
|
85
|
+
value: u,
|
|
86
|
+
dash: [],
|
|
87
|
+
color: a
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "line",
|
|
91
|
+
axis: "y",
|
|
92
|
+
value: d,
|
|
93
|
+
dash: [],
|
|
94
|
+
color: a
|
|
95
|
+
},
|
|
96
|
+
...x,
|
|
97
|
+
...t.annotations ?? []
|
|
98
|
+
], C = e.showTicks ?? !0, w = t.interaction !== !1 && {
|
|
99
|
+
zoom: !1,
|
|
100
|
+
...typeof t.interaction == "object" ? t.interaction : {},
|
|
101
|
+
...e.draggable ? { dragPoints: !0 } : {}
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
...t,
|
|
105
|
+
series: m,
|
|
106
|
+
annotations: S,
|
|
107
|
+
tooltip: t.tooltip ?? (C ? void 0 : { render: (t) => {
|
|
108
|
+
let n = t.items[0];
|
|
109
|
+
if (!n) return null;
|
|
110
|
+
let r = e.quadrants?.[s(e, n.x, n.y)]?.label;
|
|
111
|
+
return [n.label ?? e.name ?? "", r ?? ""].filter(Boolean).join("\n");
|
|
112
|
+
} }),
|
|
113
|
+
xAxis: {
|
|
114
|
+
min: n,
|
|
115
|
+
max: r,
|
|
116
|
+
title: e.xLabel,
|
|
117
|
+
reverse: f,
|
|
118
|
+
nice: !1,
|
|
119
|
+
grid: !1,
|
|
120
|
+
tickCount: 4,
|
|
121
|
+
visible: C || !!e.xLabel,
|
|
122
|
+
...C ? {} : { format: () => "" }
|
|
123
|
+
},
|
|
124
|
+
yAxis: {
|
|
125
|
+
min: c,
|
|
126
|
+
max: l,
|
|
127
|
+
title: e.yLabel,
|
|
128
|
+
nice: !1,
|
|
129
|
+
grid: !1,
|
|
130
|
+
tickCount: 4,
|
|
131
|
+
visible: C || !!e.yLabel,
|
|
132
|
+
...C ? {} : { format: () => "" }
|
|
133
|
+
},
|
|
134
|
+
legend: t.legend ?? !1,
|
|
135
|
+
padding: t.padding ?? (C ? void 0 : {
|
|
136
|
+
top: 4,
|
|
137
|
+
right: 4,
|
|
138
|
+
bottom: 4,
|
|
139
|
+
left: 4
|
|
140
|
+
}),
|
|
141
|
+
interaction: w
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
//#endregion
|
|
145
|
+
export { i as DEFAULT_QUADRANT_COLORS, n as barSeries, t as lineSeries, c as quadrantChartOptions, s as quadrantOf, r as scatterSeries, e as withSeriesType };
|
|
146
|
+
|
|
147
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.js","names":["withSeriesType","series","s","type","stack","lineSeries","area","barSeries","stacked","scatterSeries","DEFAULT_QUADRANT_COLORS","DIVIDER","splits","x0","x1","config","y0","y1","quadrantOf","right","x","xs","y","ys","quadrantChartOptions","reverseX","color","corner","p","left","rect","xa","xb","ya","yb","position","ends","visualLeft","visualRight","texts","annotations","base","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 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): ChartSeries[] =>\n series.map((s) => ({\n ...s,\n type: s.type ?? type,\n ...(stack !== undefined && (s.type ?? type) === \"bar\"\n ? { stack: s.stack ?? stack }\n : {}),\n }));\n\n/** Series of a LineChart (`area` fills them) */\nexport const lineSeries = (series: readonly ChartSeries[], area = false) =>\n withSeriesType(series, area ? \"area\" : \"line\");\n\n/** Series of a BarChart (`stacked` stacks them) */\nexport const barSeries = (series: readonly ChartSeries[], stacked = false) =>\n withSeriesType(series, \"bar\", stacked ? \"stack\" : undefined);\n\n/** Series of a ScatterChart */\nexport const scatterSeries = (series: readonly ChartSeries[]) =>\n withSeriesType(series, \"scatter\");\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":";AAaA,IAAaA,KACX,GACA,GACA,MAEAC,EAAO,KAAK,OAAO;CACjB,GAAGC;CACH,MAAMA,EAAE,QAAQC;CAChB,GAAIC,MAAU,KAAA,MAAcF,EAAE,QAAQC,OAAU,QAC5C,EAAE,OAAOD,EAAE,SAASE,EAAM,IAC1B,CAAC;AACP,EAAE,GAGSC,KAAc,GAAgC,IAAO,OAChEL,EAAeC,GAAQK,IAAO,SAAS,MAAM,GAGlCC,KAAa,GAAgC,IAAU,OAClEP,EAAeC,GAAQ,OAAOO,IAAU,UAAU,KAAA,CAAS,GAGhDC,KAAiB,MAC5BT,EAAeC,GAAQ,SAAS,GA4FrBS,IACX;CACE,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;AACf,GAEIC,IAAU,4DAEVC,KAAU,MAA2B;CACzC,IAAM,CAACC,GAAIC,KAAMC,EAAO,WAAW,CAAC,GAAG,EAAE,GACnC,CAACC,GAAIC,KAAMF,EAAO,WAAW,CAAC,GAAG,EAAE;CACzC,OAAO;EACL;EACA;EACA;EACA;EACA,IAAIA,EAAO,WAAWF,IAAKC,KAAM;EACjC,IAAIC,EAAO,WAAWC,IAAKC,KAAM;CACnC;AACF,GAGaC,KACX,GAIA,GACA,MACmB;CACnB,IAAM,EAAE,OAAI,UAAON,EAAOG,CAAwB,GAC5CI,IAAQJ,EAAO,WAAWK,IAAIC,IAAKD,KAAKC;CAE9C,OADYC,KAAKC,IAEbJ,IACE,aACA,YACFA,IACE,gBACA;AACR,GAoBaK,KACX,GACA,IAAqC,CAAC,MACrB;CACjB,IAAM,EAAE,OAAI,OAAI,OAAI,OAAI,OAAI,UAAOZ,EAAOG,CAAM,GAC1CU,IAAW,CAAC,CAACV,EAAO,UACpBW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AW;GACX,SAASiB,KAAa,CAAC,CAAC3B,EAAO;GAC/B,GAAI2B,IAAY,CAAC,IAAI,EAAE,cAAc,GAAG;EAC1C;EACA,OAAO;GACL,KAAK1B;GACL,KAAKC;GACL,OAAOF,EAAO;GACd,MAAM;GACN,MAAM;GACN,WAAW;GACX,SAAS2B,KAAa,CAAC,CAAC3B,EAAO;GAC/B,GAAI2B,IAAY,CAAC,IAAI,EAAE,cAAc,GAAG;EAC1C;EACA,QAAQD,EAAK,UAAU;EACvB,SACEA,EAAK,YACJC,IAAY,KAAA,IAAY;GAAE,KAAK;GAAG,OAAO;GAAG,QAAQ;GAAG,MAAM;EAAE;EAClE;CACF;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=Math.sqrt(50),t=Math.sqrt(10),n=Math.sqrt(2),r=(r,i,a)=>{let o=Math.abs(i-r);if(!(o>0)||!Number.isFinite(o))return 0;let s=o/Math.max(1,a),c=10**Math.floor(Math.log10(s)),l=s/c;return(l>=e?10:l>=t?5:l>=n?2:1)*c},i=(e,t)=>{let n=Math.max(0,-Math.floor(Math.log10(t))+1);return n>0&&n<20?+e.toFixed(n):e},a=(e,t,n)=>{e>t&&([e,t]=[t,e]);let a=r(e,t,n);if(!a)return Number.isFinite(e)?[e]:[];let o=Math.ceil(e/a-1e-9),s=Math.floor(t/a+1e-9),c=[];for(let e=o;e<=s&&c.length<1e3;e++)c.push(i(e*a,a));return c},o=(e,t,n)=>{e>t&&([e,t]=[t,e]);let a=r(e,t,n);for(let o=0;o<3&&a;o++){let o=Math.floor(e/a)*a,s=Math.ceil(t/a)*a;e=i(o,a),t=i(s,a);let c=r(e,t,n);if(c===a)break;a=c}return[e,t]},s=(e,t,n=[0,1])=>{if(!Number.isFinite(e)||!Number.isFinite(t))return n;if(e>t&&([e,t]=[t,e]),t-e>0)return[e,t];let r=e===0?1:Math.abs(e)*.1;return[e-r,t+r]},c=e=>e>0&&Number.isFinite(e)?Math.min(12,Math.max(0,-Math.floor(Math.log10(e)+1e-9))):0;exports.ensureSpan=s,exports.linearTicks=a,exports.niceDomain=o,exports.stepDecimals=c,exports.tickStep=r;
|
|
2
|
+
//# sourceMappingURL=scale.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale.cjs","names":["E10","E5","E2","tickStep","span","max","min","raw","count","base","error","roundTo","decimals","step","value","linearTicks","start","end","ticks","i","niceDomain","nextMin","nextMax","next","ensureSpan","fallback","pad","stepDecimals"],"sources":["../../../../../../charts/src/engine/scale.ts"],"sourcesContent":["// Numeric ticks and ranges.\n\nconst E10 = Math.sqrt(50);\nconst E5 = Math.sqrt(10);\nconst E2 = Math.sqrt(2);\n\n/** Tick step close to `(max - min) / count`, of the form 1, 2 or 5 × 10^k */\nexport const tickStep = (min: number, max: number, count: number): number => {\n const span = Math.abs(max - min);\n if (!(span > 0) || !Number.isFinite(span)) return 0;\n const raw = span / Math.max(1, count);\n const power = Math.floor(Math.log10(raw));\n const base = 10 ** power;\n const error = raw / base;\n const factor = error >= E10 ? 10 : error >= E5 ? 5 : error >= E2 ? 2 : 1;\n return factor * base;\n};\n\n/** Rounds a value computed from a step (avoids 0.30000000000000004) */\nconst roundTo = (value: number, step: number): number => {\n const decimals = Math.max(0, -Math.floor(Math.log10(step)) + 1);\n return decimals > 0 && decimals < 20 ? +value.toFixed(decimals) : value;\n};\n\n/** Tick values inside [min, max] */\nexport const linearTicks = (\n min: number,\n max: number,\n count: number,\n): number[] => {\n if (min > max) [min, max] = [max, min];\n const step = tickStep(min, max, count);\n if (!step) return Number.isFinite(min) ? [min] : [];\n const start = Math.ceil(min / step - 1e-9);\n const end = Math.floor(max / step + 1e-9);\n const ticks: number[] = [];\n // Guard against pathological ranges\n for (let i = start; i <= end && ticks.length < 1000; i++) {\n ticks.push(roundTo(i * step, step));\n }\n return ticks;\n};\n\n/** Extends [min, max] to tick boundaries */\nexport const niceDomain = (\n min: number,\n max: number,\n count: number,\n): [number, number] => {\n if (min > max) [min, max] = [max, min];\n let step = tickStep(min, max, count);\n for (let i = 0; i < 3 && step; i++) {\n const nextMin = Math.floor(min / step) * step;\n const nextMax = Math.ceil(max / step) * step;\n min = roundTo(nextMin, step);\n max = roundTo(nextMax, step);\n const next = tickStep(min, max, count);\n if (next === step) break;\n step = next;\n }\n return [min, max];\n};\n\n/**\n * Range covering [min, max] with a usable span: a single value (or no data)\n * becomes a small range around it.\n */\nexport const ensureSpan = (\n min: number,\n max: number,\n fallback: [number, number] = [0, 1],\n): [number, number] => {\n if (!Number.isFinite(min) || !Number.isFinite(max)) return fallback;\n if (min > max) [min, max] = [max, min];\n if (max - min > 0) return [min, max];\n const pad = min === 0 ? 1 : Math.abs(min) * 0.1;\n return [min - pad, max + pad];\n};\n\n/** Number of decimals that keeps ticks distinct for a step */\nexport const stepDecimals = (step: number): number =>\n step > 0 && Number.isFinite(step)\n ? Math.min(12, Math.max(0, -Math.floor(Math.log10(step) + 1e-9)))\n : 0;\n"],"mappings":"AAEA,IAAMA,EAAM,KAAK,KAAK,EAAE,EAClBC,EAAK,KAAK,KAAK,EAAE,EACjBC,EAAK,KAAK,KAAK,CAAC,EAGTC,GAAY,EAAa,EAAa,IAA0B,CAC3E,IAAMC,EAAO,KAAK,IAAIC,EAAMC,CAAG,EAC/B,GAAI,EAAEF,EAAO,IAAM,CAAC,OAAO,SAASA,CAAI,EAAG,MAAO,GAClD,IAAMG,EAAMH,EAAO,KAAK,IAAI,EAAGI,CAAK,EAE9BC,EAAO,IADC,KAAK,MAAM,KAAK,MAAMF,CAAG,CACpB,EACbG,EAAQH,EAAME,EAEpB,OADeC,GAASV,EAAM,GAAKU,GAAST,EAAK,EAAIS,GAASR,EAAK,EAAI,GACvDO,CAClB,EAGME,GAAW,EAAe,IAAyB,CACvD,IAAMC,EAAW,KAAK,IAAI,EAAG,CAAC,KAAK,MAAM,KAAK,MAAMC,CAAI,CAAC,EAAI,CAAC,EAC9D,OAAOD,EAAW,GAAKA,EAAW,GAAK,CAACE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ACA,EAAKD,CAAG,EACnC,IAAMqB,EAAMpB,IAAQ,EAAI,EAAI,KAAK,IAAIA,CAAG,EAAI,GAC5C,MAAO,CAACA,EAAMoB,EAAKrB,EAAMqB,CAAG,CAC9B,EAGaC,EAAgB,GAC3Bd,EAAO,GAAK,OAAO,SAASA,CAAI,EAC5B,KAAK,IAAI,GAAI,KAAK,IAAI,EAAG,CAAC,KAAK,MAAM,KAAK,MAAMA,CAAI,EAAI,IAAI,CAAC,CAAC,EAC9D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region ../charts/src/engine/scale.ts
|
|
2
|
+
var e = Math.sqrt(50), t = Math.sqrt(10), n = Math.sqrt(2), r = (r, i, a) => {
|
|
3
|
+
let o = Math.abs(i - r);
|
|
4
|
+
if (!(o > 0) || !Number.isFinite(o)) return 0;
|
|
5
|
+
let s = o / Math.max(1, a), c = 10 ** Math.floor(Math.log10(s)), l = s / c;
|
|
6
|
+
return (l >= e ? 10 : l >= t ? 5 : l >= n ? 2 : 1) * c;
|
|
7
|
+
}, i = (e, t) => {
|
|
8
|
+
let n = Math.max(0, -Math.floor(Math.log10(t)) + 1);
|
|
9
|
+
return n > 0 && n < 20 ? +e.toFixed(n) : e;
|
|
10
|
+
}, a = (e, t, n) => {
|
|
11
|
+
e > t && ([e, t] = [t, e]);
|
|
12
|
+
let a = r(e, t, n);
|
|
13
|
+
if (!a) return Number.isFinite(e) ? [e] : [];
|
|
14
|
+
let o = Math.ceil(e / a - 1e-9), s = Math.floor(t / a + 1e-9), c = [];
|
|
15
|
+
for (let e = o; e <= s && c.length < 1e3; e++) c.push(i(e * a, a));
|
|
16
|
+
return c;
|
|
17
|
+
}, o = (e, t, n) => {
|
|
18
|
+
e > t && ([e, t] = [t, e]);
|
|
19
|
+
let a = r(e, t, n);
|
|
20
|
+
for (let o = 0; o < 3 && a; o++) {
|
|
21
|
+
let o = Math.floor(e / a) * a, s = Math.ceil(t / a) * a;
|
|
22
|
+
e = i(o, a), t = i(s, a);
|
|
23
|
+
let c = r(e, t, n);
|
|
24
|
+
if (c === a) break;
|
|
25
|
+
a = c;
|
|
26
|
+
}
|
|
27
|
+
return [e, t];
|
|
28
|
+
}, s = (e, t, n = [0, 1]) => {
|
|
29
|
+
if (!Number.isFinite(e) || !Number.isFinite(t)) return n;
|
|
30
|
+
if (e > t && ([e, t] = [t, e]), t - e > 0) return [e, t];
|
|
31
|
+
let r = e === 0 ? 1 : Math.abs(e) * .1;
|
|
32
|
+
return [e - r, t + r];
|
|
33
|
+
}, c = (e) => e > 0 && Number.isFinite(e) ? Math.min(12, Math.max(0, -Math.floor(Math.log10(e) + 1e-9))) : 0;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { s as ensureSpan, a as linearTicks, o as niceDomain, c as stepDecimals, r as tickStep };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scale.js","names":["E10","E5","E2","tickStep","span","max","min","raw","count","base","error","roundTo","decimals","step","value","linearTicks","start","end","ticks","i","niceDomain","nextMin","nextMax","next","ensureSpan","fallback","pad","stepDecimals"],"sources":["../../../../../../charts/src/engine/scale.ts"],"sourcesContent":["// Numeric ticks and ranges.\n\nconst E10 = Math.sqrt(50);\nconst E5 = Math.sqrt(10);\nconst E2 = Math.sqrt(2);\n\n/** Tick step close to `(max - min) / count`, of the form 1, 2 or 5 × 10^k */\nexport const tickStep = (min: number, max: number, count: number): number => {\n const span = Math.abs(max - min);\n if (!(span > 0) || !Number.isFinite(span)) return 0;\n const raw = span / Math.max(1, count);\n const power = Math.floor(Math.log10(raw));\n const base = 10 ** power;\n const error = raw / base;\n const factor = error >= E10 ? 10 : error >= E5 ? 5 : error >= E2 ? 2 : 1;\n return factor * base;\n};\n\n/** Rounds a value computed from a step (avoids 0.30000000000000004) */\nconst roundTo = (value: number, step: number): number => {\n const decimals = Math.max(0, -Math.floor(Math.log10(step)) + 1);\n return decimals > 0 && decimals < 20 ? +value.toFixed(decimals) : value;\n};\n\n/** Tick values inside [min, max] */\nexport const linearTicks = (\n min: number,\n max: number,\n count: number,\n): number[] => {\n if (min > max) [min, max] = [max, min];\n const step = tickStep(min, max, count);\n if (!step) return Number.isFinite(min) ? [min] : [];\n const start = Math.ceil(min / step - 1e-9);\n const end = Math.floor(max / step + 1e-9);\n const ticks: number[] = [];\n // Guard against pathological ranges\n for (let i = start; i <= end && ticks.length < 1000; i++) {\n ticks.push(roundTo(i * step, step));\n }\n return ticks;\n};\n\n/** Extends [min, max] to tick boundaries */\nexport const niceDomain = (\n min: number,\n max: number,\n count: number,\n): [number, number] => {\n if (min > max) [min, max] = [max, min];\n let step = tickStep(min, max, count);\n for (let i = 0; i < 3 && step; i++) {\n const nextMin = Math.floor(min / step) * step;\n const nextMax = Math.ceil(max / step) * step;\n min = roundTo(nextMin, step);\n max = roundTo(nextMax, step);\n const next = tickStep(min, max, count);\n if (next === step) break;\n step = next;\n }\n return [min, max];\n};\n\n/**\n * Range covering [min, max] with a usable span: a single value (or no data)\n * becomes a small range around it.\n */\nexport const ensureSpan = (\n min: number,\n max: number,\n fallback: [number, number] = [0, 1],\n): [number, number] => {\n if (!Number.isFinite(min) || !Number.isFinite(max)) return fallback;\n if (min > max) [min, max] = [max, min];\n if (max - min > 0) return [min, max];\n const pad = min === 0 ? 1 : Math.abs(min) * 0.1;\n return [min - pad, max + pad];\n};\n\n/** Number of decimals that keeps ticks distinct for a step */\nexport const stepDecimals = (step: number): number =>\n step > 0 && Number.isFinite(step)\n ? Math.min(12, Math.max(0, -Math.floor(Math.log10(step) + 1e-9)))\n : 0;\n"],"mappings":";AAEA,IAAMA,IAAM,KAAK,KAAK,EAAE,GAClBC,IAAK,KAAK,KAAK,EAAE,GACjBC,IAAK,KAAK,KAAK,CAAC,GAGTC,KAAY,GAAa,GAAa,MAA0B;CAC3E,IAAMC,IAAO,KAAK,IAAIC,IAAMC,CAAG;CAC/B,IAAI,EAAEF,IAAO,MAAM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,IAAMF,EAAQU,GAASR,CAAI,GAC3B,IAAMF,EAAQW,GAAST,CAAI;EAC3B,IAAMU,IAAOpB,EAASG,GAAKD,GAAKG,CAAK;EACrC,IAAIe,MAASV,GAAM;EACnB,IAAOU;CACT;CACA,OAAO,CAACjB,GAAKD,CAAG;AAClB,GAMamB,KACX,GACA,GACA,IAA6B,CAAC,GAAG,CAAC,MACb;CACrB,IAAI,CAAC,OAAO,SAASlB,CAAG,KAAK,CAAC,OAAO,SAASD,CAAG,GAAG,OAAOoB;CAE3D,IADInB,IAAMD,MAAK,CAACC,GAAKD,KAAO,CAACA,GAAKC,CAAG,IACjCD,IAAMC,IAAM,GAAG,OAAO,CAACA,GAAKD,CAAG;CACnC,IAAMqB,IAAMpB,MAAQ,IAAI,IAAI,KAAK,IAAIA,CAAG,IAAI;CAC5C,OAAO,CAACA,IAAMoB,GAAKrB,IAAMqB,CAAG;AAC9B,GAGaC,KAAgB,MAC3Bd,IAAO,KAAK,OAAO,SAASA,CAAI,IAC5B,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,CAAC,KAAK,MAAM,KAAK,MAAMA,CAAI,IAAI,IAAI,CAAC,CAAC,IAC9D"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./color.cjs"),t=require("./data.cjs"),n=require("./layout.cjs"),r=require("./model.cjs"),i=require("./axis.cjs");var a={top:12,right:16,bottom:4,left:4},o=(e,t)=>t,s=(t,n)=>{let r=n.resolve??o;return(t??[]).map(t=>{if(t.type===`rect`){let i=t.color?r(t.color,n.primary):n.primary;return{type:`rect`,x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1,color:i,opacity:t.opacity??.08,label:t.label,labelPosition:t.labelPosition??`top-left`,labelColor:t.labelColor?r(t.labelColor,i):e.mix(i,n.text,.2)}}return t.type===`text`?{type:`text`,x:t.x,y:t.y,text:t.text,anchor:t.anchor??`center`,color:t.color?r(t.color,n.textMuted):n.textMuted,weight:t.weight??500}:{type:`line`,axis:t.axis,value:t.value,color:t.color?r(t.color,n.textMuted):n.textMuted,width:t.width??1,dash:[...t.dash??[4,4]],label:t.label}})},c=e=>{let{model:t,view:r,theme:o,width:s,height:c,measure:l}=e,u=t.y.tickCount??(c>=220?5:Math.max(2,Math.round((c-48)/52))),d=i.axisTicks(t.y,r.y,u),f=0;if(t.y.visible)for(let e of d.labels)f=Math.max(f,l(e));let p=48;if(t.x.type===`category`){p=0;let e=Math.max(1,Math.floor(t.x.categories.length/200));for(let n=0;n<t.x.categories.length;n+=e)p=Math.max(p,l(t.x.categories[n]))}let m={...a,...e.padding},h=n.computePlot({width:s,height:c,padding:m,yLabelWidth:t.y.visible?Math.ceil(f):0,xAxisVisible:t.x.visible,xTitle:!!t.x.title&&t.x.visible,yTitle:!!t.y.title&&t.y.visible,fontSize:o.fontSize});e.top&&(h.y+=e.top);let g=t.x.type===`category`?Math.max(1,Math.floor(h.width/(p+14))):t.x.tickCount??Math.max(2,Math.floor(h.width/96)),_=i.axisTicks(t.x,r.x,g);return{plot:h,scales:n.createScales(h,r,t.x.reverse,t.y.reverse),xTicks:_,yTicks:d}},l=(e,t,n)=>{let r=[];for(let i of e.series){if(i.hidden||i.type!==`scatter`||!i.showLabels)continue;let{x:e,y:a,count:o,labels:s,size:c}=i.cols;if(s)for(let l=0;l<o&&r.length<300;l++){let o=s[l];if(!o)continue;let u=e[l],d=a[l];if(u<t.x[0]||u>t.x[1]||d<t.y[0]||d>t.y[1])continue;let f=c&&c[l]>0?c[l]:i.pointSize;r.push({x:n.xToPx(u),y:n.yToPx(d),r:f/2,text:o})}}return r},u=(e,t,n)=>{let r=e.cols.x[t]+(e.type===`bar`?e.barOffset:0),i=e.type===`bar`&&e.barTop?e.barTop[t]:e.cols.y[t];return{px:n.xToPx(r),py:n.yToPx(i)}},d=(e,t,n,r,i)=>{let a=u(e,t,i),o=!1;if(e.type===`bar`&&e.barBase){let s=e.barHalfWidth/i.xPerPx,c=i.yToPx(e.barBase[t]);o=Math.abs(n-a.px)<=s&&r>=Math.min(c,a.py)-2&&r<=Math.max(c,a.py)+2}return{series:e,index:t,px:a.px,py:a.py,dx:Math.abs(i.xToPx(e.cols.x[t])-n),dist:o?0:Math.hypot(a.px-n,a.py-r),inside:o}},f=(e,t)=>e.cols.size&&e.cols.size[t]>0?e.cols.size[t]:e.pointSize,p=(e,t,n,i,a)=>{let o=Math.max(e.pointSize/2+6,10)+a,s=i.pxToX(t),c=i.pxToY(n),l=o*i.xPerPx,u=o*i.yPerPx,d=-1,p=1/0,{x:m,y:h}=e.cols;return r.gridOf(e).query(s-l,s+l,c-u,c+u,r=>{let o=Math.hypot(i.xToPx(m[r])-t,i.yToPx(h[r])-n);o<=Math.max(f(e,r)/2+4,8)+a&&o<=p&&(p=o,d=r)}),d},m=(e,n)=>{let{x:r,y:i,count:a,sorted:o}=e.cols;if(o)return t.nearestIndex(r,i,a,n);let s=-1,c=1/0;for(let e=0;e<a;e++){if(!Number.isFinite(i[e]))continue;let t=Math.abs(r[e]-n);t<c&&(c=t,s=e)}return s},h=(t,n)=>{let r=t.pointColors?.[n],i=t.cols.labels?.[n];return{seriesIndex:t.index,seriesId:t.id,seriesName:t.name,index:n,x:t.cols.x[n],y:t.cols.y[n],color:r?e.toCss(r):t.colorCss,...i===void 0?{}:{label:i}}},g=(e,t)=>{if(!e.length)return null;e.sort((e,t)=>e.series.index-t.series.index);let n=e.map(e=>h(e.series,e.index)),r=n[0].x;return{items:n,x:r,xLabel:t?.formatValue(r)??String(r)}},_=(e,t,n,r,i,a=0)=>{let{plot:o}=t,s=6+a;if(r<o.x-s||r>o.x+o.width+s||i<o.y-s||i>o.y+o.height+s)return null;let c=t.pxToX(r),l=[],u=[];for(let n of e.series)if(!(n.hidden||n.cols.count===0)){if(n.type===`scatter`){let e=p(n,r,i,t,a);e>=0&&l.push(d(n,e,r,i,t))}else{let e=m(n,c);e>=0&&u.push(d(n,e,r,i,t))}}if(e.tooltipMode===`nearest`){let e=[...l,...u].filter(e=>e.inside||e.series.type===`scatter`||e.dist<=32+a);return e.length?g([e.reduce((e,t)=>t.dist<=e.dist?t:e)],n):null}if(!u.length)return l.length?g([l.reduce((e,t)=>t.dist<=e.dist?t:e)],n):null;let f=Math.min(...u.map(e=>e.dx)),_=e.x.type===`category`?.5/t.xPerPx:0,v=u.filter(e=>e.dx<=f+Math.max(1,_)),y=v.reduce((e,t)=>t.dx<e.dx?t:e),b=g([y,...v.filter(e=>e!==y),...l],n);return b&&(b.x=h(y.series,y.index).x,b.xLabel=n?.formatValue(b.x)??String(b.x)),b},v=(e,t)=>e===t||!!e&&!!t&&e.items.length===t.items.length&&e.items.every((e,n)=>e.index===t.items[n].index&&e.seriesIndex===t.items[n].seriesIndex),y=(e,t,n)=>{let r=n?.formatValue??String;if(t.items.every(t=>e.series[t.seriesIndex].type===`scatter`)&&t.items.length===1){let n=t.items[0],i=[{color:null,name:e.x.title??`x`,value:t.xLabel},{color:null,name:e.y.title??`y`,value:r(n.y)}];return n.label!==void 0&&e.series.length>1&&i.push({color:null,name:``,value:n.seriesName}),{title:n.label??n.seriesName,titleColor:n.color,rows:i}}return{title:t.xLabel,titleColor:null,rows:t.items.map(e=>({color:e.color,name:e.label?`${e.seriesName} · ${e.label}`:e.seriesName,value:r(e.y)}))}},b=(e,t,n)=>{let r=[],{plot:i}=t;for(let a of n.items){let n=e.series[a.seriesIndex];if(n.type===`bar`&&n.barBase&&n.barTop){let e=t.xToPx(a.x+n.barOffset),i=Math.max(n.barHalfWidth/t.xPerPx,1),o=t.yToPx(n.barBase[a.index]),s=t.yToPx(n.barTop[a.index]);r.push({kind:`bar`,x:e-i,y:Math.min(o,s),width:i*2,height:Math.max(1,Math.abs(o-s))});continue}let o=t.xToPx(a.x),s=t.yToPx(a.y);if(o<i.x-1||o>i.x+i.width+1||s<i.y-1||s>i.y+i.height+1)continue;let c=n.type===`scatter`?f(n,a.index)+6:Math.max(10,n.lineWidth*2+6);r.push({kind:`dot`,x:o,y:s,size:c,color:a.color})}return r},x=(e,t,n)=>n??(e.tooltipMode===`axis`&&t.items.some(t=>e.series[t.seriesIndex].type!==`scatter`));exports.DEFAULT_PADDING=a,exports.collectPointLabels=l,exports.dotSize=f,exports.fallbackResolve=o,exports.hitTest=_,exports.hoverItemOf=h,exports.hoverMarks=b,exports.layoutChart=c,exports.pointOf=u,exports.resolveAnnotations=s,exports.sameHover=v,exports.showsCrosshair=x,exports.tooltipContent=y;
|
|
2
|
+
//# sourceMappingURL=scene.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene.cjs","names":["mix","axisTicks","computePlot","createScales","nearestIndex","toCss","require_color","require_data","require_layout","require_model","require_axis","DEFAULT_PADDING","fallbackResolve","fallback","resolveAnnotations","resolve","theme","annotations","a","color","layoutChart","input","yCount","model","height","yTicks","view","yLabelWidth","label","measure","categoryWidth","step","i","padding","plot","xCount","xTicks","collectPointLabels","labels","series","texts","count","text","xi","x","yi","y","d","size","s","pointOf","xv","yv","sc","candidateOf","p","inside","half","base","px","py","dotSize","nearestScatter","radius","slop","rx","ry","best","bestDist","nearestX","sorted","bestD","hoverItemOf","pc","index","eventOf","candidates","b","items","c","hitTest","margin","scatter","others","all","bestDx","bandPx","aligned","first","event","sameHover","it","tooltipContent","yFormat","rows","hoverMarks","marks","cx","showsCrosshair","crosshair"],"sources":["../../../../../../charts/src/engine/scene.ts"],"sourcesContent":["// The DOM-free half of a chart: annotations, layout, point labels, hit\n// testing and tooltip content. Shared by createChart (DOM + GPU),\n// createCanvasChart (any 2D context) and the React Native views.\n\nimport { axisTicks, type AxisTicks } from \"./axis\";\nimport { mix, toCss, type Rgba } from \"./color\";\nimport { nearestIndex } from \"./data\";\nimport { computePlot, createScales, type Rect, type Scales } from \"./layout\";\nimport { gridOf, type ChartModel, type SeriesModel } from \"./model\";\nimport type { PointLabel, ResolvedAnnotation } from \"./overlay\";\nimport type { ChartTheme } from \"./theme\";\nimport type {\n ChartAnnotation,\n ChartHoverEvent,\n ChartHoverItem,\n ChartPadding,\n ChartView,\n} from \"./types\";\n\nexport const MAX_POINT_LABELS = 300;\nexport const DEFAULT_PADDING = { top: 12, right: 16, bottom: 4, left: 4 };\n\nexport const fallbackResolve = (_value: string, fallback: Rgba) => fallback;\n\n/** Annotation colors resolved against the theme */\nexport const resolveAnnotations = (\n annotations: readonly ChartAnnotation[] | undefined,\n theme: ChartTheme,\n): ResolvedAnnotation[] => {\n const resolve = theme.resolve ?? fallbackResolve;\n return (annotations ?? []).map((a) => {\n if (a.type === \"rect\") {\n const color = a.color ? resolve(a.color, theme.primary) : theme.primary;\n return {\n type: \"rect\",\n x0: a.x0,\n x1: a.x1,\n y0: a.y0,\n y1: a.y1,\n color,\n opacity: a.opacity ?? 0.08,\n label: a.label,\n labelPosition: a.labelPosition ?? \"top-left\",\n labelColor: a.labelColor\n ? resolve(a.labelColor, color)\n : mix(color, theme.text, 0.2),\n };\n }\n if (a.type === \"text\") {\n return {\n type: \"text\",\n x: a.x,\n y: a.y,\n text: a.text,\n anchor: a.anchor ?? \"center\",\n color: a.color ? resolve(a.color, theme.textMuted) : theme.textMuted,\n weight: a.weight ?? 500,\n };\n }\n return {\n type: \"line\",\n axis: a.axis,\n value: a.value,\n color: a.color ? resolve(a.color, theme.textMuted) : theme.textMuted,\n width: a.width ?? 1,\n dash: [...(a.dash ?? [4, 4])],\n label: a.label,\n };\n });\n};\n\nexport interface ChartLayout {\n plot: Rect;\n scales: Scales;\n xTicks: AxisTicks;\n yTicks: AxisTicks;\n}\n\nexport interface LayoutInput {\n model: ChartModel;\n view: ChartView;\n theme: ChartTheme;\n /** Size of the drawing area (legend excluded), CSS pixels */\n width: number;\n height: number;\n padding?: ChartPadding;\n /** Offset of the drawing area (e.g. below a legend) */\n top?: number;\n /** Width of a tick label in the theme font */\n measure: (text: string) => number;\n}\n\n/** Ticks, room for the axes and the plot rectangle */\nexport const layoutChart = (input: LayoutInput): ChartLayout => {\n const { model, view, theme, width, height, measure } = input;\n // same count as the nice range of the model (its ends are then ticks),\n // fewer on short charts\n const yCount =\n model.y.tickCount ??\n (height >= 220 ? 5 : Math.max(2, Math.round((height - 48) / 52)));\n const yTicks = axisTicks(model.y, view.y, yCount);\n let yLabelWidth = 0;\n if (model.y.visible) {\n for (const label of yTicks.labels)\n yLabelWidth = Math.max(yLabelWidth, measure(label));\n }\n let categoryWidth = 48;\n if (model.x.type === \"category\") {\n categoryWidth = 0;\n const step = Math.max(1, Math.floor(model.x.categories.length / 200));\n for (let i = 0; i < model.x.categories.length; i += step) {\n categoryWidth = Math.max(categoryWidth, measure(model.x.categories[i]));\n }\n }\n const padding = { ...DEFAULT_PADDING, ...input.padding };\n const plot = computePlot({\n width,\n height,\n padding,\n yLabelWidth: model.y.visible ? Math.ceil(yLabelWidth) : 0,\n xAxisVisible: model.x.visible,\n xTitle: !!model.x.title && model.x.visible,\n yTitle: !!model.y.title && model.y.visible,\n fontSize: theme.fontSize,\n });\n if (input.top) plot.y += input.top;\n const xCount =\n model.x.type === \"category\"\n ? Math.max(1, Math.floor(plot.width / (categoryWidth + 14)))\n : (model.x.tickCount ?? Math.max(2, Math.floor(plot.width / 96)));\n const xTicks = axisTicks(model.x, view.x, xCount);\n const scales = createScales(plot, view, model.x.reverse, model.y.reverse);\n return { plot, scales, xTicks, yTicks };\n};\n\n/** Labels of the visible scatter points (`showLabels`) */\nexport const collectPointLabels = (\n model: ChartModel,\n view: ChartView,\n s: Scales,\n): PointLabel[] => {\n const labels: PointLabel[] = [];\n for (const series of model.series) {\n if (series.hidden || series.type !== \"scatter\" || !series.showLabels)\n continue;\n const { x, y, count, labels: texts, size } = series.cols;\n if (!texts) continue;\n for (let i = 0; i < count && labels.length < MAX_POINT_LABELS; i++) {\n const text = texts[i];\n if (!text) continue;\n const xi = x[i];\n const yi = y[i];\n if (xi < view.x[0] || xi > view.x[1] || yi < view.y[0] || yi > view.y[1])\n continue;\n const d = size && size[i] > 0 ? size[i] : series.pointSize;\n labels.push({ x: s.xToPx(xi), y: s.yToPx(yi), r: d / 2, text });\n }\n }\n return labels;\n};\n\n// ---------------------------------------------------------------- hit tests\n\ninterface Candidate {\n series: SeriesModel;\n index: number;\n /** Pixel position of the point */\n px: number;\n py: number;\n dx: number;\n dist: number;\n inside: boolean;\n}\n\n/** Pixel position of a point (the top of a bar) */\nexport const pointOf = (s: SeriesModel, i: number, sc: Scales) => {\n const xv = s.cols.x[i] + (s.type === \"bar\" ? s.barOffset : 0);\n const yv = s.type === \"bar\" && s.barTop ? s.barTop[i] : s.cols.y[i];\n return { px: sc.xToPx(xv), py: sc.yToPx(yv) };\n};\n\nconst candidateOf = (\n s: SeriesModel,\n i: number,\n px: number,\n py: number,\n sc: Scales,\n): Candidate => {\n const p = pointOf(s, i, sc);\n let inside = false;\n if (s.type === \"bar\" && s.barBase) {\n const half = s.barHalfWidth / sc.xPerPx;\n const base = sc.yToPx(s.barBase[i]);\n inside =\n Math.abs(px - p.px) <= half &&\n py >= Math.min(base, p.py) - 2 &&\n py <= Math.max(base, p.py) + 2;\n }\n return {\n series: s,\n index: i,\n px: p.px,\n py: p.py,\n dx: Math.abs(sc.xToPx(s.cols.x[i]) - px),\n dist: inside ? 0 : Math.hypot(p.px - px, p.py - py),\n inside,\n };\n};\n\n/** Diameter of a scatter dot */\nexport const dotSize = (s: SeriesModel, i: number) =>\n s.cols.size && s.cols.size[i] > 0 ? s.cols.size[i] : s.pointSize;\n\nconst nearestScatter = (\n s: SeriesModel,\n px: number,\n py: number,\n sc: Scales,\n slop: number,\n) => {\n const radius = Math.max(s.pointSize / 2 + 6, 10) + slop;\n const xv = sc.pxToX(px);\n const yv = sc.pxToY(py);\n const rx = radius * sc.xPerPx;\n const ry = radius * sc.yPerPx;\n let best = -1;\n let bestDist = Infinity;\n const { x, y } = s.cols;\n gridOf(s).query(xv - rx, xv + rx, yv - ry, yv + ry, (i) => {\n const d = Math.hypot(sc.xToPx(x[i]) - px, sc.yToPx(y[i]) - py);\n const reach = Math.max(dotSize(s, i) / 2 + 4, 8) + slop;\n if (d <= reach && d <= bestDist) {\n bestDist = d;\n best = i;\n }\n });\n return best;\n};\n\nconst nearestX = (s: SeriesModel, xv: number) => {\n const { x, y, count, sorted } = s.cols;\n if (sorted) return nearestIndex(x, y, count, xv);\n let best = -1;\n let bestD = Infinity;\n for (let i = 0; i < count; i++) {\n if (!Number.isFinite(y[i])) continue;\n const d = Math.abs(x[i] - xv);\n if (d < bestD) {\n bestD = d;\n best = i;\n }\n }\n return best;\n};\n\n/** Hover payload item of a point */\nexport const hoverItemOf = (s: SeriesModel, index: number): ChartHoverItem => {\n const pc = s.pointColors?.[index];\n const label = s.cols.labels?.[index];\n return {\n seriesIndex: s.index,\n seriesId: s.id,\n seriesName: s.name,\n index,\n x: s.cols.x[index],\n y: s.cols.y[index],\n color: pc ? toCss(pc) : s.colorCss,\n ...(label !== undefined ? { label } : {}),\n };\n};\n\nconst eventOf = (\n candidates: Candidate[],\n xTicks: AxisTicks | null,\n): ChartHoverEvent | null => {\n if (!candidates.length) return null;\n candidates.sort((a, b) => a.series.index - b.series.index);\n const items = candidates.map((c) => hoverItemOf(c.series, c.index));\n const x = items[0].x;\n return { items, x, xLabel: xTicks?.formatValue(x) ?? String(x) };\n};\n\n/**\n * Points under a pixel of the stage: the nearest point (scatter / `nearest`\n * tooltips) or every series at the nearest x (`axis` tooltips).\n * `slop` widens the reach of the dots (touch screens).\n */\nexport const hitTest = (\n model: ChartModel,\n sc: Scales,\n xTicks: AxisTicks | null,\n px: number,\n py: number,\n slop = 0,\n): ChartHoverEvent | null => {\n const { plot } = sc;\n const margin = 6 + slop;\n if (\n px < plot.x - margin ||\n px > plot.x + plot.width + margin ||\n py < plot.y - margin ||\n py > plot.y + plot.height + margin\n ) {\n return null;\n }\n const xv = sc.pxToX(px);\n const scatter: Candidate[] = [];\n const others: Candidate[] = [];\n for (const s of model.series) {\n if (s.hidden || s.cols.count === 0) continue;\n if (s.type === \"scatter\") {\n const i = nearestScatter(s, px, py, sc, slop);\n if (i >= 0) scatter.push(candidateOf(s, i, px, py, sc));\n } else {\n const i = nearestX(s, xv);\n if (i >= 0) others.push(candidateOf(s, i, px, py, sc));\n }\n }\n if (model.tooltipMode === \"nearest\") {\n const all = [...scatter, ...others].filter(\n (c) => c.inside || c.series.type === \"scatter\" || c.dist <= 32 + slop,\n );\n if (!all.length) return null;\n const best = all.reduce((a, b) => (b.dist <= a.dist ? b : a));\n return eventOf([best], xTicks);\n }\n if (!others.length) {\n if (!scatter.length) return null;\n return eventOf(\n [scatter.reduce((a, b) => (b.dist <= a.dist ? b : a))],\n xTicks,\n );\n }\n const bestDx = Math.min(...others.map((c) => c.dx));\n const bandPx = model.x.type === \"category\" ? 0.5 / sc.xPerPx : 0;\n const aligned = others.filter((c) => c.dx <= bestDx + Math.max(1, bandPx));\n const first = aligned.reduce((a, b) => (b.dx < a.dx ? b : a));\n const ordered = [first, ...aligned.filter((c) => c !== first), ...scatter];\n const event = eventOf(ordered, xTicks);\n if (event) {\n event.x = hoverItemOf(first.series, first.index).x;\n event.xLabel = xTicks?.formatValue(event.x) ?? String(event.x);\n }\n return event;\n};\n\n/** Whether two hover payloads point at the same points */\nexport const sameHover = (\n a: ChartHoverEvent | null,\n b: ChartHoverEvent | null,\n): boolean =>\n a === b ||\n (!!a &&\n !!b &&\n a.items.length === b.items.length &&\n a.items.every(\n (it, i) =>\n it.index === b.items[i].index &&\n it.seriesIndex === b.items[i].seriesIndex,\n ));\n\n// ------------------------------------------------------------------ tooltip\n\nexport interface TooltipRow {\n /** Swatch color (CSS) */\n color: string | null;\n name: string;\n value: string;\n}\n\nexport interface TooltipContent {\n title: string;\n /** Swatch of the title (single scatter point) */\n titleColor: string | null;\n rows: TooltipRow[];\n}\n\n/** Default tooltip content of a hover payload */\nexport const tooltipContent = (\n model: ChartModel,\n event: ChartHoverEvent,\n yTicks: AxisTicks | null,\n): TooltipContent => {\n const yFormat = yTicks?.formatValue ?? String;\n const scatterOnly = event.items.every(\n (it) => model.series[it.seriesIndex].type === \"scatter\",\n );\n if (scatterOnly && event.items.length === 1) {\n const it = event.items[0];\n const rows: TooltipRow[] = [\n { color: null, name: model.x.title ?? \"x\", value: event.xLabel },\n { color: null, name: model.y.title ?? \"y\", value: yFormat(it.y) },\n ];\n if (it.label !== undefined && model.series.length > 1)\n rows.push({ color: null, name: \"\", value: it.seriesName });\n return { title: it.label ?? it.seriesName, titleColor: it.color, rows };\n }\n return {\n title: event.xLabel,\n titleColor: null,\n rows: event.items.map((it) => ({\n color: it.color,\n name: it.label ? `${it.seriesName} · ${it.label}` : it.seriesName,\n value: yFormat(it.y),\n })),\n };\n};\n\n/** Shape of the hover marker of an item: a ring on a point, or a bar highlight */\nexport type HoverMark =\n | { kind: \"dot\"; x: number; y: number; size: number; color: string }\n | { kind: \"bar\"; x: number; y: number; width: number; height: number };\n\n/** Markers of the hovered points (pixels of the stage) */\nexport const hoverMarks = (\n model: ChartModel,\n sc: Scales,\n event: ChartHoverEvent,\n): HoverMark[] => {\n const marks: HoverMark[] = [];\n const { plot } = sc;\n for (const it of event.items) {\n const s = model.series[it.seriesIndex];\n if (s.type === \"bar\" && s.barBase && s.barTop) {\n const cx = sc.xToPx(it.x + s.barOffset);\n const half = Math.max(s.barHalfWidth / sc.xPerPx, 1);\n const a = sc.yToPx(s.barBase[it.index]);\n const b = sc.yToPx(s.barTop[it.index]);\n marks.push({\n kind: \"bar\",\n x: cx - half,\n y: Math.min(a, b),\n width: half * 2,\n height: Math.max(1, Math.abs(a - b)),\n });\n continue;\n }\n const px = sc.xToPx(it.x);\n const py = sc.yToPx(it.y);\n if (\n px < plot.x - 1 ||\n px > plot.x + plot.width + 1 ||\n py < plot.y - 1 ||\n py > plot.y + plot.height + 1\n ) {\n continue;\n }\n const size =\n s.type === \"scatter\"\n ? dotSize(s, it.index) + 6\n : Math.max(10, s.lineWidth * 2 + 6);\n marks.push({ kind: \"dot\", x: px, y: py, size, color: it.color });\n }\n return marks;\n};\n\n/** Whether the guide line follows the pointer */\nexport const showsCrosshair = (\n model: ChartModel,\n event: ChartHoverEvent,\n crosshair: boolean | undefined,\n) =>\n crosshair ??\n (model.tooltipMode === \"axis\" &&\n event.items.some((it) => model.series[it.seriesIndex].type !== \"scatter\"));\n"],"mappings":"kIAoBA,IAAaW,EAAkB,CAAE,IAAK,GAAI,MAAO,GAAI,OAAQ,EAAG,KAAM,CAAE,EAE3DC,GAAmB,EAAgB,IAAmBC,EAGtDC,GACX,EACA,IACyB,CACzB,IAAMC,EAAUC,EAAM,SAAWJ,EACjC,OAAQK,GAAe,CAAC,EAAA,CAAG,IAAK,GAAM,CACpC,GAAIC,EAAE,OAAS,OAAQ,CACrB,IAAMC,EAAQD,EAAE,MAAQH,EAAQG,EAAE,MAAOF,EAAM,OAAO,EAAIA,EAAM,QAChE,MAAO,CACL,KAAM,OACN,GAAIE,EAAE,GACN,GAAIA,EAAE,GACN,GAAIA,EAAE,GACN,GAAIA,EAAE,GACN,QACA,QAASA,EAAE,SAAW,IACtB,MAAOA,EAAE,MACT,cAAeA,EAAE,eAAiB,WAClC,WAAYA,EAAE,WACVH,EAAQG,EAAE,WAAYC,CAAK,EAC3BnB,EAAAA,IAAImB,EAAOH,EAAM,KAAM,EAAG,CAChC,CACF,CAYA,OAXIE,EAAE,OAAS,OACN,CACL,KAAM,OACN,EAAGA,EAAE,EACL,EAAGA,EAAE,EACL,KAAMA,EAAE,KACR,OAAQA,EAAE,QAAU,SACpB,MAAOA,EAAE,MAAQH,EAAQG,EAAE,MAAOF,EAAM,SAAS,EAAIA,EAAM,UAC3D,OAAQE,EAAE,QAAU,GACtB,EAEK,CACL,KAAM,OACN,KAAMA,EAAE,KACR,MAAOA,EAAE,MACT,MAAOA,EAAE,MAAQH,EAAQG,EAAE,MAAOF,EAAM,SAAS,EAAIA,EAAM,UAC3D,MAAOE,EAAE,OAAS,EAClB,KAAM,CAAC,GAAIA,EAAE,MAAQ,CAAC,EAAG,CAAC,CAAE,EAC5B,MAAOA,EAAE,KACX,CACF,CAAC,CACH,EAwBaE,E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