@vielzeug/prism 2.2.6 → 3.0.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/README.md +19 -40
- package/dist/_dev.cjs +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +1 -2
- package/dist/_dev.js.map +1 -1
- package/dist/axes/axis.cjs +1 -1
- package/dist/axes/axis.cjs.map +1 -1
- package/dist/axes/axis.d.ts +1 -0
- package/dist/axes/axis.d.ts.map +1 -1
- package/dist/axes/axis.js +15 -11
- package/dist/axes/axis.js.map +1 -1
- package/dist/charts/area/area-chart.cjs +1 -1
- package/dist/charts/area/area-chart.cjs.map +1 -1
- package/dist/charts/area/area-chart.d.ts +2 -2
- package/dist/charts/area/area-chart.d.ts.map +1 -1
- package/dist/charts/area/area-chart.js +45 -49
- package/dist/charts/area/area-chart.js.map +1 -1
- package/dist/charts/area/area-renderer.cjs +1 -1
- package/dist/charts/area/area-renderer.cjs.map +1 -1
- package/dist/charts/area/area-renderer.d.ts +2 -2
- package/dist/charts/area/area-renderer.d.ts.map +1 -1
- package/dist/charts/area/area-renderer.js +14 -14
- package/dist/charts/area/area-renderer.js.map +1 -1
- package/dist/charts/bar/bar-chart.cjs +1 -1
- package/dist/charts/bar/bar-chart.cjs.map +1 -1
- package/dist/charts/bar/bar-chart.d.ts +2 -2
- package/dist/charts/bar/bar-chart.d.ts.map +1 -1
- package/dist/charts/bar/bar-chart.js +140 -143
- package/dist/charts/bar/bar-chart.js.map +1 -1
- package/dist/charts/bar/bar-hit-test.cjs +1 -1
- package/dist/charts/bar/bar-hit-test.cjs.map +1 -1
- package/dist/charts/bar/bar-hit-test.js +5 -4
- package/dist/charts/bar/bar-hit-test.js.map +1 -1
- package/dist/charts/bar/bar-renderer.cjs +1 -1
- package/dist/charts/bar/bar-renderer.js +24 -24
- package/dist/charts/line/line-chart.cjs +1 -1
- package/dist/charts/line/line-chart.cjs.map +1 -1
- package/dist/charts/line/line-chart.d.ts +2 -2
- package/dist/charts/line/line-chart.d.ts.map +1 -1
- package/dist/charts/line/line-chart.js +46 -50
- package/dist/charts/line/line-chart.js.map +1 -1
- package/dist/charts/line/line-renderer.cjs +1 -1
- package/dist/charts/line/line-renderer.cjs.map +1 -1
- package/dist/charts/line/line-renderer.d.ts +2 -2
- package/dist/charts/line/line-renderer.d.ts.map +1 -1
- package/dist/charts/line/line-renderer.js +34 -34
- package/dist/charts/line/line-renderer.js.map +1 -1
- package/dist/charts/pie/pie-chart.cjs +1 -1
- package/dist/charts/pie/pie-chart.cjs.map +1 -1
- package/dist/charts/pie/pie-chart.d.ts +2 -2
- package/dist/charts/pie/pie-chart.d.ts.map +1 -1
- package/dist/charts/pie/pie-chart.js +84 -79
- package/dist/charts/pie/pie-chart.js.map +1 -1
- package/dist/charts/sparkline/sparkline.cjs +1 -1
- package/dist/charts/sparkline/sparkline.cjs.map +1 -1
- package/dist/charts/sparkline/sparkline.d.ts +2 -2
- package/dist/charts/sparkline/sparkline.d.ts.map +1 -1
- package/dist/charts/sparkline/sparkline.js +100 -101
- package/dist/charts/sparkline/sparkline.js.map +1 -1
- package/dist/core/chart-base.cjs +1 -1
- package/dist/core/chart-base.cjs.map +1 -1
- package/dist/core/chart-base.d.ts +2 -4
- package/dist/core/chart-base.d.ts.map +1 -1
- package/dist/core/chart-base.js +21 -30
- package/dist/core/chart-base.js.map +1 -1
- package/dist/core/chart-scaffold.cjs +1 -1
- package/dist/core/chart-scaffold.cjs.map +1 -1
- package/dist/core/chart-scaffold.d.ts +9 -10
- package/dist/core/chart-scaffold.d.ts.map +1 -1
- package/dist/core/chart-scaffold.js +31 -43
- package/dist/core/chart-scaffold.js.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/layout.cjs +1 -1
- package/dist/core/layout.cjs.map +1 -1
- package/dist/core/layout.js +1 -1
- package/dist/core/layout.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -12
- package/dist/interaction/legend.cjs +1 -1
- package/dist/interaction/legend.cjs.map +1 -1
- package/dist/interaction/legend.js +1 -1
- package/dist/interaction/legend.js.map +1 -1
- package/dist/interaction/tooltip.cjs +1 -1
- package/dist/interaction/tooltip.cjs.map +1 -1
- package/dist/interaction/tooltip.d.ts.map +1 -1
- package/dist/interaction/tooltip.js +29 -29
- package/dist/interaction/tooltip.js.map +1 -1
- package/dist/prism.cjs +1 -1
- package/dist/prism.cjs.map +1 -1
- package/dist/prism.iife.js +1 -1
- package/dist/prism.iife.js.map +1 -1
- package/dist/prism.js +1 -1
- package/dist/prism.js.map +1 -1
- package/dist/types.d.ts +24 -48
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -9
- package/dist/core/resolve.cjs +0 -2
- package/dist/core/resolve.cjs.map +0 -1
- package/dist/core/resolve.d.ts +0 -9
- package/dist/core/resolve.d.ts.map +0 -1
- package/dist/core/resolve.js +0 -15
- package/dist/core/resolve.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-hit-test.cjs","names":[],"sources":["../../../src/charts/bar/bar-hit-test.ts"],"sourcesContent":["import type { Datum } from '../../types';\nimport type { BarScaleContext } from './bar-scale-context';\n\nexport function findCatIdx(pos: number, categories: string[], sc: BarScaleContext): number {\n for (let i = 0; i < categories.length; i++) {\n const center = sc.bandCenter(categories[i]);\n const start = center - sc.bandwidth / 2;\n\n if (pos >= start && pos < start + sc.bandwidth) return i;\n }\n\n return -1;\n}\n\nexport function findSeriesIdx(\n pos: { x: number; y: number },\n catIdx: number,\n categories: string[],\n sc: BarScaleContext,\n seriesCount: number,\n): number {\n if (sc.stacked) {\n if (sc.horizontal) {\n for (let si = 0; si < seriesCount; si++) {\n const rightX = sc.valueScale.map(sc.stackedTops[si]?.[catIdx] ?? 0);\n\n if (rightX >= pos.x) return si;\n }\n\n return seriesCount - 1;\n } else {\n for (let si = 0; si < seriesCount; si++) {\n const topY = sc.valueScale.map(sc.stackedTops[si]?.[catIdx] ?? 0);\n\n if (topY <= pos.y) return si;\n }\n\n return seriesCount - 1;\n }\n } else {\n const subSize = sc.bandwidth / seriesCount;\n const bandStart = sc.bandCenter(categories[catIdx]) - sc.bandwidth / 2;\n const offset = sc.horizontal ? pos.y - bandStart : pos.x - bandStart;\n const subIdx = Math.floor(offset / subSize);\n\n return Math.max(0, Math.min(seriesCount - 1, subIdx));\n }\n}\n\nexport function isOutsideBars(\n pos: { x: number; y: number },\n catIdx: number,\n allData: (Datum | undefined)[][],\n sc: BarScaleContext,\n seriesCount: number,\n): boolean {\n const lastSi = seriesCount - 1;\n const maxVal = sc.stacked\n ? (sc.stackedTops[lastSi]?.[catIdx] ?? 0)\n : Math.max(...Array.from({ length: seriesCount }, (_, si) => allData[si]?.[catIdx]?.value ?? 0));\n const maxPx = sc.valueScale.map(maxVal);\n\n return sc.horizontal ? pos.x > maxPx : pos.y < maxPx;\n}\n"],"mappings":"AAGA,SAAgB,EAAW,EAAa,EAAsB,EAA6B,CACzF,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,OAAQ,IAAK,CAE1C,IAAM,EADS,EAAG,WAAW,EAAW,EAC1B,EAAS,EAAG,UAAY,EAEtC,GAAI,GAAO,GAAS,EAAM,EAAQ,EAAG,UAAW,OAAO,CACzD,CAEA,MAAO,EACT,CAEA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACQ,CACR,GAAI,EAAG,
|
|
1
|
+
{"version":3,"file":"bar-hit-test.cjs","names":[],"sources":["../../../src/charts/bar/bar-hit-test.ts"],"sourcesContent":["import type { Datum } from '../../types';\nimport type { BarScaleContext } from './bar-scale-context';\n\nexport function findCatIdx(pos: number, categories: string[], sc: BarScaleContext): number {\n for (let i = 0; i < categories.length; i++) {\n const center = sc.bandCenter(categories[i]);\n const start = center - sc.bandwidth / 2;\n\n if (pos >= start && pos < start + sc.bandwidth) return i;\n }\n\n return -1;\n}\n\nexport function findSeriesIdx(\n pos: { x: number; y: number },\n catIdx: number,\n categories: string[],\n sc: BarScaleContext,\n seriesCount: number,\n): number {\n if (sc.stacked) {\n if (sc.horizontal) {\n for (let si = 0; si < seriesCount; si++) {\n const rightX = sc.valueScale.map(sc.stackedTops[si]?.[catIdx] ?? 0);\n\n if (rightX >= pos.x) return si;\n }\n\n return seriesCount - 1;\n } else {\n for (let si = 0; si < seriesCount; si++) {\n const topY = sc.valueScale.map(sc.stackedTops[si]?.[catIdx] ?? 0);\n\n if (topY <= pos.y) return si;\n }\n\n return seriesCount - 1;\n }\n } else {\n const subSize = sc.bandwidth / seriesCount;\n const bandStart = sc.bandCenter(categories[catIdx]) - sc.bandwidth / 2;\n const offset = sc.horizontal ? pos.y - bandStart : pos.x - bandStart;\n const subIdx = Math.floor(offset / subSize);\n\n return Math.max(0, Math.min(seriesCount - 1, subIdx));\n }\n}\n\nexport function isOutsideBars(\n pos: { x: number; y: number },\n catIdx: number,\n allData: (Datum | undefined)[][],\n sc: BarScaleContext,\n seriesCount: number,\n): boolean {\n const lastSi = seriesCount - 1;\n const maxVal = sc.stacked\n ? (sc.stackedTops[lastSi]?.[catIdx] ?? 0)\n : Math.max(...Array.from({ length: seriesCount }, (_, si) => allData[si]?.[catIdx]?.value ?? 0));\n const maxPx = sc.valueScale.map(maxVal);\n\n return sc.horizontal ? pos.x > maxPx : pos.y < maxPx;\n}\n"],"mappings":"AAGA,SAAgB,EAAW,EAAa,EAAsB,EAA6B,CACzF,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,OAAQ,IAAK,CAE1C,IAAM,EADS,EAAG,WAAW,EAAW,EAC1B,EAAS,EAAG,UAAY,EAEtC,GAAI,GAAO,GAAS,EAAM,EAAQ,EAAG,UAAW,OAAO,CACzD,CAEA,MAAO,EACT,CAEA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACQ,CACR,GAAI,EAAG,QAAS,CACd,GAAI,EAAG,WAAY,CACjB,IAAK,IAAI,EAAK,EAAG,EAAK,EAAa,IAGjC,GAFe,EAAG,WAAW,IAAI,EAAG,YAAY,EAAG,GAAG,IAAW,CAE7D,GAAU,EAAI,EAAG,OAAO,EAG9B,OAAO,EAAc,CACvB,CACE,IAAK,IAAI,EAAK,EAAG,EAAK,EAAa,IAGjC,GAFa,EAAG,WAAW,IAAI,EAAG,YAAY,EAAG,GAAG,IAAW,CAE3D,GAAQ,EAAI,EAAG,OAAO,EAG5B,OAAO,EAAc,CAEzB,CAAO,CACL,IAAM,EAAU,EAAG,UAAY,EACzB,EAAY,EAAG,WAAW,EAAW,EAAO,EAAI,EAAG,UAAY,EAC/D,EAAS,EAAG,WAAa,EAAI,EAAI,EAAY,EAAI,EAAI,EACrD,EAAS,KAAK,MAAM,EAAS,CAAO,EAE1C,OAAO,KAAK,IAAI,EAAG,KAAK,IAAI,EAAc,EAAG,CAAM,CAAC,CACtD,CACF,CAEA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACS,CACT,IAAM,EAAS,EAAc,EACvB,EAAS,EAAG,QACb,EAAG,YAAY,EAAO,GAAG,IAAW,EACrC,KAAK,IAAI,GAAG,MAAM,KAAK,CAAE,OAAQ,CAAY,GAAI,EAAG,IAAO,EAAQ,EAAG,GAAG,EAAO,EAAE,OAAS,CAAC,CAAC,EAC3F,EAAQ,EAAG,WAAW,IAAI,CAAM,EAEtC,OAAO,EAAG,WAAa,EAAI,EAAI,EAAQ,EAAI,EAAI,CACjD"}
|
|
@@ -7,10 +7,11 @@ function e(e, t, n) {
|
|
|
7
7
|
return -1;
|
|
8
8
|
}
|
|
9
9
|
function t(e, t, n, r, i) {
|
|
10
|
-
if (r.stacked)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
if (r.stacked) {
|
|
11
|
+
if (r.horizontal) {
|
|
12
|
+
for (let n = 0; n < i; n++) if (r.valueScale.map(r.stackedTops[n]?.[t] ?? 0) >= e.x) return n;
|
|
13
|
+
return i - 1;
|
|
14
|
+
}
|
|
14
15
|
for (let n = 0; n < i; n++) if (r.valueScale.map(r.stackedTops[n]?.[t] ?? 0) <= e.y) return n;
|
|
15
16
|
return i - 1;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-hit-test.js","names":[],"sources":["../../../src/charts/bar/bar-hit-test.ts"],"sourcesContent":["import type { Datum } from '../../types';\nimport type { BarScaleContext } from './bar-scale-context';\n\nexport function findCatIdx(pos: number, categories: string[], sc: BarScaleContext): number {\n for (let i = 0; i < categories.length; i++) {\n const center = sc.bandCenter(categories[i]);\n const start = center - sc.bandwidth / 2;\n\n if (pos >= start && pos < start + sc.bandwidth) return i;\n }\n\n return -1;\n}\n\nexport function findSeriesIdx(\n pos: { x: number; y: number },\n catIdx: number,\n categories: string[],\n sc: BarScaleContext,\n seriesCount: number,\n): number {\n if (sc.stacked) {\n if (sc.horizontal) {\n for (let si = 0; si < seriesCount; si++) {\n const rightX = sc.valueScale.map(sc.stackedTops[si]?.[catIdx] ?? 0);\n\n if (rightX >= pos.x) return si;\n }\n\n return seriesCount - 1;\n } else {\n for (let si = 0; si < seriesCount; si++) {\n const topY = sc.valueScale.map(sc.stackedTops[si]?.[catIdx] ?? 0);\n\n if (topY <= pos.y) return si;\n }\n\n return seriesCount - 1;\n }\n } else {\n const subSize = sc.bandwidth / seriesCount;\n const bandStart = sc.bandCenter(categories[catIdx]) - sc.bandwidth / 2;\n const offset = sc.horizontal ? pos.y - bandStart : pos.x - bandStart;\n const subIdx = Math.floor(offset / subSize);\n\n return Math.max(0, Math.min(seriesCount - 1, subIdx));\n }\n}\n\nexport function isOutsideBars(\n pos: { x: number; y: number },\n catIdx: number,\n allData: (Datum | undefined)[][],\n sc: BarScaleContext,\n seriesCount: number,\n): boolean {\n const lastSi = seriesCount - 1;\n const maxVal = sc.stacked\n ? (sc.stackedTops[lastSi]?.[catIdx] ?? 0)\n : Math.max(...Array.from({ length: seriesCount }, (_, si) => allData[si]?.[catIdx]?.value ?? 0));\n const maxPx = sc.valueScale.map(maxVal);\n\n return sc.horizontal ? pos.x > maxPx : pos.y < maxPx;\n}\n"],"mappings":";AAGA,SAAgB,EAAW,GAAa,GAAsB,GAA6B;CACzF,KAAK,IAAI,IAAI,GAAG,IAAI,EAAW,QAAQ,KAAK;EAE1C,IAAM,IADS,EAAG,WAAW,EAAW,EAC1B,IAAS,EAAG,YAAY;EAEtC,IAAI,KAAO,KAAS,IAAM,IAAQ,EAAG,WAAW,OAAO;CACzD;CAEA,OAAO;AACT;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACQ;CACR,IAAI,EAAG,
|
|
1
|
+
{"version":3,"file":"bar-hit-test.js","names":[],"sources":["../../../src/charts/bar/bar-hit-test.ts"],"sourcesContent":["import type { Datum } from '../../types';\nimport type { BarScaleContext } from './bar-scale-context';\n\nexport function findCatIdx(pos: number, categories: string[], sc: BarScaleContext): number {\n for (let i = 0; i < categories.length; i++) {\n const center = sc.bandCenter(categories[i]);\n const start = center - sc.bandwidth / 2;\n\n if (pos >= start && pos < start + sc.bandwidth) return i;\n }\n\n return -1;\n}\n\nexport function findSeriesIdx(\n pos: { x: number; y: number },\n catIdx: number,\n categories: string[],\n sc: BarScaleContext,\n seriesCount: number,\n): number {\n if (sc.stacked) {\n if (sc.horizontal) {\n for (let si = 0; si < seriesCount; si++) {\n const rightX = sc.valueScale.map(sc.stackedTops[si]?.[catIdx] ?? 0);\n\n if (rightX >= pos.x) return si;\n }\n\n return seriesCount - 1;\n } else {\n for (let si = 0; si < seriesCount; si++) {\n const topY = sc.valueScale.map(sc.stackedTops[si]?.[catIdx] ?? 0);\n\n if (topY <= pos.y) return si;\n }\n\n return seriesCount - 1;\n }\n } else {\n const subSize = sc.bandwidth / seriesCount;\n const bandStart = sc.bandCenter(categories[catIdx]) - sc.bandwidth / 2;\n const offset = sc.horizontal ? pos.y - bandStart : pos.x - bandStart;\n const subIdx = Math.floor(offset / subSize);\n\n return Math.max(0, Math.min(seriesCount - 1, subIdx));\n }\n}\n\nexport function isOutsideBars(\n pos: { x: number; y: number },\n catIdx: number,\n allData: (Datum | undefined)[][],\n sc: BarScaleContext,\n seriesCount: number,\n): boolean {\n const lastSi = seriesCount - 1;\n const maxVal = sc.stacked\n ? (sc.stackedTops[lastSi]?.[catIdx] ?? 0)\n : Math.max(...Array.from({ length: seriesCount }, (_, si) => allData[si]?.[catIdx]?.value ?? 0));\n const maxPx = sc.valueScale.map(maxVal);\n\n return sc.horizontal ? pos.x > maxPx : pos.y < maxPx;\n}\n"],"mappings":";AAGA,SAAgB,EAAW,GAAa,GAAsB,GAA6B;CACzF,KAAK,IAAI,IAAI,GAAG,IAAI,EAAW,QAAQ,KAAK;EAE1C,IAAM,IADS,EAAG,WAAW,EAAW,EAC1B,IAAS,EAAG,YAAY;EAEtC,IAAI,KAAO,KAAS,IAAM,IAAQ,EAAG,WAAW,OAAO;CACzD;CAEA,OAAO;AACT;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACQ;CACR,IAAI,EAAG,SAAS;EACd,IAAI,EAAG,YAAY;GACjB,KAAK,IAAI,IAAK,GAAG,IAAK,GAAa,KAGjC,IAFe,EAAG,WAAW,IAAI,EAAG,YAAY,EAAG,GAAG,MAAW,CAE7D,KAAU,EAAI,GAAG,OAAO;GAG9B,OAAO,IAAc;EACvB;EACE,KAAK,IAAI,IAAK,GAAG,IAAK,GAAa,KAGjC,IAFa,EAAG,WAAW,IAAI,EAAG,YAAY,EAAG,GAAG,MAAW,CAE3D,KAAQ,EAAI,GAAG,OAAO;EAG5B,OAAO,IAAc;CAEzB;CAAO;EACL,IAAM,IAAU,EAAG,YAAY,GACzB,IAAY,EAAG,WAAW,EAAW,EAAO,IAAI,EAAG,YAAY,GAC/D,IAAS,EAAG,aAAa,EAAI,IAAI,IAAY,EAAI,IAAI,GACrD,IAAS,KAAK,MAAM,IAAS,CAAO;EAE1C,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAc,GAAG,CAAM,CAAC;CACtD;AACF;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACS;CACT,IAAM,IAAS,IAAc,GACvB,IAAS,EAAG,UACb,EAAG,YAAY,EAAO,GAAG,MAAW,IACrC,KAAK,IAAI,GAAG,MAAM,KAAK,EAAE,QAAQ,EAAY,IAAI,GAAG,MAAO,EAAQ,EAAG,GAAG,EAAO,EAAE,SAAS,CAAC,CAAC,GAC3F,IAAQ,EAAG,WAAW,IAAI,CAAM;CAEtC,OAAO,EAAG,aAAa,EAAI,IAAI,IAAQ,EAAI,IAAI;AACjD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../
|
|
1
|
+
const e=require("../../svg/element.cjs"),t=require("../../animation/transition.cjs");var n=new WeakMap;function r(r,i,a,o,s,c){for(;r.children.length>i.length;){let e=r.lastElementChild;e&&r.removeChild(e)}let l=a.bandwidth(),u=c.stacked?l:l/c.seriesCount,d=c.stacked?0:u*c.seriesIndex,f=c.horizontal??!1,p=[],m=[];for(let t=0;t<i.length;t++){let n=i[t],l=a.map(n.key)+d,h=c.baselineYs?c.baselineYs[t]:s,g=o.map(n.y),_=r.children[t],v=!_;if(_||(_=e.createSvgElement(`rect`,{class:`prism-bar`}),r.appendChild(_)),_.style.display=n.present?``:`none`,f){let t=Math.max(0,Math.abs(h-g)),n=Math.min(g,h);e.setAttributes(_,{fill:c.color,height:Math.max(0,u-1),rx:c.borderRadius,ry:c.borderRadius,y:l}),c.transition?v?(e.setAttributes(_,{width:0,x:h}),p.push({attrs:{width:{from:0,to:t},x:{from:h,to:n}},el:_})):m.push({attrs:{width:{from:Number(_.getAttribute(`width`)??t),to:t},x:{from:Number(_.getAttribute(`x`)??n),to:n}},el:_}):e.setAttributes(_,{width:t,x:n})}else{let t=Math.max(0,Math.abs(h-g)),n=Math.min(g,h);e.setAttributes(_,{fill:c.color,rx:c.borderRadius,ry:c.borderRadius,width:Math.max(0,u-1),x:l}),c.transition?v?(e.setAttributes(_,{height:0,y:h}),p.push({attrs:{height:{from:0,to:t},y:{from:h,to:n}},el:_})):m.push({attrs:{height:{from:Number(_.getAttribute(`height`)??t),to:t},y:{from:Number(_.getAttribute(`y`)??n),to:n}},el:_}):e.setAttributes(_,{height:t,y:n})}}if(c.transition){n.get(r)?.();let e=[];p.length>0&&e.push(t.animate(p,c.transition,void 0,c.disposalSignal)),m.length>0&&e.push(t.animate(m,{...c.transition,stagger:0},void 0,c.disposalSignal)),n.set(r,()=>{for(let t of e)t()})}}exports.renderBars=r;
|
|
2
2
|
//# sourceMappingURL=bar-renderer.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSvgElement as e, setAttributes as t } from "../../svg/element.js";
|
|
2
|
+
import { animate as n } from "../../animation/transition.js";
|
|
3
3
|
//#region src/charts/bar/bar-renderer.ts
|
|
4
4
|
var r = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
function i(i, a, o, s, c, l) {
|
|
@@ -8,17 +8,17 @@ function i(i, a, o, s, c, l) {
|
|
|
8
8
|
e && i.removeChild(e);
|
|
9
9
|
}
|
|
10
10
|
let u = o.bandwidth(), d = l.stacked ? u : u / l.seriesCount, f = l.stacked ? 0 : d * l.seriesIndex, p = l.horizontal ?? !1, m = [], h = [];
|
|
11
|
-
for (let
|
|
12
|
-
let r = a[
|
|
13
|
-
if (v || (v =
|
|
14
|
-
let e = Math.max(0, Math.abs(g - _)),
|
|
15
|
-
|
|
11
|
+
for (let n = 0; n < a.length; n++) {
|
|
12
|
+
let r = a[n], u = o.map(r.key) + f, g = l.baselineYs ? l.baselineYs[n] : c, _ = s.map(r.y), v = i.children[n], y = !v;
|
|
13
|
+
if (v || (v = e("rect", { class: "prism-bar" }), i.appendChild(v)), v.style.display = r.present ? "" : "none", p) {
|
|
14
|
+
let e = Math.max(0, Math.abs(g - _)), n = Math.min(_, g);
|
|
15
|
+
t(v, {
|
|
16
16
|
fill: l.color,
|
|
17
17
|
height: Math.max(0, d - 1),
|
|
18
18
|
rx: l.borderRadius,
|
|
19
19
|
ry: l.borderRadius,
|
|
20
20
|
y: u
|
|
21
|
-
}), l.transition ? y ? (
|
|
21
|
+
}), l.transition ? y ? (t(v, {
|
|
22
22
|
width: 0,
|
|
23
23
|
x: g
|
|
24
24
|
}), m.push({
|
|
@@ -29,7 +29,7 @@ function i(i, a, o, s, c, l) {
|
|
|
29
29
|
},
|
|
30
30
|
x: {
|
|
31
31
|
from: g,
|
|
32
|
-
to:
|
|
32
|
+
to: n
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
el: v
|
|
@@ -40,24 +40,24 @@ function i(i, a, o, s, c, l) {
|
|
|
40
40
|
to: e
|
|
41
41
|
},
|
|
42
42
|
x: {
|
|
43
|
-
from: Number(v.getAttribute("x") ??
|
|
44
|
-
to:
|
|
43
|
+
from: Number(v.getAttribute("x") ?? n),
|
|
44
|
+
to: n
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
el: v
|
|
48
|
-
}) :
|
|
48
|
+
}) : t(v, {
|
|
49
49
|
width: e,
|
|
50
|
-
x:
|
|
50
|
+
x: n
|
|
51
51
|
});
|
|
52
52
|
} else {
|
|
53
|
-
let e = Math.max(0, Math.abs(g - _)),
|
|
54
|
-
|
|
53
|
+
let e = Math.max(0, Math.abs(g - _)), n = Math.min(_, g);
|
|
54
|
+
t(v, {
|
|
55
55
|
fill: l.color,
|
|
56
56
|
rx: l.borderRadius,
|
|
57
57
|
ry: l.borderRadius,
|
|
58
58
|
width: Math.max(0, d - 1),
|
|
59
59
|
x: u
|
|
60
|
-
}), l.transition ? y ? (
|
|
60
|
+
}), l.transition ? y ? (t(v, {
|
|
61
61
|
height: 0,
|
|
62
62
|
y: g
|
|
63
63
|
}), m.push({
|
|
@@ -68,7 +68,7 @@ function i(i, a, o, s, c, l) {
|
|
|
68
68
|
},
|
|
69
69
|
y: {
|
|
70
70
|
from: g,
|
|
71
|
-
to:
|
|
71
|
+
to: n
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
el: v
|
|
@@ -79,25 +79,25 @@ function i(i, a, o, s, c, l) {
|
|
|
79
79
|
to: e
|
|
80
80
|
},
|
|
81
81
|
y: {
|
|
82
|
-
from: Number(v.getAttribute("y") ??
|
|
83
|
-
to:
|
|
82
|
+
from: Number(v.getAttribute("y") ?? n),
|
|
83
|
+
to: n
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
el: v
|
|
87
|
-
}) :
|
|
87
|
+
}) : t(v, {
|
|
88
88
|
height: e,
|
|
89
|
-
y:
|
|
89
|
+
y: n
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
if (l.transition) {
|
|
94
94
|
r.get(i)?.();
|
|
95
|
-
let
|
|
96
|
-
m.length > 0 &&
|
|
95
|
+
let e = [];
|
|
96
|
+
m.length > 0 && e.push(n(m, l.transition, void 0, l.disposalSignal)), h.length > 0 && e.push(n(h, {
|
|
97
97
|
...l.transition,
|
|
98
98
|
stagger: 0
|
|
99
99
|
}, void 0, l.disposalSignal)), r.set(i, () => {
|
|
100
|
-
for (let
|
|
100
|
+
for (let t of e) t();
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("../../svg/element.cjs"),t=require("../../axes/axis.cjs"),n=require("../../axes/grid.cjs"),r=require("../../core/cartesian-scales.cjs"),i=require("../../core/layout.cjs"),a=require("../../core/chart-scaffold.cjs"),o=require("../../interaction/crosshair.cjs"),s=require("../../interaction/series-interaction.cjs"),c=require("../../theme/index.cjs"),l=require("./line-renderer.cjs");function u(u,d){let f=null,p=d.series;return a.createChartScaffold(u,d,u=>{let{groups:m,legend:h,tooltip:g}=u,_=u.dimensions,v=i.chartArea(_.width,_.height,_.margin),y=p.map(e=>e.data),b=y.flat().map(e=>e.key),x=y.flat().map(e=>e.value);if(b.length===0){a.clearCartesianDom(m,h,g,f);return}d.crosshair&&!f&&(f=o.createCrosshair(u.chartArea,d.crosshair));let S=r.buildXScale(b,v.width),C=r.buildYScale(x,v.height);for(d.yAxis?.grid&&n.renderGrid(m.grid,C,d.yAxis.grid,v.width,`horizontal`,t.resolveTickCount(d.yAxis,v.height,`left`)),d.xAxis?.grid&&n.renderGrid(m.grid,S,d.xAxis.grid,v.height,`vertical`,t.resolveTickCount(d.xAxis,v.width,`bottom`)),d.xAxis&&(t.positionAxis(m.xAxis,d.xAxis.position??`bottom`,v.width,v.height),t.renderAxis(m.xAxis,S,d.xAxis,v.width,`bottom`)),d.yAxis&&(t.positionAxis(m.yAxis,d.yAxis.position??`left`,v.width,v.height),t.renderAxis(m.yAxis,C,d.yAxis,v.height,`left`));m.series.children.length>p.length;)m.series.removeChild(m.series.lastChild);let w=[];for(let t=0;t<p.length;t++){let n=p[t],r=m.series.children[t];r||(r=e.createSvgElement(`g`,{class:`prism-line-series`}),m.series.appendChild(r));let i=l.computePoints(y[t],S,C);w.push(i),l.renderLine(r,i,{color:c.seriesColor(t,n.color),curve:n.curve??`linear`,disposalSignal:u.disposalSignal,pointRadius:n.pointRadius??3,showPoints:n.showPoints??!1,strokeWidth:n.strokeWidth??2,transition:d.transition})}return h?.update(p.map((e,t)=>({color:c.seriesColor(t,e.color),name:e.name}))),g?.hide(),s.createSeriesInteraction({crosshair:f,dims:()=>u.dimensions,getData:()=>y,getPoints:()=>w,getSeriesList:()=>p,onClick:d.onClick,onHover:d.onHover,svg:u.svg,tooltip:g})},e=>{p=e})}exports.createLineChart=u;
|
|
2
2
|
//# sourceMappingURL=line-chart.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.cjs","names":[],"sources":["../../../src/charts/line/line-chart.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"line-chart.cjs","names":[],"sources":["../../../src/charts/line/line-chart.ts"],"sourcesContent":["import { positionAxis, renderAxis, resolveTickCount } from '../../axes/axis';\nimport { renderGrid } from '../../axes/grid';\nimport { buildXScale, buildYScale } from '../../core/cartesian-scales';\nimport { clearCartesianDom, createChartScaffold } from '../../core/chart-scaffold';\nimport { chartArea } from '../../core/layout';\nimport { createCrosshair } from '../../interaction/crosshair';\nimport { createSeriesInteraction } from '../../interaction/series-interaction';\nimport { createSvgElement } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { seriesColor } from '../../theme';\nimport type { ChartHandle, LineChartConfig, LineSeriesConfig } from '../../types';\nimport { computePoints, renderLine } from './line-renderer';\n\nexport function createLineChart(container: HTMLElement, config: LineChartConfig): ChartHandle<LineSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let seriesList = config.series;\n\n return createChartScaffold(\n container,\n config,\n (ctx) => {\n const { groups, legend, tooltip } = ctx;\n const dims = ctx.dimensions;\n const area = chartArea(dims.width, dims.height, dims.margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const allY = allData.flat().map((d) => d.value);\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n\n return;\n }\n\n if (config.crosshair && !crosshair) {\n crosshair = createCrosshair(ctx.chartArea, config.crosshair);\n }\n\n const xScale = buildXScale(allX, area.width);\n const yScale = buildYScale(allY, area.height);\n\n if (config.yAxis?.grid) {\n renderGrid(\n groups.grid,\n yScale,\n config.yAxis.grid,\n area.width,\n 'horizontal',\n resolveTickCount(config.yAxis, area.height, 'left'),\n );\n }\n\n if (config.xAxis?.grid) {\n renderGrid(\n groups.grid,\n xScale,\n config.xAxis.grid,\n area.height,\n 'vertical',\n resolveTickCount(config.xAxis, area.width, 'bottom'),\n );\n }\n\n if (config.xAxis) {\n positionAxis(groups.xAxis, config.xAxis.position ?? 'bottom', area.width, area.height);\n renderAxis(groups.xAxis, xScale, config.xAxis, area.width, 'bottom');\n }\n\n if (config.yAxis) {\n positionAxis(groups.yAxis, config.yAxis.position ?? 'left', area.width, area.height);\n renderAxis(groups.yAxis, yScale, config.yAxis, area.height, 'left');\n }\n\n while (groups.series.children.length > seriesList.length) {\n groups.series.removeChild(groups.series.lastChild!);\n }\n\n const allPoints: Point[][] = [];\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n let group = groups.series.children[i] as SVGGElement | undefined;\n\n if (!group) {\n group = createSvgElement('g', { class: 'prism-line-series' });\n groups.series.appendChild(group);\n }\n\n const points = computePoints(allData[i], xScale, yScale);\n\n allPoints.push(points);\n\n renderLine(group, points, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n pointRadius: series.pointRadius ?? 3,\n showPoints: series.showPoints ?? false,\n strokeWidth: series.strokeWidth ?? 2,\n transition: config.transition,\n });\n }\n\n legend?.update(seriesList.map((s, i) => ({ color: seriesColor(i, s.color), name: s.name })));\n tooltip?.hide();\n\n return createSeriesInteraction({\n crosshair,\n dims: () => ctx.dimensions,\n getData: () => allData,\n getPoints: () => allPoints,\n getSeriesList: () => seriesList,\n onClick: config.onClick,\n onHover: config.onHover,\n svg: ctx.svg,\n tooltip,\n });\n },\n (data) => {\n seriesList = data;\n },\n );\n}\n"],"mappings":"6YAaA,SAAgB,EAAgB,EAAwB,EAA0D,CAChH,IAAI,EAAuD,KACvD,EAAa,EAAO,OAExB,OAAO,EAAA,oBACL,EACA,EACC,GAAQ,CACP,GAAM,CAAE,SAAQ,SAAQ,WAAY,EAC9B,EAAO,EAAI,WACX,EAAO,EAAA,UAAU,EAAK,MAAO,EAAK,OAAQ,EAAK,MAAM,EACrD,EAAU,EAAW,IAAK,GAAW,EAAO,IAAI,EAChD,EAAO,EAAQ,KAAK,CAAC,CAAC,IAAK,GAAU,EAAM,GAAG,EAC9C,EAAO,EAAQ,KAAK,CAAC,CAAC,IAAK,GAAM,EAAE,KAAK,EAE9C,GAAI,EAAK,SAAW,EAAG,CACrB,EAAA,kBAAkB,EAAQ,EAAQ,EAAS,CAAS,EAEpD,MACF,CAEI,EA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,MAAO,EAAO,OAAS,SACvB,eAAgB,EAAI,eACpB,YAAa,EAAO,aAAe,EACnC,WAAY,EAAO,YAAc,GACjC,YAAa,EAAO,aAAe,EACnC,WAAY,EAAO,UACrB,CAAC,CACH,CAKA,OAHA,GAAQ,OAAO,EAAW,KAAK,EAAG,KAAO,CAAE,MAAO,EAAA,YAAY,EAAG,EAAE,KAAK,EAAG,KAAM,EAAE,IAAK,EAAE,CAAC,EAC3F,GAAS,KAAK,EAEP,EAAA,wBAAwB,CAC7B,YACA,SAAY,EAAI,WAChB,YAAe,EACf,cAAiB,EACjB,kBAAqB,EACrB,QAAS,EAAO,QAChB,QAAS,EAAO,QAChB,IAAK,EAAI,IACT,SACF,CAAC,CACH,EACC,GAAS,CACR,EAAa,CACf,CACF,CACF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ChartHandle, LineChartConfig } from '../../types';
|
|
2
|
-
export declare function createLineChart(container: HTMLElement, config: LineChartConfig): ChartHandle
|
|
1
|
+
import type { ChartHandle, LineChartConfig, LineSeriesConfig } from '../../types';
|
|
2
|
+
export declare function createLineChart(container: HTMLElement, config: LineChartConfig): ChartHandle<LineSeriesConfig[]>;
|
|
3
3
|
//# sourceMappingURL=line-chart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../src/charts/line/line-chart.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../src/charts/line/line-chart.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGlF,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,GAAG,WAAW,CAAC,gBAAgB,EAAE,CAAC,CA6GhH"}
|
|
@@ -1,61 +1,57 @@
|
|
|
1
|
-
import "../../_dev.js";
|
|
2
1
|
import { createSvgElement as e } from "../../svg/element.js";
|
|
3
|
-
import {
|
|
4
|
-
import { renderGrid as
|
|
5
|
-
import { buildXScale as
|
|
6
|
-
import { chartArea as
|
|
7
|
-
import { clearCartesianDom as
|
|
8
|
-
import { resolveMaybeSignal as l } from "../../core/resolve.js";
|
|
2
|
+
import { positionAxis as t, renderAxis as n, resolveTickCount as r } from "../../axes/axis.js";
|
|
3
|
+
import { renderGrid as i } from "../../axes/grid.js";
|
|
4
|
+
import { buildXScale as a, buildYScale as o } from "../../core/cartesian-scales.js";
|
|
5
|
+
import { chartArea as s } from "../../core/layout.js";
|
|
6
|
+
import { clearCartesianDom as c, createChartScaffold as l } from "../../core/chart-scaffold.js";
|
|
9
7
|
import { createCrosshair as u } from "../../interaction/crosshair.js";
|
|
10
8
|
import { createSeriesInteraction as d } from "../../interaction/series-interaction.js";
|
|
11
9
|
import { seriesColor as f } from "../../theme/index.js";
|
|
12
10
|
import { computePoints as p, renderLine as m } from "./line-renderer.js";
|
|
13
11
|
//#region src/charts/line/line-chart.ts
|
|
14
12
|
function h(h, g) {
|
|
15
|
-
let _ = null, v =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
transition: g.transition
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return y?.update(C.map((e, t) => ({
|
|
42
|
-
color: f(t, e.color),
|
|
43
|
-
name: e.name
|
|
44
|
-
}))), b?.hide(), d({
|
|
45
|
-
crosshair: _,
|
|
46
|
-
dims: () => c.dimensions.value,
|
|
47
|
-
getData: () => w,
|
|
48
|
-
getPoints: () => k,
|
|
49
|
-
getSeriesList: () => v.value,
|
|
50
|
-
onClick: g.onClick,
|
|
51
|
-
onHover: g.onHover,
|
|
52
|
-
svg: c.svg,
|
|
53
|
-
tooltip: b
|
|
13
|
+
let _ = null, v = g.series;
|
|
14
|
+
return l(h, g, (l) => {
|
|
15
|
+
let { groups: h, legend: y, tooltip: b } = l, x = l.dimensions, S = s(x.width, x.height, x.margin), C = v.map((e) => e.data), w = C.flat().map((e) => e.key), T = C.flat().map((e) => e.value);
|
|
16
|
+
if (w.length === 0) {
|
|
17
|
+
c(h, y, b, _);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
g.crosshair && !_ && (_ = u(l.chartArea, g.crosshair));
|
|
21
|
+
let E = a(w, S.width), D = o(T, S.height);
|
|
22
|
+
for (g.yAxis?.grid && i(h.grid, D, g.yAxis.grid, S.width, "horizontal", r(g.yAxis, S.height, "left")), g.xAxis?.grid && i(h.grid, E, g.xAxis.grid, S.height, "vertical", r(g.xAxis, S.width, "bottom")), g.xAxis && (t(h.xAxis, g.xAxis.position ?? "bottom", S.width, S.height), n(h.xAxis, E, g.xAxis, S.width, "bottom")), g.yAxis && (t(h.yAxis, g.yAxis.position ?? "left", S.width, S.height), n(h.yAxis, D, g.yAxis, S.height, "left")); h.series.children.length > v.length;) h.series.removeChild(h.series.lastChild);
|
|
23
|
+
let O = [];
|
|
24
|
+
for (let t = 0; t < v.length; t++) {
|
|
25
|
+
let n = v[t], r = h.series.children[t];
|
|
26
|
+
r || (r = e("g", { class: "prism-line-series" }), h.series.appendChild(r));
|
|
27
|
+
let i = p(C[t], E, D);
|
|
28
|
+
O.push(i), m(r, i, {
|
|
29
|
+
color: f(t, n.color),
|
|
30
|
+
curve: n.curve ?? "linear",
|
|
31
|
+
disposalSignal: l.disposalSignal,
|
|
32
|
+
pointRadius: n.pointRadius ?? 3,
|
|
33
|
+
showPoints: n.showPoints ?? !1,
|
|
34
|
+
strokeWidth: n.strokeWidth ?? 2,
|
|
35
|
+
transition: g.transition
|
|
54
36
|
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
}
|
|
38
|
+
return y?.update(v.map((e, t) => ({
|
|
39
|
+
color: f(t, e.color),
|
|
40
|
+
name: e.name
|
|
41
|
+
}))), b?.hide(), d({
|
|
42
|
+
crosshair: _,
|
|
43
|
+
dims: () => l.dimensions,
|
|
44
|
+
getData: () => C,
|
|
45
|
+
getPoints: () => O,
|
|
46
|
+
getSeriesList: () => v,
|
|
47
|
+
onClick: g.onClick,
|
|
48
|
+
onHover: g.onHover,
|
|
49
|
+
svg: l.svg,
|
|
50
|
+
tooltip: b
|
|
51
|
+
});
|
|
52
|
+
}, (e) => {
|
|
53
|
+
v = e;
|
|
54
|
+
});
|
|
59
55
|
}
|
|
60
56
|
//#endregion
|
|
61
57
|
export { h as createLineChart };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.js","names":[],"sources":["../../../src/charts/line/line-chart.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"line-chart.js","names":[],"sources":["../../../src/charts/line/line-chart.ts"],"sourcesContent":["import { positionAxis, renderAxis, resolveTickCount } from '../../axes/axis';\nimport { renderGrid } from '../../axes/grid';\nimport { buildXScale, buildYScale } from '../../core/cartesian-scales';\nimport { clearCartesianDom, createChartScaffold } from '../../core/chart-scaffold';\nimport { chartArea } from '../../core/layout';\nimport { createCrosshair } from '../../interaction/crosshair';\nimport { createSeriesInteraction } from '../../interaction/series-interaction';\nimport { createSvgElement } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { seriesColor } from '../../theme';\nimport type { ChartHandle, LineChartConfig, LineSeriesConfig } from '../../types';\nimport { computePoints, renderLine } from './line-renderer';\n\nexport function createLineChart(container: HTMLElement, config: LineChartConfig): ChartHandle<LineSeriesConfig[]> {\n let crosshair: ReturnType<typeof createCrosshair> | null = null;\n let seriesList = config.series;\n\n return createChartScaffold(\n container,\n config,\n (ctx) => {\n const { groups, legend, tooltip } = ctx;\n const dims = ctx.dimensions;\n const area = chartArea(dims.width, dims.height, dims.margin);\n const allData = seriesList.map((series) => series.data);\n const allX = allData.flat().map((datum) => datum.key);\n const allY = allData.flat().map((d) => d.value);\n\n if (allX.length === 0) {\n clearCartesianDom(groups, legend, tooltip, crosshair);\n\n return;\n }\n\n if (config.crosshair && !crosshair) {\n crosshair = createCrosshair(ctx.chartArea, config.crosshair);\n }\n\n const xScale = buildXScale(allX, area.width);\n const yScale = buildYScale(allY, area.height);\n\n if (config.yAxis?.grid) {\n renderGrid(\n groups.grid,\n yScale,\n config.yAxis.grid,\n area.width,\n 'horizontal',\n resolveTickCount(config.yAxis, area.height, 'left'),\n );\n }\n\n if (config.xAxis?.grid) {\n renderGrid(\n groups.grid,\n xScale,\n config.xAxis.grid,\n area.height,\n 'vertical',\n resolveTickCount(config.xAxis, area.width, 'bottom'),\n );\n }\n\n if (config.xAxis) {\n positionAxis(groups.xAxis, config.xAxis.position ?? 'bottom', area.width, area.height);\n renderAxis(groups.xAxis, xScale, config.xAxis, area.width, 'bottom');\n }\n\n if (config.yAxis) {\n positionAxis(groups.yAxis, config.yAxis.position ?? 'left', area.width, area.height);\n renderAxis(groups.yAxis, yScale, config.yAxis, area.height, 'left');\n }\n\n while (groups.series.children.length > seriesList.length) {\n groups.series.removeChild(groups.series.lastChild!);\n }\n\n const allPoints: Point[][] = [];\n\n for (let i = 0; i < seriesList.length; i++) {\n const series = seriesList[i];\n let group = groups.series.children[i] as SVGGElement | undefined;\n\n if (!group) {\n group = createSvgElement('g', { class: 'prism-line-series' });\n groups.series.appendChild(group);\n }\n\n const points = computePoints(allData[i], xScale, yScale);\n\n allPoints.push(points);\n\n renderLine(group, points, {\n color: seriesColor(i, series.color),\n curve: series.curve ?? 'linear',\n disposalSignal: ctx.disposalSignal,\n pointRadius: series.pointRadius ?? 3,\n showPoints: series.showPoints ?? false,\n strokeWidth: series.strokeWidth ?? 2,\n transition: config.transition,\n });\n }\n\n legend?.update(seriesList.map((s, i) => ({ color: seriesColor(i, s.color), name: s.name })));\n tooltip?.hide();\n\n return createSeriesInteraction({\n crosshair,\n dims: () => ctx.dimensions,\n getData: () => allData,\n getPoints: () => allPoints,\n getSeriesList: () => seriesList,\n onClick: config.onClick,\n onHover: config.onHover,\n svg: ctx.svg,\n tooltip,\n });\n },\n (data) => {\n seriesList = data;\n },\n );\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,EAAgB,GAAwB,GAA0D;CAChH,IAAI,IAAuD,MACvD,IAAa,EAAO;CAExB,OAAO,EACL,GACA,IACC,MAAQ;EACP,IAAM,EAAE,WAAQ,WAAQ,eAAY,GAC9B,IAAO,EAAI,YACX,IAAO,EAAU,EAAK,OAAO,EAAK,QAAQ,EAAK,MAAM,GACrD,IAAU,EAAW,KAAK,MAAW,EAAO,IAAI,GAChD,IAAO,EAAQ,KAAK,CAAC,CAAC,KAAK,MAAU,EAAM,GAAG,GAC9C,IAAO,EAAQ,KAAK,CAAC,CAAC,KAAK,MAAM,EAAE,KAAK;EAE9C,IAAI,EAAK,WAAW,GAAG;GACrB,EAAkB,GAAQ,GAAQ,GAAS,CAAS;GAEpD;EACF;EAEA,AAAI,EAAO,aAAa,CAAC,MACvB,IAAY,EAAgB,EAAI,WAAW,EAAO,SAAS;EAG7D,IAAM,IAAS,EAAY,GAAM,EAAK,KAAK,GACrC,IAAS,EAAY,GAAM,EAAK,MAAM;EAkC5C,KAhCI,EAAO,OAAO,QAChB,EACE,EAAO,MACP,GACA,EAAO,MAAM,MACb,EAAK,OACL,cACA,EAAiB,EAAO,OAAO,EAAK,QAAQ,MAAM,CACpD,GAGE,EAAO,OAAO,QAChB,EACE,EAAO,MACP,GACA,EAAO,MAAM,MACb,EAAK,QACL,YACA,EAAiB,EAAO,OAAO,EAAK,OAAO,QAAQ,CACrD,GAGE,EAAO,UACT,EAAa,EAAO,OAAO,EAAO,MAAM,YAAY,UAAU,EAAK,OAAO,EAAK,MAAM,GACrF,EAAW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js"),t=require("../../animation/easing.cjs"),n=require("../../animation/motion.cjs"),r=require("../../animation/tween.cjs"),i=require("../../svg/path.cjs");var a=new WeakMap;function o(e,t){return t===`monotone`?i.monotonePath(e):t===`step`?i.stepPath(e):i.linePath(e)}function s(i,s,c){let l=n.resolveMotion(c.transition,0),u=l.duration,d=t.resolveEasing(l.easing),f=i.querySelector(`.prism-line-path`);f||(f=e.createSvgElement(`path`,{class:`prism-line-path`,fill:`none`}),i.appendChild(f)),e.setAttributes(f,{stroke:c.color,"stroke-width":c.strokeWidth});let p=i.querySelector(`.prism-line-dots`);if(c.showPoints?p||(p=e.createSvgElement(`g`,{class:`prism-line-dots`}),i.appendChild(p)):p&&=(p.remove(),null),u===0){if(e.setAttributes(f,{d:o(s,c.curve)}),p){for(;p.children.length>s.length;)p.removeChild(p.lastChild);for(let t=0;t<s.length;t++){let n=p.children[t];n||(n=e.createSvgElement(`circle`,{class:`prism-line-dot`}),p.appendChild(n)),e.setAttributes(n,{cx:s[t].x,cy:s[t].y,fill:c.color,r:c.pointRadius})}}return}a.get(i)?.();let m=!!f.getAttribute(`d`),h=[],g=null;if(p){let t=p.children.length;for(let e=0;e<t;e++){let t=p.children[e],n={x:Number(t.getAttribute(`cx`)),y:Number(t.getAttribute(`cy`))};h.push(n),g=n}for(;p.children.length>s.length;)p.removeChild(p.lastChild);for(let t=p.children.length;t<s.length;t++){let n=e.createSvgElement(`circle`,{class:`prism-line-dot`});e.setAttributes(n,{cx:s[t].x,cy:s[t].y,fill:c.color,r:c.pointRadius}),p.appendChild(n)}}for(let e=h.length;e<s.length;e++)h.push(g??s[e]);let _=null;function v(t){if(c.disposalSignal?.aborted){a.delete(i);return}_===null&&(_=t);let n=Math.min(1,(t-_)/u),l=d(n),m=s.map((e,t)=>{let n=h[t]??e;return{x:r.tweenNumber(n.x,e.x,l),y:r.tweenNumber(n.y,e.y,l)}});if(e.setAttributes(f,{d:o(m,c.curve)}),p)for(let t=0;t<s.length;t++){let n=p.children[t];n&&e.setAttributes(n,{cx:m[t].x,cy:m[t].y})}if(n<1){let e=requestAnimationFrame(v);a.set(i,()=>cancelAnimationFrame(e))}else a.delete(i)}if(!m)e.setAttributes(f,{d:o(s,c.curve)});else{let e=requestAnimationFrame(v);a.set(i,()=>cancelAnimationFrame(e))}}function c(e,t,n){return e.some(e=>e.key==null)||e.some(e=>typeof e.key==`string`),e.map(e=>({x:t.map(e.key),y:n.map(e.value)}))}exports.computePoints=c,exports.renderLine=s;
|
|
2
2
|
//# sourceMappingURL=line-renderer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-renderer.cjs","names":[],"sources":["../../../src/charts/line/line-renderer.ts"],"sourcesContent":["import { warn } from '../../_dev';\nimport { resolveEasing } from '../../animation/easing';\nimport { resolveMotion } from '../../animation/motion';\nimport { tweenNumber } from '../../animation/tween';\nimport { createSvgElement, setAttributes } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { linePath, monotonePath, stepPath } from '../../svg/path';\nimport type {
|
|
1
|
+
{"version":3,"file":"line-renderer.cjs","names":[],"sources":["../../../src/charts/line/line-renderer.ts"],"sourcesContent":["import { warn } from '../../_dev';\nimport { resolveEasing } from '../../animation/easing';\nimport { resolveMotion } from '../../animation/motion';\nimport { tweenNumber } from '../../animation/tween';\nimport { createSvgElement, setAttributes } from '../../svg/element';\nimport type { Point } from '../../svg/path';\nimport { linePath, monotonePath, stepPath } from '../../svg/path';\nimport type { ContinuousDatum, Scale, TransitionConfig } from '../../types';\n\nexport interface LineRenderOptions {\n color: string;\n curve: 'linear' | 'monotone' | 'step';\n /** Aborted when the owning chart is disposed — stops the transition's `requestAnimationFrame` loop from rescheduling. */\n disposalSignal?: AbortSignal;\n pointRadius: number;\n showPoints: boolean;\n strokeWidth: number;\n transition?: TransitionConfig;\n}\n\nconst activeAnimations = new WeakMap<SVGGElement, () => void>();\n\nfunction buildPath(pts: Point[], curve: LineRenderOptions['curve']): string {\n return curve === 'monotone' ? monotonePath(pts) : curve === 'step' ? stepPath(pts) : linePath(pts);\n}\n\nexport function renderLine(parent: SVGGElement, points: Point[], options: LineRenderOptions): void {\n const motion = resolveMotion(options.transition, 0);\n const dur = motion.duration;\n const easing = resolveEasing(motion.easing);\n\n let path = parent.querySelector<SVGPathElement>('.prism-line-path');\n\n if (!path) {\n path = createSvgElement('path', { class: 'prism-line-path', fill: 'none' });\n parent.appendChild(path);\n }\n\n setAttributes(path, { stroke: options.color, 'stroke-width': options.strokeWidth });\n\n let dotsGroup = parent.querySelector<SVGGElement>('.prism-line-dots');\n\n if (options.showPoints) {\n if (!dotsGroup) {\n dotsGroup = createSvgElement('g', { class: 'prism-line-dots' });\n parent.appendChild(dotsGroup);\n }\n } else if (dotsGroup) {\n dotsGroup.remove();\n dotsGroup = null;\n }\n\n if (dur === 0) {\n setAttributes(path, { d: buildPath(points, options.curve) });\n\n if (dotsGroup) {\n while (dotsGroup.children.length > points.length) dotsGroup.removeChild(dotsGroup.lastChild!);\n\n for (let i = 0; i < points.length; i++) {\n let c = dotsGroup.children[i] as SVGCircleElement | undefined;\n\n if (!c) {\n c = createSvgElement('circle', { class: 'prism-line-dot' });\n dotsGroup.appendChild(c);\n }\n\n setAttributes(c, { cx: points[i].x, cy: points[i].y, fill: options.color, r: options.pointRadius });\n }\n }\n\n return;\n }\n\n activeAnimations.get(parent)?.();\n\n const hasExisting = !!path.getAttribute('d');\n\n const fromPts: Point[] = [];\n let lastKnown: Point | null = null;\n\n if (dotsGroup) {\n const existingCount = dotsGroup.children.length;\n\n for (let i = 0; i < existingCount; i++) {\n const c = dotsGroup.children[i] as SVGCircleElement;\n const pt = { x: Number(c.getAttribute('cx')), y: Number(c.getAttribute('cy')) };\n\n fromPts.push(pt);\n lastKnown = pt;\n }\n\n while (dotsGroup.children.length > points.length) dotsGroup.removeChild(dotsGroup.lastChild!);\n\n for (let i = dotsGroup.children.length; i < points.length; i++) {\n const c = createSvgElement('circle', { class: 'prism-line-dot' });\n\n setAttributes(c, { cx: points[i].x, cy: points[i].y, fill: options.color, r: options.pointRadius });\n dotsGroup.appendChild(c);\n }\n }\n\n for (let i = fromPts.length; i < points.length; i++) {\n fromPts.push(lastKnown ?? points[i]);\n }\n\n let startTime: number | null = null;\n\n function frame(ts: number) {\n if (options.disposalSignal?.aborted) {\n activeAnimations.delete(parent);\n\n return;\n }\n\n if (startTime === null) startTime = ts;\n\n const t = Math.min(1, (ts - startTime) / dur);\n const e = easing(t);\n const interpolated: Point[] = points.map((to, i) => {\n const from = fromPts[i] ?? to;\n\n return { x: tweenNumber(from.x, to.x, e), y: tweenNumber(from.y, to.y, e) };\n });\n\n setAttributes(path!, { d: buildPath(interpolated, options.curve) });\n\n if (dotsGroup) {\n for (let i = 0; i < points.length; i++) {\n const c = dotsGroup.children[i] as SVGCircleElement | undefined;\n\n if (c) setAttributes(c, { cx: interpolated[i].x, cy: interpolated[i].y });\n }\n }\n\n if (t < 1) {\n const id = requestAnimationFrame(frame);\n\n activeAnimations.set(parent, () => cancelAnimationFrame(id));\n } else {\n activeAnimations.delete(parent);\n }\n }\n\n if (!hasExisting) {\n setAttributes(path, { d: buildPath(points, options.curve) });\n } else {\n const id = requestAnimationFrame(frame);\n\n activeAnimations.set(parent, () => cancelAnimationFrame(id));\n }\n}\n\nexport function computePoints(data: ContinuousDatum[], xScale: Scale<Date | number>, yScale: Scale<number>): Point[] {\n if (data.some((d) => d.key == null)) {\n warn(\n 'computePoints: datum.key is null or undefined — data must use the Datum shape { key, value }. Did you pass { x, y } instead?',\n );\n } else if (data.some((d) => typeof d.key === 'string')) {\n warn('computePoints: string keys are not supported for line/area charts — use numeric or Date keys.');\n }\n\n return data.map((d) => ({\n x: xScale.map(d.key as Date | number),\n y: yScale.map(d.value),\n }));\n}\n"],"mappings":"0NAoBA,IAAM,EAAmB,IAAI,QAE7B,SAAS,EAAU,EAAc,EAA2C,CAC1E,OAAO,IAAU,WAAa,EAAA,aAAa,CAAG,EAAI,IAAU,OAAS,EAAA,SAAS,C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AE9D,EACF,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IAAK,CACtC,IAAM,EAAI,EAAU,SAAS,GAEzB,GAAG,EAAA,cAAc,EAAG,CAAE,GAAI,EAAa,EAAE,CAAC,EAAG,GAAI,EAAa,EAAE,CAAC,CAAE,CAAC,CAC1E,CAGF,GAAI,EAAI,EAAG,CACT,IAAM,EAAK,sBAAsB,CAAK,EAEtC,EAAiB,IAAI,MAAc,qBAAqB,CAAE,CAAC,CAC7D,MACE,EAAiB,OAAO,CAAM,CAElC,CAEA,GAAI,CAAC,EACH,EAAA,cAAc,EAAM,CAAE,EAAG,EAAU,EAAQ,EAAQ,KAAK,CAAE,CAAC,MACtD,CACL,IAAM,EAAK,sBAAsB,CAAK,EAEtC,EAAiB,IAAI,MAAc,qBAAqB,CAAE,CAAC,CAC7D,CACF,CAEA,SAAgB,EAAc,EAAyB,EAA8B,EAAgC,CASnH,OARI,EAAK,KAAM,GAAM,EAAE,KAAO,IAAI,GAIvB,EAAK,KAAM,GAAM,OAAO,EAAE,KAAQ,QAAQ,EAI9C,EAAK,IAAK,IAAO,CACtB,EAAG,EAAO,IAAI,EAAE,GAAoB,EACpC,EAAG,EAAO,IAAI,EAAE,KAAK,CACvB,EAAE,CACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Point } from '../../svg/path';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ContinuousDatum, Scale, TransitionConfig } from '../../types';
|
|
3
3
|
export interface LineRenderOptions {
|
|
4
4
|
color: string;
|
|
5
5
|
curve: 'linear' | 'monotone' | 'step';
|
|
@@ -11,5 +11,5 @@ export interface LineRenderOptions {
|
|
|
11
11
|
transition?: TransitionConfig;
|
|
12
12
|
}
|
|
13
13
|
export declare function renderLine(parent: SVGGElement, points: Point[], options: LineRenderOptions): void;
|
|
14
|
-
export declare function computePoints(data:
|
|
14
|
+
export declare function computePoints(data: ContinuousDatum[], xScale: Scale<Date | number>, yScale: Scale<number>): Point[];
|
|
15
15
|
//# sourceMappingURL=line-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-renderer.d.ts","sourceRoot":"","sources":["../../../src/charts/line/line-renderer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"line-renderer.d.ts","sourceRoot":"","sources":["../../../src/charts/line/line-renderer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE5E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IACtC,yHAAyH;IACzH,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAQD,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CA4HjG;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,EAAE,CAanH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { resolveEasing as e } from "../../animation/easing.js";
|
|
2
|
-
import { resolveMotion as t } from "../../animation/motion.js";
|
|
3
|
-
import { tweenNumber as n } from "../../animation/tween.js";
|
|
4
1
|
import "../../_dev.js";
|
|
5
|
-
import { createSvgElement as
|
|
2
|
+
import { createSvgElement as e, setAttributes as t } from "../../svg/element.js";
|
|
3
|
+
import { resolveEasing as n } from "../../animation/easing.js";
|
|
4
|
+
import { resolveMotion as r } from "../../animation/motion.js";
|
|
5
|
+
import { tweenNumber as i } from "../../animation/tween.js";
|
|
6
6
|
import { linePath as a, monotonePath as o, stepPath as s } from "../../svg/path.js";
|
|
7
7
|
//#region src/charts/line/line-renderer.ts
|
|
8
8
|
var c = /* @__PURE__ */ new WeakMap();
|
|
@@ -10,23 +10,23 @@ function l(e, t) {
|
|
|
10
10
|
return t === "monotone" ? o(e) : t === "step" ? s(e) : a(e);
|
|
11
11
|
}
|
|
12
12
|
function u(a, o, s) {
|
|
13
|
-
let u =
|
|
14
|
-
p || (p =
|
|
13
|
+
let u = r(s.transition, 0), d = u.duration, f = n(u.easing), p = a.querySelector(".prism-line-path");
|
|
14
|
+
p || (p = e("path", {
|
|
15
15
|
class: "prism-line-path",
|
|
16
16
|
fill: "none"
|
|
17
|
-
}), a.appendChild(p)),
|
|
17
|
+
}), a.appendChild(p)), t(p, {
|
|
18
18
|
stroke: s.color,
|
|
19
19
|
"stroke-width": s.strokeWidth
|
|
20
20
|
});
|
|
21
21
|
let m = a.querySelector(".prism-line-dots");
|
|
22
|
-
if (s.showPoints ? m || (m =
|
|
23
|
-
if (
|
|
22
|
+
if (s.showPoints ? m || (m = e("g", { class: "prism-line-dots" }), a.appendChild(m)) : m &&= (m.remove(), null), d === 0) {
|
|
23
|
+
if (t(p, { d: l(o, s.curve) }), m) {
|
|
24
24
|
for (; m.children.length > o.length;) m.removeChild(m.lastChild);
|
|
25
|
-
for (let
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
cx: o[
|
|
29
|
-
cy: o[
|
|
25
|
+
for (let n = 0; n < o.length; n++) {
|
|
26
|
+
let r = m.children[n];
|
|
27
|
+
r || (r = e("circle", { class: "prism-line-dot" }), m.appendChild(r)), t(r, {
|
|
28
|
+
cx: o[n].x,
|
|
29
|
+
cy: o[n].y,
|
|
30
30
|
fill: s.color,
|
|
31
31
|
r: s.pointRadius
|
|
32
32
|
});
|
|
@@ -37,23 +37,23 @@ function u(a, o, s) {
|
|
|
37
37
|
c.get(a)?.();
|
|
38
38
|
let h = !!p.getAttribute("d"), g = [], _ = null;
|
|
39
39
|
if (m) {
|
|
40
|
-
let
|
|
41
|
-
for (let
|
|
42
|
-
let
|
|
43
|
-
x: Number(
|
|
44
|
-
y: Number(
|
|
40
|
+
let n = m.children.length;
|
|
41
|
+
for (let e = 0; e < n; e++) {
|
|
42
|
+
let t = m.children[e], n = {
|
|
43
|
+
x: Number(t.getAttribute("cx")),
|
|
44
|
+
y: Number(t.getAttribute("cy"))
|
|
45
45
|
};
|
|
46
46
|
g.push(n), _ = n;
|
|
47
47
|
}
|
|
48
48
|
for (; m.children.length > o.length;) m.removeChild(m.lastChild);
|
|
49
|
-
for (let
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
cx: o[
|
|
53
|
-
cy: o[
|
|
49
|
+
for (let n = m.children.length; n < o.length; n++) {
|
|
50
|
+
let r = e("circle", { class: "prism-line-dot" });
|
|
51
|
+
t(r, {
|
|
52
|
+
cx: o[n].x,
|
|
53
|
+
cy: o[n].y,
|
|
54
54
|
fill: s.color,
|
|
55
55
|
r: s.pointRadius
|
|
56
|
-
}), m.appendChild(
|
|
56
|
+
}), m.appendChild(r);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
for (let e = g.length; e < o.length; e++) g.push(_ ?? o[e]);
|
|
@@ -64,26 +64,26 @@ function u(a, o, s) {
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
v === null && (v = e);
|
|
67
|
-
let
|
|
68
|
-
let
|
|
67
|
+
let n = Math.min(1, (e - v) / d), r = f(n), u = o.map((e, t) => {
|
|
68
|
+
let n = g[t] ?? e;
|
|
69
69
|
return {
|
|
70
|
-
x: n
|
|
71
|
-
y: n
|
|
70
|
+
x: i(n.x, e.x, r),
|
|
71
|
+
y: i(n.y, e.y, r)
|
|
72
72
|
};
|
|
73
73
|
});
|
|
74
|
-
if (
|
|
75
|
-
let
|
|
76
|
-
|
|
74
|
+
if (t(p, { d: l(u, s.curve) }), m) for (let e = 0; e < o.length; e++) {
|
|
75
|
+
let n = m.children[e];
|
|
76
|
+
n && t(n, {
|
|
77
77
|
cx: u[e].x,
|
|
78
78
|
cy: u[e].y
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
if (
|
|
81
|
+
if (n < 1) {
|
|
82
82
|
let e = requestAnimationFrame(y);
|
|
83
83
|
c.set(a, () => cancelAnimationFrame(e));
|
|
84
84
|
} else c.delete(a);
|
|
85
85
|
}
|
|
86
|
-
if (!h)
|
|
86
|
+
if (!h) t(p, { d: l(o, s.curve) });
|
|
87
87
|
else {
|
|
88
88
|
let e = requestAnimationFrame(y);
|
|
89
89
|
c.set(a, () => cancelAnimationFrame(e));
|