teechart.js 4.0.4 → 5.0.0-beta.1
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/3D-COMPATIBILITY.md +45 -0
- package/README.md +463 -27
- package/dist/chunks/chart-p639xVyw.js +16 -0
- package/dist/chunks/chart-p639xVyw.js.map +1 -0
- package/dist/chunks/palette-series-DfyYptK1.js +16 -0
- package/dist/chunks/palette-series-DfyYptK1.js.map +1 -0
- package/dist/chunks/series-DeozLXIv.js +16 -0
- package/dist/chunks/series-DeozLXIv.js.map +1 -0
- package/dist/teechart.3d.esm.js +27 -0
- package/dist/teechart.3d.esm.js.map +1 -0
- package/dist/teechart.auto.esm.js +16 -0
- package/dist/teechart.auto.esm.js.map +1 -0
- package/dist/teechart.core.esm.js +16 -0
- package/dist/teechart.core.esm.js.map +1 -0
- package/dist/teechart.esm.js +16 -0
- package/dist/teechart.esm.js.map +1 -0
- package/dist/teechart.js +14 -3
- package/dist/teechart.js.map +1 -1
- package/dist/teechart.maps.esm.js +16 -0
- package/dist/teechart.maps.esm.js.map +1 -0
- package/dist/types/accessibility.d.ts +29 -0
- package/dist/types/accessibility.d.ts.map +1 -0
- package/dist/types/auto.d.ts +4 -0
- package/dist/types/auto.d.ts.map +1 -0
- package/dist/types/chart-options.d.ts +826 -0
- package/dist/types/chart-options.d.ts.map +1 -0
- package/dist/types/chart.d.ts +252 -0
- package/dist/types/chart.d.ts.map +1 -0
- package/dist/types/checkbox.d.ts +12 -0
- package/dist/types/checkbox.d.ts.map +1 -0
- package/dist/types/core/elements/axes.d.ts +17 -0
- package/dist/types/core/elements/axes.d.ts.map +1 -0
- package/dist/types/core/elements/axis-grid.d.ts +20 -0
- package/dist/types/core/elements/axis-grid.d.ts.map +1 -0
- package/dist/types/core/elements/axis-labels.d.ts +54 -0
- package/dist/types/core/elements/axis-labels.d.ts.map +1 -0
- package/dist/types/core/elements/axis-ticks.d.ts +19 -0
- package/dist/types/core/elements/axis-ticks.d.ts.map +1 -0
- package/dist/types/core/elements/axis-title.d.ts +16 -0
- package/dist/types/core/elements/axis-title.d.ts.map +1 -0
- package/dist/types/core/elements/axis.d.ts +125 -0
- package/dist/types/core/elements/axis.d.ts.map +1 -0
- package/dist/types/core/elements/chart-image.d.ts +13 -0
- package/dist/types/core/elements/chart-image.d.ts.map +1 -0
- package/dist/types/core/elements/font.d.ts +28 -0
- package/dist/types/core/elements/font.d.ts.map +1 -0
- package/dist/types/core/elements/format.d.ts +125 -0
- package/dist/types/core/elements/format.d.ts.map +1 -0
- package/dist/types/core/elements/gradient.d.ts +23 -0
- package/dist/types/core/elements/gradient.d.ts.map +1 -0
- package/dist/types/core/elements/legend-symbol.d.ts +49 -0
- package/dist/types/core/elements/legend-symbol.d.ts.map +1 -0
- package/dist/types/core/elements/legend.d.ts +131 -0
- package/dist/types/core/elements/legend.d.ts.map +1 -0
- package/dist/types/core/elements/margins.d.ts +9 -0
- package/dist/types/core/elements/margins.d.ts.map +1 -0
- package/dist/types/core/elements/panel.d.ts +13 -0
- package/dist/types/core/elements/panel.d.ts.map +1 -0
- package/dist/types/core/elements/scroll.d.ts +14 -0
- package/dist/types/core/elements/scroll.d.ts.map +1 -0
- package/dist/types/core/elements/shadow.d.ts +14 -0
- package/dist/types/core/elements/shadow.d.ts.map +1 -0
- package/dist/types/core/elements/stroke.d.ts +19 -0
- package/dist/types/core/elements/stroke.d.ts.map +1 -0
- package/dist/types/core/elements/wall.d.ts +13 -0
- package/dist/types/core/elements/wall.d.ts.map +1 -0
- package/dist/types/core/elements/zoom.d.ts +33 -0
- package/dist/types/core/elements/zoom.d.ts.map +1 -0
- package/dist/types/core/primitives.d.ts +33 -0
- package/dist/types/core/primitives.d.ts.map +1 -0
- package/dist/types/core.d.ts +96 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/data/data-engine.d.ts +245 -0
- package/dist/types/data/data-engine.d.ts.map +1 -0
- package/dist/types/date.format.d.ts +5 -0
- package/dist/types/date.format.d.ts.map +1 -0
- package/dist/types/declarative-tools.d.ts +6 -0
- package/dist/types/declarative-tools.d.ts.map +1 -0
- package/dist/types/do-http-request.d.ts +2 -0
- package/dist/types/do-http-request.d.ts.map +1 -0
- package/dist/types/dom-tip.d.ts +41 -0
- package/dist/types/dom-tip.d.ts.map +1 -0
- package/dist/types/events.d.ts +82 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/extras.d.ts +18 -0
- package/dist/types/extras.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interaction.d.ts +67 -0
- package/dist/types/interaction.d.ts.map +1 -0
- package/dist/types/map-series-definition.d.ts +5 -0
- package/dist/types/map-series-definition.d.ts.map +1 -0
- package/dist/types/maps/africa-map.d.ts +10 -0
- package/dist/types/maps/africa-map.d.ts.map +1 -0
- package/dist/types/maps/asia-map.d.ts +10 -0
- package/dist/types/maps/asia-map.d.ts.map +1 -0
- package/dist/types/maps/australia-map.d.ts +10 -0
- package/dist/types/maps/australia-map.d.ts.map +1 -0
- package/dist/types/maps/europe-map.d.ts +10 -0
- package/dist/types/maps/europe-map.d.ts.map +1 -0
- package/dist/types/maps/europe27-map.d.ts +10 -0
- package/dist/types/maps/europe27-map.d.ts.map +1 -0
- package/dist/types/maps/layout-map.d.ts +51 -0
- package/dist/types/maps/layout-map.d.ts.map +1 -0
- package/dist/types/maps/map-types.d.ts +19 -0
- package/dist/types/maps/map-types.d.ts.map +1 -0
- package/dist/types/maps/south-america-map.d.ts +10 -0
- package/dist/types/maps/south-america-map.d.ts.map +1 -0
- package/dist/types/maps/spain-map.d.ts +11 -0
- package/dist/types/maps/spain-map.d.ts.map +1 -0
- package/dist/types/maps/svg-map.d.ts +37 -0
- package/dist/types/maps/svg-map.d.ts.map +1 -0
- package/dist/types/maps/usa-map.d.ts +12 -0
- package/dist/types/maps/usa-map.d.ts.map +1 -0
- package/dist/types/maps/world-map.d.ts +14 -0
- package/dist/types/maps/world-map.d.ts.map +1 -0
- package/dist/types/maps.d.ts +15 -0
- package/dist/types/maps.d.ts.map +1 -0
- package/dist/types/marks-animation.d.ts +16 -0
- package/dist/types/marks-animation.d.ts.map +1 -0
- package/dist/types/modern-theme.d.ts +14 -0
- package/dist/types/modern-theme.d.ts.map +1 -0
- package/dist/types/optional-options.d.ts +6 -0
- package/dist/types/optional-options.d.ts.map +1 -0
- package/dist/types/palette.d.ts +11 -0
- package/dist/types/palette.d.ts.map +1 -0
- package/dist/types/platform.d.ts +27 -0
- package/dist/types/platform.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +80 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/quadrants-plugin.d.ts +45 -0
- package/dist/types/quadrants-plugin.d.ts.map +1 -0
- package/dist/types/register-all.d.ts +3 -0
- package/dist/types/register-all.d.ts.map +1 -0
- package/dist/types/rendering/canvas-graphics.d.ts +65 -0
- package/dist/types/rendering/canvas-graphics.d.ts.map +1 -0
- package/dist/types/rendering/graphics.d.ts +59 -0
- package/dist/types/rendering/graphics.d.ts.map +1 -0
- package/dist/types/rendering/renderer.d.ts +58 -0
- package/dist/types/rendering/renderer.d.ts.map +1 -0
- package/dist/types/rendering/three-graphics.d.ts +22 -0
- package/dist/types/rendering/three-graphics.d.ts.map +1 -0
- package/dist/types/responsive.d.ts +8 -0
- package/dist/types/responsive.d.ts.map +1 -0
- package/dist/types/series/activity-gauge.d.ts +18 -0
- package/dist/types/series/activity-gauge.d.ts.map +1 -0
- package/dist/types/series/arc-gauge.d.ts +74 -0
- package/dist/types/series/arc-gauge.d.ts.map +1 -0
- package/dist/types/series/area.d.ts +24 -0
- package/dist/types/series/area.d.ts.map +1 -0
- package/dist/types/series/bar.d.ts +17 -0
- package/dist/types/series/bar.d.ts.map +1 -0
- package/dist/types/series/box-plot.d.ts +140 -0
- package/dist/types/series/box-plot.d.ts.map +1 -0
- package/dist/types/series/bubble.d.ts +25 -0
- package/dist/types/series/bubble.d.ts.map +1 -0
- package/dist/types/series/bullet.d.ts +86 -0
- package/dist/types/series/bullet.d.ts.map +1 -0
- package/dist/types/series/candle.d.ts +27 -0
- package/dist/types/series/candle.d.ts.map +1 -0
- package/dist/types/series/circular-gauge.d.ts +100 -0
- package/dist/types/series/circular-gauge.d.ts.map +1 -0
- package/dist/types/series/color-series.d.ts +59 -0
- package/dist/types/series/color-series.d.ts.map +1 -0
- package/dist/types/series/composed-series.d.ts +76 -0
- package/dist/types/series/composed-series.d.ts.map +1 -0
- package/dist/types/series/custom-bar.d.ts +63 -0
- package/dist/types/series/custom-bar.d.ts.map +1 -0
- package/dist/types/series/custom-series.d.ts +74 -0
- package/dist/types/series/custom-series.d.ts.map +1 -0
- package/dist/types/series/donut.d.ts +17 -0
- package/dist/types/series/donut.d.ts.map +1 -0
- package/dist/types/series/gantt.d.ts +47 -0
- package/dist/types/series/gantt.d.ts.map +1 -0
- package/dist/types/series/high-low-bar.d.ts +24 -0
- package/dist/types/series/high-low-bar.d.ts.map +1 -0
- package/dist/types/series/histogram.d.ts +36 -0
- package/dist/types/series/histogram.d.ts.map +1 -0
- package/dist/types/series/horiz-area.d.ts +11 -0
- package/dist/types/series/horiz-area.d.ts.map +1 -0
- package/dist/types/series/horiz-bar.d.ts +23 -0
- package/dist/types/series/horiz-bar.d.ts.map +1 -0
- package/dist/types/series/line.d.ts +22 -0
- package/dist/types/series/line.d.ts.map +1 -0
- package/dist/types/series/linear-gauge.d.ts +73 -0
- package/dist/types/series/linear-gauge.d.ts.map +1 -0
- package/dist/types/series/map-series.d.ts +82 -0
- package/dist/types/series/map-series.d.ts.map +1 -0
- package/dist/types/series/numeric-gauge.d.ts +96 -0
- package/dist/types/series/numeric-gauge.d.ts.map +1 -0
- package/dist/types/series/palette-series.d.ts +39 -0
- package/dist/types/series/palette-series.d.ts.map +1 -0
- package/dist/types/series/pie.d.ts +81 -0
- package/dist/types/series/pie.d.ts.map +1 -0
- package/dist/types/series/point-xy.d.ts +13 -0
- package/dist/types/series/point-xy.d.ts.map +1 -0
- package/dist/types/series/polar.d.ts +37 -0
- package/dist/types/series/polar.d.ts.map +1 -0
- package/dist/types/series/sankey.d.ts +90 -0
- package/dist/types/series/sankey.d.ts.map +1 -0
- package/dist/types/series/series-list.d.ts +127 -0
- package/dist/types/series/series-list.d.ts.map +1 -0
- package/dist/types/series/series-list.types.d.ts +43 -0
- package/dist/types/series/series-list.types.d.ts.map +1 -0
- package/dist/types/series/sliced.d.ts +13 -0
- package/dist/types/series/sliced.d.ts.map +1 -0
- package/dist/types/series/surface.d.ts +24 -0
- package/dist/types/series/surface.d.ts.map +1 -0
- package/dist/types/series/treemap.d.ts +107 -0
- package/dist/types/series/treemap.d.ts.map +1 -0
- package/dist/types/series/violin.d.ts +105 -0
- package/dist/types/series/violin.d.ts.map +1 -0
- package/dist/types/series/volume.d.ts +11 -0
- package/dist/types/series/volume.d.ts.map +1 -0
- package/dist/types/series-definitions.d.ts +30 -0
- package/dist/types/series-definitions.d.ts.map +1 -0
- package/dist/types/series-registry.d.ts +37 -0
- package/dist/types/series-registry.d.ts.map +1 -0
- package/dist/types/series-utils.d.ts +29 -0
- package/dist/types/series-utils.d.ts.map +1 -0
- package/dist/types/series.d.ts +342 -0
- package/dist/types/series.d.ts.map +1 -0
- package/dist/types/slider.d.ts +49 -0
- package/dist/types/slider.d.ts.map +1 -0
- package/dist/types/spline.d.ts +2 -0
- package/dist/types/spline.d.ts.map +1 -0
- package/dist/types/table/chart-table.d.ts +27 -0
- package/dist/types/table/chart-table.d.ts.map +1 -0
- package/dist/types/teechart-3d.d.ts +4 -0
- package/dist/types/teechart-3d.d.ts.map +1 -0
- package/dist/types/theme.d.ts +41 -0
- package/dist/types/theme.d.ts.map +1 -0
- package/dist/types/three/chart-3d.d.ts +77 -0
- package/dist/types/three/chart-3d.d.ts.map +1 -0
- package/dist/types/three/chart-options-3d.d.ts +5 -0
- package/dist/types/three/chart-options-3d.d.ts.map +1 -0
- package/dist/types/three/teechart-3d.d.ts +25 -0
- package/dist/types/three/teechart-3d.d.ts.map +1 -0
- package/dist/types/three-context.d.ts +184 -0
- package/dist/types/three-context.d.ts.map +1 -0
- package/dist/types/three-context.types.d.ts +177 -0
- package/dist/types/three-context.types.d.ts.map +1 -0
- package/dist/types/three-parametric-geometry.d.ts +7 -0
- package/dist/types/three-parametric-geometry.d.ts.map +1 -0
- package/dist/types/three.d.ts +6 -0
- package/dist/types/three.d.ts.map +1 -0
- package/dist/types/tools/animate-hover.d.ts +13 -0
- package/dist/types/tools/animate-hover.d.ts.map +1 -0
- package/dist/types/tools/annotation.d.ts +169 -0
- package/dist/types/tools/annotation.d.ts.map +1 -0
- package/dist/types/tools/base-animation.d.ts +83 -0
- package/dist/types/tools/base-animation.d.ts.map +1 -0
- package/dist/types/tools/cursor-tool.d.ts +51 -0
- package/dist/types/tools/cursor-tool.d.ts.map +1 -0
- package/dist/types/tools/drag-tool.d.ts +28 -0
- package/dist/types/tools/drag-tool.d.ts.map +1 -0
- package/dist/types/tools/index.d.ts +8 -0
- package/dist/types/tools/index.d.ts.map +1 -0
- package/dist/types/tools/tool.d.ts +27 -0
- package/dist/types/tools/tool.d.ts.map +1 -0
- package/dist/types/tools/tools.d.ts +33 -0
- package/dist/types/tools/tools.d.ts.map +1 -0
- package/dist/types/utils.d.ts +23 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/worker.d.ts +92 -0
- package/dist/types/worker.d.ts.map +1 -0
- package/package.json +74 -27
- package/dist/Tween.js +0 -13
- package/dist/date.format.js +0 -145
- package/dist/excanvas/canvas.text.js +0 -489
- package/dist/excanvas/excanvas.compiled.js +0 -35
- package/dist/excanvas/excanvas.js +0 -924
- package/dist/excanvas/excanvas_text.js +0 -1416
- package/dist/three.js +0 -990
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teechart.core.esm.js","sources":["../../../src/tools/cursor-tool.ts","../../../src/tools/drag-tool.ts","../../../src/accessibility.ts","../../../src/checkbox.ts","../../../src/series/circular-gauge.ts","../../../src/slider.ts","../../../src/data/data-engine.ts","../../../src/optional-options.ts","../../../src/responsive.ts","../../../src/worker.ts","../../../src/extras.ts","../../../src/marks-animation.ts","../../../src/series/activity-gauge.ts","../../../src/series/arc-gauge.ts","../../../src/series/box-plot.ts","../../../src/series/horiz-bar.ts","../../../src/series/bullet.ts","../../../src/series/candle.ts","../../../src/series/gantt.ts","../../../src/series/high-low-bar.ts","../../../src/series/histogram.ts","../../../src/series/horiz-area.ts","../../../src/series/numeric-gauge.ts","../../../src/series/polar.ts","../../../src/series/sankey.ts","../../../src/series/sliced.ts","../../../src/series/treemap.ts","../../../src/series/violin.ts","../../../src/series/volume.ts","../../../src/series/color-series.ts","../../../src/series/surface.ts","../../../src/series/linear-gauge.ts","../../../src/series-definitions.ts","../../../src/series/composed-series.ts","../../../src/table/chart-table.ts"],"sourcesContent":["import { Format } from \"../core/elements/format.js\"\nimport { Point, Rectangle } from \"../core/primitives.js\"\nimport type { Axis } from \"../core/elements/axis.js\"\nimport type { Chart } from \"../chart.js\"\nimport { Tool } from \"./tool.js\"\n\ntype CursorDirection = \"both\" | \"vertical\" | \"horizontal\"\ntype CursorRender = \"full\" | \"copy\" | \"layer\"\ntype CursorSymbol = \"circle\" | \"square\" | \"diamond\" | \"none\"\n\n/**\n * @constructor\n * @augments Tool\n * @class Draws mouse draggable horizontal and / or vertical lines inside axes\n * @param {Tee.Chart} chart The parent chart this cursor tool belongs to.\n * @property {String} direction Determines if the cursor will be displayed as \"vertical\", \"horizontal\" or \"both\".\n * @property {Format} format Properties to control the cursor lines stroke appearance.\n * @property {Point} size The size of cursor, {x:0, y:0} means lines will cover full axes bounds.\n * @property {boolean} followMouse When true the cursor follows mouse movement over the chart.\n */\nexport class CursorTool extends Tool {\n\tdirection: CursorDirection\n\tsize: Point\n\tfollowMouse: boolean\n\tdragging: number\n\tformat: Format\n\thorizAxis: Axis | null\n\tvertAxis: Axis | null\n\trender: CursorRender\n\tsymbol: CursorSymbol\n\tsymbolSize: number\n\tprivate _pp: Point\n\tprivate _canvasCopy: HTMLCanvasElement | null\n\tprivate _ctxCopy: CanvasRenderingContext2D | null\n\tprivate _hitEpsilon: number\n\tprivate _old: Point | null\n\tprivate _rect: Rectangle\n\tonchange: ((point: Point) => void) | undefined\n\n\tconstructor(chart: Chart) {\n\t\tsuper(chart)\n\t\tthis.direction = \"both\"\n\t\tthis.size = new Point(0, 0)\n\t\tthis.followMouse = true\n\t\tthis.dragging = -1\n\t\tthis.format = new Format(chart)\n\t\tthis.format.stroke.fill = \"#475569\"\n\t\tthis.format.stroke.size = 1.5\n\t\tthis.horizAxis = chart ? chart.axes.bottom : null\n\t\tthis.vertAxis = chart ? chart.axes.left : null\n\t\tthis.render = \"copy\"\n\t\tthis.symbol = \"circle\"\n\t\tthis.symbolSize = 9\n\t\tthis._hitEpsilon = 3\n\t\tthis._old = null\n\t\tthis._rect = new Rectangle()\n\t\tthis._pp = new Point(0, 0)\n\t\tthis._canvasCopy = null\n\t\tthis._ctxCopy = null\n\t}\n\n\tgetHitTarget(point: Point): number {\n\t\tlet result = -1\n\t\tconst rectangle = this._rect\n\t\tconst oldPoint = this._old\n\n\t\tif (rectangle.contains(point) && oldPoint) {\n\t\t\tconst nearVertical = Math.abs(oldPoint.x - point.x) < this._hitEpsilon\n\t\t\tconst nearHorizontal = Math.abs(oldPoint.y - point.y) < this._hitEpsilon\n\t\t\tconst direction = this.direction\n\t\t\tif (direction === \"both\" && nearVertical && nearHorizontal) result = 0\n\t\t\telse if (nearVertical && (direction === \"both\" || direction === \"vertical\")) result = 1\n\t\t\telse if (nearHorizontal && (direction === \"both\" || direction === \"horizontal\")) result = 2\n\t\t}\n\t\treturn result\n\t}\n\n\tcalculateBounds(): void {\n\t\tconst chartRectangle = this.chart.chartRect\n\t\tconst horizontalAxis = this.horizAxis\n\t\tconst verticalAxis = this.vertAxis\n\t\tconst rectangle = this._rect\n\n\t\trectangle.x = horizontalAxis ? horizontalAxis.startPos : chartRectangle.x\n\t\trectangle.width = horizontalAxis ? horizontalAxis.endPos - rectangle.x : chartRectangle.width\n\n\t\trectangle.y = verticalAxis ? verticalAxis.startPos : chartRectangle.y\n\t\trectangle.height = verticalAxis ? verticalAxis.endPos - rectangle.y : chartRectangle.height\n\t}\n\n\tmousedown(event: Event): boolean {\n\t\tthis.chart.calcMouse(event, this._pp)\n\t\tthis.dragging = this.followMouse ? -1 : this.getHitTarget(this._pp)\n\t\treturn this.dragging > -1\n\t}\n\n\tclicked(): boolean {\n\t\tthis.dragging = -1\n\t\treturn false\n\t}\n\n\tmousemove(point: Point): void {\n\t\tconst dragging = this.dragging\n\t\tconst followsMouse = this.followMouse\n\t\tlet oldPoint = this._old\n\t\tconst rectangle = this._rect\n\n\t\tif (followsMouse || dragging > -1) {\n\t\t\tif (!oldPoint) oldPoint = this._old = new Point()\n\n\t\t\tif (oldPoint.x !== point.x || oldPoint.y !== point.y) {\n\t\t\t\tthis.calculateBounds()\n\n\t\t\t\tif (rectangle.contains(point)) {\n\t\t\t\t\tif (followsMouse || dragging === 0 || dragging === 1) oldPoint.x = point.x\n\t\t\t\t\tif (followsMouse || dragging === 0 || dragging === 2) oldPoint.y = point.y\n\n\t\t\t\t\tif (this.render === \"full\") this.chart.draw()\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (this._canvasCopy)\n\t\t\t\t\t\t\tif (this.render === \"copy\") this.restoreCopy(this.chart.drawContext)\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconst b = this.chart.bounds\n\t\t\t\t\t\t\t\tthis._ctxCopy?.clearRect(b.x, b.y, b.width, b.height)\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.drawCursor(this.render === \"copy\" ? this.chart.ctx : this._ctxCopy)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.onchange?.(point)\n\t\t\t\t\tthis._emit(\"change\", point)\n\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst hitTarget = this.getHitTarget(point)\n\n\t\tif (oldPoint && hitTarget > -1) {\n\t\t\tthis.chart.newCursor = hitTarget === 0 ? \"move\" : hitTarget === 1 ? \"e-resize\" : \"n-resize\"\n\t\t} else this.chart.newCursor = \"default\"\n\t}\n\n\tsetRender(render: CursorRender): void {\n\t\tthis.render = render\n\n\t\tif (this._canvasCopy) {\n\t\t\tthis.resetCopy()\n\t\t\tthis.chart.draw()\n\t\t}\n\t}\n\n\tprivate restoreCopy(context: CanvasRenderingContext2D): void {\n\t\tif (this._canvasCopy) this.copyBitmap(this._canvasCopy, context)\n\t}\n\n\tprivate copyBitmap(source: HTMLCanvasElement, context: CanvasRenderingContext2D): void {\n\t\tcontext.save()\n\t\tcontext.setTransform(1, 0, 0, 1, 0, 0)\n\t\tcontext.globalAlpha = 1\n\t\t// Transparent pixels must replace the previous frame, including the old cursor.\n\t\tcontext.globalCompositeOperation = \"copy\"\n\t\tcontext.shadowColor = \"transparent\"\n\t\tcontext.filter = \"none\"\n\t\tcontext.drawImage(source, 0, 0)\n\t\tcontext.restore()\n\t}\n\n\tresetCopy(): void {\n\t\tconst canvas = this.chart.canvas\n\t\tconst canvasCopy = this._canvasCopy\n\n\t\tif (!canvasCopy) return\n\n\t\tif (this.render === \"layer\") {\n\t\t\tcanvasCopy.style.position = \"absolute\"\n\t\t\tcanvas.parentNode?.appendChild(canvasCopy)\n\n\t\t\tcanvasCopy.setAttribute(\"left\", `${canvas.offsetLeft}px`)\n\t\t\tcanvasCopy.setAttribute(\"top\", `${canvas.offsetTop}px`)\n\n\t\t\tcanvasCopy.style.left = `${canvas.offsetLeft}px`\n\t\t\tcanvasCopy.style.top = `${canvas.offsetTop}px`\n\n\t\t\tcanvasCopy.style.zIndex = \"10\"\n\t\t\tcanvasCopy.style.pointerEvents = \"none\"\n\t\t} else if (canvasCopy.parentNode) canvasCopy.parentNode.removeChild(canvasCopy)\n\t}\n\n\tdraw(): void {\n\t\tif (this.render === \"full\") this.drawCursor(this.chart.ctx)\n\t\telse {\n\t\t\tif (!this._canvasCopy) {\n\t\t\t\tthis._canvasCopy = this.chart.canvas.cloneNode() as HTMLCanvasElement\n\t\t\t\tthis.resetCopy()\n\t\t\t\tthis._ctxCopy = this._canvasCopy.getContext(\"2d\")\n\t\t\t}\n\n\t\t\tif (this.render === \"copy\") {\n\t\t\t\tconst canvas = this.chart.canvas\n\t\t\t\tif (this._canvasCopy.width !== canvas.width || this._canvasCopy.height !== canvas.height) {\n\t\t\t\t\tthis._canvasCopy.width = canvas.width\n\t\t\t\t\tthis._canvasCopy.height = canvas.height\n\t\t\t\t}\n\t\t\t\tif (this._ctxCopy) this.copyBitmap(canvas, this._ctxCopy)\n\n\t\t\t\tthis.drawCursor(this.chart.ctx)\n\t\t\t} else this.drawCursor(this._ctxCopy)\n\t\t}\n\t}\n\n\tdrawCursor(context: CanvasRenderingContext2D | null): void {\n\t\tif (!context) return\n\n\t\tconst direction = this.direction\n\t\tconst bothDirections = direction === \"both\"\n\t\tconst rectangle = this._rect\n\t\tconst oldPoint = this._old\n\n\t\tthis.calculateBounds()\n\n\t\tif (!oldPoint) return\n\n\t\tcontext.save()\n\t\tcontext.beginPath()\n\n\t\tif (bothDirections || direction === \"vertical\") {\n\t\t\tconst halfHeight = this.size.y * 0.5\n\t\t\tcontext.moveTo(oldPoint.x, halfHeight === 0 ? rectangle.y : oldPoint.y - halfHeight)\n\t\t\tcontext.lineTo(oldPoint.x, halfHeight === 0 ? rectangle.y + rectangle.height : oldPoint.y + halfHeight)\n\t\t}\n\n\t\tif (bothDirections || direction === \"horizontal\") {\n\t\t\tconst halfWidth = this.size.x * 0.5\n\t\t\tcontext.moveTo(halfWidth === 0 ? rectangle.x : oldPoint.x - halfWidth, oldPoint.y)\n\t\t\tcontext.lineTo(halfWidth === 0 ? rectangle.x + rectangle.width : oldPoint.x + halfWidth, oldPoint.y)\n\t\t}\n\n\t\tcontext.strokeStyle = \"white\"\n\t\tcontext.lineWidth = Math.max(this.format.stroke.size + 3, 4)\n\t\tcontext.setLineDash([])\n\t\tcontext.stroke()\n\n\t\tthis.format.stroke.prepare(this.format.stroke.fill, context)\n\t\tcontext.stroke()\n\n\t\tif (this.symbol !== \"none\") {\n\t\t\tconst radius = this.symbolSize * 0.5\n\t\t\tcontext.beginPath()\n\t\t\tif (this.symbol === \"circle\") context.arc(oldPoint.x, oldPoint.y, radius, 0, Math.PI * 2)\n\t\t\telse if (this.symbol === \"square\")\n\t\t\t\tcontext.rect(oldPoint.x - radius, oldPoint.y - radius, this.symbolSize, this.symbolSize)\n\t\t\telse {\n\t\t\t\tcontext.moveTo(oldPoint.x, oldPoint.y - radius)\n\t\t\t\tcontext.lineTo(oldPoint.x + radius, oldPoint.y)\n\t\t\t\tcontext.lineTo(oldPoint.x, oldPoint.y + radius)\n\t\t\t\tcontext.lineTo(oldPoint.x - radius, oldPoint.y)\n\t\t\t\tcontext.closePath()\n\t\t\t}\n\t\t\tcontext.fillStyle = \"white\"\n\t\t\tcontext.fill()\n\t\t\tcontext.stroke()\n\t\t}\n\t\tcontext.restore()\n\t}\n}\n","import { Point } from \"../core/primitives.js\"\nimport type { Series } from \"../series.js\"\nimport type { Chart } from \"../chart.js\"\nimport { Tool } from \"./tool.js\"\n\ninterface DragTarget {\n\tseries: Series | null\n\tindex: number\n}\n\n/**\n * @constructor\n * @augments Tool\n * @class Allows dragging series data by mouse or touch\n * @param {Tee.Chart} chart The parent chart this tool belongs to.\n * @property {Tee.Series} [series=null] A series to be dragged, or null to drag all.\n */\nexport class DragTool extends Tool {\n\tseries: Series | null\n\ttarget: DragTarget\n\tpoint: Point\n\tonchanging: ((tool: DragTool, value: number) => number) | undefined\n\tonchanged: ((tool: DragTool, value: number) => void) | undefined\n\n\tconstructor(chart: Chart) {\n\t\tsuper(chart)\n\t\tthis.series = null\n\t\tthis.target = { series: null, index: -1 }\n\t\tthis.point = new Point(0, 0)\n\t}\n\n\tclicked(): boolean {\n\t\tthis.target.series = null\n\t\tthis.target.index = -1\n\t\treturn false\n\t}\n\n\tmousedown(event: Event): boolean {\n\t\tconst series = this.chart.series.items\n\t\tconst point = this.point\n\t\tconst target = this.target\n\n\t\tthis.chart.calcMouse(event, point)\n\n\t\ttarget.series = null\n\t\ttarget.index = -1\n\n\t\tif (this.series?.visible) {\n\t\t\ttarget.index = this.series.clicked(point)\n\t\t\tif (target.index !== -1) target.series = this.series\n\t\t} else\n\t\t\tfor (const candidate of series) {\n\t\t\t\tif (candidate.visible) {\n\t\t\t\t\ttarget.index = candidate.clicked(point)\n\t\t\t\t\tif (target.index !== -1) {\n\t\t\t\t\t\ttarget.series = candidate\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\treturn target.index !== -1\n\t}\n\n\tmousemove(point: Point): void {\n\t\tconst target = this.target\n\t\tconst series = target.series\n\t\tif (target.index !== -1 && series) {\n\t\t\tlet value = series.mandatoryAxis.fromPos(series.yMandatory ? point.y : point.x)\n\n\t\t\tif (this.onchanging) value = this.onchanging(this, value)\n\n\t\t\tseries.data.values[target.index] = value\n\n\t\t\tif (this.onchanged) this.onchanged(this, value)\n\t\t\tthis._emit(\"changed\", this, value)\n\t\t\tthis.chart.draw()\n\t\t}\n\t}\n}\n","import type { Chart } from \"./chart.js\"\nimport { getDocument } from \"./platform.js\"\nimport type { Series } from \"./series.js\"\n\n/** Options that expose the chart to assistive technology; a canvas has no semantics of its own. */\nexport interface AccessibilityOptions {\n\t/** Short name announced for the chart. Defaults to the chart title. */\n\tlabel?: string\n\t/**\n\t * Longer text for screen readers. `true` generates a summary of the visible series that is kept up to\n\t * date after every draw; a string is used as it is.\n\t */\n\tdescription?: string | boolean\n\t/**\n\t * Makes the canvas focusable and lets the arrow keys move through the points: left and right between\n\t * the points of a series, up and down between series, Home and End to the first and last point and\n\t * Escape to leave. The focused point is highlighted when the series has hover enabled, announced in a\n\t * live region next to the canvas and reported by the chart's `pointfocus` event.\n\t */\n\tkeyboard?: boolean\n}\n\nfunction round(value: number): string {\n\treturn Number.isInteger(value) ? String(value) : value.toFixed(2).replace(/\\.?0+$/, \"\")\n}\n\nfunction describeSeries(series: Series, index: number): string {\n\tconst name = series.title || `Series ${index + 1}`\n\tconst numbers = (series.data.values as unknown[]).filter(\n\t\t(value): value is number => typeof value === \"number\" && Number.isFinite(value)\n\t)\n\tif (numbers.length === 0) return `${name}, no data`\n\n\tconst points = numbers.length === 1 ? \"1 point\" : `${numbers.length} points`\n\tlet minimum = numbers[0]\n\tlet maximum = numbers[0]\n\tfor (const value of numbers) {\n\t\tif (value < minimum) minimum = value\n\t\tif (value > maximum) maximum = value\n\t}\n\treturn `${name}, ${points}, from ${round(minimum)} to ${round(maximum)}`\n}\n\n/**\n * Describes the visible series of a chart in plain text: title, the number of series and, for each,\n * its name, point count and value range.\n */\nexport function describeChart(chart: Chart): string {\n\tconst visible = chart.series.items.filter(series => series.visible)\n\tconst title = chart.title.text\n\tconst parts: string[] = []\n\tif (title) parts.push(title)\n\n\tif (visible.length === 0) parts.push(\"Chart without data\")\n\telse {\n\t\tconst count = visible.length === 1 ? \"1 series\" : `${visible.length} series`\n\t\tparts.push(`Chart with ${count}: ${visible.map((series, index) => describeSeries(series, index)).join(\"; \")}`)\n\t}\n\treturn `${parts.join(\". \")}.`\n}\n\ninterface AccessibleCanvas {\n\tsetAttribute?(name: string, value: string): void\n\tremoveAttribute?(name: string): void\n\ttextContent?: string | null\n\taddEventListener?(type: string, listener: (event: never) => void): void\n\tremoveEventListener?(type: string, listener: (event: never) => void): void\n\tparentNode?: { insertBefore(node: unknown, reference: unknown): void } | null\n\tnextSibling?: unknown\n}\n\ninterface LiveRegion {\n\ttextContent: string | null\n\tsetAttribute?(name: string, value: string): void\n\tstyle?: Record<string, string>\n\tparentNode?: { removeChild(node: unknown): void } | null\n}\n\ninterface NavigationKey {\n\tkey: string\n\tpreventDefault?(): void\n}\n\nconst visuallyHidden: Record<string, string> = {\n\tposition: \"absolute\",\n\twidth: \"1px\",\n\theight: \"1px\",\n\tmargin: \"-1px\",\n\tpadding: \"0\",\n\toverflow: \"hidden\",\n\tclip: \"rect(0 0 0 0)\",\n\twhiteSpace: \"nowrap\",\n\tborder: \"0\"\n}\n\nfunction navigableSeries(chart: Chart): Series[] {\n\treturn chart.series.items.filter(series => series.visible && series.data.values.length > 0)\n}\n\nfunction announcement(series: Series, index: number): string {\n\tconst label = series.data.labels[index]\n\tconst value = series.data.values[index]\n\tconst where = label === undefined || label === \"\" ? `point ${index + 1}` : String(label)\n\tconst shown = typeof value === \"number\" ? round(value) : String(value)\n\treturn `${series.title || \"Series\"}, ${where}: ${shown}`\n}\n\n/** Keyboard navigation of the points; returns a function that removes everything it added. */\nfunction enableKeyboard(chart: Chart, canvas: AccessibleCanvas): () => void {\n\tlet seriesPosition = 0\n\tlet pointIndex = -1\n\tlet region: LiveRegion | null = null\n\n\tconst document = getDocument()\n\tif (document && canvas.parentNode) {\n\t\tregion = document.createElement(\"div\") as unknown as LiveRegion\n\t\tregion.setAttribute?.(\"role\", \"status\")\n\t\tregion.setAttribute?.(\"aria-live\", \"polite\")\n\t\tif (region.style) Object.assign(region.style, visuallyHidden)\n\t\tcanvas.parentNode.insertBefore(region, canvas.nextSibling ?? null)\n\t}\n\n\tconst focusPoint = (series: Series, index: number): void => {\n\t\tfor (const other of chart.series.items) if (other !== series && other.over !== -1) other.doHover(-1)\n\t\tseries.doHover(index)\n\t\tif (region) region.textContent = announcement(series, index)\n\t\tchart._emit(\"pointfocus\", series, index)\n\t}\n\n\tconst onKeyDown = (event: NavigationKey): void => {\n\t\tconst list = navigableSeries(chart)\n\t\tif (list.length === 0) return\n\n\t\tseriesPosition = Math.min(seriesPosition, list.length - 1)\n\t\tconst series = list[seriesPosition]\n\t\tconst last = series.data.values.length - 1\n\t\tlet nextSeries = seriesPosition\n\t\tlet next = pointIndex < 0 ? 0 : pointIndex\n\n\t\tswitch (event.key) {\n\t\t\tcase \"ArrowRight\":\n\t\t\t\tnext = pointIndex < 0 ? 0 : Math.min(last, pointIndex + 1)\n\t\t\t\tbreak\n\t\t\tcase \"ArrowLeft\":\n\t\t\t\tnext = pointIndex < 0 ? last : Math.max(0, pointIndex - 1)\n\t\t\t\tbreak\n\t\t\tcase \"ArrowDown\":\n\t\t\t\tnextSeries = Math.min(list.length - 1, seriesPosition + 1)\n\t\t\t\tbreak\n\t\t\tcase \"ArrowUp\":\n\t\t\t\tnextSeries = Math.max(0, seriesPosition - 1)\n\t\t\t\tbreak\n\t\t\tcase \"Home\":\n\t\t\t\tnext = 0\n\t\t\t\tbreak\n\t\t\tcase \"End\":\n\t\t\t\tnext = last\n\t\t\t\tbreak\n\t\t\tcase \"Escape\":\n\t\t\t\tfor (const other of chart.series.items) if (other.over !== -1) other.doHover(-1)\n\t\t\t\tpointIndex = -1\n\t\t\t\tif (region) region.textContent = \"\"\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\treturn\n\t\t}\n\n\t\tevent.preventDefault?.()\n\t\tseriesPosition = nextSeries\n\t\tconst target = list[nextSeries]\n\t\tpointIndex = Math.min(next, target.data.values.length - 1)\n\t\tfocusPoint(target, pointIndex)\n\t}\n\n\tcanvas.setAttribute?.(\"tabindex\", \"0\")\n\tcanvas.addEventListener?.(\"keydown\", onKeyDown as (event: never) => void)\n\n\treturn () => {\n\t\tcanvas.removeEventListener?.(\"keydown\", onKeyDown as (event: never) => void)\n\t\tcanvas.removeAttribute?.(\"tabindex\")\n\t\tregion?.parentNode?.removeChild(region)\n\t\tregion = null\n\t}\n}\n\n/**\n * Applies the accessibility options to the chart canvas and returns a function that stops keeping them\n * up to date. Generated texts follow the chart: they are refreshed after every draw.\n */\nexport function applyAccessibility(chart: Chart, options: AccessibilityOptions): () => void {\n\tconst canvas = chart.canvas as unknown as AccessibleCanvas\n\tconst automatic = options.label === undefined || options.description === true\n\n\tlet applied: string | undefined\n\n\tconst refresh = (): void => {\n\t\tconst label = options.label ?? chart.title.text\n\t\tconst description = options.description === true ? describeChart(chart) : options.description\n\t\t// Draws are frequent; only touch the DOM when the text changed.\n\t\tconst key = `${label}\\n${description}`\n\t\tif (key === applied) return\n\t\tapplied = key\n\n\t\tcanvas.setAttribute?.(\"role\", \"img\")\n\n\t\tif (label) canvas.setAttribute?.(\"aria-label\", label)\n\t\telse canvas.removeAttribute?.(\"aria-label\")\n\n\t\tif (typeof description === \"string\" && description !== \"\") {\n\t\t\tcanvas.setAttribute?.(\"aria-description\", description)\n\t\t\t// Canvas fallback content is exposed to assistive technology by browsers without aria-description.\n\t\t\tcanvas.textContent = description\n\t\t} else {\n\t\t\tcanvas.removeAttribute?.(\"aria-description\")\n\t\t}\n\t}\n\n\trefresh()\n\tconst stopKeyboard = options.keyboard ? enableKeyboard(chart, canvas) : undefined\n\tconst stopRefresh = automatic ? chart.on(\"draw\", refresh) : undefined\n\n\t// The DOM changes made for the keyboard outlive the chart unless they are undone with it.\n\tconst stop = (): void => {\n\t\tstopDestroy()\n\t\tstopRefresh?.()\n\t\tstopKeyboard?.()\n\t}\n\tconst stopDestroy = chart.once(\"destroy\", stop)\n\n\treturn stop\n}\n","import type { Chart } from \"./chart.js\"\nimport { Format } from \"./core/elements/format.js\"\nimport { Annotation } from \"./tools/index.js\"\n\nexport class CheckBox extends Annotation {\n\tonchange: ((checkbox: CheckBox) => void) | undefined\n\tcheck: Format\n\tchecked = true\n\n\tconstructor(chart: Chart, text = \"\", checked?: boolean) {\n\t\tsuper(chart)\n\t\tthis.transparent = true\n\t\tthis.text = text\n\t\tthis.checked = checked ?? true\n\t\tthis.margins.left = 10\n\t\tthis.cursor = \"pointer\"\n\t\tthis.check = new Format(chart)\n\t\tthis.check.fill = \"white\"\n\t\tthis.chart.canvas.addEventListener(\"touchstart\", () => {})\n\t}\n\n\tasync draw(): Promise<void> {\n\t\tawait super.draw()\n\t\tconst ctx = this.chart.drawContext\n\t\tconst x = this.position.x + 2\n\t\tconst h = this.bounds.height * 0.6\n\t\tconst y = this.position.y + (this.bounds.height - h) * 0.4\n\t\tthis.check.rectangle(x, y, h, h)\n\t\tif (this.checked) {\n\t\t\tctx.beginPath()\n\t\t\tctx.moveTo(x + 3, y + 5)\n\t\t\tctx.lineTo(x + 4, y + 8)\n\t\t\tctx.lineTo(x + 7, y + 2)\n\t\t\tthis.check.stroke.prepare()\n\t\t\tctx.stroke()\n\t\t}\n\t}\n\n\tonclick(): boolean {\n\t\tthis.checked = !this.checked\n\t\tif (this.onchange) this.onchange(this)\n\t\treturn true\n\t}\n}\n","import type { Chart } from \"../chart.js\"\nimport type { GaugeBand } from \"../chart-options.js\"\nimport { Format, percentLocation } from \"../core/elements/format.js\"\nimport type { Point, Rectangle } from \"../core/primitives.js\"\nimport { getNavigator } from \"../platform.js\"\nimport { Series } from \"../series.js\"\nimport type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { Annotation, BaseAnimation } from \"../tools/index.js\"\nimport { trunc } from \"../utils.js\"\n\ninterface CircularGaugePoint extends Point {\n\tvalue: number\n\tinTicks: boolean\n}\n\ninterface CircularGaugeBounds extends Rectangle {\n\tcustom?: boolean\n\t(r: Rectangle): void\n}\n\ninterface GaugeRange {\n\tvalue: number\n\tfill: string\n}\n\n/**\n * @constructor\n * @memberOf Tee\n * @class Parameters to draw a circular gauge meter.\n * @property {Number} [min=0] The minimum gauge range value.\n * @property {Number} [max=100] The maxnimum gauge range value.\n * @property {Number} [step=0] The increment between gauge range labels.\n * @property {Number} [value=0] The position of gauge hand inside the min max range.\n * @property {Number} [angle=280] Amount in degrees of the circular gauge size.\n * @property {Number} [rotation=0] Gauge rotation in degrees.\n * @property {Boolean} [rotateText=false] Gauge labels are rotated or not according to label angle position.\n * @property {String} [shape=\"circle\"] Gauge style (\"circle\", \"rectangle\", \"segment\").\n * @property {Boolean} [drag.enabled=true] Allows mouse/touch dragging the Gauge hand to change current value.\n * @property {Format} bevel Formatting properties to outmost external gauge bevel.\n * @property {Format} center Formatting properties for center gauge symbol.\n */\nexport class CircularGauge extends Series {\n\tdeclare bevel: Format\n\tdeclare center: Format\n\tdeclare ticks: Format\n\tdeclare ticksBack: Format\n\tdeclare minor: Format\n\tdeclare minorBack: Format\n\tdeclare hand: Format\n\tdeclare back: Format\n\t/** The gauge pointer is a Format. Only CustomSeries have a point marker (`Pointer`). */\n\tdeclare pointer: Format\n\tdeclare units: Annotation\n\tdeclare dragging: boolean\n\tbounds: CircularGaugeBounds\n\tuseAxes = false\n\tmin = 0\n\tmax = 100\n\tstep = 0\n\tvalue = 0\n\tangle = 280\n\trotation = 0\n\trotateText = false\n\tshape = \"circle\"\n\tinverted = false\n\tdrag = { enabled: true }\n\tonchange: ((gauge: CircularGauge) => void) | undefined\n\tongetText: ((value: number) => string) | undefined\n\t/** Formats the value shown by the readout (`marks`); the tick labels use `ongetText`. */\n\tformatValue: ((value: number) => string) | undefined\n\tondrawHand: ((gauge: CircularGauge, hand: Format) => void) | undefined\n\thands: Format[] = []\n\tcx = 0\n\tcy = 0\n\tcex = 0\n\tcey = 0\n\ttick0 = 0\n\ttick1 = 0\n\ttickMin = 0\n\ttickText = 0\n\tinitRot = 0\n\tendRot = 0\n\t_oldValue = 0\n\t_newValue = 0\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tthis.bevel = new Format(this.chart)\n\t\tthis.bevel.gradient.visible = true\n\t\tthis.bevel.gradient.colors = [\"white\"]\n\t\tthis.bevel.shadow.visible = false\n\t\tthis.bevel.visible = false\n\t\tthis.bevel.stroke.fill = \"\"\n\n\t\tthis.center = new Format(this.chart)\n\t\tthis.center.stroke.fill = \"\"\n\t\tthis.center.gradient.visible = true\n\t\tthis.center.size = 10\n\t\tthis.center.visible = false\n\t\tthis.center.shadow.visible = true\n\t\tthis.center.gradient.offset = { x: 2, y: -2 }\n\t\tthis.center.location = { x: 0, y: 0 } // %\n\n\t\tthis.center.top = new Format(this.chart)\n\t\tthis.center.top.size = 40 // %\n\t\tthis.center.top.visible = true\n\t\tthis.center.top.stroke.fill = \"\"\n\t\tthis.center.top.gradient.colors = [\"silver\", \"white\"]\n\t\tthis.center.top.gradient.visible = true\n\t\tthis.center.top.gradient.direction = \"topbottom\"\n\n\t\tthis.ticks = new Format(this.chart)\n\t\tthis.ticks.length = 6 // %\n\t\tthis.ticks.stroke.fill = \"silver\"\n\t\tthis.ticks.visible = true\n\t\tthis.ticks.outside = true\n\t\tthis.ticks.triangle = false\n\t\tthis.ticks.fill = \"white\"\n\n\t\tthis.ticksBack = new Format(this.chart)\n\t\tthis.ticksBack.stroke.fill = \"\"\n\t\tthis.ticksBack.fill = \"black\"\n\t\tthis.ticksBack.gradient.visible = true\n\t\tthis.ticksBack.gradient.colors = [\"red\", \"yellow\", \"green\"]\n\t\tthis.ticksBack.gradient.direction = \"rightleft\"\n\t\tthis.ticksBack.visible = false\n\t\tthis.ticksBack.radius = 0\n\n\t\tthis.minor = new Format(this.chart)\n\t\tthis.minor.stroke.fill = \"silver\"\n\t\tthis.minor.visible = true\n\t\tthis.minor.count = 4\n\t\tthis.minor.shape = \"\" // ellipse\n\n\t\tthis.minorBack = new Format(this.chart)\n\t\tthis.minorBack.stroke.fill = \"\"\n\t\tthis.minorBack.visible = false\n\t\tthis.minorBack.fill = \"white\"\n\t\tthis.minorBack.gradient.visible = false\n\t\tthis.minorBack.gradient.direction = \"leftright\"\n\t\tthis.minorBack.gradient.colors = [\"green\", \"yellow\", \"red\"]\n\t\tthis.minorBack.radius = 0\n\n\t\tthis.hand = this.addHand()\n\n\t\tthis.back = new Format(this.chart)\n\t\tthis.back.fill = \"black\"\n\t\tthis.back.visible = true\n\t\tthis.back.gradient.visible = true\n\t\tthis.back.gradient.colors = [\"rgba(255,126,95,0.8)\", \"rgba(254,180,123,0.8)\"]\n\t\tthis.back.stroke.fill = \"\"\n\n\t\tthis.pointer = new Format(this.chart)\n\t\tthis.pointer.size = 3\n\t\tthis.pointer.fill = \"black\"\n\t\tthis.pointer.stroke.fill = \"\"\n\t\tthis.pointer.visible = false\n\n\t\tthis.marks.location = { x: 0, y: 10 } // %\n\t\tthis.marks.visible = true\n\t\tthis.marks.format.fill = \"black\"\n\t\tthis.marks.format.font.fill = \"black\"\n\t\tthis.marks.format.gradient.visible = true\n\t\tthis.marks.format.gradient.colors = [\"rgba(255,126,95,0.6)\", \"rgba(254,180,123,0.6)\"]\n\t\tthis.marks.format.shadow.visible = true\n\t\tthis.marks.format.shadow.blur = 8\n\t\tthis.marks.format.shadow.color = \"black\"\n\n\t\tthis.format.visible = true\n\t\tthis.format.gradient.visible = true\n\t\tthis.format.gradient.colors = [\"white\"]\n\t\tthis.format.shadow.visible = true\n\t\tthis.format.font.style = \"12px Verdana\"\n\t\tthis.format.font.fill = \"black\"\n\t\tthis.format.font.visible = true\n\t\tthis.format.size = 2 // %\n\t\tthis.format.round = { x: 6, y: 6 }\n\n\t\tthis.format.padding = 0.5 // %\n\n\t\tthis.units = new Annotation(this.chart)\n\t\tthis.units.transparent = true\n\t\tthis.units.format.font.fill = \"black\"\n\t\tthis.units.location = { x: 0, y: 24 } // %\n\n\t\tthis.bounds = this.getRect() as CircularGaugeBounds\n\n\t\tthis.hover.enabled = true\n\n\t\tthis.animate = new BaseAnimation(this.chart, f => {\n\t\t\tthis.value = this._oldValue + f * (this._newValue - this._oldValue)\n\t\t\tthis.chart.draw()\n\t\t})\n\n\t\tthis.animate.duration = 100\n\t\tthis.animate.onstop = () => {\n\t\t\tthis.value = this._newValue\n\n\t\t\tif (this.onchange) this.onchange(this)\n\t\t\tthis._emit(\"change\", this)\n\n\t\t\tthis.chart.draw()\n\t\t}\n\t}\n\n\taddHand(): Format {\n\t\tconst hand = new Format(this.chart)\n\t\thand.size = 6\n\t\thand.length = 60 // %\n\t\thand.back = 20 // %\n\t\thand.gradient.visible = true\n\t\thand.gradient.colors[0] = \"orange\"\n\t\thand.shadow.visible = true\n\t\thand.shadow.blur = 12\n\t\thand.shadow.color = \"black\"\n\t\thand.stroke.fill = \"\"\n\n\t\thand.pointer = true\n\t\thand.shape = \"needle\" // \"rectangle\"\n\n\t\thand.visible = true\n\n\t\tthis.hands.push(hand)\n\t\treturn hand\n\t}\n\n\tdestroy(): void {\n\t\tthis.units?.destroy?.()\n\t\tsuper.destroy()\n\t}\n\n\t/**\n\t * Paints colored bands behind the ticks. Each band ends at `to` and starts where the previous one ends, the\n\t * first one at `min`. An empty list removes the bands.\n\t */\n\tsetRanges(bands: readonly GaugeBand[]): this {\n\t\tthis.ticksBack.ranges = bands.map(band => ({ value: band.to, fill: band.color }))\n\t\tthis.ticksBack.visible = bands.length > 0\n\t\treturn this\n\t}\n\n\tcalcBounds(): Rectangle {\n\t\treturn this.bounds.custom ? this.bounds : this.cellRect(this.bounds, true)\n\t}\n\n\tdraw(): void {\n\t\tlet ta = this.angle * 0.01745,\n\t\t\tr = this.calcBounds(),\n\t\t\trax: number,\n\t\t\tray: number\n\t\tconst format = this.format\n\t\tconst back = this.back\n\t\tconst ticks = this.ticks\n\t\tconst ticksBack = this.ticksBack\n\t\tconst minor = this.minor as Format & { count: number; shape: string; size: number }\n\t\tconst minorBack = this.minorBack\n\t\tconst marks = this.marks\n\t\tconst hand = this.hand\n\t\tconst center = this.center\n\t\tconst pointer = this.pointer\n\n\t\tthis.cx = r.x + r.width * 0.5\n\t\tthis.cy = r.y + r.height * 0.5\n\n\t\tif (this.bounds.custom) {\n\t\t\trax = r.width\n\t\t\tray = r.height\n\t\t} else {\n\t\t\tray = rax = Math.min(r.width, r.height)\n\t\t}\n\n\t\tlet tar = this,\n\t\t\tctx = tar.chart.drawContext,\n\t\t\txx = 1.57,\n\t\t\tra = rax\n\n\t\tthis.initRot = tar.rotation * 0.01745 + (6.283 - ta) * 0.5\n\t\twhile (this.initRot >= 6.283) this.initRot -= 6.283\n\n\t\tthis.endRot = this.initRot + ta\n\t\twhile (this.endRot >= 6.283) this.endRot -= 6.283\n\n\t\tfunction drawRange(t: Format, p0: number, p1: number, start: number, end: number): void {\n\t\t\tconst radius = t.radius as number | undefined\n\t\t\tif (radius !== undefined && radius > 0) p1 = ra * radius * 0.01\n\n\t\t\tctx.beginPath()\n\t\t\tctx.arc(0, 0, p0, start, end, false)\n\t\t\tctx.arc(0, 0, p1, end, start, true)\n\n\t\t\tt.draw(ctx, null, -p1, -p1, 2 * p1, 2 * p1)\n\t\t}\n\n\t\tfunction tryBack(t: Format, p0: number, p1: number): void {\n\t\t\tif (t.visible && t.fill !== \"\") {\n\t\t\t\tconst ranges = t.ranges as GaugeRange[] | undefined\n\t\t\t\tif (ranges && ranges.length > 0) {\n\t\t\t\t\tlet sx = xx,\n\t\t\t\t\t\tendsx: number,\n\t\t\t\t\t\told = t.fill,\n\t\t\t\t\t\toldg = t.gradient.visible,\n\t\t\t\t\t\ttartot = tar.max - tar.min,\n\t\t\t\t\t\tdifRot = tar.endRot - tar.initRot\n\n\t\t\t\t\tt.gradient.visible = false\n\n\t\t\t\t\tif (tar.inverted) sx += difRot\n\n\t\t\t\t\tfor (let rangeIndex = 0; rangeIndex < ranges.length; rangeIndex++) {\n\t\t\t\t\t\tconst item = Math.min(tar.max, ranges[rangeIndex].value)\n\n\t\t\t\t\t\tconst rangeValue = rangeIndex === 0 ? item : item - ranges[rangeIndex - 1].value + tar.min\n\n\t\t\t\t\t\tif (tar.inverted) endsx = sx - (difRot * (rangeValue - tar.min)) / tartot\n\t\t\t\t\t\telse endsx = sx + (difRot * (rangeValue - tar.min)) / tartot\n\n\t\t\t\t\t\tt.fill = ranges[rangeIndex].fill\n\n\t\t\t\t\t\tif (t.fill !== \"\") {\n\t\t\t\t\t\t\tif (tar.inverted) drawRange(t, p0, p1, endsx, sx)\n\t\t\t\t\t\t\telse drawRange(t, p0, p1, sx, endsx)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsx = endsx\n\n\t\t\t\t\t\tif (item >= tar.max) break\n\t\t\t\t\t}\n\n\t\t\t\t\tt.fill = old\n\t\t\t\t\tt.gradient.visible = oldg\n\t\t\t\t} else drawRange(t, p0, p1, xx, xx + (tar.endRot - tar.initRot))\n\t\t\t}\n\t\t}\n\n\t\tfunction drawShape(fo: Format): boolean {\n\t\t\tif (fo.visible)\n\t\t\t\tif (tar.shape === \"circle\") fo.ellipse(tar.cx, tar.cy, rax, ray)\n\t\t\t\telse if (tar.shape === \"segment\") {\n\t\t\t\t\tctx.beginPath()\n\n\t\t\t\t\tconst minAngle = tar.units.visible ? 275 : 240,\n\t\t\t\t\t\trot0 = xx + tar.rotation * 0.01745 + (6.283 - Math.max(minAngle, tar.angle) * 0.01745) * 0.5\n\n\t\t\t\t\tconst halfx = 0.5 * rax,\n\t\t\t\t\t\thalfy = 0.5 * ray\n\n\t\t\t\t\tctx.arc(tar.cx, tar.cy, halfx, rot0, rot0 + Math.max(minAngle * 0.01745, ta), false)\n\t\t\t\t\tctx.closePath()\n\t\t\t\t\tfo.draw(ctx, null, tar.cx - halfx, tar.cy - halfy, rax, ray)\n\t\t\t\t} else fo.rectangle(tar.cx - rax * 0.5, tar.cy - ray * 0.5, rax, ray)\n\n\t\t\treturn !!fo.visible\n\t\t}\n\n\t\tif (drawShape(format)) {\n\t\t\trax *= 1 - format.size * 0.01\n\t\t\tray *= 1 - format.size * 0.01\n\t\t\tif (!this.bounds.custom) {\n\t\t\t\tra = ray = rax\n\t\t\t}\n\t\t}\n\n\t\tif (drawShape(this.bevel)) {\n\t\t\trax *= 1 - format.size * 0.002\n\t\t\tray *= 1 - format.size * 0.002\n\t\t\tif (!this.bounds.custom) {\n\t\t\t\tra = ray = rax\n\t\t\t}\n\t\t}\n\n\t\tdrawShape(back)\n\n\t\tvar o = ticks.outside,\n\t\t\t//a=this.mandatoryAxis,\n\t\t\tpos = this.min,\n\t\t\trange = this.max - this.min,\n\t\t\tstep = this.step\n\n\t\tif (step === 0) step = range / 20\n\n\t\t// A floor keeps the loop finite, without forbidding steps below 0.1 on narrow ranges.\n\t\tstep = Math.max(range / 1000, step) || 1\n\n\t\tthis.tick1 = o ? ra * 0.48 : ra * 0.41\n\t\tthis.tick0 = this.tick1 - ra * (Number(ticks.length) * 0.01)\n\t\tthis.tickText = o ? ra * 0.39 : this.rotateText ? ra * 0.46 : ra * 0.48\n\t\tthis.tickMin = o ? ra * 0.45 : ra * 0.38\n\n\t\tformat.font.prepare()\n\n\t\tvar fh = format.textHeight(\"Wj\"),\n\t\t\ttickCount = range / step,\n\t\t\ttextStep = Math.max(1, trunc(tickCount / ((ra * ta) / 6.283 / fh)))\n\n\t\tctx.fillStyle = format.font.fill\n\n\t\tctx.save()\n\n\t\tvar cex2 = this.cx,\n\t\t\tcey2 = this.cy\n\n\t\tif (tar.bounds.custom)\n\t\t\tif (rax > ray) cey2 += (0.75 * ray * ray) / rax\n\t\t\telse cex2 += (0.75 * rax * rax) / ray\n\n\t\tctx.translate(cex2, cey2)\n\n\t\tctx.rotate(this.initRot)\n\n\t\ttryBack(ticksBack, this.tick0, this.tick1)\n\t\ttryBack(minorBack, this.tickMin, this.tick1)\n\n\t\tfunction isHover(h: Format, p: number, dif: number): Format | null {\n\t\t\treturn h.enabled && h.valid ? (Math.abs(p - Number(h.value)) < dif ? h : null) : null\n\t\t}\n\n\t\tvar roStep = (step * ta) / range / minor.count,\n\t\t\ttotRot = this.initRot,\n\t\t\toffY = this.rotateText ? 0 : format.textHeight(\"Wj\") * 0.3,\n\t\t\ttickIndex = 0\n\n\t\tif (!ticks.visible && o) this.tickText = this.tickMin * 0.9\n\n\t\twhile (pos <= this.max) {\n\t\t\tif (ticks.visible) {\n\t\t\t\tconst fTick = isHover(this.hover, pos, 0.2 * step) || ticks\n\n\t\t\t\tctx.beginPath()\n\t\t\t\tctx.moveTo(0, this.tick0)\n\n\t\t\t\tif (ticks.triangle) {\n\t\t\t\t\tctx.lineTo(-3, this.tick1)\n\t\t\t\t\tctx.lineTo(3, this.tick1)\n\t\t\t\t\tctx.closePath()\n\t\t\t\t\tfTick.draw(ctx, null, -3, this.tick0, 3, this.tick1)\n\t\t\t\t} else {\n\t\t\t\t\tctx.lineTo(0, this.tick1)\n\n\t\t\t\t\tfTick.stroke.prepare()\n\t\t\t\t\tctx.stroke()\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (format.font.visible && tickIndex % textStep === 0) {\n\t\t\t\tif (this.angle !== 360 || pos + step <= this.max) {\n\t\t\t\t\tconst ts = this.tickText - format.textHeight() * format.padding\n\n\t\t\t\t\tctx.translate(0, ts)\n\n\t\t\t\t\tconst rr = this.rotateText ? Math.PI : totRot\n\n\t\t\t\t\tctx.rotate(-rr)\n\n\t\t\t\t\tformat.font.prepare()\n\n\t\t\t\t\tctx.fillStyle = format.font.fill\n\n\t\t\t\t\tlet ppos = tar.inverted ? this.max - pos + this.min : pos,\n\t\t\t\t\t\tst: string\n\n\t\t\t\t\tif (tar.ongetText) st = tar.ongetText(ppos)\n\t\t\t\t\telse if (trunc(ppos) === ppos) st = ppos.toFixed(0)\n\t\t\t\t\telse st = ppos.toFixed(this.decimals)\n\n\t\t\t\t\tctx.fillText(st, 0, offY)\n\n\t\t\t\t\tctx.rotate(rr)\n\t\t\t\t\tctx.translate(0, -ts)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (minor.visible) {\n\t\t\t\tif (pos < this.max)\n\t\t\t\t\tfor (let mit = 0; mit < minor.count; mit++) {\n\t\t\t\t\t\tctx.rotate(roStep)\n\n\t\t\t\t\t\tif (mit < minor.count - 1) {\n\t\t\t\t\t\t\tconst miStep = step / minor.count,\n\t\t\t\t\t\t\t\tnPos = pos + (mit + 1) * miStep,\n\t\t\t\t\t\t\t\tfminTick = isHover(this.hover, nPos, 0.2 * miStep) || minor\n\n\t\t\t\t\t\t\tif (nPos > this.max) break\n\n\t\t\t\t\t\t\tif (minor.shape === \"ellipse\") minor.ellipse(0, (this.tickMin + this.tick1) * 0.5, minor.size, minor.size)\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tctx.beginPath()\n\t\t\t\t\t\t\t\tctx.moveTo(0, this.tickMin)\n\t\t\t\t\t\t\t\tctx.lineTo(0, this.tick1)\n\n\t\t\t\t\t\t\t\tfminTick.stroke.prepare()\n\t\t\t\t\t\t\t\tctx.stroke()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t} else ctx.rotate(roStep * minor.count)\n\n\t\t\ttotRot += roStep * minor.count\n\n\t\t\tpos += step\n\t\t\ttickIndex++\n\t\t}\n\n\t\tctx.restore()\n\n\t\t// marker\n\t\t//var m=this.marks;\n\t\tif (marks.visible) {\n\t\t\tmarks.text = this.formatValue ? this.formatValue(this.value) : this.value.toFixed(this.decimals)\n\t\t\tmarks.resize()\n\t\t\tmarks.position.x = this.cx - marks.bounds.width * 0.5 + percentLocation(marks.location).x * rax * 0.01\n\t\t\tmarks.position.y = this.cy + percentLocation(marks.location).y * ray * 0.01\n\t\t\tmarks.draw()\n\t\t}\n\n\t\t// units;\n\t\tconst u = this.units\n\t\tif (u.visible) {\n\t\t\tu.resize()\n\t\t\tu.position.x = this.cx - u.bounds.width * 0.5 + percentLocation(u.location).x * rax * 0.01\n\t\t\tu.position.y = this.cy + percentLocation(u.location).y * ray * 0.01\n\t\t\tu.draw()\n\t\t}\n\n\t\tctx.save()\n\n\t\t// hands\n\t\thand.value = this.value\n\n\t\tfor (let h = 0; h < this.hands.length; h++)\n\t\t\tif (this.hands[h].visible) this.drawHand(this.hands[h], ta, range, rax, ray, ra, center, ctx, pointer)\n\n\t\tctx.restore()\n\n\t\t// Center:\n\t\tif (center.visible) {\n\t\t\tconst ces = ra * center.size * 0.01\n\n\t\t\tcenter.ellipse(this.cex, this.cey, ces, ces)\n\n\t\t\tconst top = center.top\n\t\t\tif (top?.visible) {\n\t\t\t\tconst cet = ces * top.size * 0.01\n\t\t\t\ttop.ellipse(this.cex, this.cey, cet, cet)\n\t\t\t}\n\t\t}\n\t}\n\n\tdrawHand(\n\t\than: Format,\n\t\tta: number,\n\t\trange: number,\n\t\trax: number,\n\t\tray: number,\n\t\tra: number,\n\t\tcenter: Format,\n\t\tctx: CanvasRenderingContext2D,\n\t\tpointer: Format\n\t): void {\n\t\than.value = this.limitValue(Number(han.value))\n\n\t\tvar ppos = this.inverted ? this.max - han.value + this.min : han.value,\n\t\t\thandRot = this.rotation * 0.01745 + (9.4248 - ta) * 0.5 + (ta * (ppos - this.min)) / range\n\n\t\tthis.cex = this.cx + rax * percentLocation(center.location).x * 0.005\n\t\tthis.cey = this.cy + ray * percentLocation(center.location).y * 0.005\n\n\t\tctx.save()\n\n\t\tctx.translate(this.cex, this.cey)\n\t\tctx.rotate(handRot)\n\n\t\tvar hs = han.size,\n\t\t\trah = ra * han.back * 0.5 * 0.01,\n\t\t\trad = Math.min(hs, 6),\n\t\t\traend = ra * Number(han.length) * 0.5 * 0.01\n\n\t\tctx.beginPath()\n\n\t\tif (hs > 1) {\n\t\t\tctx.moveTo(-rah + rad, -hs)\n\n\t\t\tif (han.shape === \"needle\") {\n\t\t\t\tctx.quadraticCurveTo(-rah, -hs, -rah, -hs + rad)\n\t\t\t\tctx.lineTo(-rah, hs - rad)\n\t\t\t\tctx.quadraticCurveTo(-rah, hs, -rah + rad, hs)\n\t\t\t\tctx.lineTo(raend, 0)\n\t\t\t} else {\n\t\t\t\tctx.lineTo(-rah + rad, hs)\n\t\t\t\tctx.lineTo(raend, hs)\n\t\t\t\tctx.lineTo(raend, -hs)\n\t\t\t}\n\n\t\t\tctx.closePath()\n\t\t} else {\n\t\t\tctx.moveTo(-rah, 0)\n\t\t\tctx.lineTo(raend, 0)\n\t\t}\n\n\t\tif (hs > 1) han.draw(ctx, null, -rah, -hs, rah + raend, 2 * hs)\n\t\telse {\n\t\t\than.stroke.prepare()\n\t\t\tctx.strokeStyle = han.fill\n\t\t\tctx.stroke()\n\t\t}\n\n\t\tif (this.ondrawHand) this.ondrawHand(this, han)\n\n\t\t// Pointer:\n\t\tif (han.pointer && pointer.visible)\n\t\t\tpointer.ellipse((this.tickMin + this.tick1) * 0.5, 0, pointer.size, pointer.size)\n\n\t\tctx.restore()\n\t}\n\n\tlimitValue(v: number): number {\n\t\treturn Math.min(this.max, Math.max(this.min, v))\n\t}\n\n\tsetValue(v: number): boolean {\n\t\tv = this.limitValue(v)\n\n\t\tconst res = this.value !== v\n\n\t\tif (res) {\n\t\t\tconst animate = this.animate\n\t\t\tif (animate?.active && animate.duration > 0) {\n\t\t\t\tthis._oldValue = this.value\n\t\t\t\tthis._newValue = v\n\t\t\t\tanimate.animate(this.chart)\n\t\t\t} else {\n\t\t\t\tthis.value = v\n\n\t\t\t\tif (this.onchange) this.onchange(this)\n\t\t\t\tthis._emit(\"change\", this)\n\t\t\t}\n\t\t}\n\n\t\treturn res\n\t}\n\n\tonclick(): void {}\n\n\tclicked(): number {\n\t\tthis.dragging = false\n\t\treturn -1\n\t}\n\n\tinValue(p: CircularGaugePoint, r: Rectangle): boolean {\n\t\tif (!r.contains(p)) return false\n\n\t\tvar dx = p.x - this.cex,\n\t\t\tdy = p.y - this.cey,\n\t\t\td = Math.sqrt(dx * dx + dy * dy)\n\n\t\tvar ang = Math.atan2(dy, dx) - Math.PI * 0.5\n\t\twhile (ang < 0) ang += 6.283\n\n\t\tvar rIni: number, rEnd: number, val: boolean\n\n\t\tif (this.initRot > this.endRot) {\n\t\t\trIni = this.endRot\n\t\t\trEnd = this.initRot\n\t\t\tval = ang >= rEnd || ang <= rIni\n\t\t} else {\n\t\t\trEnd = this.endRot\n\t\t\trIni = this.initRot\n\t\t\tval = ang >= rIni && ang <= rEnd\n\t\t}\n\n\t\tif (val) {\n\t\t\tlet res: number\n\n\t\t\tif (this.initRot > this.endRot)\n\t\t\t\tif (ang > rEnd) res = (ang - rEnd) / (6.283 - rEnd + rIni)\n\t\t\t\telse res = (6.283 - rEnd + ang) / (6.283 - rEnd + rIni)\n\t\t\telse res = (ang - rIni) / (rEnd - rIni)\n\n\t\t\tlet v = this.min + (this.max - this.min) * res\n\n\t\t\tif (this.inverted) v = this.min + (this.max - this.min) * (1 - res)\n\n\t\t\tp.value = v\n\n\t\t\tp.inTicks = d >= Math.min(this.tick0, this.tickText) && d <= this.tick1\n\n\t\t\treturn true\n\t\t} else {\n\t\t\tp.inTicks = false\n\t\t\treturn false\n\t\t}\n\t}\n\n\tmousemove(p: CircularGaugePoint): void {\n\t\tfunction changeHover(g: CircularGauge, v: number | null): void {\n\t\t\tif (g.hover.value !== v) {\n\t\t\t\tg.hover.value = v\n\t\t\t\tg.hover.valid = v !== null\n\t\t\t\tg.chart._scheduleDraw()\n\t\t\t}\n\t\t}\n\n\t\tconst r = this.calcBounds(),\n\t\t\tok = this.inValue(p, r)\n\t\tif (\n\t\t\tthis.dragging ||\n\t\t\t(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(getNavigator()?.userAgent || \"\") &&\n\t\t\t\tthis.drag.enabled)\n\t\t) {\n\t\t\tif (ok && this.setValue(p.value)) {\n\t\t\t\tthis.chart.draw()\n\t\t\t}\n\n\t\t\tthis.chart.newCursor = \"pointer\"\n\t\t} else if (p.inTicks && this.drag.enabled) {\n\t\t\tchangeHover(this, p.value)\n\t\t\tthis.chart.newCursor = \"pointer\"\n\t\t} else {\n\t\t\tchangeHover(this, null)\n\t\t}\n\t}\n\n\tmousedown(e: Event): boolean {\n\t\tconst p: CircularGaugePoint = { x: 0, y: 0, value: 0, inTicks: false }\n\n\t\tif (this.drag.enabled) {\n\t\t\tconst r = this.calcBounds()\n\t\t\tthis.chart.calcMouse(e, p)\n\n\t\t\tif (this.inValue(p, r)) {\n\t\t\t\tthis.dragging = true\n\n\t\t\t\tthis.hover.value = null\n\t\t\t\tthis.hover.valid = false\n\n\t\t\t\tif (this.setValue(p.value)) this.chart.draw()\n\t\t\t} else this.dragging = false\n\n\t\t\treturn this.dragging\n\t\t} else return false\n\t}\n\n\t/**\n\t */\n\tsetChart(series: Series, chart: Chart): void {\n\t\tsuper.setChart(series, chart)\n\t\tconst gauge = series as CircularGauge\n\t\tgauge.back.setChart(chart)\n\t\tgauge.center.setChart(chart)\n\t\tgauge.center.top?.setChart(chart)\n\t\tgauge.ticks.setChart(chart)\n\t\tgauge.ticksBack.setChart(chart)\n\t\tgauge.minor.setChart(chart)\n\t\tgauge.minorBack.setChart(chart)\n\t\tgauge.hand.setChart(chart)\n\t\tgauge.units.setChart(chart)\n\t\tgauge.pointer.setChart(chart)\n\t\tgauge.bevel.setChart(chart)\n\t}\n}\n","import type { Chart } from \"./chart.js\"\nimport { Format } from \"./core/elements/format.js\"\nimport { type PointLike, Rectangle } from \"./core/primitives.js\"\nimport { Tool } from \"./tools/tool.js\"\n\nfunction contains(r: Rectangle, p: PointLike): boolean {\n\treturn p.x >= r.x && p.x <= r.x + r.width && p.y >= r.y && p.y <= r.y + r.height\n}\n\nexport class Slider extends Tool {\n\tdeclare chart: Chart\n\tthumb: Format\n\tback: Format\n\tgrip: Format\n\tgripSize: number\n\tbounds: Rectangle\n\ttransparent: boolean\n\tmargin: number\n\tmin: number\n\tmax: number\n\tposition: number\n\tuseRange: boolean\n\tthumbSize: number\n\thorizontal: boolean\n\tcursor: string\n\tdelta: number\n\t_thumbRectTmp: Rectangle\n\t_mousePointTmp: PointLike\n\ttouchDragging: boolean\n\tresizeBegin = false\n\tresizeEnd = false\n\tdragging = false\n\tonDrawThumb: ((slider: Slider) => void) | undefined\n\tinvertThumb: boolean | undefined\n\tlock = false\n\tonChanging: ((slider: Slider, value: number, ...range: number[]) => number | undefined) | undefined\n\tprivate readonly touchTarget: HTMLCanvasElement\n\tprivate readonly cleanupChart: Chart\n\tprivate readonly chartCleanup = () => this.destroy()\n\tprivate readonly onTouchStart = (event: Event) => {\n\t\tthis.touchDragging = true\n\t\tevent.preventDefault()\n\t}\n\tprivate readonly onTouchEnd = (event: Event) => {\n\t\tthis.touchDragging = false\n\t\tevent.preventDefault()\n\t}\n\n\tconstructor(chart: Chart, position?: number) {\n\t\tsuper(chart)\n\n\t\tthis.touchDragging = false\n\n\t\tthis.thumb = new Format(chart)\n\t\tconst t = this.thumb\n\t\tt.round = { x: 4, y: 4 }\n\t\tt.stroke.size = 0.5\n\t\tt.gradient.visible = false\n\t\tt.gradient.direction = \"leftright\"\n\t\tt.shadow.visible = false\n\n\t\tthis.back = new Format(chart)\n\t\tconst f = this.back\n\t\tf.fill = \"white\"\n\t\tf.gradient.visible = false\n\t\tf.stroke.fill = \"darkgrey\"\n\t\tf.round = { x: 4, y: 4 }\n\n\t\tthis.grip = new Format(chart)\n\t\tconst g = this.grip\n\t\tg.round = { x: 4, y: 4 }\n\t\tg.stroke.fill = \"rgb(20,20,20,1.0)\"\n\n\t\tthis.gripSize = 3\n\t\tthis.bounds = new Rectangle(10, 10, 200, 20)\n\t\tthis.transparent = false\n\n\t\tthis.margin = 16 // %\n\t\tthis.min = 0\n\t\tthis.max = 100\n\n\t\tthis.position = typeof position === \"undefined\" ? 50 : position\n\n\t\tthis.useRange = false\n\t\tthis.thumbSize = 8\n\t\tthis.horizontal = true\n\t\tthis.cursor = \"pointer\"\n\t\tthis.delta = 0\n\n\t\tthis._thumbRectTmp = new Rectangle()\n\t\tthis._mousePointTmp = { x: 0, y: 0 }\n\n\t\tthis.cleanupChart = chart\n\t\tthis.touchTarget = chart.interactionCanvas || chart.canvas\n\t\tthis.touchTarget.addEventListener(\"touchstart\", this.onTouchStart)\n\t\tthis.touchTarget.addEventListener(\"touchend\", this.onTouchEnd)\n\t\tthis.touchTarget.addEventListener(\"touchcancel\", this.onTouchEnd)\n\t\tchart._eventCleanups.push(this.chartCleanup)\n\t}\n\n\tdestroy(): void {\n\t\tif (this.destroyed) return\n\t\tthis.touchTarget.removeEventListener(\"touchstart\", this.onTouchStart)\n\t\tthis.touchTarget.removeEventListener(\"touchend\", this.onTouchEnd)\n\t\tthis.touchTarget.removeEventListener(\"touchcancel\", this.onTouchEnd)\n\t\tthis.touchDragging = false\n\t\tconst index = this.cleanupChart._eventCleanups.indexOf(this.chartCleanup)\n\t\tif (index !== -1) this.cleanupChart._eventCleanups.splice(index, 1)\n\t\tsuper.destroy()\n\t}\n\n\tthumbRect(r: Rectangle): void {\n\t\tconst b = this.bounds\n\t\tconst range = this.max - this.min\n\t\tconst v = range > 0 ? (this.position - this.min) / range : 0\n\n\t\tif (this.horizontal) {\n\t\t\tr.width = this.thumbSize\n\t\t\tr.x = b.x + v * b.width - r.width * 0.5\n\t\t\tr.y = b.y\n\t\t\tr.height = b.height\n\t\t} else {\n\t\t\tr.height = this.thumbSize\n\t\t\tr.y = b.y + v * b.height - r.height * 0.5\n\t\t\tr.x = b.x\n\t\t\tr.width = b.width\n\t\t}\n\t}\n\n\tgripRect(r: Rectangle): Rectangle {\n\t\tif (this.horizontal) {\n\t\t\tconst h = r.height * 0.2\n\t\t\treturn new Rectangle(r.x - this.gripSize, r.y + r.height * 0.5 - h, 2 * this.gripSize, 2 * h)\n\t\t}\n\n\t\tconst w = r.width * 0.2\n\t\treturn new Rectangle(r.x + r.width * 0.5 - w, r.y - this.gripSize, 2 * w, 2 * this.gripSize)\n\t}\n\n\tdraw(): void {\n\t\tconst b = this.bounds\n\t\tconst r = this._thumbRectTmp\n\t\tconst d = this.horizontal ? b.height : b.width\n\t\tconst m = d * this.margin * 0.01\n\n\t\tif (!this.transparent) {\n\t\t\tif (this.horizontal) this.back.rectangle(b.x, b.y + m, b.width, d - 2 * m)\n\t\t\telse this.back.rectangle(b.x + m, b.y, d - 2 * m, b.height)\n\t\t}\n\n\t\tif (this.onDrawThumb) this.onDrawThumb(this)\n\n\t\tthis.thumbRect(r)\n\n\t\tif (this.invertThumb) {\n\t\t\tconst th = this.thumb\n\n\t\t\tif (this.horizontal) {\n\t\t\t\tth.rectangle(b.x, b.y + m, r.x, b.height - 2 * m)\n\t\t\t\tth.rectangle(b.x + r.x + r.width, b.y + m, b.width, b.height - 2 * m)\n\t\t\t} else {\n\t\t\t\tth.rectangle(b.x + m, b.y, b.width - 2 * m, r.y)\n\t\t\t\tth.rectangle(b.x + m, b.y + r.y + r.height, b.width - 2 * m, b.height)\n\t\t\t}\n\t\t} else this.thumb.rectangle(r)\n\n\t\tif (this.useRange) {\n\t\t\tif (this.horizontal) {\n\t\t\t\tconst r1 = this.gripRect(r)\n\t\t\t\tthis.grip.rectangle(r1)\n\t\t\t\tr1.x += r.width\n\t\t\t\tthis.grip.rectangle(r1)\n\t\t\t}\n\t\t}\n\t}\n\n\tclickAt(pos: number): void {\n\t\tconst b = this.bounds\n\t\tconst off = this.horizontal ? b.x : b.y\n\t\tconst s = this.horizontal ? b.width : b.height\n\t\tconst ra = this.max - this.min\n\t\tlet v = this.min + Math.max(0, ((pos + this.delta - off) * ra) / s)\n\n\t\tif (v > this.max) v = this.max\n\n\t\tif (this.onChanging) {\n\t\t\tconst v2 = this.onChanging(this, v)\n\t\t\tif (typeof v2 !== \"undefined\") v = v2\n\t\t}\n\n\t\tif (v < this.min) v = this.min\n\t\telse if (v > this.max) v = this.max\n\n\t\tthis.chart.newCursor = this.cursor\n\n\t\tif (this.position !== v) {\n\t\t\tthis.position = v\n\n\t\t\t//requestAnimationFrame(function() { this.chart.draw(); });\n\n\t\t\tthis.chart.draw()\n\t\t}\n\t}\n\n\tresized(): void {\n\t\tif (this.onChanging) this.onChanging(this, this.position)\n\t\tthis.chart.draw()\n\t\tthis.chart.newCursor = \"col-resize\"\n\t}\n\n\tmousemove(p: PointLike): void {\n\t\tconst b = this.bounds\n\t\tconst r = this._thumbRectTmp\n\t\tconst s = this.horizontal ? b.width : b.height\n\t\tconst pp = this.horizontal ? p.x : p.y\n\t\tconst ra = this.max - this.min\n\n\t\tthis.thumbRect(r)\n\n\t\tif (this.resizeBegin && pp < r.x + r.width) {\n\t\t\tconst old = this.thumbSize\n\t\t\tconst dif = r.x - pp\n\t\t\tconst v2 = 0.5 * ((dif * ra) / s)\n\t\t\tthis.thumbSize += dif\n\t\t\tthis.position -= v2\n\n\t\t\tif (this.position < this.min) {\n\t\t\t\tthis.position = this.min\n\t\t\t\tthis.thumbSize = old\n\t\t\t}\n\n\t\t\tthis.resized()\n\t\t} else if (this.resizeEnd && pp > r.x) {\n\t\t\tconst dif2 = r.x + r.width - pp\n\t\t\tconst v3 = 0.5 * ((dif2 * ra) / s)\n\t\t\tthis.thumbSize -= dif2\n\t\t\tthis.position -= v3\n\t\t\tthis.resized()\n\t\t} else if (this.dragging || this.touchDragging) {\n\t\t\tthis.clickAt(pp)\n\t\t} else {\n\t\t\tlet ingrip = false\n\n\t\t\tif (this.useRange) {\n\t\t\t\tconst r1 = this.gripRect(r)\n\t\t\t\tingrip = contains(r1, p)\n\t\t\t\tif (!ingrip) {\n\t\t\t\t\tr1.x += r.width\n\t\t\t\t\tingrip = contains(r1, p)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ingrip) this.chart.newCursor = \"col-resize\"\n\t\t\telse if (contains(r, p)) this.chart.newCursor = this.cursor\n\t\t}\n\t}\n\n\tmousedown(event: Event): boolean {\n\t\tconst b = this.bounds\n\t\tconst r = this._thumbRectTmp\n\t\tconst p = this._mousePointTmp\n\n\t\tthis.thumbRect(r)\n\t\tthis.chart.calcMouse(event, p)\n\n\t\tconst r1 = this.gripRect(r)\n\t\tthis.resizeBegin = this.useRange && contains(r1, p)\n\t\tr1.x += r.width\n\n\t\tthis.resizeEnd = this.useRange && !this.resizeBegin && contains(r1, p)\n\t\tthis.dragging = !this.resizeBegin && !this.resizeEnd && contains(r, p)\n\n\t\tif (!this.resizeBegin && !this.resizeEnd) {\n\t\t\tif (this.dragging) this.delta = this.horizontal ? r.x + r.width * 0.5 - p.x : r.y + r.height * 0.5 - p.y\n\t\t\telse if (contains(b, p)) {\n\t\t\t\tconst tmp = this.horizontal ? r.width * 0.5 : r.height * 0.5\n\t\t\t\tthis.delta = -tmp\n\t\t\t\tthis.clickAt(tmp + (this.horizontal ? p.x : p.y))\n\t\t\t}\n\t\t}\n\n\t\treturn this.dragging || this.resizeBegin || this.resizeEnd\n\t}\n\n\tclicked(): boolean {\n\t\tconst d = this.dragging || this.resizeBegin || this.resizeEnd\n\t\tthis.resizeBegin = this.resizeEnd = this.dragging = false\n\t\tthis.delta = 0\n\t\treturn d\n\t}\n\n\tmouseout() {\n\t\tthis.resizeBegin = this.resizeEnd = this.dragging = false\n\t}\n}\n","import { Chart } from \"../chart.js\"\nimport type { Stroke } from \"../core/elements/stroke.js\"\nimport type { Series, SeriesData } from \"../series.js\"\nimport { Bar } from \"../series/bar.js\"\nimport { CircularGauge } from \"../series/circular-gauge.js\"\nimport { Line } from \"../series/line.js\"\nimport { Slider } from \"../slider.js\"\nimport { BaseAnimation, FadeAnimation, SeriesAnimation, ToolTip } from \"../tools/index.js\"\nimport {\n\tgetActiveXObject,\n\tgetDOMParser,\n\tgetDocument,\n\tgetWindow,\n\tgetXMLHttpRequest,\n\ttype LegacyXmlDocument,\n\ttype LegacyXmlHttpRequest\n} from \"../platform.js\"\nimport { trunc } from \"../utils.js\"\n\n/** The field of a record that holds the value, or a function that computes it. */\nexport type MetricName = string | ((record: DataObject) => number)\n\n/** A field name, or several field names that are matched together. */\nexport type LinkField = string | string[] | null\n\nexport interface DataMetricShape {\n\tname: MetricName | undefined\n\ttitle: string\n\tmeasure: string\n\tdimension: DataDimension\n\tdataset: DataDimension | null\n\tinitDims(): void\n\tconsider(data: DataRuntime): boolean\n}\n\n/** The class of the series the engine creates for the results of a query. */\ntype SeriesStyle = new () => Series\n\ninterface DataSort {\n\tsortBy: string\n\torder: string\n\tseries: string\n}\n\n/** A chart with the methods that the data engine adds to it in `DataEngine.createChart`. */\nexport type DataChart = Chart & {\n\tengine: DataEngine\n\tdefaultStyle: SeriesStyle | null\n\tanimateChanges: boolean\n\tsort: DataSort\n\tonnewseries?: (chart: DataChart, series: Series) => void\n\tonclickseries?: (series: Series, index: number) => void\n\tguessStyle(total: QueryTotal[]): SeriesStyle\n\tnewSeries(metric: DataMetric, tot: QueryResult): Series\n\tsetSeriesStyle(style: SeriesStyle | string | null): void\n\tfill(dimension: DataDimension | DataDimension[], metric: DataMetric | DataMetric[], dontRedraw?: boolean): void\n\tfillQuery(\n\t\ttotals: QueryResult[],\n\t\tdimension: DataDimension | DataDimension[],\n\t\tmetric: DataMetric | DataMetric[],\n\t\tdontRedraw?: boolean\n\t): void\n\tsetSeriesPalette(series: Series, dimension: DataDimension): void\n\tsortData(sortBy: string, ascending: boolean): void\n\tsortSeries(ascending: boolean): void\n\tgroupOther(maxValues: number): void\n\ttotalPoints(): number\n\tsetPositionPercent(left: number, top: number, width: number, height: number): void\n\tanimateClick(): void\n\tanimation?: SeriesAnimation\n}\n\nexport interface DataDimensionShape {\n\ttitle: string\n\tfield?: string\n\tid?: string\n\tobject: unknown\n\tdataset: DataDimension | null\n\tparent: DataDimension | null\n\tsubDimensions: DataDimension[]\n\tmetrics: DataMetric[]\n\tselected: unknown\n\tselect: ((value: DataNode) => boolean) | null\n\tselectedInclude: boolean\n\tnulls: boolean\n\thasID: boolean\n\tdateKeys: Record<string, string>\n\tengine: DataEngine | null\n\tdimensions: DataDimension[]\n\tdata: DataRuntime\n\tlinks: DataLink[]\n\tcache: boolean\n\tindex: number\n\t_link?: DataLink[] | null\n\tdatetime?: { selected: string; yearField?: number; monthField?: number; dayField?: number }\n\taddDimension(title: string, field?: string, id?: string): DataDimension\n\taddSubDimension(parent: DataDimension, title: string, field?: string, id?: string): DataDimension\n\taddMetric(title: string, name?: MetricName, measure?: string): DataMetric\n\taddLink(field: LinkField, dimension: DataDimension, datasetField: LinkField): DataLink\n\thasParent(dimension: DataDimension): boolean\n\tget(id: DataNode): DataNode\n\ttoggleSelected(series: Series, index: number): void\n\tsearch(link: DataLink, data: DataRuntime, inverted?: boolean): DataNode\n\tgetIds(): unknown[]\n\tgetValues(): unknown[]\n\tgetLinksTo(dimension: DataDimension | null): DataLink[] | null\n\tsearchAcross(links: DataLink[], value: DataRuntime): DataNode\n\ttraverse(process: (value: unknown, index?: number | string) => boolean): void\n\tdatePart(value: unknown): unknown\n\tinSelected(value: unknown): boolean\n\tisSelected(value: unknown): boolean\n\tanySelected(): boolean\n}\n\nexport interface GroupableSeriesData {\n\tvalues: number[]\n\tlabels: string[]\n\tcode?: unknown[]\n}\n\nexport interface DataLink {\n\tfield: LinkField\n\tdimension: DataDimension | null\n\tdatasetField: LinkField\n\tparent: DataDimension\n\tsearch?: (value: DataRuntime, source: DataRuntime) => boolean\n\tsearchDimension?: DataDimension\n}\n\ninterface QueryTotal {\n\tid: unknown\n\tvalue: number\n\tcount: number\n}\n\ninterface QueryResult {\n\tmetric: DataMetric\n\tdimension: DataDimension\n\tvalues: QueryTotal[]\n\tmaster: unknown\n\tmasterdim?: DataDimension\n}\n\n/** A value of the data being queried. The engine reads it by field name and does not know its shape. */\nexport type DataNode = string | number | boolean | Date | null | undefined | DataNode[] | DataObject\n\n/** An object or row of the data being queried. */\nexport interface DataObject {\n\t[field: string]: DataNode\n}\n\ntype DataRuntime = DataObject\n\ninterface XmlNode extends Node {\n\tattributes?: NamedNodeMap\n}\n\n/**\n * @constructor\n * @class Main Tee.DataEngine class to perform multi-dimensional queries and charts.\n */\nexport class DataEngine {\n\tdatasets: DataDimension[]\n\tonclickseries: ((series: Series, index: number) => void) | null | undefined\n\tdeclare cache?: boolean\n\n\tconstructor() {\n\t\tthis.datasets = []\n\t}\n\n\t/**\n\t * @param {String} title The string identifier for this dataset.\n\t * @param {object} object The custom data for this dataset.\n\t * @param {String} [field=\"\"] The object data optional field that contains an array.\n\t * @param {String} [id=\"\"] The optional field in the array that uniquely identifies each array row.\n\t * @returns {DataDimension} Returns a top-level dimension.\n\t */\n\taddDataset(title: string, object: unknown, field?: string, id?: string): DataDimension {\n\t\tif (typeof object === \"object\" && object !== null && \"implementation\" in object)\n\t\t\tobject = this.xmlToJson(object as unknown as XmlNode)\n\n\t\t/** @type {any} */\n\t\tconst d = new DataDimension(title, field, id)\n\n\t\td.object = object\n\t\td.dataset = d\n\t\td.dimensions = []\n\t\td.engine = this\n\n\t\tthis.datasets.push(d)\n\t\treturn d\n\t}\n\n\t/**\n\t * Removes a dataset from this data engine.\n\t *\n\t * @param {DataDimension|Object} dataset Dataset dimension or source object.\n\t * @returns {Boolean} Whether a dataset was removed.\n\t */\n\tremoveDataset(dataset: DataDimension | unknown): boolean {\n\t\tconst index = this.datasets.findIndex(item => item === dataset || item.object === dataset)\n\t\tif (index === -1) return false\n\t\tthis.datasets.splice(index, 1)\n\t\treturn true\n\t}\n\n\t/**\n\t * Removes all datasets from this data engine.\n\t *\n\t * @returns {DataEngine} This data engine.\n\t */\n\tclear(): this {\n\t\tthis.datasets.length = 0\n\t\treturn this\n\t}\n\n\taddJson(title: string, json: string, field?: string, id?: string): DataDimension {\n\t\treturn this.addDataset(title, JSON.parse(json), field, id)\n\t}\n\n\tapplyStyle(chart: Chart, index: number): void {\n\t\tswitch (index) {\n\t\t\tcase 0: {\n\t\t\t\tchart.panel.transparent = false\n\t\t\t\tchart.panel.format.round.x = 0\n\t\t\t\tchart.panel.format.round.y = 0\n\t\t\t\tchart.panel.format.stroke.size = 2\n\t\t\t\tchart.panel.format.stroke.fill = \"darkgray\"\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Limits the data in place, reserving the last slot for the sum of the remaining values.\n\t * @param max Positive integer maximum number of items, including the remaining item.\n\t * @returns The number of removed items, or -1 if no grouping was needed.\n\t */\n\tgroupRemaining(data: GroupableSeriesData, max: number, label: string): number {\n\t\tlet t: number,\n\t\t\tl = data.values.length,\n\t\t\tl2: number,\n\t\t\tr: number\n\n\t\tif (l > max) {\n\t\t\tr = 0\n\t\t\tl2 = l - max\n\n\t\t\tfor (t = max - 1; t < l; t++) r += data.values[t]\n\n\t\t\tdata.values[max - 1] = r\n\t\t\tdata.labels[max - 1] = label\n\t\t\tif (data.code) data.code[max - 1] = null\n\n\t\t\tdata.values.splice(max, l2)\n\t\t\tdata.labels.splice(max, l2)\n\t\t\tdata.code?.splice(max, l2)\n\n\t\t\treturn l2\n\t\t}\n\n\t\treturn -1\n\t}\n\n\tcreateSlider(chart: Chart, items: unknown[], x: number, y: number, width: number, height: number): unknown {\n\t\tconst s = new Slider(chart)\n\t\ts.min = 0\n\t\ts.max = items.length - 1\n\t\t;(s as Slider & { step: number }).step = 1\n\t\ts.position = s.min\n\t\ts.useRange = false\n\t\ts.thumbSize = 12\n\t\ts.horizontal = true\n\n\t\ts.bounds.x = x\n\t\ts.bounds.y = y\n\t\ts.bounds.width = width\n\t\ts.bounds.height = height\n\n\t\tchart.tools.add(s)\n\n\t\treturn s\n\t}\n\n\txmlToJson(xml: XmlNode): DataNode {\n\t\t// `obj` becomes a string when the element only holds text, so it is not always an object.\n\t\tlet obj: DataNode = {},\n\t\t\ts = \"\"\n\n\t\tif (xml.nodeType === 1) {\n\t\t\tif (xml.attributes && xml.attributes.length > 0) {\n\t\t\t\tfor (let j = 0; j < xml.attributes.length; j++) {\n\t\t\t\t\tconst attribute = xml.attributes.item(j)\n\t\t\t\t\tif (attribute) (obj as DataObject)[attribute.nodeName] = attribute.value\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (xml.nodeType === 3) {\n\t\t\tobj = xml.nodeValue\n\t\t}\n\n\t\tif (xml.hasChildNodes()) {\n\t\t\tfor (let i = 0; i < xml.childNodes.length; i++) {\n\t\t\t\tconst item = xml.childNodes.item(i)\n\t\t\t\tconst nodeName = item.nodeName\n\t\t\t\tconst target = obj as DataObject\n\t\t\t\tif (typeof target[nodeName] === \"undefined\") {\n\t\t\t\t\tif (nodeName === \"#text\") {\n\t\t\t\t\t\tif (item.hasChildNodes()) target[nodeName] = this.xmlToJson(item as unknown as XmlNode)\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\ts = (item.nodeValue ?? \"\").trim()\n\t\t\t\t\t\t\tif (s !== \"\") obj = s\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (nodeName === \"xml\") obj = this.xmlToJson(item as unknown as XmlNode)\n\t\t\t\t\telse target[nodeName] = this.xmlToJson(item as unknown as XmlNode)\n\t\t\t\t} else {\n\t\t\t\t\tif (!Array.isArray(target[nodeName])) target[nodeName] = [target[nodeName]]\n\t\t\t\t\t;(target[nodeName] as DataNode[]).push(this.xmlToJson(item as unknown as XmlNode))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn obj\n\t}\n\n\tloadXmlDocument(url: string): XMLDocument {\n\t\tconst XMLHttpRequestConstructor = getXMLHttpRequest()\n\t\tconst ActiveXObjectConstructor = getActiveXObject<LegacyXmlHttpRequest>()\n\t\tconst xhttp = XMLHttpRequestConstructor\n\t\t\t? new XMLHttpRequestConstructor()\n\t\t\t: ActiveXObjectConstructor\n\t\t\t\t? new ActiveXObjectConstructor(\"Microsoft.XMLHTTP\")\n\t\t\t\t: null\n\t\tif (!xhttp) throw new Error(\"XMLHttpRequest is not supported by this browser.\")\n\t\txhttp.open(\"GET\", url, false)\n\t\txhttp.send()\n\t\treturn xhttp.responseXML as XMLDocument\n\t}\n\n\tloadXmlString(text: string): XMLDocument {\n\t\tconst DOMParserConstructor = getDOMParser()\n\t\tconst ActiveXObjectConstructor = getActiveXObject<LegacyXmlDocument>()\n\t\tif (DOMParserConstructor) return new DOMParserConstructor().parseFromString(text, \"text/xml\")\n\t\tif (!ActiveXObjectConstructor) throw new Error(\"XML parsing is not supported by this browser.\")\n\n\t\tconst xmlDoc = new ActiveXObjectConstructor(\"Microsoft.XMLDOM\")\n\t\txmlDoc.async = false\n\t\txmlDoc.loadXML(text)\n\n\t\treturn xmlDoc\n\t}\n\n\t_accumulate(measure: string, value: number, total: QueryTotal): void {\n\t\ttotal.count++\n\n\t\tswitch (measure) {\n\t\t\tcase \"sum\":\n\t\t\tcase \"average\":\n\t\t\t\ttotal.value += value\n\t\t\t\tbreak\n\t\t\tcase \"high\":\n\t\t\t\tif (total.count === 1 || value > total.value) total.value = value\n\t\t\t\tbreak\n\t\t\tcase \"low\":\n\t\t\t\tif (total.count === 1 || value < total.value) total.value = value\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\tqueryDim(\n\t\tm: DataMetric,\n\t\tdim: DataDimension | null,\n\t\ttotal: QueryTotal[],\n\t\t_child: DataDimension | null = null\n\t): boolean {\n\t\tlet lin = m.dimension.getLinksTo(dim),\n\t\t\tt: number,\n\t\t\ttot2: QueryTotal\n\n\t\tif (lin) {\n\t\t\tconst lin0 = lin[0]\n\t\t\tconst totalsById = new Map<unknown, QueryTotal>()\n\t\t\tfor (const item of total) if (!totalsById.has(item.id)) totalsById.set(item.id, item)\n\t\t\tm.initDims()\n\t\t\tconst mfunc = typeof m.name === \"function\" ? m.name : null\n\n\t\t\tm.dimension.traverse((o: unknown, index?: number | string) => {\n\t\t\t\tconst record = (o ?? {}) as DataRuntime\n\t\t\t\tlet f: DataNode = null\n\n\t\t\t\tif (!m.name || m.consider(record)) {\n\t\t\t\t\tif (dim) {\n\t\t\t\t\t\tif (lin0.field === null && dim === lin0.dimension) {\n\t\t\t\t\t\t\tif (dim.hasID) f = dim.parent ? dim.data[dim.id as string] : record[dim.id as string]\n\t\t\t\t\t\t\telse if (dim === m.dimension) f = index || total.length\n\t\t\t\t\t\t\telse f = dim.field ? record[dim.field] : index\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tf = dim.searchAcross(lin, record)\n\t\t\t\t\t\t\tif (f && dim.hasID) f = (f as DataObject)[dim.id as string]\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tf = m.dimension.title\n\t\t\t\t\t\tif (!f) {\n\t\t\t\t\t\t\tf = m.dimension.dataset?.object as DataNode\n\t\t\t\t\t\t\tif (m.dimension.field) f = (f as DataObject)[m.dimension.field]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (f !== null && (!dim || dim.nulls || (f !== undefined && f !== \"\"))) {\n\t\t\t\t\t\tlet valo: DataNode = mfunc ? mfunc(record) : m.name ? record[m.name as string] : record\n\n\t\t\t\t\t\tif (typeof valo === \"undefined\") valo = null\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (typeof valo !== \"number\") valo = parseFloat(valo as string)\n\t\t\t\t\t\t\t// biome-ignore lint/suspicious/noSelfCompare: NaN values are normalized to null.\n\t\t\t\t\t\t\tif (valo !== valo) valo = null\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (valo !== null) {\n\t\t\t\t\t\t\tif (dim?.datetime) f = dim.datePart(f)\n\n\t\t\t\t\t\t\t// Preserve strict-equality grouping: NaN ids never match one another.\n\t\t\t\t\t\t\tconst existing = Number.isNaN(f) ? undefined : totalsById.get(f)\n\t\t\t\t\t\t\tif (existing) {\n\t\t\t\t\t\t\t\tif (existing.count === 0) {\n\t\t\t\t\t\t\t\t\texisting.count = 1\n\t\t\t\t\t\t\t\t\texisting.value = valo as number\n\t\t\t\t\t\t\t\t} else this._accumulate(m.measure, valo as number, existing)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst item = { id: f, value: valo as number, count: 1 }\n\t\t\t\t\t\t\t\ttotal.push(item)\n\t\t\t\t\t\t\t\ttotalsById.set(f, item)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true\n\t\t\t})\n\n\t\t\tif (m.measure === \"count\")\n\t\t\t\tfor (t = 0; t < total.length; t++) {\n\t\t\t\t\ttot2 = total[t]\n\t\t\t\t\ttot2.value = tot2.count\n\t\t\t\t}\n\t\t\telse if (m.measure === \"average\")\n\t\t\t\tfor (t = 0; t < total.length; t++) {\n\t\t\t\t\ttot2 = total[t]\n\t\t\t\t\tif (tot2.count > 0) tot2.value = tot2.value / tot2.count\n\t\t\t\t}\n\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\t_sumOfCount(total: QueryTotal[]): number {\n\t\tlet res = 0,\n\t\t\tt: number\n\t\tfor (t = 0; t < total.length; t++) res += total[t].count\n\t\treturn res\n\t}\n\n\t_initTotal(total: QueryTotal[], ids: unknown[] | null): void {\n\t\tif (ids) {\n\t\t\tfor (let ttt = 0, l = ids.length; ttt < l; ttt++) total.push({ id: ids[ttt], value: 0, count: 0 })\n\t\t}\n\t}\n\n\tquery(dimension: DataDimension | DataDimension[], metric: DataMetric | DataMetric[]): QueryResult[] {\n\t\tlet m: DataMetric,\n\t\t\tmetrics: DataMetric[],\n\t\t\tdim: DataDimension,\n\t\t\tdimensions: DataDimension[],\n\t\t\ttotal: QueryTotal[] = [],\n\t\t\ttotals: QueryResult[] = [],\n\t\t\tmt: number,\n\t\t\tdimt: number,\n\t\t\toldIds: DataNode[] = [],\n\t\t\tdl = 0,\n\t\t\tdim0: DataDimension | null = null\n\n\t\tmetrics = Array.isArray(metric) ? metric : [metric]\n\t\tdimensions = Array.isArray(dimension) ? dimension : [dimension]\n\t\tdl = dimensions.length\n\n\t\tif (dl > 0) {\n\t\t\tdim0 = dimensions[0]\n\t\t\tconst dim0sel = dim0 ? dim0.selected : null\n\t\t\toldIds = []\n\n\t\t\tif (dim0?.anySelected() && dim0sel !== null && dim0sel !== undefined)\n\t\t\t\toldIds = dim0.selectedInclude\n\t\t\t\t\t? Array.isArray(dim0sel)\n\t\t\t\t\t\t? dim0sel\n\t\t\t\t\t\t: [dim0sel]\n\t\t\t\t\t: dim0.getIds().filter(id => dim0?.inSelected(id))\n\t\t\telse if (dim0 && (dim0.id || dim0.field)) oldIds = dim0.getIds()\n\t\t}\n\n\t\tfor (mt = 0; mt < metrics.length; mt++) {\n\t\t\tm = metrics[mt]\n\t\t\tif (!m) continue\n\n\t\t\tfor (dimt = dl - 1; dimt >= 0; dimt--) {\n\t\t\t\tdim = dimensions[dimt]\n\n\t\t\t\tif (dimt > 0) {\n\t\t\t\t\tif (!dim) continue\n\n\t\t\t\t\tconst old = dim.selected,\n\t\t\t\t\t\toldInclude = dim.selectedInclude,\n\t\t\t\t\t\toldSelect = dim.select\n\t\t\t\t\tlet dimValues: DataNode[]\n\n\t\t\t\t\tif (oldSelect) dimValues = dim.getIds().filter(id => dim.isSelected(id))\n\t\t\t\t\telse if (dim.anySelected()) {\n\t\t\t\t\t\tconst selectedValues = Array.isArray(old) ? old : [old]\n\n\t\t\t\t\t\tif (dim.selectedInclude) dimValues = selectedValues\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tdimValues = dim.getIds()\n\t\t\t\t\t\t\tfor (const selected of selectedValues) {\n\t\t\t\t\t\t\t\tconst index = dimValues.indexOf(selected)\n\t\t\t\t\t\t\t\tif (index !== -1) dimValues.splice(index, 1)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else dimValues = dim.getIds()\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Each result contains one included group, regardless of the original filter mode.\n\t\t\t\t\t\tdim.selectedInclude = true\n\t\t\t\t\t\tdim.select = null\n\t\t\t\t\t\tfor (let valt = 0; valt < dimValues.length; valt++) {\n\t\t\t\t\t\t\tdim.selected = dimValues[valt]\n\t\t\t\t\t\t\tif (!dim.nulls && dim.selected === \"\") continue\n\n\t\t\t\t\t\t\ttotal = [] as QueryTotal[]\n\t\t\t\t\t\t\tthis._initTotal(total, oldIds)\n\n\t\t\t\t\t\t\tif (this.queryDim(m, dimensions[dimt - 1], total, dim)) {\n\t\t\t\t\t\t\t\tif (dim.nulls || this._sumOfCount(total) > 0)\n\t\t\t\t\t\t\t\t\ttotals.push({\n\t\t\t\t\t\t\t\t\t\tmetric: m,\n\t\t\t\t\t\t\t\t\t\tdimension: dim,\n\t\t\t\t\t\t\t\t\t\tvalues: total,\n\t\t\t\t\t\t\t\t\t\tmaster: dim.selected,\n\t\t\t\t\t\t\t\t\t\tmasterdim: dimensions[dimt - 1]\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tdim.selected = old\n\t\t\t\t\t\tdim.selectedInclude = oldInclude\n\t\t\t\t\t\tdim.select = oldSelect\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\ttotal = [] as QueryTotal[]\n\t\t\t\t\tthis._initTotal(total, oldIds)\n\n\t\t\t\t\tif (this.queryDim(m, dim, total)) totals.push({ metric: m, dimension: dim, values: total, master: null })\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (dim0 && !dim0.nulls) {\n\t\t\tconst populatedIds = new Set<unknown>()\n\t\t\tfor (const result of totals) {\n\t\t\t\tfor (const value of result.values) {\n\t\t\t\t\tif (value.count > 0) populatedIds.add(value.id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const result of totals)\n\t\t\t\tresult.values = result.values.filter(\n\t\t\t\t\tvalue => value.count > 0 || (!Number.isNaN(value.id) && populatedIds.has(value.id))\n\t\t\t\t)\n\t\t}\n\n\t\treturn totals\n\t}\n\n\tcreateChart(canvas: unknown, title?: string): DataChart {\n\t\tconst chart = new Chart(canvas as string | HTMLCanvasElement) as DataChart\n\t\tconst engine = this\n\t\tchart.engine = this\n\t\tchart.panel.margins.left = 0\n\n\t\tconst tip = new ToolTip(chart)\n\t\ttip.render = \"dom\"\n\t\tchart.tools.add(tip)\n\n\t\ttip.ongettext = (_tip: ToolTip, text: string, series: Series, index: number): string => {\n\t\t\tlet s = \"\",\n\t\t\t\tla = series.data.labels\n\n\t\t\tif (series.chart.series.count() > 1) s = `<br/>${series.title}`\n\n\t\t\tif (series.data.x) {\n\t\t\t\ts += `<br/>${series.data.x[index]}`\n\t\t\t}\n\n\t\t\treturn `${text} ${la.length > 0 ? la[index] : \"\"}${s}`\n\t\t}\n\n\t\t//chart.axes.each(function() { this.labels.valueFormat=\"0\"; });\n\n\t\tconst clickAnimation = new BaseAnimation() as BaseAnimation & {\n\t\t\ts: Stroke\n\t\t\told: string\n\t\t\tanimateHover(chart: Chart): void\n\t\t}\n\n\t\tclickAnimation.onstart = function () {\n\t\t\tthis.s.fill = \"yellow\"\n\t\t}\n\t\tclickAnimation.onstop = function () {\n\t\t\tthis.s.fill = this.old\n\t\t}\n\t\tclickAnimation.duration = 100\n\t\tclickAnimation.animateHover = function (chart: Chart): void {\n\t\t\tthis.s = chart.series.items[0].hover.stroke\n\t\t\tthis.old = this.s.fill\n\t\t\tthis.animate(chart)\n\t\t}\n\n\t\tchart.title.text = title ?? \"\"\n\n\t\tchart.guessStyle = function (total: QueryTotal[]): SeriesStyle {\n\t\t\tif (this.defaultStyle) return this.defaultStyle\n\t\t\telse {\n\t\t\t\treturn total.length > 30 ? Line : Bar\n\t\t\t}\n\t\t}\n\n\t\tchart.newSeries = function (_metric: DataMetric, tot: QueryResult): Series {\n\t\t\tlet total = tot.values,\n\t\t\t\tdimension = tot.dimension,\n\t\t\t\tmasterTitle = tot.master as DataNode\n\n\t\t\tif (!tot.masterdim) {\n\t\t\t\tif (masterTitle && dimension?.id) masterTitle = (masterTitle as DataObject)[dimension.id]\n\t\t\t\telse masterTitle = (tot.master as DataNode) || tot.metric.title\n\t\t\t}\n\n\t\t\t// Add to series\n\n\t\t\tconst SeriesStyle = chart.guessStyle(total),\n\t\t\t\tb = chart.addSeries(new SeriesStyle()),\n\t\t\t\tdata = b.data\n\n\t\t\tb.title = masterTitle === \"\" ? \"(none)\" : `${masterTitle ?? \"(none)\"}`\n\t\t\tb.marks.style = \"value\"\n\t\t\tb.cursor = \"pointer\"\n\n\t\t\t//b.valueFormat=\"0\";\n\n\t\t\tdata.values = []\n\t\t\tdata.labels = []\n\t\t\tdata.code = []\n\n\t\t\tlet tot2: QueryTotal,\n\t\t\t\tlc = chart.series.items.length,\n\t\t\t\tres: DataLink[] = [],\n\t\t\t\tf: DataNode,\n\t\t\t\tlabel: string,\n\t\t\t\tt: number\n\n\t\t\tif (dimension?.titles) {\n\t\t\t\tfindLinkInDimension(dimension.titles, dimension, res)\n\t\t\t}\n\n\t\t\tif (lc > 1) {\n\t\t\t\tlet bprev = chart.series.items[lc - 2],\n\t\t\t\t\ti: number,\n\t\t\t\t\tbdata = bprev.data\n\n\t\t\t\tfor (t = 0; t < bdata.values.length; t++) {\n\t\t\t\t\tdata.values.push(0)\n\t\t\t\t\tdata.labels.push(bdata.labels[t])\n\t\t\t\t\tdata.code.push(bdata.code?.[t])\n\t\t\t\t}\n\n\t\t\t\tfor (t = 0; t < total.length; t++) {\n\t\t\t\t\ttot2 = total[t]\n\t\t\t\t\ti = bdata.code?.indexOf(tot2.id) ?? -1\n\n\t\t\t\t\tif (i === -1) {\n\t\t\t\t\t\tdata.values.push(tot2.value)\n\n\t\t\t\t\t\tif (dimension?.titles) {\n\t\t\t\t\t\t\tf = dimension.searchAcross(res, tot2.id as DataObject)\n\t\t\t\t\t\t\tif (f) label = (f as DataObject)[dimension.titles.id as string] as string\n\t\t\t\t\t\t\telse label = \"\"\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tlabel =\n\t\t\t\t\t\t\t\ttot2.id !== null && typeof tot2.id === \"object\"\n\t\t\t\t\t\t\t\t\t? ((tot2.id as DataObject)[dimension.id as string] as string)\n\t\t\t\t\t\t\t\t\t: `${tot2.id}`\n\n\t\t\t\t\t\tdata.labels.push(label)\n\t\t\t\t\t\tdata.code.push(tot2.id)\n\t\t\t\t\t} else data.values[i] = tot2.value\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t//let labeldim=dimension;\n\t\t\t\t//hasDim=(!tot.masterdim) && labeldim && labeldim.hasID;\n\n\t\t\t\tfor (t = 0; t < total.length; t++) {\n\t\t\t\t\ttot2 = total[t]\n\t\t\t\t\tdata.values.push(tot2.value)\n\n\t\t\t\t\tif (dimension?.titles) {\n\t\t\t\t\t\tf = dimension.searchAcross(res, tot2.id as DataObject)\n\t\t\t\t\t\tif (f) label = (f as DataObject)[dimension.titles.id as string] as string\n\t\t\t\t\t\telse label = \"\"\n\t\t\t\t\t} else label = `${tot2.id}` // (hasDim ? tot2.id[labeldim.id] : tot2.id);\n\n\t\t\t\t\tdata.labels.push(label)\n\t\t\t\t\tdata.code.push(tot2.id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (SeriesStyle === CircularGauge) (b as CircularGauge).setValue(b.data.values[0])\n\n\t\t\tif (this.onnewseries) this.onnewseries(this, b)\n\n\t\t\treturn b\n\t\t}\n\n\t\tchart.defaultStyle = null\n\t\tchart.animateChanges = false\n\n\t\t// Changes all series to style.\n\t\t// style can be a string of function from: Tee.Bar, Tee.Line, Tee.Pie, etc.\n\n\t\t/** @this {Tee.Chart} */\n\t\tchart.setSeriesStyle = function (style: SeriesStyle | string | null): void {\n\t\t\tif (!style || style === \"\" || style === \"auto\") {\n\t\t\t\tthis.defaultStyle = null\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlet s = this.series,\n\t\t\t\tnewS: Series,\n\t\t\t\tdata: SeriesData,\n\t\t\t\tSt: SeriesStyle\n\n\t\t\tfunction resolvePath(path: string, root: unknown = globalThis): unknown {\n\t\t\t\treturn path.split(\".\").reduce((obj, key) => {\n\t\t\t\t\treturn (obj as Record<string, unknown> | undefined)?.[key]\n\t\t\t\t}, root)\n\t\t\t}\n\n\t\t\tif (typeof style === \"string\") {\n\t\t\t\tconst resolvedStyle = resolvePath(style)\n\n\t\t\t\tif (!resolvedStyle) {\n\t\t\t\t\tthrow new Error(`Unknown style: ${style}`)\n\t\t\t\t}\n\n\t\t\t\tSt = resolvedStyle as SeriesStyle\n\t\t\t} else {\n\t\t\t\tSt = style\n\t\t\t}\n\t\t\tthis.defaultStyle = St\n\n\t\t\tfor (let t = 0; t < s.items.length; t++) {\n\t\t\t\tdata = s.items[t].data\n\t\t\t\tnewS = new St()\n\n\t\t\t\tnewS.setChart(newS, this) // addSeries ?\n\t\t\t\tnewS.format.fill = s.items[t].format.fill\n\n\t\t\t\tnewS.data = data\n\t\t\t\ts.items[t] = newS\n\t\t\t}\n\n\t\t\tthis.draw()\n\t\t}\n\n\t\t// Creates a query based on dimension and metric, and adds the resulting\n\t\t// data to chart.\n\t\t// When dontRedraw = true, the chart will not be repainted.\n\n\t\tchart.fill = function (\n\t\t\tdimension: DataDimension | DataDimension[],\n\t\t\tmetric: DataMetric | DataMetric[],\n\t\t\tdontRedraw = false\n\t\t): void {\n\t\t\tthis.fillQuery(this.engine.query(dimension, metric), dimension, metric, dontRedraw)\n\t\t}\n\n\t\tchart.fillQuery = function (\n\t\t\ttotals: QueryResult[],\n\t\t\tdimension: DataDimension | DataDimension[],\n\t\t\tmetric: DataMetric | DataMetric[],\n\t\t\tdontRedraw = false\n\t\t): void {\n\t\t\tlet t: number,\n\t\t\t\ttot: QueryResult,\n\t\t\t\tm: DataMetric,\n\t\t\t\told = chart.series.items\n\n\t\t\tchart.series.items = []\n\n\t\t\tif (totals) {\n\t\t\t\tfor (t = 0; t < totals.length; t++) {\n\t\t\t\t\ttot = totals[t]\n\t\t\t\t\tm = tot.metric\n\n\t\t\t\t\tconst created: Series & { onclick?: (series: Series, index: number) => boolean } = this.newSeries(m, tot)\n\t\t\t\t\tcreated.onclick = chart.engine._onclickseries\n\n\t\t\t\t\tif (chart.title.text === \"\" || typeof chart.title.text === \"undefined\") chart.title.text = m.dimension.title\n\n\t\t\t\t\tif (!Array.isArray(metric)) {\n\t\t\t\t\t\tchart.legend.title.text = `${m.title}\\n${m.measure}`\n\t\t\t\t\t\tchart.legend.title.format.font.textAlign = \"right\"\n\t\t\t\t\t}\n\n\t\t\t\t\tconst dim2 = Array.isArray(dimension) ? dimension[0] : dimension\n\n\t\t\t\t\tif (dim2 && dim2 !== m.dataset) {\n\t\t\t\t\t\tchart.axes.bottom.title.text = dim2.datetime\n\t\t\t\t\t\t\t? `${dim2.title} ${dim2.dateKeys[dim2.datetime.selected]}`\n\t\t\t\t\t\t\t: dim2.title\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totals.length > 0) chart.axes.left.title.text = totals[0].metric.title\n\t\t\t}\n\n\t\t\t//chart.axes.bottom.title.text=dimension.title;\n\n\t\t\tconst sort = this.sort\n\n\t\t\tif (sort.sortBy !== \"\") this.sortData(sort.sortBy, sort.order === \"ascending\")\n\n\t\t\tif (sort.series !== \"\") this.sortSeries(sort.series === \"ascending\")\n\n\t\t\tif (chart.animateChanges)\n\t\t\t\tif (old.length === chart.series.items.length) {\n\t\t\t\t\tconst ss = chart.series.items[0],\n\t\t\t\t\t\tssvalues = ss.data.values\n\n\t\t\t\t\t// Only animate between two series of the same type.\n\t\t\t\t\tif (old[0].constructor === ss.constructor) {\n\t\t\t\t\t\tif (old[0].data.values.length === ssvalues.length) {\n\t\t\t\t\t\t\tlet newValues = ssvalues.slice(0),\n\t\t\t\t\t\t\t\tval: number\n\n\t\t\t\t\t\t\tconst a = new BaseAnimation(chart, (step: number) => {\n\t\t\t\t\t\t\t\tfor (let t = 0; t < ssvalues.length; t++) {\n\t\t\t\t\t\t\t\t\tval = old[0].data.values[t]\n\t\t\t\t\t\t\t\t\tssvalues[t] = val + (newValues[t] - val) * step\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\tconst oldauto = chart.axes.left.automatic\n\t\t\t\t\t\t\tchart.axes.left.automatic = false\n\n\t\t\t\t\t\t\ta.duration = 150\n\t\t\t\t\t\t\ta.animate()\n\n\t\t\t\t\t\t\tchart.axes.left.automatic = oldauto\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tif (!dontRedraw) chart.draw()\n\t\t}\n\n\t\tthis.applyStyle(chart, 0)\n\n\t\tchart.animateClick = () => {\n\t\t\tclickAnimation.animateHover(chart)\n\t\t}\n\n\t\tthis.onclickseries = null\n\n\t\t// Changes series items colors, setting \"silver\" to disabled ones.\n\n\t\tchart.setSeriesPalette = (series: Series, dimension: DataDimension): void => {\n\t\t\tlet p = series.palette,\n\t\t\t\tl = series.count(),\n\t\t\t\tc = series.data.code,\n\t\t\t\to: DataNode\n\t\t\tp.colors = new Array(l)\n\n\t\t\tfor (let t = 0; t < l; t++) {\n\t\t\t\to = c?.[t] as DataNode\n\n\t\t\t\tif (!dimension.isSelected(o)) p.colors[t] = \"silver\"\n\t\t\t}\n\t\t}\n\n\t\tfunction totalOf(items: Series[], index: number): number {\n\t\t\tlet res = 0,\n\t\t\t\ttt: number\n\t\t\tfor (tt = 0; tt < items.length; tt++) res += items[tt].data.values[index]\n\t\t\treturn res\n\t\t}\n\n\t\t// Reorders all series points, using output order from the first series.\n\t\t// sortBy can be \"values\" or \"labels\"\n\n\t\tchart.sortData = function (sortBy: string, ascending: boolean): void {\n\t\t\tlet sorted: number[],\n\t\t\t\tl = this.series.count(),\n\t\t\t\ts0 = this.series.items[0]\n\n\t\t\tif (l > 0) {\n\t\t\t\tif (l > 1 && sortBy === \"values\") {\n\t\t\t\t\tlet d = s0.data.values,\n\t\t\t\t\t\tlen = d.length,\n\t\t\t\t\t\tt: number,\n\t\t\t\t\t\titems = this.series.items\n\n\t\t\t\t\tsorted = new Array(len)\n\n\t\t\t\t\tfor (t = 0; t < len; t++) sorted[t] = t\n\n\t\t\t\t\tsorted.sort((a, b) => {\n\t\t\t\t\t\tconst ta = totalOf(items, a),\n\t\t\t\t\t\t\ttb = totalOf(items, b)\n\t\t\t\t\t\treturn ascending ? ta - tb : tb - ta\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tconst order = this.series.items[0].doSort(sortBy, ascending)\n\t\t\t\t\tif (!order) return\n\t\t\t\t\tsorted = order\n\t\t\t\t}\n\n\t\t\t\tthis.series.each((s: Series) => {\n\t\t\t\t\tlet data2: GroupableSeriesData = { values: [], labels: [], code: [] },\n\t\t\t\t\t\tdata = s.data,\n\t\t\t\t\t\ttt: number\n\n\t\t\t\t\tfor (let t = 0; t < data.values.length; t++) {\n\t\t\t\t\t\ttt = sorted[t]\n\t\t\t\t\t\tdata2.values.push(data.values[tt])\n\t\t\t\t\t\tdata2.labels.push(data.labels[tt])\n\t\t\t\t\t\tdata2.code?.push(data.code?.[tt])\n\t\t\t\t\t}\n\n\t\t\t\t\t// The new data has no source or x values, as before.\n\t\t\t\t\ts.data = { ...data2, source: undefined }\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// Re-orders all series in chart, based on series \"title\" text:\n\n\t\tchart.sortSeries = function (ascending: boolean): void {\n\t\t\tconst i = this.series.items,\n\t\t\t\tlen = i.length\n\n\t\t\tif (len < 2) return\n\n\t\t\tlet sorted: number[] = new Array(len),\n\t\t\t\tA: string,\n\t\t\t\tB: string,\n\t\t\t\tbefore = ascending ? -1 : 1,\n\t\t\t\tafter = ascending ? 1 : -1,\n\t\t\t\tt: number\n\n\t\t\tfor (t = 0; t < len; t++) sorted[t] = t\n\n\t\t\tsorted.sort((a, b) => {\n\t\t\t\tA = i[a].title.toLowerCase()\n\t\t\t\tB = i[b].title.toLowerCase()\n\t\t\t\treturn A < B ? before : A === B ? 0 : after\n\t\t\t})\n\n\t\t\tconst newList = new Array(len)\n\t\t\tfor (t = 0; t < len; t++) newList[t] = i[sorted[t]]\n\n\t\t\tthis.series.items = newList\n\t\t}\n\n\t\t// For all series in chart, groups trailing values into an \"Other\" item, keeping at most maxValues items.\n\n\t\tchart.groupOther = function (maxValues: number): void {\n\t\t\tthis.series.each((series: Series) => {\n\t\t\t\tengine.groupRemaining(series.data, maxValues, \"Other\")\n\t\t\t})\n\t\t}\n\n\t\tchart.totalPoints = function () {\n\t\t\tlet res = 0\n\t\t\tthis.series.each((s: Series) => {\n\t\t\t\tres += s.data.values.length\n\t\t\t})\n\t\t\treturn res\n\t\t}\n\n\t\t// \"sortBy\" can be: 'values' or 'labels' or '' (empty)\n\n\t\tchart.sort = { sortBy: \"\", order: \"descending\", series: \"ascending\" }\n\n\t\tchart.setPositionPercent = function (left: number, top: number, width: number, height: number): void {\n\t\t\tconst runtimeWindow = getWindow()\n\t\t\tconst runtimeDocument = getDocument()\n\n\t\t\tfunction getParentWidth() {\n\t\t\t\tif (runtimeWindow?.innerHeight) return runtimeWindow.innerWidth\n\t\t\t\telse if (runtimeDocument?.documentElement?.clientHeight) return runtimeDocument.documentElement.clientWidth\n\t\t\t\telse if (runtimeDocument?.body) return runtimeDocument.body.clientWidth\n\t\t\t\telse return 0\n\t\t\t}\n\n\t\t\tfunction getParentHeight() {\n\t\t\t\tif (runtimeWindow?.innerHeight) return runtimeWindow.innerHeight\n\t\t\t\telse if (runtimeDocument?.documentElement?.clientHeight) return runtimeDocument.documentElement.clientHeight\n\t\t\t\telse if (runtimeDocument?.body) return runtimeDocument.body.clientHeight\n\t\t\t\telse return 0\n\t\t\t}\n\n\t\t\tconst h = getParentHeight(),\n\t\t\t\tw = getParentWidth(),\n\t\t\t\tc = this.canvas,\n\t\t\t\tx = left * w * 0.01,\n\t\t\t\ty = top * h * 0.01\n\n\t\t\twidth *= w * 0.01\n\t\t\theight *= h * 0.01\n\n\t\t\twidth = width | 0\n\t\t\theight = height | 0\n\n\t\t\tc.style.position = \"absolute\"\n\t\t\tc.style.left = `${x}px`\n\t\t\tc.style.top = `${y}px`\n\t\t\tc.style.width = `${width}px`\n\t\t\tc.style.height = `${height}px`\n\n\t\t\tc.setAttribute(\"width\", String(width))\n\t\t\tc.setAttribute(\"height\", String(height))\n\n\t\t\tthis.bounds.width = width\n\t\t\tthis.bounds.height = height\n\t\t\tthis.draw()\n\t\t}\n\n\t\tif (SeriesAnimation) {\n\t\t\tconst anim = new SeriesAnimation(chart)\n\t\t\tchart.animation = anim\n\t\t\tanim.kind = \"zoomin\"\n\t\t\tanim.duration = 300\n\n\t\t\tconst fade = new FadeAnimation(chart)\n\t\t\tfade.fade.series = true\n\t\t\tanim.items.push(fade)\n\t\t}\n\n\t\treturn chart\n\t}\n\n\t_onclickseries(series: Series, index: number): boolean {\n\t\tconst c = series.chart as DataChart\n\n\t\tif (c.onclickseries) {\n\t\t\tc.animateClick()\n\t\t\tc.onclickseries(series, index)\n\t\t}\n\n\t\treturn false\n\t}\n}\n\nexport class DataMetric implements DataMetricShape {\n\tdeclare name: MetricName | undefined\n\tdeclare title: string\n\tdeclare measure: string\n\tdeclare dimension: DataDimension\n\tdeclare dataset: DataDimension | null\n\tdeclare allDims: DataDimension[]\n\n\tconstructor(dimension: DataDimension, title: string, name?: MetricName) {\n\t\tthis.name = name\n\t\tthis.title = title || (typeof name === \"string\" ? name : \"\")\n\t\tthis.dimension = dimension\n\n\t\tconst dataset = dimension.dataset\n\t\tthis.dataset = dataset\n\t\tthis.measure = \"sum\" // average, high, low, count\n\t}\n\n\tinitDims(): void {\n\t\tconst engine = this.dimension.dataset?.engine\n\t\tif (!engine) return\n\n\t\tlet t: number,\n\t\t\tl = engine.datasets.length,\n\t\t\ttt: number,\n\t\t\td: DataDimension[],\n\t\t\tld: number,\n\t\t\tdd: DataDimension,\n\t\t\tdim = this.dimension\n\n\t\tthis.allDims = []\n\n\t\tfor (t = 0; t < l; t++) {\n\t\t\td = engine.datasets[t].dimensions\n\t\t\tld = d.length\n\n\t\t\tfor (tt = 0; tt < ld; tt++) {\n\t\t\t\tdd = d[tt]\n\n\t\t\t\tif (dim !== dd && !dim.hasParent(dd) && dd.anySelected()) {\n\t\t\t\t\tif (dd.dataset === dim.dataset) dd._link = null\n\t\t\t\t\telse dd._link = dim.getLinksTo(dd)\n\n\t\t\t\t\tthis.allDims.push(dd)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconsider(data: DataRuntime): boolean {\n\t\tlet f: DataNode\n\n\t\tfor (const dimension of this.allDims) {\n\t\t\tif (dimension._link) {\n\t\t\t\tf = data\n\n\t\t\t\tfor (const link of dimension._link) f = dimension.search(link, f as DataObject)\n\n\t\t\t\tif (f && dimension.id) f = (f as DataObject)[dimension.id]\n\t\t\t} else f = data[(dimension.id || dimension.field) as string]\n\n\t\t\tif (typeof f === \"undefined\" || f === null) return false\n\t\t\tif (dimension.datetime) f = dimension.datePart(f)\n\t\t\tif (!dimension.inSelected(f)) return false\n\t\t}\n\n\t\treturn true\n\t}\n}\n\nexport class DataDimension implements DataDimensionShape {\n\tdeclare title: string\n\tdeclare field?: string\n\tdeclare id?: string\n\tdeclare object: unknown\n\tdeclare dataset: DataDimension | null\n\tdeclare parent: DataDimension | null\n\tdeclare subDimensions: DataDimension[]\n\tdeclare metrics: DataMetric[]\n\tdeclare selected: DataNode\n\tdeclare select: ((value: DataNode) => boolean) | null\n\tdeclare selectedInclude: boolean\n\tdeclare nulls: boolean\n\tdeclare hasID: boolean\n\tdeclare dateKeys: Record<string, string>\n\tdeclare engine: DataEngine | null\n\tdeclare dimensions: DataDimension[]\n\tdeclare data: DataRuntime\n\tdeclare links: DataLink[]\n\tdeclare cache: boolean\n\tdeclare index: number\n\tdeclare _link?: DataLink[] | null\n\tdeclare datetime?: { selected: string; yearField?: number; monthField?: number; dayField?: number }\n\t/** A dimension that gives the titles for the ids of this one. */\n\tdeclare titles?: DataDimension\n\n\tconstructor(title: string, field?: string, id?: string) {\n\t\tthis.dataset = null\n\t\tthis.parent = null\n\n\t\tthis.engine = null\n\n\t\tthis.subDimensions = []\n\n\t\tthis.field = field\n\t\tthis.id = id\n\t\tthis.title = title || field || \"\"\n\n\t\tthis.nulls = true\n\n\t\tthis.hasID = typeof id !== \"undefined\" && id !== null && id !== \"\"\n\n\t\tthis.metrics = []\n\t\tthis.links = []\n\n\t\tthis.selected = null\n\t\tthis.select = null\n\t\tthis.selectedInclude = true\n\n\t\tthis.dateKeys = { c: \"Century\", x: \"Decade\", y: \"Year\", m: \"Month\", w: \"Weekday\", d: \"Day\" }\n\t}\n\n\taddDimension(title: string, field?: string, id?: string): DataDimension {\n\t\treturn this.addSubDimension(this, title, field, id)\n\t}\n\n\t/** @this {any} */\n\taddSubDimension(parent: DataDimension, title: string, field?: string, id?: string): DataDimension {\n\t\t/** @type {any} */\n\t\tconst d = new DataDimension(title, field, id)\n\n\t\td.engine = this.engine\n\t\td.parent = parent\n\n\t\tif (parent) {\n\t\t\td.dataset = parent.dataset\n\n\t\t\tif (d.dataset) d.index = d.dataset.dimensions.push(d)\n\n\t\t\tparent.subDimensions.push(d)\n\t\t}\n\n\t\treturn d\n\t}\n\n\taddMetric(title: string, name?: MetricName, measure?: string): DataMetric {\n\t\tconst r = new DataMetric(this, title, name)\n\n\t\tif (measure) r.measure = measure\n\n\t\tthis.metrics.push(r)\n\t\treturn r\n\t}\n\n\taddLink(field: LinkField, dimension: DataDimension, datasetField: LinkField): DataLink {\n\t\tconst l = { field: field, dimension: dimension, datasetField: datasetField, parent: this }\n\t\tthis.links.push(l)\n\t\treturn l\n\t}\n\n\thasParent(dimension: DataDimension): boolean {\n\t\tlet d = this.parent\n\t\twhile (d)\n\t\t\tif (d === dimension) return true\n\t\t\telse d = d.parent\n\n\t\treturn false\n\t}\n\n\tinSelected(data: DataNode): boolean {\n\t\tif (this.select) return this.select(data)\n\t\telse if (Array.isArray(this.selected))\n\t\t\treturn this.selectedInclude ? this.selected.indexOf(data) !== -1 : this.selected.indexOf(data) === -1\n\t\telse return this.selectedInclude ? this.selected === data : this.selected !== data\n\t}\n\n\t/** @this {any} */\n\tget(id: DataNode): DataNode {\n\t\tlet t = this.id,\n\t\t\tdata: DataNode,\n\t\t\tdate = this.datetime\n\n\t\tthis.traverse((o: DataNode) => {\n\t\t\tif (date) o = this.datePart(o)\n\n\t\t\tif (id === (t ? (o as DataObject)[t] : o)) {\n\t\t\t\tdata = o\n\t\t\t\treturn false\n\t\t\t} else return true\n\t\t})\n\n\t\treturn data\n\t}\n\n\t/** @this {any} */\n\tdatePart(date: DataNode): DataNode {\n\t\tconst da = this.datetime\n\t\tif (!da) return date\n\t\tconst s = da.selected\n\n\t\tif (typeof date === \"string\") {\n\t\t\tconst parts = date.match(/(\\d+)/g) ?? []\n\n\t\t\tif (s === \"y\") return parts[da.yearField || 2]\n\t\t\telse if (s === \"m\") return parts[da.monthField || 0]\n\t\t\telse if (s === \"x\") return 10 * trunc(parseInt(parts[2] as string, 10) / 10)\n\t\t\telse if (s === \"d\") return parts[da.dayField || 1]\n\t\t\telse if (s === \"w\") return new Date(date).getDay()\n\t\t} else if (date instanceof Date) {\n\t\t\tif (s === \"y\") return date.getFullYear()\n\t\t\telse if (s === \"m\") return date.getMonth() + 1\n\t\t\telse if (s === \"x\") return 10 * trunc(date.getFullYear() / 10)\n\t\t\telse if (s === \"d\") return date.getDate()\n\t\t\telse if (s === \"w\") return date.getDay()\n\t\t}\n\n\t\treturn date\n\t}\n\n\t/** @this {any} */\n\tgetValues(): DataNode[] {\n\t\tconst seen = new Set<unknown>()\n\t\tconst r: DataNode[] = [],\n\t\t\tf = this.field,\n\t\t\tid = this.id\n\n\t\tthis.traverse((value: DataNode) => {\n\t\t\tif (id) value = f ? (value as DataObject)[f] : (value as DataObject)[id]\n\n\t\t\tif (this.datetime) value = this.datePart(value)\n\n\t\t\tif (Number.isNaN(value) || !seen.has(value)) {\n\t\t\t\tseen.add(value)\n\t\t\t\tr.push(value)\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\n\t\treturn r\n\t}\n\n\t/** @this {any} */\n\tgetIds(): DataNode[] {\n\t\tconst seen = new Set<unknown>()\n\t\tlet r: DataNode[] = [],\n\t\t\tf: DataNode,\n\t\t\tid = this.id,\n\t\t\tfield = this.field,\n\t\t\tp = this.parent ? this.parent : this\n\n\t\tp.traverse((value: DataNode) => {\n\t\t\tf = id ? (value as DataObject)[id] : field ? (value as DataObject)[field] : value\n\t\t\tif (this.datetime) f = this.datePart(f)\n\n\t\t\tif (this.nulls || (f !== null && f !== undefined && f !== \"\"))\n\t\t\t\tif (Number.isNaN(f) || !seen.has(f)) {\n\t\t\t\t\tseen.add(f)\n\t\t\t\t\tr.push(f)\n\t\t\t\t}\n\n\t\t\treturn true\n\t\t})\n\n\t\treturn r\n\t}\n\n\tisSelected(data: DataNode): boolean {\n\t\treturn !this.anySelected() || this.inSelected(data)\n\t}\n\n\tanySelected() {\n\t\tif (this.select) return true\n\t\telse {\n\t\t\tconst s = this.selected\n\n\t\t\tif (s !== null && typeof s !== \"undefined\")\n\t\t\t\tif (Array.isArray(s)) return s.length > 0\n\t\t\t\telse return true\n\n\t\t\treturn false\n\t\t}\n\t}\n\n\ttoggleSelected(series: Series, index: number): void {\n\t\tif (!Array.isArray(this.selected)) this.selected = this.selected == null ? [] : [this.selected]\n\n\t\tconst code = series.data.code?.[index] as DataNode\n\n\t\tconst i = this.selected.indexOf(code)\n\n\t\tif (i === -1) this.selected.push(code)\n\t\telse {\n\t\t\tthis.selected.splice(i, 1)\n\t\t\tif (this.selected.length === 0) this.selected = null\n\t\t}\n\n\t\t;(series.chart as DataChart).setSeriesPalette(series, this)\n\t}\n\n\ttraverse(process: (value: DataNode, index?: number | string) => boolean): void {\n\t\tfunction traverseLevel(dataset: DataNode, levelIndex: number): boolean {\n\t\t\tfunction doProcess(da2: DataNode, t2 = 0): boolean {\n\t\t\t\tlet tt: number, o3: DataNode, kk: string\n\n\t\t\t\tif (da2 && typeof da2 === \"object\") {\n\t\t\t\t\tconst source = da2 as DataObject\n\t\t\t\t\tconst k = Object.keys(source),\n\t\t\t\t\t\tkl = k.length,\n\t\t\t\t\t\tlev2 = levels[0],\n\t\t\t\t\t\thasSelected2 = lev2.anySelected()\n\n\t\t\t\t\tfor (tt = 0; tt < kl; tt++) {\n\t\t\t\t\t\tkk = k[tt]\n\n\t\t\t\t\t\tif (!hasSelected2 || lev2.isSelected(kk)) {\n\t\t\t\t\t\t\to3 = source[kk]\n\t\t\t\t\t\t\tlev2.data = o3 as DataObject\n\n\t\t\t\t\t\t\tif (!process(o3, kk)) return false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true\n\t\t\t\t} else return process(da2, t2)\n\t\t\t}\n\n\t\t\tlet t: number,\n\t\t\t\tml: number,\n\t\t\t\tlev = levels[levelIndex],\n\t\t\t\thasSelected = lev.anySelected(),\n\t\t\t\tda: DataNode = lev.field ? (dataset as DataObject)[lev.field] : dataset,\n\t\t\t\tdaSel: DataNode = lev.parent ? dataset : da\n\n\t\t\tif (!hasSelected || lev.isSelected(lev.id ? (daSel as DataObject)[lev.id] : daSel)) {\n\t\t\t\tlev.data = daSel as DataObject\n\n\t\t\t\tif (Array.isArray(da)) {\n\t\t\t\t\tml = da.length\n\n\t\t\t\t\tif (levelIndex > 0)\n\t\t\t\t\t\tfor (t = 0; t < ml; t++) {\n\t\t\t\t\t\t\tif (!traverseLevel(da[t], levelIndex - 1)) return false\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tfor (t = 0; t < ml; t++) {\n\t\t\t\t\t\t\tif (!process(da[t], t)) return false\n\t\t\t\t\t\t}\n\t\t\t\t} else if (levelIndex > 0) {\n\t\t\t\t\tif (!doProcess(da)) return false\n\t\t\t\t} else if (!process(daSel)) return false\n\t\t\t}\n\n\t\t\treturn true\n\t\t}\n\n\t\tlet levels: DataDimension[] = [],\n\t\t\tdi: DataDimension | null = this\n\n\t\tdo {\n\t\t\tlevels.push(di)\n\t\t\tdi = di.parent\n\t\t} while (di)\n\n\t\tconst o = this.dataset?.object as DataNode\n\t\tif (o !== null && o !== undefined) traverseLevel(o, levels.length - 1)\n\t}\n\n\t/** @this {any} */\n\tsearchAcross(lin: DataLink[], o: DataRuntime): DataNode {\n\t\tlet f: DataNode = o,\n\t\t\ttmp: DataDimension = this\n\n\t\tfor (let links = 0; links < lin.length; links++) {\n\t\t\tf = tmp.search(lin[links], f as DataObject, links > 0)\n\n\t\t\tif (links < lin.length - 1) {\n\t\t\t\ttmp = lin[links + 1].parent\n\t\t\t\tlin[links + 1].searchDimension = tmp\n\t\t\t}\n\t\t}\n\n\t\tif (f && this.engine?.cache) {\n\t\t\tif (!o.cache) o.cache = []\n\n\t\t\tconst cache = o.cache as DataNode[]\n\t\t\tif (!cache[this.index]) cache[this.index] = f\n\t\t}\n\n\t\treturn f\n\t}\n\n\t/** @this {any} */\n\tsearch(link: DataLink, data: DataRuntime, inverted = false): DataNode {\n\t\tconst cached = data.cache as DataNode[] | undefined\n\t\tif (cached?.[this.index]) return cached[this.index]\n\n\t\tlet f: DataNode = null,\n\t\t\tvalues: DataNode,\n\t\t\tld: DataDimension,\n\t\t\tt: number,\n\t\t\tlinkSearch = link.search,\n\t\t\tlinkField = inverted ? link.field : link.datasetField,\n\t\t\tlinkValues = inverted ? link.datasetField : link.field,\n\t\t\tisArray = Array.isArray(linkValues)\n\n\t\tif (isArray) {\n\t\t\tconst list: DataNode[] = []\n\n\t\t\tconst fields = linkValues as string[]\n\t\t\tfor (t = 0; t < fields.length; t++) list.push(data[fields[t]])\n\t\t\tvalues = list\n\t\t} else values = data[linkValues as string]\n\n\t\tld = (link.searchDimension || link.dimension) as DataDimension\n\n\t\tdo {\n\t\t\tld.traverse((o: DataNode) => {\n\t\t\t\tif (linkSearch) {\n\t\t\t\t\tif (linkSearch(o as DataObject, data)) {\n\t\t\t\t\t\tf = o\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t} else if (isArray) {\n\t\t\t\t\tlet result = true\n\n\t\t\t\t\tconst wanted = values as DataNode[]\n\t\t\t\t\tfor (t = 0; t < wanted.length; t++) {\n\t\t\t\t\t\tif ((o as DataObject)[(linkField as string[])[t]] !== wanted[t]) {\n\t\t\t\t\t\t\tresult = false\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tf = o\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\t// biome-ignore lint/suspicious/noDoubleEquals: <explanation> TODO: review if this can be safely changed to ===\n\t\t\t\t} else if ((o as DataObject)[linkField as string] == values) {\n\t\t\t\t\tf = o\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\treturn true\n\t\t\t})\n\n\t\t\tif (!f) break\n\t\t\telse if (ld.dataset !== this.dataset) return f\n\t\t\telse if (ld !== this) {\n\t\t\t\tif (ld.parent) {\n\t\t\t\t\tld = ld.parent\n\t\t\t\t\tf = ld.data\n\t\t\t\t} else break\n\t\t\t}\n\t\t} while (ld !== this)\n\n\t\treturn f ? (this.id ? f : (f as DataObject)[this.field as string]) : null\n\t}\n\n\tgetLinksTo(dimension: DataDimension | null): DataLink[] | null {\n\t\tif (!dimension || dimension === this.dataset || dimension.dataset === this.dataset)\n\t\t\treturn [{ field: null, dimension: dimension, datasetField: null, parent: this }]\n\t\telse {\n\t\t\tlet res: DataLink[] = [],\n\t\t\t\td = findLinkInDimension(dimension, this, res)\n\n\t\t\tif (!d) d = findLinkInDimension(this, dimension, res)\n\n\t\t\treturn d ? res : null\n\t\t}\n\t}\n}\n\nfunction findLinkInDimension(needle: DataDimension, haystack: DataDimension, res: DataLink[]): DataLink | null {\n\tlet d: DataDimension | null,\n\t\tt: number,\n\t\t_this: DataDimension | null = haystack,\n\t\tli: DataLink[] | undefined,\n\t\tlil: number,\n\t\tneed: DataDimension | null,\n\t\tr: DataLink | null\n\n\tdo {\n\t\tli = _this.links\n\n\t\tif (li) {\n\t\t\tlil = li.length\n\t\t\tfor (t = 0; t < lil; t++) {\n\t\t\t\td = li[t].dimension\n\t\t\t\tif (!d) continue\n\t\t\t\tdo {\n\t\t\t\t\tneed = needle\n\n\t\t\t\t\tdo {\n\t\t\t\t\t\tif (d === need) {\n\t\t\t\t\t\t\tli[t].searchDimension = li[t].dimension ?? undefined\n\t\t\t\t\t\t\tres.push(li[t])\n\t\t\t\t\t\t\treturn li[t]\n\t\t\t\t\t\t}\n\t\t\t\t\t\tneed = need.parent\n\t\t\t\t\t} while (need)\n\n\t\t\t\t\tr = findLinkInDimension(needle, d, res)\n\n\t\t\t\t\tif (r) {\n\t\t\t\t\t\tres.unshift(li[t])\n\t\t\t\t\t\treturn r\n\t\t\t\t\t} else {\n\t\t\t\t\t\tr = findLinkInDimension(d, needle, res)\n\t\t\t\t\t\tif (r) {\n\t\t\t\t\t\t\tres.unshift(li[t])\n\t\t\t\t\t\t\treturn r\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\td = d.parent\n\t\t\t\t} while (d)\n\t\t\t}\n\t\t}\n\t\t_this = _this.parent\n\t} while (_this)\n\n\tconst subDimensions = haystack.subDimensions\n\n\tfor (t = 0; t < subDimensions.length; t++) {\n\t\tr = findLinkInDimension(needle, subDimensions[t], res)\n\t\tif (r) return r\n\t}\n\n\treturn null\n}\n","import { type AccessibilityOptions, applyAccessibility } from \"./accessibility.js\"\nimport type { Chart } from \"./chart.js\"\nimport { type AnimationOptions, findOrAddTool, registerOptionSection, type ToolsOptions } from \"./chart-options.js\"\nimport { observeSize } from \"./responsive.js\"\nimport { Annotation, CursorTool, DragTool, FadeAnimation, SeriesAnimation } from \"./tools/index.js\"\n\n// This module has no top-level side effects on purpose: the `tools`, `animation`, `accessibility` and\n// `responsive` chart options are opt-in so that importing `Chart` does not pull them into a bundle.\n\nconst annotations = new WeakMap<Chart, Annotation[]>()\n\nfunction applyToolsOptions(chart: Chart, tools: ToolsOptions): void {\n\tif (tools.cursor !== undefined) {\n\t\tconst cursor = findOrAddTool(chart, CursorTool)\n\t\tconst options = tools.cursor\n\t\tif (options.enabled !== undefined) cursor.active = options.enabled\n\t\tif (options.direction !== undefined) cursor.direction = options.direction\n\t\tif (options.render !== undefined) cursor.render = options.render\n\t\tif (options.followMouse !== undefined) cursor.followMouse = options.followMouse\n\t\tif (options.color !== undefined) cursor.format.stroke.fill = options.color\n\t\tif (options.width !== undefined) cursor.format.stroke.size = options.width\n\t\tif (options.symbol !== undefined) cursor.symbol = options.symbol\n\t\tif (options.symbolSize !== undefined) cursor.symbolSize = options.symbolSize\n\t}\n\n\tif (tools.drag?.enabled !== undefined) findOrAddTool(chart, DragTool).active = tools.drag.enabled\n\n\tif (tools.annotations === undefined) return\n\n\t// The list describes every declarative annotation, so a later update replaces the previous ones.\n\tfor (const previous of annotations.get(chart) ?? []) chart.tools.remove(previous, true)\n\n\tconst created: Annotation[] = []\n\tfor (const options of tools.annotations) {\n\t\tconst annotation = new Annotation(chart, options.text, options.x, options.y)\n\t\tif (options.visible !== undefined) annotation.visible = options.visible\n\t\tif (options.transparent !== undefined) annotation.transparent = options.transparent\n\t\tif (options.backgroundColor !== undefined) annotation.format.fill = options.backgroundColor\n\t\tif (options.borderColor !== undefined) annotation.format.stroke.fill = options.borderColor\n\t\tif (options.borderWidth !== undefined) annotation.format.stroke.size = options.borderWidth\n\t\tif (options.fontColor !== undefined) annotation.format.font.fill = options.fontColor\n\t\tif (options.fontSize !== undefined) annotation.format.font.setSize(options.fontSize)\n\t\tif (options.fontFamily !== undefined) {\n\t\t\tconst fontStyle = annotation.format.font.style.split(\" \")\n\t\t\tfontStyle[fontStyle.findIndex(part => part.endsWith(\"px\")) + 1] = options.fontFamily\n\t\t\tannotation.format.font.style = fontStyle.join(\" \")\n\t\t}\n\t\tchart.tools.add(annotation)\n\t\tcreated.push(annotation)\n\t}\n\tannotations.set(chart, created)\n}\n\nfunction applyAnimationOptions(chart: Chart, options: AnimationOptions): void {\n\tconst animation = new SeriesAnimation()\n\tif (options.duration !== undefined) animation.duration = options.duration\n\tif (options.kind !== undefined) animation.kind = options.kind\n\tif (options.mode !== undefined) animation.mode = options.mode\n\n\tconst fade = options.fade\n\tif (fade) {\n\t\tconst fadeAnimation = new FadeAnimation()\n\t\tif (fade.duration !== undefined) fadeAnimation.duration = fade.duration\n\t\tif (options.mode !== undefined) fadeAnimation.mode = options.mode\n\t\tfadeAnimation.fade.series = fade.series\n\t\tfadeAnimation.fade.marks = fade.marks\n\t\tfadeAnimation.fade.legend = fade.legend\n\t\tfadeAnimation.fade.title = fade.title\n\t\tfadeAnimation.fade.axes = fade.axes\n\t\tfadeAnimation.fade.panel = fade.panel\n\t\tanimation.items.push(fadeAnimation)\n\t}\n\n\tanimation.animate(chart)\n}\n\n/**\n * Enables the `tools` (cursor, drag, annotations), `animation`, `accessibility` and `responsive` chart\n * options. Calling it includes their code in the application bundle.\n */\nexport function registerAllOptions(): void {\n\tregisterOptionSection(\"tools\", applyToolsOptions)\n\tregisterOptionSection(\"animation\", applyAnimationOptions)\n\tregisterOptionSection(\"accessibility\", (chart: Chart, options: AccessibilityOptions) =>\n\t\tapplyAccessibility(chart, options)\n\t)\n\tregisterOptionSection(\"responsive\", (chart: Chart) => observeSize(chart))\n}\n","import type { Chart } from \"./chart.js\"\nimport { getPlatformConstructor } from \"./platform.js\"\n\ninterface SizeObserverEntry {\n\tcontentRect?: { width: number; height: number }\n}\n\ninterface SizeObserver {\n\tobserve(target: unknown): void\n\tdisconnect(): void\n}\n\ntype SizeObserverConstructor = new (callback: (entries: SizeObserverEntry[]) => void) => SizeObserver\n\n/**\n * Keeps the chart as large as its canvas is displayed, resizing it whenever the element changes size.\n * Returns a function that stops observing; it is also called when the chart is destroyed. Does nothing\n * where `ResizeObserver` is not available.\n */\nexport function observeSize(chart: Chart): () => void {\n\tconst Observer = getPlatformConstructor<SizeObserver>(\"ResizeObserver\") as SizeObserverConstructor | undefined\n\tif (!Observer) return () => undefined\n\n\tlet observer: SizeObserver | null = new Observer(entries => {\n\t\tconst size = entries[entries.length - 1]?.contentRect\n\t\tif (!size || chart.destroyed) return\n\n\t\tconst width = Math.round(size.width)\n\t\tconst height = Math.round(size.height)\n\t\t// An element that is not displayed reports no size, and a resize to the current size is wasted work.\n\t\tif (width <= 0 || height <= 0) return\n\t\tif (width === Math.round(chart.bounds.width) && height === Math.round(chart.bounds.height)) return\n\n\t\tchart.resize(width, height)\n\t})\n\n\tobserver.observe(chart.canvas)\n\n\tconst stop = (): void => {\n\t\toff()\n\t\tobserver?.disconnect()\n\t\tobserver = null\n\t}\n\tconst off = chart.once(\"destroy\", stop)\n\n\treturn stop\n}\n","import { Chart } from \"./chart.js\"\nimport type { ChartOptions } from \"./chart-options.js\"\nimport type { ChartPointerEvent, ChartPointerEventKind } from \"./interaction.js\"\n\n// Drawing a chart in a Web Worker: the page transfers control of its canvas to a worker, forwards the\n// pointer events and size changes, and the worker owns the chart and its `OffscreenCanvas`.\n//\n// page: const chart = createWorkerChart(canvas, new Worker(\"chart-worker.js\", { type: \"module\" }), options)\n// worker: registerAllSeriesTypes(); startChartWorker()\n//\n// This module has no top-level side effects. Options travel with `postMessage`, so they must be\n// structured-cloneable: use data options, not callbacks or plugins. Series types other than the default\n// ones are registered in the worker script.\n\n/** The part of a `Worker` or of the worker global scope that is used to exchange messages. */\nexport interface ChartMessagePort {\n\tpostMessage(message: unknown, transfer?: Transferable[]): void\n\taddEventListener(type: \"message\", listener: (event: { data: unknown }) => void): void\n\tremoveEventListener?(type: \"message\", listener: (event: { data: unknown }) => void): void\n}\n\n/** Messages sent by the page to the worker. */\nexport type ChartWorkerRequest =\n\t| {\n\t\t\ttype: \"teechart:init\"\n\t\t\tcanvas: OffscreenCanvas\n\t\t\toptions: ChartOptions\n\t\t\twidth: number\n\t\t\theight: number\n\t\t\tpixelRatio: number\n\t }\n\t| { type: \"teechart:options\"; options: ChartOptions }\n\t| { type: \"teechart:resize\"; width: number; height: number; pixelRatio: number }\n\t| { type: \"teechart:pointer\"; kind: ChartPointerEventKind; event: ChartPointerEvent }\n\t| { type: \"teechart:blob\"; id: number; format?: string; quality?: number }\n\t| { type: \"teechart:destroy\" }\n\n/** Messages sent by the worker to the page. */\nexport type ChartWorkerResponse =\n\t| { type: \"teechart:ready\" }\n\t| { type: \"teechart:cursor\"; cursor: string }\n\t| { type: \"teechart:blob\"; id: number; blob: Blob | null; error?: string }\n\t| { type: \"teechart:error\"; message: string }\n\nfunction isMessage<T extends { type: string }>(data: unknown, prefix = \"teechart:\"): data is T {\n\treturn (\n\t\ttypeof data === \"object\" &&\n\t\tdata !== null &&\n\t\ttypeof (data as { type?: unknown }).type === \"string\" &&\n\t\t(data as { type: string }).type.startsWith(prefix)\n\t)\n}\n\nexport interface ChartWorkerHostOptions {\n\t/** The port to listen on and answer through; the global scope of the worker by default. */\n\tport?: ChartMessagePort\n\t/** Creates the chart for the transferred canvas; use it to run code before the first draw. */\n\tcreateChart?: (canvas: OffscreenCanvas, options: ChartOptions) => Chart\n}\n\n/**\n * Runs inside a Worker. It creates the chart when the page sends its canvas and keeps it in sync with the\n * options, size and pointer events that the page forwards. Returns a function that stops it.\n */\nexport function startChartWorker(host: ChartWorkerHostOptions = {}): () => void {\n\tconst port = host.port ?? (globalThis as unknown as ChartMessagePort)\n\tlet chart: Chart | null = null\n\tlet cursor = \"\"\n\n\tconst reply = (message: ChartWorkerResponse): void => port.postMessage(message)\n\n\tconst listener = (event: { data: unknown }): void => {\n\t\tconst message = event.data\n\t\tif (!isMessage<ChartWorkerRequest>(message)) return\n\n\t\ttry {\n\t\t\tswitch (message.type) {\n\t\t\t\tcase \"teechart:init\": {\n\t\t\t\t\tchart?.destroy()\n\t\t\t\t\tchart = host.createChart?.(message.canvas, message.options) ?? new Chart(message.canvas, message.options)\n\t\t\t\t\tif (message.pixelRatio !== 1) chart.setPixelRatio(message.pixelRatio)\n\t\t\t\t\tif (message.width > 0 && message.height > 0) chart.resize(message.width, message.height)\n\t\t\t\t\telse chart.draw()\n\t\t\t\t\treply({ type: \"teechart:ready\" })\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase \"teechart:options\":\n\t\t\t\t\tchart?.setOptions(message.options)\n\t\t\t\t\tbreak\n\t\t\t\tcase \"teechart:resize\":\n\t\t\t\t\tif (chart) {\n\t\t\t\t\t\tif (chart.pixelRatio !== message.pixelRatio) chart.setPixelRatio(message.pixelRatio)\n\t\t\t\t\t\tchart.resize(message.width, message.height)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tcase \"teechart:pointer\": {\n\t\t\t\t\tif (!chart) break\n\t\t\t\t\tchart.dispatchPointerEvent(message.kind, message.event)\n\t\t\t\t\tconst next = chart.newCursor ?? \"\"\n\t\t\t\t\tif (message.kind === \"move\" && next !== cursor) {\n\t\t\t\t\t\tcursor = next\n\t\t\t\t\t\treply({ type: \"teechart:cursor\", cursor })\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase \"teechart:blob\": {\n\t\t\t\t\tconst { id } = message\n\t\t\t\t\tif (!chart) {\n\t\t\t\t\t\treply({ type: \"teechart:blob\", id, blob: null, error: \"The chart is not ready\" })\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tchart.toBlob(message.format, message.quality).then(\n\t\t\t\t\t\tblob => reply({ type: \"teechart:blob\", id, blob }),\n\t\t\t\t\t\t(error: unknown) => reply({ type: \"teechart:blob\", id, blob: null, error: String(error) })\n\t\t\t\t\t)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase \"teechart:destroy\":\n\t\t\t\t\tchart?.destroy()\n\t\t\t\t\tchart = null\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treply({ type: \"teechart:error\", message: error instanceof Error ? error.message : String(error) })\n\t\t}\n\t}\n\n\tport.addEventListener(\"message\", listener)\n\treturn () => {\n\t\tport.removeEventListener?.(\"message\", listener)\n\t\tchart?.destroy()\n\t\tchart = null\n\t}\n}\n\n/** The page side handle of a chart drawn in a worker. */\nexport interface WorkerChart {\n\t/** Resolves when the worker has created and drawn the chart, and rejects when it reports an error. */\n\treadonly ready: Promise<void>\n\t/** Applies a declarative options patch in the worker (see `Chart.setOptions`). */\n\tsetOptions(options: ChartOptions): void\n\t/** Resizes the chart; by default the size of the canvas element is followed automatically. */\n\tresize(width: number, height: number): void\n\t/** Encodes the chart image in the worker; rejects if encoding fails or the chart is destroyed. */\n\ttoBlob(format?: string, quality?: number): Promise<Blob>\n\t/** Stops forwarding events, destroys the chart in the worker and leaves the canvas to the garbage collector. */\n\tdestroy(): void\n}\n\nexport interface WorkerChartOptions {\n\t/** Device pixels per CSS pixel. Defaults to `window.devicePixelRatio`. */\n\tpixelRatio?: number\n\t/** Prevents the page from scrolling when the wheel is used over the chart, which zoom needs. */\n\tcaptureWheel?: boolean\n}\n\ntype TransferableCanvas = HTMLCanvasElement & { transferControlToOffscreen(): OffscreenCanvas }\n\n/**\n * Runs in the page. Hands `canvas` to `worker`, which must call `startChartWorker`, and forwards pointer\n * events and size changes. The canvas can only be transferred once and should be sized with CSS.\n */\nexport function createWorkerChart(\n\tcanvas: HTMLCanvasElement,\n\tworker: ChartMessagePort,\n\toptions: ChartOptions,\n\tinit: WorkerChartOptions = {}\n): WorkerChart {\n\tconst transferable = canvas as TransferableCanvas\n\tif (typeof transferable.transferControlToOffscreen !== \"function\")\n\t\tthrow new Error(\"This browser cannot transfer a canvas to a worker (OffscreenCanvas is not supported)\")\n\n\tconst pixelRatio = () => init.pixelRatio ?? globalThis.devicePixelRatio ?? 1\n\tconst size = (): { width: number; height: number } => ({\n\t\twidth: canvas.clientWidth || canvas.width,\n\t\theight: canvas.clientHeight || canvas.height\n\t})\n\n\tlet resolveReady: () => void = () => {}\n\tlet rejectReady: (error: Error) => void = () => {}\n\tconst ready = new Promise<void>((resolve, reject) => {\n\t\tresolveReady = resolve\n\t\trejectReady = reject\n\t})\n\t// A rejected promise nobody awaits must not be reported as an unhandled rejection.\n\tready.catch(() => {})\n\n\tconst blobs = new Map<number, { resolve: (blob: Blob) => void; reject: (error: Error) => void }>()\n\tlet blobId = 0\n\tlet destroyed = false\n\n\tconst listener = (event: { data: unknown }): void => {\n\t\tconst message = event.data\n\t\tif (!isMessage<ChartWorkerResponse>(message)) return\n\t\tif (message.type === \"teechart:ready\") resolveReady()\n\t\telse if (message.type === \"teechart:cursor\") canvas.style.cursor = message.cursor\n\t\telse if (message.type === \"teechart:error\") rejectReady(new Error(message.message))\n\t\telse if (message.type === \"teechart:blob\") {\n\t\t\tconst pending = blobs.get(message.id)\n\t\t\tblobs.delete(message.id)\n\t\t\tif (message.blob) pending?.resolve(message.blob)\n\t\t\telse pending?.reject(new Error(message.error ?? \"The chart could not be encoded\"))\n\t\t}\n\t}\n\tworker.addEventListener(\"message\", listener)\n\n\tconst send = (message: ChartWorkerRequest, transfer?: Transferable[]): void => {\n\t\tif (!destroyed) worker.postMessage(message, transfer)\n\t}\n\n\tconst initial = size()\n\tconst offscreen = transferable.transferControlToOffscreen()\n\tsend(\n\t\t{\n\t\t\ttype: \"teechart:init\",\n\t\t\tcanvas: offscreen,\n\t\t\toptions,\n\t\t\twidth: initial.width,\n\t\t\theight: initial.height,\n\t\t\tpixelRatio: pixelRatio()\n\t\t},\n\t\t[offscreen]\n\t)\n\n\tconst forward = (kind: ChartPointerEventKind) => (event: Event) => {\n\t\tconst pointer = event as PointerEvent & WheelEvent\n\t\tconst rect = canvas.getBoundingClientRect()\n\t\tif (kind === \"wheel\" && init.captureWheel) event.preventDefault()\n\t\tsend({\n\t\t\ttype: \"teechart:pointer\",\n\t\t\tkind,\n\t\t\tevent: {\n\t\t\t\tx: pointer.clientX - rect.left,\n\t\t\t\ty: pointer.clientY - rect.top,\n\t\t\t\tbutton: pointer.button,\n\t\t\t\tdeltaY: kind === \"wheel\" ? pointer.deltaY : undefined,\n\t\t\t\tpointerId: pointer.pointerId\n\t\t\t}\n\t\t})\n\t}\n\n\tconst listeners: Array<[string, EventListener, AddEventListenerOptions?]> = [\n\t\t[\"pointermove\", forward(\"move\")],\n\t\t[\"pointerdown\", forward(\"down\")],\n\t\t[\"pointerup\", forward(\"up\")],\n\t\t[\"pointercancel\", forward(\"cancel\")],\n\t\t[\"pointerleave\", forward(\"leave\")],\n\t\t[\"wheel\", forward(\"wheel\"), { passive: !init.captureWheel }]\n\t]\n\tfor (const [type, handler, listenerOptions] of listeners) canvas.addEventListener(type, handler, listenerOptions)\n\n\tlet observer: ResizeObserver | null = null\n\tlet lastWidth = initial.width\n\tlet lastHeight = initial.height\n\tif (typeof ResizeObserver !== \"undefined\") {\n\t\tobserver = new ResizeObserver(() => {\n\t\t\tconst next = size()\n\t\t\tif (next.width === lastWidth && next.height === lastHeight) return\n\t\t\tlastWidth = next.width\n\t\t\tlastHeight = next.height\n\t\t\tsend({ type: \"teechart:resize\", width: next.width, height: next.height, pixelRatio: pixelRatio() })\n\t\t})\n\t\tobserver.observe(canvas)\n\t}\n\n\treturn {\n\t\tready,\n\t\tsetOptions: patch => send({ type: \"teechart:options\", options: patch }),\n\t\tresize: (width, height) => {\n\t\t\tlastWidth = width\n\t\t\tlastHeight = height\n\t\t\tsend({ type: \"teechart:resize\", width, height, pixelRatio: pixelRatio() })\n\t\t},\n\t\ttoBlob: (format, quality) =>\n\t\t\tnew Promise<Blob>((resolve, reject) => {\n\t\t\t\tif (destroyed) {\n\t\t\t\t\treject(new Error(\"The chart was destroyed\"))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst id = ++blobId\n\t\t\t\tblobs.set(id, { resolve, reject })\n\t\t\t\tsend({ type: \"teechart:blob\", id, format, quality })\n\t\t\t}),\n\t\tdestroy: () => {\n\t\t\tif (destroyed) return\n\t\t\tsend({ type: \"teechart:destroy\" })\n\t\t\tdestroyed = true\n\t\t\tobserver?.disconnect()\n\t\t\tfor (const [type, handler, listenerOptions] of listeners)\n\t\t\t\tcanvas.removeEventListener(type, handler, listenerOptions)\n\t\t\tworker.removeEventListener?.(\"message\", listener)\n\t\t\tfor (const pending of blobs.values()) pending.reject(new Error(\"The chart was destroyed\"))\n\t\t\tblobs.clear()\n\t\t}\n\t}\n}\n","import { Chart } from \"./chart.js\"\nimport { Rectangle } from \"./core/primitives.js\"\nimport { Slider } from \"./slider.js\"\nimport { pointerOf } from \"./series-utils.js\"\nimport { drawSpline } from \"./spline.js\"\nimport type { Axis } from \"./core/elements/axis.js\"\nimport { CanvasRenderer } from \"./rendering/renderer.js\"\n\ninterface ScrollerTarget extends Chart {\n\tonscroll?: () => void\n}\n\ninterface AxisState {\n\tmi: number\n\tma: number\n\tsp: number\n\tep: number\n}\n\ninterface ScrollerSeriesItem {\n\tvisible: boolean\n\tuseAxes: boolean\n\tpointer?: { visible: boolean }\n\tdraw(): void\n}\n\ninterface ScrollerSeries {\n\tminXValue(): number\n\tmaxXValue(): number\n\tminYValue(): number\n\tmaxYValue(): number\n\teach(callback: (series: ScrollerSeriesItem) => void): void\n}\n\n/*\n\tCopyright 2010 by Robin W. Spencer\n\thttp://scaledinnovation.com/analytics/splines/aboutSplines.html\n\n\tModifications by Steema Software.\n\n\tThis program is free software: you can redistribute it and/or modify\n\tit under the terms of the GNU General Public License as published by\n\tthe Free Software Foundation, either version 3 of the License, or\n\t(at your option) any later version.\n\n\tThis program is distributed in the hope that it will be useful,\n\tbut WITHOUT ANY WARRANTY; without even the implied warranty of\n\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\tGNU General Public License for more details.\n\n\tYou can find a copy of the GNU General Public License\n\tat http://www.gnu.org/licenses/.\n*/\nexport class Scroller extends Chart {\n\ttarget: ScrollerTarget\n\tscroller: Slider\n\tonChanging: ((scroller: Scroller, minimum: number, maximum: number) => void) | undefined\n\n\tconstructor(canvas: HTMLCanvasElement, target: ScrollerTarget) {\n\t\tsuper(canvas)\n\n\t\tthis.target = target\n\n\t\tconst clearTargetTooltip = (): void => target.domTip.stop(target)\n\t\tthis.canvas.addEventListener(\"pointerenter\", clearTargetTooltip)\n\t\tthis.canvas.addEventListener(\"mouseenter\", clearTargetTooltip)\n\t\tthis._eventCleanups.push(() => {\n\t\t\tthis.canvas.removeEventListener(\"pointerenter\", clearTargetTooltip)\n\t\t\tthis.canvas.removeEventListener(\"mouseenter\", clearTargetTooltip)\n\t\t})\n\n\t\tthis.aspect.clip = false\n\t\tthis.panel.transparent = true\n\t\tthis.title.visible = false\n\n\t\tthis.scroller = new Slider(this)\n\t\tconst scroller = this.scroller\n\t\tscroller.useRange = true\n\t\tscroller.thumbSize = 100\n\n\t\tconst u = scroller.thumb\n\t\tu.shadow.height = 0\n\t\tu.transparency = 0.6\n\t\tu.stroke.fill = \"black\"\n\t\tu.shadow.visible = false\n\n\t\tscroller.horizontal = true\n\t\tconst b = scroller.bounds\n\t\tb.x = 0\n\t\tb.y = 0\n\t\tb.width = this.bounds.width\n\t\tb.height = this.bounds.height\n\t\tscroller.margin = 0\n\n\t\tscroller.lock = false\n\n\t\tthis.tools.add(scroller)\n\n\t\tconst owner = this\n\n\t\ttarget.ondraw = () => {\n\t\t\tif (!scroller.lock) owner.draw()\n\t\t}\n\t\ttarget.onscroll = function () {\n\t\t\tconst a = this.axes.bottom\n\t\t\tconst li = this.series as unknown as ScrollerSeries\n\t\t\tconst mi = li.minXValue()\n\t\t\tconst ma = li.maxXValue()\n\t\t\tconst dif = a.maximum - a.minimum\n\n\t\t\tif (a.minimum < mi) {\n\t\t\t\ta.minimum = mi\n\t\t\t\ta.maximum = a.minimum + dif\n\t\t\t}\n\t\t\tif (a.maximum > ma) {\n\t\t\t\ta.maximum = ma\n\t\t\t\ta.minimum = a.maximum - dif\n\t\t\t}\n\t\t}\n\n\t\tscroller.onChanging = function (s: Slider, v: number) {\n\t\t\tconst width = s.bounds.width || 1\n\t\t\tconst range = s.max - s.min\n\t\t\tlet r = ((s.thumbSize * range) / width) * 0.5\n\t\t\tconst li = target.series as unknown as ScrollerSeries\n\t\t\tconst mi = li.minXValue()\n\t\t\tconst ma = li.maxXValue()\n\n\t\t\tif (!Number.isFinite(r)) r = 0\n\n\t\t\tif (v - r < mi) v = mi + r\n\t\t\telse if (v + r > ma) v = ma - r\n\n\t\t\ttarget.axes.bottom.setMinMax(v - r, v + r)\n\t\t\tthis.lock = true\n\n\t\t\t//requestAnimationFrame(function() {target.draw();});\n\n\t\t\ttarget.draw()\n\t\t\tthis.lock = false\n\n\t\t\tif (owner.onChanging) owner.onChanging(owner, v - r, v + r)\n\n\t\t\treturn v\n\t\t}\n\n\t\tscroller.onDrawThumb = (s: Slider) => {\n\t\t\tconst r = target.chartRect\n\t\t\tconst ctx = target.ctx\n\t\t\tconst graphics = target.graphics\n\t\t\tconst cRect = new Rectangle(scroller.bounds.x, scroller.bounds.y, scroller.bounds.width, scroller.bounds.height)\n\t\t\ttarget.chartRect = cRect\n\t\t\ttarget.ctx = scroller.chart.ctx\n\t\t\t// Stroke.prepare styles chart.graphics, so it must point at the scroller's context too.\n\t\t\ttarget.graphics = scroller.chart.graphics\n\n\t\t\tfunction saveAxis(axis: Axis, data: AxisState): AxisState {\n\t\t\t\tconst res = {\n\t\t\t\t\tmi: axis.minimum,\n\t\t\t\t\tma: axis.maximum,\n\t\t\t\t\tsp: axis.startPos,\n\t\t\t\t\tep: axis.endPos\n\t\t\t\t}\n\t\t\t\trestoreAxis(axis, data)\n\t\t\t\treturn res\n\t\t\t}\n\n\t\t\tfunction restoreAxis(axis: Axis, old: AxisState): void {\n\t\t\t\taxis.minimum = old.mi\n\t\t\t\taxis.maximum = old.ma\n\t\t\t\taxis.startPos = old.sp\n\t\t\t\taxis.endPos = old.ep\n\t\t\t\taxis.scale = (old.ep - old.sp) / (old.ma - old.mi)\n\t\t\t}\n\n\t\t\tconst b = scroller.bounds\n\t\t\tconst c = target\n\t\t\tconst li = c.series as unknown as ScrollerSeries\n\n\t\t\ts.min = li.minXValue()\n\t\t\ts.max = li.maxXValue()\n\n\t\t\tconst h = saveAxis(c.axes.bottom, {\n\t\t\t\tsp: b.x,\n\t\t\t\tep: b.x + b.width,\n\t\t\t\tmi: s.min,\n\t\t\t\tma: s.max\n\t\t\t})\n\t\t\tconst v = saveAxis(c.axes.left, {\n\t\t\t\tsp: b.y,\n\t\t\t\tep: b.y + b.height,\n\t\t\t\tmi: li.minYValue(),\n\t\t\t\tma: li.maxYValue()\n\t\t\t})\n\n\t\t\tconst p = (h.mi + h.ma) * 0.5\n\t\t\tconst dif = h.ma - h.mi\n\t\t\tconst totalRange = s.max - s.min\n\n\t\t\t//if (s.position!=p) {\n\t\t\ts.thumbSize = totalRange !== 0 ? (dif * s.bounds.width) / totalRange : s.bounds.width\n\t\t\tconst ra = dif * 0.5\n\t\t\tif (owner.onChanging) owner.onChanging(owner, p - ra, p + ra)\n\t\t\ts.position = p\n\t\t\t//}\n\n\t\t\tc.series.each(seriesItem => {\n\t\t\t\tif (seriesItem.visible && seriesItem.useAxes) {\n\t\t\t\t\tconst pointer = pointerOf(seriesItem)\n\t\t\t\t\tif (pointer !== undefined) {\n\t\t\t\t\t\t//disable points in Scroller. Bug sizing\n\t\t\t\t\t\tconst oldVisible = pointer.visible\n\t\t\t\t\t\tpointer.visible = false\n\t\t\t\t\t\tseriesItem.draw?.()\n\t\t\t\t\t\tpointer.visible = oldVisible\n\t\t\t\t\t} else seriesItem.draw?.()\n\t\t\t\t}\n\t\t\t})\n\n\t\t\trestoreAxis(c.axes.bottom, h)\n\t\t\trestoreAxis(c.axes.left, v)\n\n\t\t\tc.chartRect = r\n\t\t\tc.ctx = ctx\n\t\t\tc.graphics = graphics\n\t\t}\n\t}\n\n\tuseRange(value: boolean): void {\n\t\tthis.scroller.useRange = value\n\t\tthis.draw()\n\t}\n\n\tinvertThumb(value: boolean): void {\n\t\tthis.scroller.invertThumb = value\n\t\tthis.draw()\n\t}\n\n\tsetBounds(x: number, y: number, width: number, height: number): void {\n\t\tthis.bounds.x = x\n\t\tthis.bounds.y = y\n\t\tthis.bounds.width = width\n\t\tthis.bounds.height = height\n\n\t\tconst b = this.scroller.bounds\n\t\tb.x = x\n\t\tb.y = y\n\t\tb.width = width\n\t\tb.height = height\n\t}\n}\n\nexport function SliderControl(canvas: HTMLCanvasElement): Slider {\n\tconst tmpChart = new Chart(canvas)\n\ttmpChart.panel.transparent = true\n\ttmpChart.title.visible = false\n\n\tconst slider = new Slider(tmpChart)\n\tconst size =\n\t\ttmpChart.renderer instanceof CanvasRenderer\n\t\t\t? tmpChart.renderer.getSize()\n\t\t\t: { width: tmpChart.canvas.width, height: tmpChart.canvas.height }\n\n\tslider.bounds.x = slider.thumbSize + 1\n\tslider.bounds.width = size.width - 2 * slider.thumbSize - 2\n\tslider.bounds.y = (size.height - slider.bounds.height) * 0.5\n\n\ttmpChart.tools.add(slider)\n\treturn slider\n}\n\nexport { drawSpline }\n","import { Series } from \"./series.js\"\nimport { BaseAnimation } from \"./tools/base-animation.js\"\nimport { trunc } from \"./utils.js\"\n\nexport class MarksAnimation extends BaseAnimation {\n\tseries: Series | null\n\tcurrent = -1\n\tmarks: { ongettext?: unknown } | undefined\n\toldGetText: unknown = null\n\n\tconstructor(target?: Series | BaseAnimation) {\n\t\tsuper(target)\n\t\tif (target instanceof Series) {\n\t\t\tthis.series = target\n\t\t\tthis.chart = target.chart\n\t\t} else this.series = null\n\t\tthis.marks = this.series?.marks\n\t}\n\n\tmarksText(_series: Series, index: number, result: string): string {\n\t\treturn index <= this.current ? result : \"\"\n\t}\n\n\tstart(): void {\n\t\tif (!this.marks) return\n\t\tthis.oldGetText = this.marks.ongettext\n\t\tthis.marks.ongettext = this.marksText.bind(this)\n\t}\n\n\tstop(): void {\n\t\tif (this.marks) this.marks.ongettext = this.oldGetText\n\t\tthis.current = -1\n\t}\n\n\tdoStep(fraction: number): void {\n\t\tif (this.series) this.current = trunc(this.series.data.values.length * fraction)\n\t}\n}\n","import { Rectangle } from \"../core/primitives.js\"\nimport { Donut } from \"./donut.js\"\n\n/**\n * @constructor\n * @extends Donut\n * @class Draws comparative of values plotted as concentric circular bands\n * @property {Number} [rotation=270] Rotates all slices by specified degree from 0 to 360.\n * @property {Number} [angleWidth=values%] Indicates the width of the Donut/Pie/ActivityGauge in degrees form 0 to 360.\n */\nexport class ActivityGauge extends Donut {\n\tdeclare add: (value: number, label: string) => void\n\tconstructor(o: number[] = [], o2: string[] = []) {\n\t\tsuper([], [])\n\t\tthis.data = {\n\t\t\tvalues: o != null ? o : [],\n\t\t\tlabels: o2 != null ? o2 : [],\n\t\t\tsource: null\n\t\t}\n\n\t\tthis.donutArray = []\n\t\tthis.maxWidth = 230\n\t\tthis.maxDrawWidth = this.maxWidth\n\n\t\tif (o != null) {\n\t\t\tfor (let i = 0; i < o.length; i++) {\n\t\t\t\tconst donutCenterSize = 40\n\t\t\t\tconst tmpDonut = donutCenterSize + ((100 - donutCenterSize) * i) / o.length\n\t\t\t\tconst tmpMaxRadius = donutCenterSize + ((100 - donutCenterSize) * (i + 1)) / o.length\n\t\t\t\tconst tmpAngleWidth = Math.abs((this.maxDrawWidth * o[o.length - 1 - i]) / this.maxValue())\n\t\t\t\tthis.donutArray.push(\n\t\t\t\t\tcreateDonut(o[o.length - 1 - i], o2[o.length - 1 - i], tmpDonut, tmpMaxRadius, tmpAngleWidth)\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tthis.clicked = function (p) {\n\t\t\tlet index = -1,\n\t\t\t\ti = 0\n\t\t\twhile (i < this.donutArray.length && index === -1) {\n\t\t\t\tif (index === -1 && this.donutArray[i].clicked(p) !== -1) index = this.donutArray.length - i - 1\n\t\t\t\ti++\n\t\t\t}\n\t\t\treturn index\n\t\t}\n\n\t\tfunction createDonut(value: number, label: string, tmpDonut: number, maxRadius: number, angleWidth: number) {\n\t\t\tconst donut = new Donut([value], [label])\n\t\t\tdonut.concentric = true\n\t\t\tdonut.marks.visible = false\n\t\t\tdonut.format.shadow.visible = false\n\t\t\tdonut.format.gradient.visible = false\n\t\t\tdonut.donut = tmpDonut\n\t\t\tdonut.maxRadius = maxRadius\n\t\t\tdonut.angleWidth = angleWidth\n\t\t\tdonut.rotation = 270\n\t\t\tdonut.visible = false\n\t\t\treturn donut\n\t\t}\n\n\t\tfunction copyFormat(donut: Donut, origin: ActivityGauge, colorNum: number) {\n\t\t\tconst donutFormat = donut.format\n\t\t\tconst originFormat = origin.format\n\t\t\tdonutFormat.fill =\n\t\t\t\torigin.chart.palette.colors[origin.donutArray.length - 1 - (colorNum % origin.chart.palette.colors.length)]\n\t\t\tdonutFormat.font.baseLine = originFormat.font.baseLine\n\t\t\tdonutFormat.font.fill = originFormat.font.fill\n\t\t\tdonutFormat.font.style = originFormat.font.style\n\t\t\tdonutFormat.font.textAlign = originFormat.font.textAlign\n\t\t\t// Each ring is painted with its own color: the gradient of the gauge only supplies its direction.\n\t\t\tdonutFormat.gradient.colors = [donutFormat.fill]\n\t\t\tdonutFormat.gradient.direction = originFormat.gradient.direction\n\t\t\tdonutFormat.gradient.offset.x = originFormat.gradient.offset.x\n\t\t\tdonutFormat.gradient.offset.y = originFormat.gradient.offset.y\n\t\t\tdonutFormat.gradient.stops = originFormat.gradient.stops\n\t\t\tdonutFormat.gradient.visible = originFormat.gradient.visible\n\t\t\tdonutFormat.round.x = originFormat.round.x\n\t\t\tdonutFormat.round.y = originFormat.round.y\n\t\t\tdonutFormat.shadow.blur = originFormat.shadow.blur\n\t\t\tdonutFormat.shadow.color = originFormat.shadow.color\n\t\t\tdonutFormat.shadow.height = originFormat.shadow.height\n\t\t\tdonutFormat.shadow.visible = originFormat.shadow.visible\n\t\t\tdonutFormat.shadow.width = originFormat.shadow.width\n\t\t\tdonutFormat.stroke.fill = originFormat.stroke.fill.slice(0)\n\t\t\tdonutFormat.stroke.cap = originFormat.stroke.cap\n\t\t\tdonutFormat.stroke.dash = originFormat.stroke.dash\n\t\t\tdonutFormat.stroke.join = originFormat.stroke.join\n\t\t\tdonutFormat.stroke.size = originFormat.stroke.size\n\t\t\tdonutFormat.transparency = originFormat.transparency\n\t\t\tdonut.fill = (_i: number) =>\n\t\t\t\tdonut.getFillStyle(\n\t\t\t\t\tnew Rectangle(\n\t\t\t\t\t\tdonut.center.x - donut.radius,\n\t\t\t\t\t\tdonut.center.y - donut.radius,\n\t\t\t\t\t\tdonut.radius * 2,\n\t\t\t\t\t\tdonut.radius * 2\n\t\t\t\t\t),\n\t\t\t\t\tdonutFormat.fill\n\t\t\t\t)\n\t\t}\n\n\t\tthis.add = function (value, label) {\n\t\t\tconst donut = createDonut(value, label, 0, 0, 0)\n\t\t\tthis.donutArray.push(donut)\n\t\t\tthis.data.values.push(value)\n\t\t\tthis.data.labels.push(label)\n\t\t\tif (this.chart != null) this.linkDonutsToChart()\n\t\t}\n\n\t\tthis.draw = function () {\n\t\t\tfor (let i = 0; i < this.donutArray.length; i++) {\n\t\t\t\tconst c = this.donutArray[i].chart.drawContext\n\t\t\t\tcopyFormat(this.donutArray[i], this, i)\n\t\t\t\tc.fillStyle = this.donutArray[i].getFillStyle(\n\t\t\t\t\tthis.donutArray[i].chart.chartRect,\n\t\t\t\t\tthis.donutArray[i].format.fill\n\t\t\t\t)\n\t\t\t\tthis.recalcWidth()\n\t\t\t\tthis.donutArray[i].draw()\n\t\t\t}\n\t\t}\n\t}\n\n\taddRandom(count: number): ActivityGauge {\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tthis.add(Math.floor(Math.random() * 20 + 10), String.fromCharCode(65 + i))\n\t\t}\n\t\treturn this\n\t}\n\n\tmaxValue(): number {\n\t\tlet temporaryValue = this.data.values[0]\n\t\tfor (let i = 0; i < this.data.values.length; i++) {\n\t\t\tif (temporaryValue < this.data.values[i]) temporaryValue = this.data.values[i]\n\t\t}\n\t\treturn temporaryValue\n\t}\n\n\tlinkDonutsToChart(): void {\n\t\tfor (let i = 0; i < this.donutArray.length; i++) {\n\t\t\tthis.donutArray[i].setChart(this.donutArray[i], this.chart)\n\t\t}\n\t}\n\n\tminValue(): number {\n\t\tlet temporaryValue = this.data.values[0]\n\t\tfor (let i = 0; i < this.data.values.length; i++) {\n\t\t\tif (temporaryValue > this.data.values[i]) temporaryValue = this.data.values[i]\n\t\t}\n\t\treturn temporaryValue\n\t}\n\n\trecalcWidth(): void {\n\t\tfor (let i = 0; i < this.donutArray.length; i++) {\n\t\t\tconst donutCenterSize = 40\n\t\t\tthis.donutArray[i].donut = donutCenterSize + ((100 - donutCenterSize) * i) / this.data.values.length\n\t\t\tthis.donutArray[i].maxRadius = donutCenterSize + ((100 - donutCenterSize) * (i + 1)) / this.data.values.length\n\t\t\tthis.donutArray[i].angleWidth = Math.abs(\n\t\t\t\t(Number(this.maxDrawWidth) * this.data.values[this.data.values.length - 1 - i]) / this.maxValue()\n\t\t\t)\n\t\t}\n\t}\n}\n","import type { GaugeBand } from \"../chart-options.js\"\nimport type { Point, Rectangle } from \"../core/primitives.js\"\nimport { Series } from \"../series.js\"\nimport type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { BaseAnimation } from \"../tools/index.js\"\n\ninterface ArcGaugeMouse extends Point {\n\tvalue: number\n}\n\ninterface ArcLayout {\n\tcx: number\n\tcy: number\n\tradius: number\n\tstart: number\n\tsweep: number\n}\n\nconst DEGREES = Math.PI / 180\nconst FONT_FAMILY = \"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\"\n\n/** Bounding box of an arc of radius 1 centered on the origin, including the center when the arc is open. */\nfunction arcExtent(start: number, sweep: number): { minX: number; maxX: number; minY: number; maxY: number } {\n\tconst angles = [start, start + sweep]\n\tfor (let quarter = Math.ceil(start / (Math.PI / 2)); quarter * (Math.PI / 2) < start + sweep; quarter++) {\n\t\tangles.push(quarter * (Math.PI / 2))\n\t}\n\tconst xs = angles.map(Math.cos)\n\tconst ys = angles.map(Math.sin)\n\tif (sweep < 2 * Math.PI) {\n\t\txs.push(0)\n\t\tys.push(0)\n\t}\n\treturn { minX: Math.min(...xs), maxX: Math.max(...xs), minY: Math.min(...ys), maxY: Math.max(...ys) }\n}\n\n/**\n * @class A flat radial gauge: a track and a rounded arc that grows with the value. The sweep goes from a\n * semicircle (`angle = 180`) to a complete ring (`angle = 360`).\n * @property {Number} [min=0] The value at the start of the track.\n * @property {Number} [max=100] The value at the end of the track.\n * @property {Number} [value=0] The current value.\n * @property {Number} [angle=240] Degrees covered by the track.\n * @property {Number} [rotation=0] Degrees the track is turned clockwise; 0 leaves the gap at the bottom.\n * @property {Number} [thickness=14] Track width as a percentage of the radius.\n * @property {Boolean} [roundCaps=true] Rounds the ends of the track and the arc.\n * @property {Boolean} [inverted=false] Fills from the end of the track instead of from the start.\n */\nexport class ArcGauge extends Series {\n\tuseAxes = false\n\tmin = 0\n\tmax = 100\n\tvalue = 0\n\tangle = 240\n\trotation = 0\n\tthickness = 14\n\troundCaps = true\n\tinverted = false\n\t/** Value that snaps dragging, 0 for none. */\n\tstep = 0\n\t/** Colors the arc by the band that contains the value. */\n\tranges: GaugeBand[] = []\n\t/** A value marked with a short line across the track. */\n\ttarget: number | undefined\n\t/** Draws a knob at the end of the arc. */\n\tknob = false\n\t/** Text under the value. */\n\tcaption = \"\"\n\t/** Text next to the value, such as \"%\" or \"km/h\". */\n\tunits = \"\"\n\t/** Draws `min` and `max` under the ends of the track; a complete ring has no ends. */\n\tlimits = true\n\t/** Draws the value in the middle. */\n\tshowValue = true\n\tformatValue: ((value: number) => string) | undefined\n\ttrackColor = \"#e2e8f0\"\n\ttextColor = \"#0f172a\"\n\tmutedColor = \"#64748b\"\n\t/** Fill of the knob; use the color of the surface the gauge is drawn on. */\n\tsurfaceColor = \"#ffffff\"\n\tdrag = { enabled: false }\n\tonchange: ((gauge: ArcGauge) => void) | undefined\n\tdragging = false\n\tprivate frame: Rectangle\n\t_oldValue = 0\n\t_newValue = 0\n\tprivate layout: ArcLayout = { cx: 0, cy: 0, radius: 0, start: 0, sweep: 0 }\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\t\tthis.legend.visible = false\n\t\tthis.marks.visible = false\n\t\tthis.frame = this.getRect()\n\n\t\tthis.animate = new BaseAnimation(this.chart, f => {\n\t\t\tthis.value = this._oldValue + f * (this._newValue - this._oldValue)\n\t\t\tthis.chart.draw()\n\t\t})\n\t\tthis.animate.duration = 400\n\t\tthis.animate.onstop = () => {\n\t\t\tthis.value = this._newValue\n\t\t\tthis.onchange?.(this)\n\t\t\tthis._emit(\"change\", this)\n\t\t\tthis.chart.draw()\n\t\t}\n\t}\n\n\tcalcBounds(): Rectangle {\n\t\treturn this.cellRect(this.frame, true)\n\t}\n\n\tlimitValue(value: number): number {\n\t\treturn Math.min(this.max, Math.max(this.min, value))\n\t}\n\n\t/** Color of the arc for `value`: the band that contains it, or the fill of the series. */\n\tcolorAt(value: number): string {\n\t\tfor (const band of this.ranges) if (value <= band.to) return band.color\n\t\treturn this.ranges.length > 0 ? this.ranges[this.ranges.length - 1].color : this.format.fill || \"#3b82f6\"\n\t}\n\n\t/** Sets the value, animating the arc when the animation is active. Returns whether the value changed. */\n\tsetValue(value: number, animated = true): boolean {\n\t\tconst next = this.limitValue(value)\n\t\tif (next === this.value) return false\n\n\t\tconst animate = this.animate\n\t\tif (animated && animate?.active && animate.duration > 0) {\n\t\t\tthis._oldValue = this.value\n\t\t\tthis._newValue = next\n\t\t\tanimate.animate(this.chart)\n\t\t} else {\n\t\t\tthis.value = next\n\t\t\tthis.onchange?.(this)\n\t\t\tthis._emit(\"change\", this)\n\t\t}\n\t\treturn true\n\t}\n\n\tprivate text(value: number): string {\n\t\tif (this.formatValue) return this.formatValue(value)\n\t\tconst scale = 10 ** this.decimals\n\t\treturn String(Math.round(value * scale) / scale)\n\t}\n\n\tdraw(): void {\n\t\tconst ctx = this.chart.drawContext\n\t\tconst area = this.calcBounds()\n\t\tconst sweep = Math.min(360, Math.max(1, this.angle)) * DEGREES\n\t\t// A complete ring starts at the top; an open one is centered on the gap at the bottom.\n\t\tconst start = ((sweep >= 2 * Math.PI ? 270 : 90 + (360 - sweep / DEGREES) / 2) + this.rotation) * DEGREES\n\t\tconst extent = arcExtent(start, sweep)\n\t\tconst width = Math.min(0.5, Math.max(0.01, this.thickness * 0.01))\n\t\tconst closed = sweep >= 2 * Math.PI\n\t\tconst showLimits = this.limits && !closed\n\t\tconst below = showLimits ? 0.2 : 0\n\n\t\tconst radius =\n\t\t\tMath.min(\n\t\t\t\tarea.width / (extent.maxX - extent.minX + width),\n\t\t\t\tarea.height / (extent.maxY - extent.minY + width + below)\n\t\t\t) * 0.98\n\t\tconst cx = area.x + area.width * 0.5 - ((extent.minX + extent.maxX) / 2) * radius\n\t\tconst cy = area.y + area.height * 0.5 - ((extent.minY + extent.maxY + below) / 2) * radius\n\t\tthis.layout = { cx, cy, radius, start, sweep }\n\n\t\tif (!(radius > 0)) return\n\n\t\tconst range = this.max - this.min || 1\n\t\tconst fraction = Math.min(1, Math.max(0, (this.value - this.min) / range))\n\t\tconst lineWidth = width * radius\n\n\t\tctx.save()\n\t\tctx.lineCap = this.roundCaps ? \"round\" : \"butt\"\n\t\tctx.lineWidth = lineWidth\n\n\t\tctx.beginPath()\n\t\tctx.arc(cx, cy, radius, start, start + sweep, false)\n\t\tctx.strokeStyle = this.trackColor\n\t\tctx.stroke()\n\n\t\tconst color = this.colorAt(this.value)\n\t\tif (fraction > 0) {\n\t\t\tctx.beginPath()\n\t\t\tif (this.inverted) ctx.arc(cx, cy, radius, start + sweep * (1 - fraction), start + sweep, false)\n\t\t\telse ctx.arc(cx, cy, radius, start, start + sweep * fraction, false)\n\t\t\tctx.strokeStyle = color\n\t\t\tctx.stroke()\n\t\t}\n\n\t\t// Target line across the track.\n\t\tif (this.target !== undefined) {\n\t\t\tconst place = Math.min(1, Math.max(0, (this.target - this.min) / range))\n\t\t\tconst angle = start + sweep * (this.inverted ? 1 - place : place)\n\t\t\tconst inner = radius - lineWidth * 0.75\n\t\t\tconst outer = radius + lineWidth * 0.75\n\t\t\tctx.beginPath()\n\t\t\tctx.moveTo(cx + Math.cos(angle) * inner, cy + Math.sin(angle) * inner)\n\t\t\tctx.lineTo(cx + Math.cos(angle) * outer, cy + Math.sin(angle) * outer)\n\t\t\tctx.lineCap = \"butt\"\n\t\t\tctx.lineWidth = Math.max(2, lineWidth * 0.14)\n\t\t\tctx.strokeStyle = this.textColor\n\t\t\tctx.stroke()\n\t\t}\n\n\t\tif (this.knob) {\n\t\t\tconst angle = start + sweep * (this.inverted ? 1 - fraction : fraction)\n\t\t\tctx.beginPath()\n\t\t\tctx.arc(cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius, lineWidth * 0.78, 0, 2 * Math.PI)\n\t\t\tctx.fillStyle = this.surfaceColor\n\t\t\tctx.fill()\n\t\t\tctx.lineWidth = Math.max(2, lineWidth * 0.2)\n\t\t\tctx.strokeStyle = color\n\t\t\tctx.stroke()\n\t\t}\n\n\t\tctx.textAlign = \"center\"\n\t\tctx.textBaseline = \"middle\"\n\n\t\tif (showLimits) {\n\t\t\tconst size = Math.max(9, radius * 0.115)\n\t\t\tctx.font = `${size}px ${FONT_FAMILY}`\n\t\t\tctx.fillStyle = this.mutedColor\n\t\t\tconst label = (value: number, angle: number) =>\n\t\t\t\tctx.fillText(\n\t\t\t\t\tthis.text(value),\n\t\t\t\t\tcx + Math.cos(angle) * radius,\n\t\t\t\t\tcy + Math.sin(angle) * radius + lineWidth * 0.5 + size * 0.9\n\t\t\t\t)\n\t\t\tlabel(this.inverted ? this.max : this.min, start)\n\t\t\tlabel(this.inverted ? this.min : this.max, start + sweep)\n\t\t}\n\n\t\tif (this.showValue) this.drawValue(radius, width, extent.maxY <= 0.1, cx, cy)\n\n\t\tctx.restore()\n\t}\n\n\tprivate drawValue(radius: number, width: number, open: boolean, cx: number, cy: number): void {\n\t\tconst ctx = this.chart.drawContext\n\t\tconst text = this.text(this.value)\n\t\tconst room = radius * (2 - width) * 0.8\n\t\tconst caption = this.caption !== \"\"\n\n\t\tlet size = radius * (open ? 0.36 : 0.5)\n\t\tctx.font = `600 ${size}px ${FONT_FAMILY}`\n\t\tconst units = this.units !== \"\"\n\t\tconst unitsSize = () => size * 0.42\n\t\tconst measure = () => {\n\t\t\tctx.font = `600 ${size}px ${FONT_FAMILY}`\n\t\t\tconst value = ctx.measureText(text).width\n\t\t\tctx.font = `500 ${unitsSize()}px ${FONT_FAMILY}`\n\t\t\treturn value + (units ? ctx.measureText(this.units).width + size * 0.12 : 0)\n\t\t}\n\n\t\tlet total = measure()\n\t\tif (total > room) {\n\t\t\tsize *= room / total\n\t\t\ttotal = measure()\n\t\t}\n\n\t\t// Half open gauges keep the value just above the center line, closed ones center it.\n\t\tconst captionSize = Math.max(9, size * 0.34)\n\t\tconst block = size + (caption ? captionSize * 1.5 : 0)\n\t\tconst top = open ? cy - radius * 0.1 - block : cy - block * 0.5\n\t\tconst baseline = top + size * 0.5\n\n\t\tctx.font = `600 ${size}px ${FONT_FAMILY}`\n\t\tconst valueWidth = ctx.measureText(text).width\n\t\tconst left = cx - total * 0.5\n\n\t\tctx.textAlign = \"left\"\n\t\tctx.fillStyle = this.textColor\n\t\tctx.fillText(text, left, baseline)\n\n\t\tif (units) {\n\t\t\tctx.font = `500 ${unitsSize()}px ${FONT_FAMILY}`\n\t\t\tctx.fillStyle = this.mutedColor\n\t\t\tctx.textBaseline = \"alphabetic\"\n\t\t\tctx.fillText(this.units, left + valueWidth + size * 0.12, baseline + size * 0.3)\n\t\t\tctx.textBaseline = \"middle\"\n\t\t}\n\n\t\tif (caption) {\n\t\t\tctx.textAlign = \"center\"\n\t\t\tctx.font = `500 ${captionSize}px ${FONT_FAMILY}`\n\t\t\tctx.fillStyle = this.mutedColor\n\t\t\tctx.fillText(this.caption, cx, top + size + captionSize * 0.9)\n\t\t}\n\t}\n\n\t/** The value at the canvas position `p`, snapped to `step`, or null when `p` is not on the track. */\n\tvalueAt(p: Point, anywhere = false): number | null {\n\t\tconst { cx, cy, radius, start, sweep } = this.layout\n\t\tconst dx = p.x - cx\n\t\tconst dy = p.y - cy\n\t\tconst distance = Math.hypot(dx, dy)\n\t\tconst slop = Math.max(this.thickness * 0.01 * radius * 1.2, 12)\n\t\tif (!anywhere && Math.abs(distance - radius) > slop) return null\n\n\t\tlet relative = Math.atan2(dy, dx) - start\n\t\trelative = ((relative % (2 * Math.PI)) + 2 * Math.PI) % (2 * Math.PI)\n\t\t// The gap belongs to the nearest end of the track.\n\t\tif (relative > sweep) relative = relative - sweep < (2 * Math.PI - sweep) / 2 ? sweep : 0\n\n\t\tconst place = relative / sweep\n\t\tconst range = this.max - this.min\n\t\tlet value = this.inverted ? this.max - place * range : this.min + place * range\n\t\tif (this.step > 0) value = this.min + Math.round((value - this.min) / this.step) * this.step\n\t\treturn this.limitValue(value)\n\t}\n\n\tmousedown(e: Event): boolean {\n\t\tif (!this.drag.enabled) return false\n\n\t\tconst p: ArcGaugeMouse = { x: 0, y: 0, value: 0 }\n\t\tthis.chart.calcMouse(e, p)\n\t\tconst value = this.valueAt(p)\n\t\tthis.dragging = value !== null\n\t\tif (value !== null && this.setValue(value, false)) this.chart.draw()\n\t\treturn this.dragging\n\t}\n\n\tmousemove(p: Point): void {\n\t\tif (!this.drag.enabled) return\n\n\t\tif (this.dragging) {\n\t\t\tconst value = this.valueAt(p, true)\n\t\t\tif (value !== null && this.setValue(value, false)) this.chart.draw()\n\t\t\tthis.chart.newCursor = \"pointer\"\n\t\t} else if (this.valueAt(p) !== null) this.chart.newCursor = \"pointer\"\n\t}\n\n\tclicked(): number {\n\t\tthis.dragging = false\n\t\treturn -1\n\t}\n}\n","import type { Point } from \"../core/primitives.js\"\nimport { Series, type TooltipParts } from \"../series.js\"\nimport type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { quantile } from \"../series-utils.js\"\n\n/** Five-number summary of a box, with the values that fall outside the whiskers. */\nexport interface BoxPlotSummary {\n\tmin: number\n\tq1: number\n\tmedian: number\n\tq3: number\n\tmax: number\n\t/** Values beyond the whiskers. */\n\toutliers?: number[]\n\tmean?: number\n\tcount?: number\n}\n\n/**\n * One box: a name and either the raw `values` to summarize or an already computed summary\n * (`min`, `q1`, `median`, `q3`, `max`). When `values` is given, the summary fields are ignored.\n */\nexport interface BoxPlotGroup extends Partial<BoxPlotSummary> {\n\tname?: string\n\tvalues?: number[]\n\t/** Overrides the palette color of the box. */\n\tcolor?: string\n}\n\n/** Where the whiskers end: at the farthest value within `whiskerRange` times the IQR, or at the minimum and maximum. */\nexport type BoxPlotWhisker = \"tukey\" | \"minmax\"\n\n/** Where the whiskers end: at the farthest value inside the fences (\"nearest\") or at the fences themselves (\"exact\"). */\nexport type BoxPlotWhiskerMode = \"nearest\" | \"exact\"\n\n/** Quartiles of sorted values, as returned by a custom quantile method. */\nexport interface BoxPlotQuartiles {\n\tq1: number\n\tmedian: number\n\tq3: number\n}\n\n/**\n * How the quartiles are computed from raw values. `7` (also \"quantiles\" and \"linear\") interpolates linearly, as R's\n * type 7 does; \"hinges\" and \"fivenum\" are Tukey's hinges; \"lower\", \"higher\", \"nearest\" and \"midpoint\" pick\n * values without interpolating. A function receives the sorted values and returns the quartiles.\n */\nexport type BoxPlotQuantiles =\n\t| 7\n\t| \"quantiles\"\n\t| \"linear\"\n\t| \"hinges\"\n\t| \"fivenum\"\n\t| \"lower\"\n\t| \"higher\"\n\t| \"nearest\"\n\t| \"midpoint\"\n\t| ((sorted: number[]) => BoxPlotQuartiles)\n\n/** Statistic that sets the lowest or highest value of the value axis. */\nexport type BoxPlotLimit = \"extreme\" | \"box\" | \"whisker\"\n\n/** Summary of the values of a box. */\nexport interface BoxPlotStats extends BoxPlotSummary {\n\toutliers: number[]\n\t/** Ends of the whiskers. */\n\tlow: number\n\thigh: number\n}\n\ninterface Box {\n\tname: string\n\tcolor: string | undefined\n\tstats: BoxPlotStats\n\t/** The finite raw values, sorted; empty for precomputed summaries. */\n\tvalues: number[]\n}\n\n/**\n * @constructor\n * @augments Tee.Series\n * @class Draws a box and whiskers for each group: the box spans the first to the third quartile with the median\n * marked inside, the whiskers reach the lowest and highest regular value and the values beyond them are drawn as\n * outliers. Each group is given as raw values, which `setData` summarizes, or as an already computed summary.\n *\n * Points are the groups: `data.values` holds the median of each group and `data.labels` its name.\n * @property {String} [whisker=\"tukey\"] \"tukey\" ends the whiskers at the farthest value within `whiskerRange` times the interquartile range; \"minmax\" at the extremes, with no outliers.\n * @property {Number} [whiskerRange=1.5] Multiple of the interquartile range used by the \"tukey\" whiskers.\n * @property {String} [whiskerMode=\"nearest\"] \"nearest\" ends the whiskers at the farthest value inside the fences; \"exact\" at the fences, limited to the data.\n * @property {Number|String|Function} [quantiles=7] How quartiles are computed: 7 (or \"linear\"), \"hinges\", \"lower\", \"higher\", \"nearest\", \"midpoint\" or a function of the sorted values.\n * @property {String} [minStats=\"extreme\"] What sets the lowest value of the axis: the \"extreme\" value (outliers included when shown), the \"box\" (Q1) or the \"whisker\".\n * @property {String} [maxStats=\"extreme\"] Same for the highest value: \"extreme\", \"box\" (Q3) or \"whisker\".\n * @property {Boolean} [showPoints=false] Draws every raw value as a dot, spread sideways by `jitter`.\n * @property {Number} [pointRadius=2.5] Radius of those dots, in pixels.\n * @property {Number} [jitter=0.5] Sideways spread of the dots, from 0 (on the center line) to 1 (the whole width of the box).\n * @property {Number} [width=60] Width of a box, in percent of the space of its category.\n * @property {Boolean} [showOutliers=true] Draws the values beyond the whiskers.\n * @property {Boolean} [showMean=false] Marks the mean of each group with a diamond (only for raw values).\n */\nexport class BoxPlot extends Series {\n\tcolorEach = \"yes\"\n\twhisker: BoxPlotWhisker = \"tukey\"\n\twhiskerRange = 1.5\n\twhiskerMode: BoxPlotWhiskerMode = \"nearest\"\n\tquantiles: BoxPlotQuantiles = 7\n\tminStats: BoxPlotLimit = \"extreme\"\n\tmaxStats: BoxPlotLimit = \"extreme\"\n\tshowPoints = false\n\tpointRadius = 2.5\n\tjitter = 0.5\n\twidth = 60\n\tshowOutliers = true\n\tshowMean = false\n\t/** Opacity of the fill of the box, from 0 to 1. */\n\tfillOpacity = 0.55\n\tlineWidth = 2\n\tmedianColor = \"#111827\"\n\t/** Outline of the mean and outlier markers. */\n\tdotStroke = \"#ffffff\"\n\tformatValue: ((value: number) => string) | undefined\n\t/** The groups as given. */\n\tsource: BoxPlotGroup[] = []\n\tboxes: Box[] = []\n\tcontinuous = false\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\t\tthis.hover.enabled = true\n\t\tthis.format.shadow.visible = false\n\t}\n\n\t/**\n\t * Replaces the groups. Each item is a `BoxPlotGroup` or a plain array of raw values; `labels` name the groups\n\t * that have no name. A flat list of numbers is one group.\n\t */\n\tsetData(\n\t\tgroups: Iterable<number> | Iterable<BoxPlotGroup | number[]>,\n\t\tlabels?: Iterable<string> | null,\n\t\tredraw = true\n\t): this {\n\t\tif (!groups || typeof groups[Symbol.iterator] !== \"function\") {\n\t\t\tthrow new TypeError(\"BoxPlot.setData requires an iterable collection of groups\")\n\t\t}\n\t\tconst items = Array.from(groups as Iterable<number | number[] | BoxPlotGroup>)\n\t\tconst names = labels == null ? [] : Array.from(labels)\n\t\tconst list = items.length > 0 && items.every(item => typeof item === \"number\") ? [items as number[]] : items\n\n\t\tthis.source = (list as Array<number[] | BoxPlotGroup>).map((item, index) => {\n\t\t\tconst group = Array.isArray(item) ? { values: item } : item\n\t\t\treturn { ...group, name: group.name ?? names[index] ?? String(index + 1) }\n\t\t})\n\t\treturn this.rebuild(redraw)\n\t}\n\n\t/** Summarizes the groups again; call it after changing `whisker`, `whiskerRange`, `whiskerMode` or `quantiles`. */\n\trebuild(redraw = true): this {\n\t\tthis.boxes = this.source.map(group => ({\n\t\t\tname: group.name ?? \"\",\n\t\t\tcolor: group.color,\n\t\t\tstats: this.summarize(group),\n\t\t\tvalues: group.values ? group.values.filter(Number.isFinite).sort((a, b) => a - b) : []\n\t\t}))\n\t\tthis.data.values = this.boxes.map(box => box.stats.median)\n\t\tthis.data.labels = this.boxes.map(box => box.name)\n\t\tif (redraw) this.chart?.draw()\n\t\treturn this\n\t}\n\n\t/** The summary of the `index`th box. */\n\tstatsOf(index: number): BoxPlotStats | undefined {\n\t\treturn this.boxes[index]?.stats\n\t}\n\n\tprivate summarize(group: BoxPlotGroup): BoxPlotStats {\n\t\tif (group.values) return this.fromValues(group.values)\n\n\t\tconst { min = 0, q1 = 0, median = 0, q3 = 0, max = 0 } = group\n\t\tconst outliers = (group.outliers ?? []).filter(Number.isFinite)\n\t\treturn {\n\t\t\tmin,\n\t\t\tq1,\n\t\t\tmedian,\n\t\t\tq3,\n\t\t\tmax,\n\t\t\toutliers,\n\t\t\tmean: group.mean,\n\t\t\tcount: group.count,\n\t\t\tlow: min,\n\t\t\thigh: max\n\t\t}\n\t}\n\n\tprivate fromValues(raw: number[]): BoxPlotStats {\n\t\tconst values = raw.filter(Number.isFinite).sort((a, b) => a - b)\n\t\tconst count = values.length\n\t\tif (count === 0) return { min: 0, q1: 0, median: 0, q3: 0, max: 0, outliers: [], count, low: 0, high: 0 }\n\n\t\tconst { q1, median, q3 } = this.quartiles(values)\n\t\tlet low = values[0]\n\t\tlet high = values[count - 1]\n\t\tlet outliers: number[] = []\n\t\tif (this.whisker === \"tukey\") {\n\t\t\tconst fenceLow = q1 - this.whiskerRange * (q3 - q1)\n\t\t\tconst fenceHigh = q3 + this.whiskerRange * (q3 - q1)\n\t\t\tconst inside = values.filter(value => value >= fenceLow && value <= fenceHigh)\n\t\t\toutliers = values.filter(value => value < fenceLow || value > fenceHigh)\n\t\t\tif (this.whiskerMode === \"exact\") {\n\t\t\t\t// The fences, but never beyond the data.\n\t\t\t\tlow = Math.max(values[0], fenceLow)\n\t\t\t\thigh = Math.min(values[count - 1], fenceHigh)\n\t\t\t} else if (inside.length > 0) {\n\t\t\t\tlow = inside[0]\n\t\t\t\thigh = inside[inside.length - 1]\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tmin: values[0],\n\t\t\tq1,\n\t\t\tmedian,\n\t\t\tq3,\n\t\t\tmax: values[count - 1],\n\t\t\toutliers,\n\t\t\tmean: values.reduce((sum, value) => sum + value, 0) / count,\n\t\t\tcount,\n\t\t\tlow,\n\t\t\thigh\n\t\t}\n\t}\n\n\t/** The quartiles of sorted values by the chosen method. */\n\tprivate quartiles(sorted: number[]): BoxPlotQuartiles {\n\t\tconst method = this.quantiles\n\t\tif (typeof method === \"function\") return method(sorted)\n\t\tif (method === \"hinges\" || method === \"fivenum\") return fivenum(sorted)\n\n\t\tconst pick = (fraction: number): number => {\n\t\t\tconst position = (sorted.length - 1) * fraction\n\t\t\tswitch (method) {\n\t\t\t\tcase \"lower\":\n\t\t\t\t\treturn sorted[Math.floor(position)]\n\t\t\t\tcase \"higher\":\n\t\t\t\t\treturn sorted[Math.ceil(position)]\n\t\t\t\tcase \"nearest\":\n\t\t\t\t\treturn sorted[Math.round(position)]\n\t\t\t\tcase \"midpoint\":\n\t\t\t\t\treturn (sorted[Math.floor(position)] + sorted[Math.ceil(position)]) / 2\n\t\t\t\tdefault:\n\t\t\t\t\treturn quantile(sorted, fraction)\n\t\t\t}\n\t\t}\n\t\treturn { q1: pick(0.25), median: pick(0.5), q3: pick(0.75) }\n\t}\n\n\t/** Half the pixel width of a category slot used by a box. */\n\tprivate halfWidth(): number {\n\t\tconst axis = this.notmandatory\n\t\treturn (Math.abs(axis.calc(1) - axis.calc(0)) * this.width * 0.01) / 2\n\t}\n\n\tprivate box(index: number): { x: number; half: number; top: number; bottom: number } | undefined {\n\t\tconst box = this.boxes[index]\n\t\tif (!box) return undefined\n\t\tconst axis = this.mandatoryAxis\n\t\tconst top = axis.calc(box.stats.q3)\n\t\tconst bottom = axis.calc(box.stats.q1)\n\t\treturn {\n\t\t\tx: this.notmandatory.calc(index),\n\t\t\thalf: this.halfWidth(),\n\t\t\ttop: Math.min(top, bottom),\n\t\t\tbottom: Math.max(top, bottom)\n\t\t}\n\t}\n\n\tdraw(): void {\n\t\tconst ctx = this.chart.ctx\n\t\tif (!ctx || this.boxes.length === 0) return\n\t\tconst rect = this.chart.chartRect\n\t\tconst axis = this.mandatoryAxis\n\n\t\tctx.save()\n\t\tctx.beginPath()\n\t\tctx.rect(rect.x, rect.y, rect.width, rect.height)\n\t\tctx.clip()\n\n\t\tfor (let index = 0; index < this.boxes.length; index++) {\n\t\t\tconst geometry = this.box(index)\n\t\t\tif (!geometry) continue\n\n\t\t\tconst { stats } = this.boxes[index]\n\t\t\tconst { x, half, top, bottom } = geometry\n\t\t\tconst color = this.boxes[index].color ?? this.getFill(index, this.format)\n\t\t\tconst hovered = this.hover.enabled && this.over === index\n\t\t\tconst cap = half * 0.5\n\n\t\t\tctx.lineWidth = Math.max(1, this.lineWidth) + (hovered ? 1 : 0)\n\t\t\tctx.strokeStyle = color\n\t\t\tctx.lineJoin = \"round\"\n\n\t\t\t// Whiskers with their caps.\n\t\t\tconst yLow = axis.calc(stats.low)\n\t\t\tconst yHigh = axis.calc(stats.high)\n\t\t\tctx.beginPath()\n\t\t\tctx.moveTo(x, bottom)\n\t\t\tctx.lineTo(x, yLow)\n\t\t\tctx.moveTo(x, top)\n\t\t\tctx.lineTo(x, yHigh)\n\t\t\tctx.moveTo(x - cap, yLow)\n\t\t\tctx.lineTo(x + cap, yLow)\n\t\t\tctx.moveTo(x - cap, yHigh)\n\t\t\tctx.lineTo(x + cap, yHigh)\n\t\t\tctx.stroke()\n\n\t\t\t// The box from the first to the third quartile.\n\t\t\tctx.globalAlpha = Math.min(1, this.fillOpacity + (hovered ? 0.2 : 0))\n\t\t\tctx.fillStyle = color\n\t\t\tctx.fillRect(x - half, top, half * 2, bottom - top)\n\t\t\tctx.globalAlpha = 1\n\t\t\tctx.strokeRect(x - half, top, half * 2, bottom - top)\n\n\t\t\t// The median.\n\t\t\tconst median = axis.calc(stats.median)\n\t\t\tctx.strokeStyle = this.medianColor\n\t\t\tctx.lineWidth = 2.5\n\t\t\tctx.beginPath()\n\t\t\tctx.moveTo(x - half, median)\n\t\t\tctx.lineTo(x + half, median)\n\t\t\tctx.stroke()\n\n\t\t\tif (this.showPoints) {\n\t\t\t\tconst radius = Math.max(1, this.pointRadius)\n\t\t\t\tconst spread = half * Math.min(1, Math.max(0, this.jitter))\n\t\t\t\tconst next = jitterSequence(index + 1)\n\t\t\t\tfor (const value of this.boxes[index].values) {\n\t\t\t\t\tconst offset = (next() * 2 - 1) * spread\n\t\t\t\t\tthis.marker(ctx, x + offset, axis.calc(value), radius, color, false)\n\t\t\t\t}\n\t\t\t} else if (this.showOutliers) {\n\t\t\t\tfor (const value of stats.outliers) this.marker(ctx, x, axis.calc(value), 3.5, color, false)\n\t\t\t}\n\t\t\tif (this.showMean && stats.mean !== undefined) this.marker(ctx, x, axis.calc(stats.mean), 5, color, true)\n\t\t}\n\n\t\tctx.restore()\n\t}\n\n\t/** A circle for an outlier, a diamond for the mean. */\n\tprivate marker(\n\t\tctx: CanvasRenderingContext2D,\n\t\tx: number,\n\t\ty: number,\n\t\tsize: number,\n\t\tcolor: string,\n\t\tdiamond: boolean\n\t): void {\n\t\tctx.beginPath()\n\t\tif (diamond) {\n\t\t\tctx.moveTo(x, y - size)\n\t\t\tctx.lineTo(x + size, y)\n\t\t\tctx.lineTo(x, y + size)\n\t\t\tctx.lineTo(x - size, y)\n\t\t\tctx.closePath()\n\t\t} else {\n\t\t\tctx.arc(x, y, size, 0, Math.PI * 2)\n\t\t}\n\t\tctx.fillStyle = diamond ? this.medianColor : color\n\t\tctx.fill()\n\t\tctx.lineWidth = 1.5\n\t\tctx.strokeStyle = this.dotStroke\n\t\tctx.stroke()\n\t}\n\n\t/** The box under `p`, including its whiskers, or -1. */\n\tclicked(p: Point): number {\n\t\tconst axis = this.mandatoryAxis\n\t\tfor (let index = this.boxes.length - 1; index >= 0; index--) {\n\t\t\tconst geometry = this.box(index)\n\t\t\tif (!geometry) continue\n\n\t\t\tconst { stats } = this.boxes[index]\n\t\t\tconst { x, half, top, bottom } = geometry\n\t\t\tif (Math.abs(p.x - x) <= half && p.y >= top && p.y <= bottom) return index\n\n\t\t\tconst a = axis.calc(stats.low)\n\t\t\tconst b = axis.calc(stats.high)\n\t\t\tif (Math.abs(p.x - x) <= 3 && p.y >= Math.min(a, b) && p.y <= Math.max(a, b)) return index\n\t\t}\n\t\treturn -1\n\t}\n\n\tprivate formatNumber(value: number): string {\n\t\treturn this.formatValue ? this.formatValue(value) : String(Math.round(value * 100) / 100)\n\t}\n\n\tvalueText(index: number): string {\n\t\tconst stats = this.boxes[index]?.stats\n\t\treturn stats ? this.formatNumber(stats.median) : \"0\"\n\t}\n\n\ttooltipParts(index: number): TooltipParts | undefined {\n\t\tconst box = this.boxes[index]\n\t\tif (!box) return undefined\n\t\tconst { stats } = box\n\t\tconst details: Array<[string, string]> = []\n\t\tif (stats.count !== undefined) details.push([\"Values\", String(stats.count)])\n\t\tdetails.push(\n\t\t\t[\"Maximum\", this.formatNumber(stats.max)],\n\t\t\t[\"Q3\", this.formatNumber(stats.q3)],\n\t\t\t[\"Median\", this.formatNumber(stats.median)],\n\t\t\t[\"Q1\", this.formatNumber(stats.q1)],\n\t\t\t[\"Minimum\", this.formatNumber(stats.min)]\n\t\t)\n\t\tif (stats.mean !== undefined) details.push([\"Mean\", this.formatNumber(stats.mean)])\n\t\tif (stats.outliers.length > 0) details.push([\"Outliers\", String(stats.outliers.length)])\n\t\treturn {\n\t\t\tlabel: box.name,\n\t\t\tvalue: this.formatNumber(stats.median),\n\t\t\tcolor: box.color ?? this.getFill(index),\n\t\t\tdetails\n\t\t}\n\t}\n\n\tlegendColor(index: number): string {\n\t\treturn this.boxes[index]?.color ?? super.legendColor(index)\n\t}\n\n\t/** Room for the outline at the ends of the value axis. */\n\tvertMargins(p: Point): void {\n\t\tp.x = p.y = this.lineWidth + 6\n\t}\n\n\tminXValue(): number {\n\t\treturn -0.5\n\t}\n\n\tmaxXValue(): number {\n\t\treturn Math.max(0, this.boxes.length - 1) + 0.5\n\t}\n\n\tminYValue(): number {\n\t\treturn this.boxes.length > 0 ? Math.min(...this.boxes.map(box => this.lowest(box.stats))) : 0\n\t}\n\n\tmaxYValue(): number {\n\t\treturn this.boxes.length > 0 ? Math.max(...this.boxes.map(box => this.highest(box.stats))) : 0\n\t}\n\n\tprivate lowest(stats: BoxPlotStats): number {\n\t\tif (this.minStats === \"box\") return stats.q1\n\t\tif (this.minStats === \"whisker\") return stats.low\n\t\treturn this.showOutliers || this.showPoints ? Math.min(stats.low, stats.min, ...stats.outliers) : stats.low\n\t}\n\n\tprivate highest(stats: BoxPlotStats): number {\n\t\tif (this.maxStats === \"box\") return stats.q3\n\t\tif (this.maxStats === \"whisker\") return stats.high\n\t\treturn this.showOutliers || this.showPoints ? Math.max(stats.high, stats.max, ...stats.outliers) : stats.high\n\t}\n}\n\n/** Tukey's hinges, as R's `fivenum`: the quartiles are the medians of the lower and upper halves. */\nfunction fivenum(sorted: number[]): BoxPlotQuartiles {\n\tconst count = sorted.length\n\tconst at = (position: number) => (sorted[Math.floor(position) - 1] + sorted[Math.ceil(position) - 1]) / 2\n\tconst half = Math.floor((count + 3) / 2) / 2\n\treturn { q1: at(half), median: at((count + 1) / 2), q3: at(count + 1 - half) }\n}\n\n/** A repeatable sequence of numbers from 0 to 1, so the dots of a box do not move on every draw. */\nfunction jitterSequence(seed: number): () => number {\n\tlet state = seed * 2654435761\n\treturn () => {\n\t\tstate = (state * 1664525 + 1013904223) % 4294967296\n\t\treturn state / 4294967296\n\t}\n}\n","import type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport type { Point, Rectangle } from \"../core/primitives.js\"\nimport { CustomBar } from \"./custom-bar.js\"\n\n/**\n * @constructor\n * @augments CustomBar\n * @class Draws data as horizontal bars\n */\nexport class HorizBar extends CustomBar {\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tthis.yMandatory = false\n\t\tthis.format.gradient.direction = \"rightleft\"\n\t}\n\n\t/**\n\t * @returns {Number} Returns the maximum width in pixels of series marks texts.\n\t */\n\tmaxMarkWidth(): number {\n\t\tlet result = 0\n\t\tconst marks = this.marks\n\t\tconst count = this.count()\n\n\t\tif (marks.visible) {\n\t\t\tconst format = marks.format\n\t\t\tformat.font.prepare()\n\n\t\t\tfor (let index = 0; index < count; index += marks.drawEvery)\n\t\t\t\tif (!this.isNull(index)) {\n\t\t\t\t\tconst width = format.textWidth(`${this.markText(index)}W`)\n\t\t\t\t\tif (width > result) result = width\n\t\t\t\t}\n\t\t}\n\t\treturn result\n\t}\n\n\thorizMargins(p: Point): void {\n\t\tconst marks = this.marks\n\t\tlet stroke = this.format.stroke\n\t\tconst hasNegativeValues = this.minXValue() < this.origin\n\n\t\tif (marks.visible && marks.location !== \"center\") {\n\t\t\tp.y = (marks.arrow.length ?? 0) + this.maxMarkWidth() + marks.margins.left + marks.margins.right\n\t\t\tstroke = marks.format.stroke\n\t\t}\n\n\t\tif (stroke.fill !== \"\") p.y += 2 * stroke.size + 1\n\n\t\tif (hasNegativeValues) p.x = p.y\n\t}\n\n\tvertMargins(p: Point): void {\n\t\tthis.initOffsets()\n\t\tp.x += this._margin\n\t\tp.y += this._margin\n\t}\n\n\tmaxYValue(): number {\n\t\treturn this.stacked === \"sideAll\" ? this.countAll() - 1 : super.maxXValue()\n\t}\n\n\tminYValue(): number {\n\t\treturn this.stacked === \"sideAll\" ? 0 : super.minXValue()\n\t}\n\n\tminXValue(): number {\n\t\tconst minimum = super.minYValue()\n\t\treturn this.useOrigin ? Math.min(this.origin, minimum) : minimum\n\t}\n\n\tmaxXValue(): number {\n\t\treturn this.stackMaxValue()\n\t}\n\n\tcalcBarBounds(p: Point, bar: Rectangle, offset: Point, originPos: number): void {\n\t\tbar.y = p.y + offset.x\n\t\tbar.height = offset.y\n\n\t\tif (this._horizAxis.inverted) {\n\t\t\tbar.x = p.x\n\t\t\tbar.width = originPos - p.x\n\t\t} else {\n\t\t\tbar.x = originPos\n\t\t\tbar.width = p.x - bar.x\n\t\t}\n\n\t\tif (bar.width < 0) {\n\t\t\tbar.x += bar.width\n\t\t\tbar.width = -bar.width\n\t\t}\n\t}\n}\n","import type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { Format } from \"../core/elements/format.js\"\nimport { Point, Rectangle } from \"../core/primitives.js\"\nimport { HorizBar } from \"./horiz-bar.js\"\n\n/**\n * Target marker drawn on top of each bullet.\n * @property {Number|Number[]} origin Target value relative to series origin. Use an array for one target per point.\n * @property {Number} width Marker thickness along the value axis, in axis units (at least 2 pixels).\n * @property {Number} height Marker span as a percent of the bullet slot, perpendicular to the value axis.\n */\nexport interface BulletLimit {\n\torigin: number | number[]\n\twidth: number\n\theight: number\n\tcolor: string\n\tvisible: boolean\n}\n\n/**\n * Qualitative ranges drawn behind each bullet.\n * @property {Number[]|Number[][]} values Consecutive range widths starting at series origin.\n * Use an array of arrays for different ranges per point.\n * @property {Number} barSize Ranges size as a percent of the bullet slot, perpendicular to the value axis.\n */\nexport interface BulletStates {\n\tcolors: string[]\n\tvalues: number[] | number[][]\n\tbarSize: number\n\tgradientVisible: boolean\n\tvisible: boolean\n}\n\n/**\n * @constructor\n * @augments HorizBar\n * @class Draws each value as a bullet: qualitative ranges, a measure bar and a target marker.\n * Every point and every Bullet series sharing a category axis is drawn in its own slot.\n * @property {Boolean} [yMandatory=false] Set to true for vertical bullets, or false for horizontal bullets.\n */\nexport class Bullet extends HorizBar {\n\tdeclare yMandatory: boolean\n\tlimit: BulletLimit = { origin: 38, width: 0.2, height: 35, color: \"red\", visible: true }\n\tstates: BulletStates = {\n\t\tcolors: [\"#111\", \"#444\", \"#777\", \"#BBB\", \"#EEE\"],\n\t\tvalues: [10, 10, 10, 10, 10],\n\t\tbarSize: 50,\n\t\tgradientVisible: false,\n\t\tvisible: true\n\t}\n\n\tprivate _rangeFormat: Format | null = null\n\tprivate _limitFormat: Format | null = null\n\tprivate _row = new Point()\n\tprivate _rect = new Rectangle()\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\t\tthis.barSize = 25\n\t\tthis.stacked = \"sideAll\"\n\t\tthis.marks.visible = false\n\t}\n\n\t/**\n\t * @returns {Number[]} Returns the qualitative range widths for the index'th point.\n\t */\n\trangesAt(index: number): number[] {\n\t\tconst values = this.states.values\n\t\tif (values.length > 0 && Array.isArray(values[0])) return (values as number[][])[index] || []\n\t\treturn values as number[]\n\t}\n\n\t/**\n\t * @returns {Number} Returns the target value (relative to series origin) for the index'th point.\n\t */\n\ttargetAt(index: number): number {\n\t\tconst origin = this.limit.origin\n\t\treturn Array.isArray(origin) ? origin[index] : origin\n\t}\n\n\tminXValue(): number {\n\t\treturn this.yMandatory ? (this.stacked === \"sideAll\" ? 0 : this._baseMinXValue()) : this.minValue()\n\t}\n\n\tmaxXValue(): number {\n\t\treturn this.yMandatory\n\t\t\t? this.stacked === \"sideAll\"\n\t\t\t\t? this.countAll() - 1\n\t\t\t\t: this._baseMaxXValue()\n\t\t\t: this.maxValue()\n\t}\n\n\tminYValue(): number {\n\t\treturn this.yMandatory ? this.minValue() : super.minYValue()\n\t}\n\n\tmaxYValue(): number {\n\t\treturn this.yMandatory ? this.maxValue() : super.maxYValue()\n\t}\n\n\t/**\n\t * @returns {Number} Returns the minimum value needed to display all bullets, in either orientation.\n\t */\n\tminValue(): number {\n\t\tconst minimum = this._baseMinYValue()\n\t\tlet result = this.useOrigin ? Math.min(this.origin, minimum) : minimum\n\t\tif (this.limit.visible)\n\t\t\tfor (let t = 0; t < this.data.values.length; t++) {\n\t\t\t\tconst target = this.targetAt(t)\n\t\t\t\tif (target !== undefined) result = Math.min(result, this.origin + target)\n\t\t\t}\n\t\treturn result\n\t}\n\n\t/**\n\t * @returns {Number} Returns the maximum value needed to display all bullets, in either orientation.\n\t */\n\tmaxValue(): number {\n\t\tlet result = this._baseMaxYValue()\n\t\tfor (let t = 0; t < this.data.values.length; t++) {\n\t\t\tif (this.states.visible) result = Math.max(result, this.origin + this.rangesAt(t).reduce((a, b) => a + b, 0))\n\n\t\t\tconst target = this.targetAt(t)\n\t\t\tif (this.limit.visible && target !== undefined)\n\t\t\t\tresult = Math.max(result, this.origin + target + Math.max(0, this.limit.width))\n\t\t}\n\t\treturn result\n\t}\n\n\t/**\n\t * @returns {Number} Returns the number of slots of visible Bullet series on this category axis.\n\t */\n\trowCount(): number {\n\t\treturn this.countAll()\n\t}\n\n\tcountAll(upToThis = false): number {\n\t\tlet count = 0\n\t\tfor (const s of this.chart.series.items) {\n\t\t\tif (upToThis && s === this) break\n\t\t\tif (s.visible && s.constructor === this.constructor && s.notmandatory === this.notmandatory)\n\t\t\t\tcount += s.data.values.length\n\t\t}\n\t\treturn count\n\t}\n\n\t// The category axis centers each slot (see rowCount), so only the value axis needs margins.\n\thorizMargins(p: Point): void {\n\t\tif (!this.yMandatory) super.horizMargins(p)\n\t}\n\n\tvertMargins(p: Point): void {\n\t\tif (!this.yMandatory) return\n\n\t\tconst marks = this.marks\n\t\tlet stroke = this.format.stroke\n\t\tif (marks.visible && marks.location !== \"center\") {\n\t\t\tp.y = (marks.arrow.length ?? 0) + marks.format.textHeight(\"Wj\") + marks.margins.top + marks.margins.bottom\n\t\t\tstroke = marks.format.stroke\n\t\t}\n\t\tif (stroke.fill !== \"\") p.y += 2 * stroke.size + 1\n\t\tif (this.minYValue() < this.origin) p.x = p.y\n\t}\n\n\tcalcBarBounds(p: Point, bar: Rectangle, offset: Point, originPos: number): void {\n\t\tif (this.yMandatory) {\n\t\t\tbar.x = p.x + offset.x\n\t\t\tbar.width = offset.y\n\t\t\tbar.y = Math.min(p.y, originPos)\n\t\t\tbar.height = Math.abs(p.y - originPos)\n\t\t} else super.calcBarBounds(p, bar, offset, originPos)\n\t}\n\n\t/**\n\t * @returns {String|undefined} Returns the label for a bullet slot on the category axis.\n\t */\n\trowLabel(row: number): string | undefined {\n\t\tfor (const s of this.chart.series.items) {\n\t\t\tif (!s.visible || s.constructor !== this.constructor || s.notmandatory !== this.notmandatory) continue\n\n\t\t\tconst count = s.data.values.length\n\t\t\tif (row < count) return s.data.labels[row] || s.title || undefined\n\t\t\trow -= count\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate rowSize(): number {\n\t\treturn this.notmandatory.calcSize(1)\n\t}\n\n\tprivate prepareFormat(format: Format | null): Format {\n\t\tif (!format) format = new Format(this.chart)\n\t\telse format.setChart(this.chart)\n\n\t\tformat.round.x = 0\n\t\tformat.round.y = 0\n\t\tformat.shadow.visible = false\n\t\tformat.stroke.fill = \"\"\n\t\tformat.z = this.format.z\n\t\tformat.depth = this.format.depth\n\t\treturn format\n\t}\n\n\tprivate setBounds(r: Rectangle, from: number, to: number, center: number, span: number, minSize = 0): void {\n\t\tconst axis = this.mandatoryAxis,\n\t\t\tp0 = axis.calc(from),\n\t\t\tp1 = axis.calc(to),\n\t\t\tstart = Math.min(p0, p1),\n\t\t\tsize = Math.max(minSize, Math.abs(p1 - p0))\n\n\t\tif (this.yMandatory) r.set(center - span * 0.5, start, span, size)\n\t\telse r.set(start, center - span * 0.5, size, span)\n\t}\n\n\tprivate drawRanges(index: number, center: number, row: number): void {\n\t\tconst ranges = this.rangesAt(index),\n\t\t\tcolors = this.states.colors\n\n\t\tif (ranges.length === 0 || colors.length === 0) return\n\n\t\tthis._rangeFormat = this.prepareFormat(this._rangeFormat)\n\n\t\tconst f = this._rangeFormat,\n\t\t\tr = this._rect,\n\t\t\tgradient = f.gradient\n\n\t\tlet sum = this.origin\n\t\tfor (let t = 0; t < ranges.length; t++) {\n\t\t\tconst color = colors[t % colors.length]\n\n\t\t\tif (this.states.gradientVisible) {\n\t\t\t\tgradient.colors = [colors[Math.max(0, t - 1) % colors.length], color]\n\t\t\t\tgradient.direction = this.yMandatory\n\t\t\t\t\t? this.mandatoryAxis.inverted\n\t\t\t\t\t\t? \"topbottom\"\n\t\t\t\t\t\t: \"bottomtop\"\n\t\t\t\t\t: this.mandatoryAxis.inverted\n\t\t\t\t\t\t? \"rightleft\"\n\t\t\t\t\t\t: \"leftright\"\n\t\t\t\tgradient.visible = true\n\t\t\t} else {\n\t\t\t\tgradient.visible = false\n\t\t\t\tf.fill = color\n\t\t\t}\n\n\t\t\tthis.setBounds(r, sum, sum + ranges[t], center, (row * this.states.barSize) / 100)\n\t\t\tif (r.width > 0 && r.height > 0) {\n\t\t\t\tf.cube(r)\n\t\t\t\tf.draw(this.chart.drawContext, null, r)\n\t\t\t}\n\n\t\t\tsum += ranges[t]\n\t\t}\n\t}\n\n\tprivate drawTarget(index: number, center: number, row: number): void {\n\t\tconst target = this.targetAt(index)\n\t\tif (target === undefined) return\n\n\t\tthis._limitFormat = this.prepareFormat(this._limitFormat)\n\n\t\tconst f = this._limitFormat,\n\t\t\tr = this._rect,\n\t\t\tfrom = this.origin + target\n\n\t\tf.gradient.visible = false\n\t\tf.fill = this.limit.color\n\n\t\tthis.setBounds(r, from, from + this.limit.width, center, (row * this.limit.height) / 100, 2)\n\n\t\tf.cube(r)\n\t\tf.draw(this.chart.drawContext, null, r)\n\t}\n\n\tprivate eachRow(callback: (index: number, center: number, row: number) => void): void {\n\t\tconst len = this.data.values.length\n\t\tif (len === 0) return\n\n\t\tthis.initOffsets()\n\n\t\tconst p = this._row,\n\t\t\trow = this.rowSize()\n\n\t\tfor (let t = 0; t < len; t++)\n\t\t\tif (!this.isNull(t)) {\n\t\t\t\tthis.calcStackPos(t, p)\n\t\t\t\tcallback(t, this.yMandatory ? p.x : p.y, row)\n\t\t\t}\n\t}\n\n\tdraw(): void {\n\t\tif (this.states.visible) this.eachRow((t, center, row) => this.drawRanges(t, center, row))\n\n\t\tsuper.draw()\n\n\t\tif (this.limit.visible) this.eachRow((t, center, row) => this.drawTarget(t, center, row))\n\t}\n}\n","import { Format } from \"../core/elements/format.js\"\nimport { Point, Rectangle } from \"../core/primitives.js\"\nimport { ArrayMax, ArrayMin } from \"../series-utils.js\"\nimport { CustomSeries } from \"./custom-series.js\"\nimport type { Chart } from \"../chart.js\"\nimport type { Series, SeriesInput, SeriesLabels } from \"../series.js\"\n\n/**\n * @constructor\n * @augments CustomSeries\n * @class Draws financial OHLC data as Candle or CandleBar points.\n * @property {String} style Defines candle style (\"candle\", \"bar\", \"openclose\").\n */\nexport class Candle extends CustomSeries {\n\tdeclare hi: Format\n\tdeclare higher: Format\n\tdeclare lo: Format\n\tdeclare lower: Format\n\tdeclare style: string\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\t// A candle series draws its own points: it has no polyline.\n\t\tthis.drawLine = false\n\t\tthis.pointer.visible = true\n\t\tthis.format.shadow.visible = true\n\t\tthis.format.shadow.blur = 10\n\n\t\tthis.format.z = 0.5\n\t\tthis.format.depth = 0.1\n\n\t\tthis.pointer.width = 7\n\n\t\tthis.hi = this.higher = this.pointer.format\n\t\tthis.hi.fill = \"green\"\n\n\t\tthis.lo = this.lower = new Format(this.chart)\n\t\tthis.lo.fill = \"red\"\n\n\t\tthis.style = \"candle\"\n\t}\n\n\t/*\n\t * @public\n\t */\n\tsetChart(series: Series, chart: Chart): void {\n\t\tconst setChart = CustomSeries.prototype.setChart\n\t\tsetChart(series, chart)\n\t\tthis.lo.setChart(chart)\n\t}\n\n\tdraw(): void {\n\t\tconst data = this.data\n\t\tconst pointCount = data.values.length\n\t\tconst point = new Point()\n\t\tconst pointer = this.pointer\n\t\tconst halfWidth = pointer.width * 0.5\n\t\tconst axis = this.mandatoryAxis\n\t\tconst context = this.chart.ctx\n\t\tif (!context) return\n\n\t\tcontext.z = this.format.z + this.format.depth * 0.5\n\n\t\tfor (let index = 0; index < pointCount; index++)\n\t\t\tif (!this.isNull(index)) {\n\t\t\t\tthis.calc(index, point)\n\t\t\t\tconst x = point.x\n\n\t\t\t\tconst open = axis.calc(Number(data.open?.[index]))\n\t\t\t\tconst high = axis.calc(Number(data.high?.[index]))\n\t\t\t\tconst low = axis.calc(Number(data.low?.[index]))\n\t\t\t\tlet y: number\n\t\t\t\tlet height: number\n\t\t\t\tlet color: Format\n\n\t\t\t\tif (point.y > open) {\n\t\t\t\t\ty = open\n\t\t\t\t\theight = point.y - open\n\t\t\t\t\tcolor = this.lo\n\t\t\t\t} else {\n\t\t\t\t\ty = point.y\n\t\t\t\t\theight = open - y\n\t\t\t\t\tcolor = this.hi\n\t\t\t\t}\n\n\t\t\t\tif (this.style === \"bar\") {\n\t\t\t\t\tcontext.beginPath()\n\n\t\t\t\t\tcontext.moveTo(x, high)\n\t\t\t\t\tcontext.lineTo(x, low)\n\t\t\t\t\tcontext.moveTo(x - halfWidth, open)\n\t\t\t\t\tcontext.lineTo(x, open)\n\t\t\t\t\tcontext.moveTo(x, point.y)\n\t\t\t\t\tcontext.lineTo(x + halfWidth, point.y)\n\n\t\t\t\t\tcolor.stroke.prepare(color.fill)\n\n\t\t\t\t\tcontext.stroke()\n\t\t\t\t} else {\n\t\t\t\t\tcolor.depth = halfWidth / 100 // totalDepth*0.5 !!\n\t\t\t\t\tcolor.z = this.format.z + this.format.depth * 0.5 - color.depth * 0.5\n\n\t\t\t\t\tconst rectangle = { x: x - halfWidth, y, width: pointer.width, height }\n\n\t\t\t\t\tif (this.pointer.style === \"cylinder\") color.cylinder(rectangle, 1, true, false)\n\t\t\t\t\telse color.cube(rectangle)\n\n\t\t\t\t\tcolor.draw(context, null, rectangle)\n\n\t\t\t\t\tif (this.hover.enabled && this.over === index) this.hover.rectangle(x - halfWidth, y, pointer.width, height)\n\t\t\t\t}\n\n\t\t\t\tif (this.style !== \"openclose\")\n\t\t\t\t\tif (high < y || low > y + height) {\n\t\t\t\t\t\tcontext.z = this.format.z + this.format.depth * 0.5\n\n\t\t\t\t\t\tcontext.beginPath()\n\n\t\t\t\t\t\tcontext.moveTo(x, y)\n\t\t\t\t\t\tcontext.lineTo(x, high)\n\n\t\t\t\t\t\tcontext.moveTo(x, y + height)\n\t\t\t\t\t\tcontext.lineTo(x, low)\n\n\t\t\t\t\t\tif (this.hover.enabled && this.over === index) this.hover.stroke.prepare(color.fill)\n\t\t\t\t\t\telse color.stroke.prepare(color.fill)\n\n\t\t\t\t\t\tcontext.stroke()\n\t\t\t\t\t}\n\t\t\t}\n\t}\n\n\tminYValue(): number {\n\t\tconst low = this.data.low\n\t\treturn low && low.length > 0 ? ArrayMin(low) : 0\n\t}\n\n\tmaxYValue(): number {\n\t\tconst high = this.data.high\n\t\treturn high && high.length > 0 ? ArrayMax(high) : 0\n\t}\n\n\taddRandom(count: number): Candle {\n\t\tconst data = this.data\n\t\tif (!count) count = 10\n\t\tdata.values.length = count\n\t\tdata.close = data.values\n\t\tif (data.open) data.open.length = count\n\t\telse data.open = new Array(count)\n\t\tif (data.high) data.high.length = count\n\t\telse data.high = new Array(count)\n\t\tif (data.low) data.low.length = count\n\t\telse data.low = new Array(count)\n\n\t\tif (count > 0) {\n\t\t\tlet tmp = 25 + Math.random() * 100\n\n\t\t\tfor (let t = 0; t < count; t++) {\n\t\t\t\tconst open = (data.open[t] = tmp)\n\t\t\t\ttmp = data.close[t] = tmp + Math.random() * 25 - 12.5\n\t\t\t\tdata.high[t] = Math.max(open, tmp) + Math.random() * 15\n\t\t\t\tdata.low[t] = Math.min(open, tmp) - Math.random() * 15\n\t\t\t}\n\t\t}\n\n\t\treturn this\n\t}\n\n\tclicked(p: Point): number {\n\t\tconst width = this.pointer.width\n\t\tconst mandatoryAxis = this.mandatoryAxis\n\t\tconst notMandatoryAxis = this.notmandatory\n\t\tconst data = this.data\n\t\tconst pointCount = data.values.length\n\t\tconst rectangle = new Rectangle()\n\n\t\trectangle.width = width\n\n\t\tfor (let index = 0; index < pointCount; index++)\n\t\t\tif (!this.isNull(index)) {\n\t\t\t\trectangle.x = notMandatoryAxis.calc(index) - width * 0.5\n\t\t\t\tconst open = mandatoryAxis.calc(Number(data.open?.[index]))\n\t\t\t\tconst close = mandatoryAxis.calc(Number(data.close?.[index]))\n\t\t\t\trectangle.y = open > close ? close : open\n\t\t\t\trectangle.height = Math.abs(open - close)\n\n\t\t\t\tif (rectangle.contains(p)) return index\n\t\t\t}\n\n\t\treturn -1\n\t}\n\n\tvertMargins() {}\n}\n","import { Point, Rectangle } from \"../core/primitives.js\"\nimport { DateUtils } from \"../date.format.js\"\nimport { Series } from \"../series.js\"\nimport type { SeriesData, SeriesInput, SeriesLabels, TooltipParts } from \"../series.js\"\nimport { ArrayMax, ArrayMin } from \"../series-utils.js\"\nimport { trunc } from \"../utils.js\"\n\n/**\n * @constructor\n * @augments Tee.Series\n * @class Draws series data as Gantt horizontal bars with start and end datetime values.\n * @property {Number} [height=70] Percent of gantt bar height. From 0 to 100.\n */\n/** The data of a Gantt series: the start and end of each task, and its position. */\ninterface GanttData extends SeriesData {\n\tx: Array<number | Date>\n\tstart: Array<number | Date>\n\tend: Array<number | Date>\n}\n\nexport class Gantt extends Series {\n\tyMandatory = false\n\tdateFormat = \"mediumDate\"\n\tnextTasks: Array<[number, number]> = []\n\tnextTasksStrokeStyle = \"Black\"\n\tnextTasksPosition = \"back\" //back, front\n\tcolorEach = \"yes\"\n\theight = 70\n\tmargin = new Point(6, 6)\n\tcontinuous = false\n\tr = new Rectangle()\n\t_h = 0\n\t/** The task data: Gantt always has its x, start and end arrays. */\n\tdeclare data: GanttData\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tthis.hover.enabled = true\n\t\tthis.hover.round.x = this.hover.round.y = 8\n\n\t\tthis.data.start = this.data.values\n\t\tthis.data.x = []\n\t\tthis.data.end = []\n\n\t\tthis.format.shadow.visible = true\n\t\tthis.format.round.x = this.format.round.y = 8\n\t\tthis.format.stroke.fill = \"black\"\n\t\tthis.format.gradient.visible = true\n\t}\n\n\taddNextTask(point1: number, point2: number): void {\n\t\tthis.nextTasks.push([point1, point2])\n\t}\n\n\taddRandom(count = 5): Gantt {\n\t\tif (!count) count = 5\n\n\t\tconst data = this.data\n\n\t\tdata.x.length = count\n\t\tdata.start.length = count\n\t\tdata.end.length = count\n\n\t\tif (count > 0) {\n\t\t\tlet year = 2012,\n\t\t\t\tmonth: number,\n\t\t\t\tday: number\n\n\t\t\tfor (let t = 0; t < count; t++) {\n\t\t\t\tdata.x[t] = t\n\n\t\t\t\tmonth = trunc(Math.random() * 12)\n\t\t\t\tday = trunc(Math.random() * 10)\n\t\t\t\tdata.start[t] = new Date(year, month, day)\n\t\t\t\tif (month < 5) month = 5 + trunc(Math.random() * 7)\n\t\t\t\tdata.end[t] = new Date(year, month, day + Math.random() * 10)\n\t\t\t}\n\t\t}\n\n\t\treturn this\n\t}\n\n\tbounds(r: Rectangle): void\n\tbounds(index: number, r?: Rectangle): boolean\n\tbounds(indexOrRectangle: number | Rectangle, r: Rectangle = this.r): boolean | undefined {\n\t\tif (typeof indexOrRectangle !== \"number\") {\n\t\t\tsuper.bounds(indexOrRectangle)\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst index = indexOrRectangle\n\t\tif (this.isNull(index)) return false\n\t\telse {\n\t\t\tthis.calc(index, r)\n\t\t\tr.y -= this._h * 0.5\n\t\t\tr.width = this.data.end\n\t\t\t\t? this.mandatoryAxis.calcSize(Number(this.data.end[index]) - Number(this.data.start[index]))\n\t\t\t\t: 0\n\t\t\tr.height = this._h\n\n\t\t\treturn true\n\t\t}\n\t}\n\n\tadd(pos: number, label: string, start: Date, end: Date): void {\n\t\tconst data = this.data\n\t\tdata.labels.push(label)\n\t\tdata.x.push(pos)\n\t\tdata.start.push(start)\n\t\tdata.end.push(end)\n\t}\n\n\ttooltipParts(index: number): TooltipParts | undefined {\n\t\tconst { start, end, labels } = this.data\n\t\tif (!start[index] || !end[index]) return undefined\n\t\tconst format = (date: number | Date) => DateUtils.format(new Date(date), this.dateFormat)\n\t\tconst startText = format(start[index])\n\t\tconst endText = format(end[index])\n\t\tconst days = Math.round((Number(end[index]) - Number(start[index])) / 86400000)\n\t\treturn {\n\t\t\tlabel: labels[index] || \"\",\n\t\t\tvalue: `${startText} → ${endText}`,\n\t\t\tcolor: this.getFill(index),\n\t\t\tdetails: [\n\t\t\t\t[\"Start\", startText],\n\t\t\t\t[\"End\", endText],\n\t\t\t\t[\"Duration\", `${days} days`]\n\t\t\t]\n\t\t}\n\t}\n\n\tclicked(p: Point): number {\n\t\tconst pointCount = this.data.values.length\n\n\t\tfor (let index = 0; index < pointCount; index++) if (this.bounds(index, this.r) && this.r.contains(p)) return index\n\n\t\treturn -1\n\t}\n\n\tdraw(): void {\n\t\tconst pointCount = this.data.values.length\n\t\tlet format = this.hover\n\t\tconst oldFill = format.fill\n\t\tconst context = this.chart.ctx\n\t\tif (!context) return\n\n\t\tif (this.nextTasksPosition === \"back\") {\n\t\t\tthis.drawLines(context)\n\t\t}\n\n\t\tthis._h = this.notmandatory.calcSize(this.height * 0.01)\n\n\t\tfor (let index = 0; index < pointCount; index++)\n\t\t\tif (this.bounds(index, this.r)) {\n\t\t\t\tformat = this.hover.enabled && this.over === index ? this.hover : this.format\n\t\t\t\t// Canvas accepts a gradient as fill style, although Format.fill is declared as a color string.\n\t\t\t\tformat.fill = this.getFillStyle(this.r, this.getFill(index, format)) as string\n\t\t\t\tformat.rectangle(this.r)\n\t\t\t}\n\n\t\tthis.hover.fill = oldFill\n\t\tif (this.nextTasksPosition === \"front\") {\n\t\t\tthis.drawLines(context)\n\t\t}\n\t}\n\n\tdrawLines(c: CanvasRenderingContext2D): void {\n\t\tfor (let i = 0; i < this.nextTasks.length; i++) {\n\t\t\tconst punts = []\n\n\t\t\tc.beginPath()\n\t\t\tc.strokeStyle = this.nextTasksStrokeStyle\n\t\t\tc.lineWidth = 2\n\t\t\tc.fillStyle = \"000000\"\n\t\t\tpunts.push(Math.round(this.chart.axes.bottom.calc(Number(this.data.end[this.nextTasks[i][0]]))))\n\t\t\tpunts.push(Math.round(this.chart.axes.left.calc(Number(this.data.x[this.nextTasks[i][0]]))))\n\t\t\tpunts.push(Math.round(this.chart.axes.bottom.calc(Number(this.data.start[this.nextTasks[i][1]]))))\n\t\t\tpunts.push(Math.round(this.chart.axes.left.calc(Number(this.data.x[this.nextTasks[i][1]]))))\n\n\t\t\tc.moveTo(punts[0], punts[1])\n\t\t\tc.lineTo(punts[0] - (punts[0] - punts[2]) / 2, punts[1])\n\t\t\tc.lineTo(punts[0] - (punts[0] - punts[2]) / 2, punts[3])\n\t\t\tc.lineTo(punts[2], punts[3])\n\n\t\t\tc.stroke()\n\t\t}\n\t}\n\n\thorizMargins(p: Point): void {\n\t\tp.x = this.margin.x\n\t\tp.y = this.margin.y\n\t}\n\n\tminYValue() {\n\t\treturn this._baseMinXValue() - 0.5\n\t}\n\n\tmaxYValue() {\n\t\treturn this._baseMaxXValue() + 0.5\n\t}\n\n\tminXValue() {\n\t\treturn ArrayMin(this.data.start)\n\t}\n\n\tmaxXValue() {\n\t\treturn ArrayMax(this.data.end)\n\t}\n}\n","import type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { Format } from \"../core/elements/format.js\"\nimport { Point, Rectangle } from \"../core/primitives.js\"\nimport { drawSpline } from \"../spline.js\"\nimport { trunc } from \"../utils.js\"\nimport { CustomSeries } from \"./custom-series.js\"\n\nexport class HighLowBar extends CustomSeries {\n\tdeclare rects: boolean | undefined\n\tuseOrigin = false\n\torigin = 0\n\tdrawLine = true\n\tcloseArea = true\n\tmaxmin: Format | undefined = undefined\n\tr = new Rectangle()\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tconst f = this.format\n\t\tf.shadow.visible = true\n\t\tf.stroke.fill = \"black\"\n\t\tf.fill = \"\"\n\t\tf.beveled = true\n\n\t\tthis.maxmin = new Format(f.chart)\n\t\tconst b = this.maxmin\n\t\tb.shadow.visible = false\n\t\tb.stroke.fill = \"red\"\n\t\tb.fill = \"\"\n\t\tb.beveled = true\n\n\t\tf.depth = 1\n\t\tf.z = 0.5\n\t\tthis.data.lows = []\n\t}\n\n\taddRandom(count = 5): HighLowBar {\n\t\tconst d = this.data\n\t\td.values.length = count\n\t\td.x = undefined\n\t\td.lows = new Array(count)\n\t\tfor (let t = 0; t < count; t++) {\n\t\t\td.values[t] = Math.random() * 1000\n\t\t\td.lows[t] = 50 + Math.random() * 150\n\t\t}\n\n\t\treturn this\n\t}\n\n\tcalcLows(index: number, p: Point): void {\n\t\tthis.isStacked ? this.calcStack(index, p, this.data.lows?.[index] ?? Number.NaN) : super.calc(index, p)\n\t}\n\n\tdraw(): void {\n\t\tconst f = this.format\n\t\tconst r = this.r\n\t\tconst len = this.data.values.length\n\t\tif (len === 0) return\n\n\t\tconst a = this.mandatoryAxis\n\t\tconst nm = this.notmandatory\n\t\tconst isY = this.yMandatory\n\t\tconst originPos = this.useOrigin\n\t\t\t? a.calc(this.origin)\n\t\t\t: (isY && a.inverted) || (!isY && !a.inverted)\n\t\t\t\t? a.startPos\n\t\t\t\t: a.endPos\n\t\tthis.isStacked = this.stacked !== \"no\"\n\t\tthis.isStack100 = this.stacked === \"100\"\n\n\t\tlet start: number,\n\t\t\told = Number.NaN,\n\t\t\tsmop: number[],\n\t\t\tbegin = 0,\n\t\t\tend = len\n\t\tconst p = new Point()\n\t\tconst c = this.chart.drawContext\n\t\tconst doStack = this.isStacked\n\t\tif (!this.smooth && !this.data.x) {\n\t\t\tbegin = Math.max(0, trunc(nm.minimum) - 1)\n\t\t\tend = Math.min(len, trunc(nm.maximum) + 2)\n\t\t}\n\t\tc.depth = f.depth\n\t\tc.z = f.z\n\t\tconst maxP = [],\n\t\t\tminP = []\n\t\tlet idx = 0\n\t\tc.beginPath()\n\t\tif (this.smooth > 0) {\n\t\t\tsmop = new Array(2 * len)\n\t\t\tfor (let t = 0; t < len; t++) {\n\t\t\t\tthis.calc(t, p)\n\t\t\t\tsmop[2 * t] = p.x\n\t\t\t\tsmop[2 * t + 1] = p.y\n\t\t\t}\n\t\t\tstart = isY ? smop[0] : smop[1]\n\t\t\tif (c.spline) c.spline(smop, true)\n\t\t\telse drawSpline(c, smop, this.smooth, true)\n\t\t\tif (doStack) {\n\t\t\t\tlet tmp = 0\n\t\t\t\tfor (let t = len - 1; t >= 0; t--) {\n\t\t\t\t\tthis.calcStack(t, p, 0)\n\t\t\t\t\tsmop[tmp++] = p.x\n\t\t\t\t\tsmop[tmp++] = p.y\n\t\t\t\t}\n\t\t\t\tc.lineTo(smop[0], smop[1])\n\t\t\t\tif (c.spline) c.spline(smop, true)\n\t\t\t\telse drawSpline(c, smop, this.smooth, false)\n\t\t\t}\n\t\t} else {\n\t\t\tthis.calc(begin, p)\n\t\t\tc.moveTo(p.x, p.y)\n\t\t\tstart = isY ? p.x : p.y\n\t\t\told = isY ? p.y : p.x\n\t\t\tif (this.stairs)\n\t\t\t\tfor (let t = begin + 1; t < end; t++) {\n\t\t\t\t\tthis.calc(t, p)\n\t\t\t\t\tc.lineTo(p.x, old)\n\t\t\t\t\tc.lineTo(p.x, p.y)\n\t\t\t\t\told = isY ? p.y : p.x\n\t\t\t\t}\n\t\t\telse if (this.rects)\n\t\t\t\tfor (let t = begin; t < end; t++) {\n\t\t\t\t\tthis.calc(t, p)\n\t\t\t\t\tconst lowPY = this.mandatoryAxis.calc(this.data.lows?.[t] ?? Number.NaN)\n\t\t\t\t\tconst nextPx = this.notmandatory.calc(Number(this.data.x?.[t + 1]))\n\t\t\t\t\tc.rect(p.x, p.y, nextPx - p.x, lowPY - p.y)\n\t\t\t\t\tmaxP[idx] = new Point(p.x, p.y)\n\t\t\t\t\tminP[idx++] = new Point(p.x, lowPY)\n\t\t\t\t\tmaxP[idx] = new Point(nextPx, p.y)\n\t\t\t\t\tminP[idx++] = new Point(nextPx, lowPY)\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tfor (let t = begin + 1; t < end; t++) {\n\t\t\t\t\tthis.calc(t, p)\n\t\t\t\t\tc.lineTo(p.x, p.y)\n\t\t\t\t}\n\t\t}\n\t\tif (doStack && this.smooth === 0)\n\t\t\tfor (let t = end - 1; t >= begin; t--) {\n\t\t\t\tthis.calcStack(t, p, 0)\n\t\t\t\tif (this.stairs) {\n\t\t\t\t\tc.lineTo(p.x, old)\n\t\t\t\t\tc.lineTo(p.x, p.y)\n\t\t\t\t\told = isY ? p.y : p.x\n\t\t\t\t} else c.lineTo(p.x, p.y)\n\t\t\t}\n\t\telse if (!doStack) {\n\t\t\tif (isY) {\n\t\t\t\tif (this.closeArea) {\n\t\t\t\t\tc.lineTo(p.x, originPos)\n\t\t\t\t\tc.lineTo(start, originPos)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tc.lineTo(originPos, p.y)\n\t\t\t\tc.lineTo(originPos, start)\n\t\t\t}\n\t\t}\n\t\tc.closePath()\n\t\tif (f.gradient.visible) f.gradient.colors[f.gradient.colors.length - 1] = f.fill\n\t\tthis.bounds(r)\n\t\tif (c.__webgl) c.beveled = f.beveled\n\t\tf.draw(c, null, r)\n\t\tfor (const points of [maxP, minP]) {\n\t\t\tc.beginPath()\n\t\t\tfor (const point of points) c.lineTo(point.x, point.y)\n\t\t\tf.stroke.prepare(f.fill, c)\n\t\t\tc.stroke()\n\t\t}\n\t\tif (this.pointer.visible) this.drawPointers()\n\t}\n\n\tminYValue(): number {\n\t\tconst v = this.yMandatory ? super.minYValue() : super.minXValue()\n\t\treturn this.yMandatory ? (this.useOrigin ? Math.min(v, this.origin) : v) : v\n\t}\n\tminXValue(): number {\n\t\tconst v = this.yMandatory ? super.minXValue() : super.minYValue()\n\t\treturn this.yMandatory ? v : this.useOrigin ? Math.min(v, this.origin) : v\n\t}\n\tmaxYValue(): number {\n\t\tconst v = this.yMandatory ? this.stackMaxValue() : super.maxXValue()\n\t\treturn this.yMandatory ? (this.useOrigin ? Math.max(v, this.origin) : v) : v\n\t}\n\tmaxXValue(): number {\n\t\tconst v = this.yMandatory ? super.maxXValue() : this.stackMaxValue()\n\t\treturn this.yMandatory ? v : this.useOrigin ? Math.max(v, this.origin) : v\n\t}\n\tvertMargins(p: Point): void {\n\t\tif (this.yMandatory && this.format.stroke.fill !== \"\") p.y += this.format.stroke.size + 2\n\t}\n\thorizMargins(p: Point): void {\n\t\tif (!this.yMandatory && this.format.stroke.fill !== \"\") p.y += this.format.stroke.size + 2\n\t}\n}\n","import type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { quantile } from \"../series-utils.js\"\nimport { Bar } from \"./bar.js\"\n\n/** Rule used to choose the number of bins when neither `bins` nor `binWidth` is set. */\nexport type HistogramRule = \"sturges\" | \"scott\" | \"sqrt\" | \"freedman\"\n\n/** What the height of each bar measures. */\nexport type HistogramNormalize = \"count\" | \"percent\" | \"density\"\n\n/**\n * @constructor\n * @augments Bar\n * @class Groups raw numbers into consecutive bins and draws how many fall in each as touching bars\n * @property {Number[]} source The raw values.\n * @property {Number} [bins=0] Number of bins; 0 chooses it with `rule`.\n * @property {Number} [binWidth=0] Width of each bin; when above 0 it replaces `bins` and `rule`.\n * @property {String} [rule=\"sturges\"] How the number of bins is chosen (\"sturges\", \"scott\", \"sqrt\", \"freedman\").\n * @property {String} [normalize=\"count\"] Bar height: \"count\", \"percent\" of the values or \"density\".\n */\nexport class Histogram extends Bar {\n\tsource: number[] = []\n\tbins = 0\n\tbinWidth = 0\n\trule: HistogramRule = \"sturges\"\n\tnormalize: HistogramNormalize = \"count\"\n\t/** Lower edge of every bin followed by the upper edge of the last one. */\n\tedges: number[] = []\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\t// Touching bars: the width of a bar is the width of its bin.\n\t\tthis.barSize = 100\n\t\tthis.marks.visible = false\n\t\tthis.format.round.x = 0\n\t\tthis.format.round.y = 0\n\t\tthis.format.gradient.visible = false\n\t\tthis.format.shadow.visible = false\n\t\tthis.colorEach = \"no\"\n\t}\n\n\t/** Replaces the raw values and groups them again. */\n\tsetData(values: Iterable<number>, _labels?: Iterable<string> | null, redraw = true): this {\n\t\tif (!values || typeof values[Symbol.iterator] !== \"function\") {\n\t\t\tthrow new TypeError(\"Histogram.setData requires an iterable collection of values\")\n\t\t}\n\t\tthis.source = Array.from(values).filter(value => Number.isFinite(value))\n\t\treturn this.rebin(redraw)\n\t}\n\n\t/** Groups `source` with the current options; call it after changing `bins`, `binWidth`, `rule` or `normalize`. */\n\trebin(redraw = true): this {\n\t\tconst data = this.data\n\t\tconst values = [...this.source].sort((a, b) => a - b)\n\t\tconst count = values.length\n\n\t\tif (count === 0) {\n\t\t\tthis.edges = []\n\t\t\tdata.values = []\n\t\t\tdata.x = []\n\t\t\tdata.labels = []\n\t\t} else {\n\t\t\tconst min = values[0]\n\t\t\tconst max = values[count - 1]\n\t\t\tconst width = this.resolveWidth(values, min, max)\n\t\t\t// Values on a shared upper edge belong to the next bin, except the maximum which closes the last one.\n\t\t\tconst bins = Math.max(1, Math.ceil((max - min) / width - 1e-9))\n\t\t\tconst counts = new Array<number>(bins).fill(0)\n\n\t\t\tfor (const value of values) counts[Math.min(bins - 1, Math.floor((value - min) / width))]++\n\n\t\t\tthis.edges = Array.from({ length: bins + 1 }, (_, index) => min + index * width)\n\t\t\tdata.x = counts.map((_, index) => min + (index + 0.5) * width)\n\t\t\tdata.values = counts.map(amount => this.scale(amount, count, width))\n\t\t\tdata.labels = counts.map((_, index) => `${this.edges[index]} - ${this.edges[index + 1]}`)\n\t\t}\n\n\t\tif (redraw) this.chart?.draw()\n\t\treturn this\n\t}\n\n\tprivate scale(amount: number, total: number, width: number): number {\n\t\tif (this.normalize === \"percent\") return (amount * 100) / total\n\t\tif (this.normalize === \"density\") return amount / (total * width)\n\t\treturn amount\n\t}\n\n\tprivate resolveWidth(values: number[], min: number, max: number): number {\n\t\tconst range = max - min\n\t\tif (range === 0) return this.binWidth > 0 ? this.binWidth : 1\n\t\tif (this.binWidth > 0) return this.binWidth\n\n\t\tlet bins = Math.floor(this.bins)\n\t\tif (bins < 1) bins = this.ruleBins(values, range)\n\t\treturn range / bins\n\t}\n\n\tprivate ruleBins(values: number[], range: number): number {\n\t\tconst count = values.length\n\n\t\tif (this.rule === \"sqrt\") return Math.ceil(Math.sqrt(count))\n\n\t\tif (this.rule === \"scott\" || this.rule === \"freedman\") {\n\t\t\tlet width: number\n\t\t\tif (this.rule === \"scott\") {\n\t\t\t\tconst mean = values.reduce((sum, value) => sum + value, 0) / count\n\t\t\t\tconst deviation = Math.sqrt(values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / count)\n\t\t\t\twidth = (3.49 * deviation) / count ** (1 / 3)\n\t\t\t} else {\n\t\t\t\twidth = (2 * (quantile(values, 0.75) - quantile(values, 0.25))) / count ** (1 / 3)\n\t\t\t}\n\t\t\t// A zero spread would give infinite bins; fall back to Sturges.\n\t\t\tif (width > 0) return Math.max(1, Math.ceil(range / width))\n\t\t}\n\n\t\treturn Math.ceil(Math.log2(count)) + 1\n\t}\n\n\t/** Pixel width of the bar of one bin, so that neighbours touch. */\n\tcalcBarOffset(axisSize: number): void {\n\t\tconst bins = this.data.values.length\n\t\tif (bins < 2 || this.stacked !== \"no\") {\n\t\t\tsuper.calcBarOffset(axisSize)\n\t\t\treturn\n\t\t}\n\n\t\tconst bin = axisSize / (bins - 1)\n\t\tconst offset = this.offsetPoint\n\t\toffset.y = this.customBarSize > 0 ? this.customBarSize : bin * this.barSize * 0.01\n\t\toffset.x = -offset.y * 0.5\n\t\tthis._margin = bin * 0.5\n\t}\n}\n","import type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { Area } from \"./area.js\"\n\n/**\n * @constructor\n * @augments Area\n * @class Horizontal area style\n */\nexport class HorizArea extends Area {\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tthis.yMandatory = false\n\t}\n}\n","import type { Chart } from \"../chart.js\"\nimport { Format, percentLocation } from \"../core/elements/format.js\"\nimport type { Point, Rectangle } from \"../core/primitives.js\"\nimport { getNavigator } from \"../platform.js\"\nimport { Series } from \"../series.js\"\nimport type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { Annotation, BaseAnimation } from \"../tools/index.js\"\n\ninterface GaugePoint extends Point {\n\tvalue: number\n\tinTicks: boolean\n}\n\ninterface GaugeBounds extends Rectangle {\n\tcustom?: boolean\n\t(r: Rectangle): void\n}\n\n/**\n *@constructor\n *@memberOf Tee\n *@class Parameters to draw a circular gauge meter.\n *@property {Number} [min=0] The minimum gauge range value.\n *@property {Number} [max=100] The maxnimum gauge range value.\n *@property {Number} [step=0] The increment between gauge range labels.\n *@property {Number} [value=0] The position of gauge hand inside the min max range.\n *@property {Number} [angle=280] Amount in degrees of the circular gauge size.\n *@property {Number} [rotation=0] Gauge rotation in degrees.\n *@property {Boolean} [rotateText=false] Gauge labels are rotated or not according to label angle position.\n *@property {String} [shape=\"circle\"] Gauge style (\"circle\", \"rectangle\", \"segment\").\n *@property {Boolean} [drag.enabled=true] Allows mouse/touch dragging the Gauge hand to change current value.\n *@property {Tee.Format} bevel Formatting properties to outmost external gauge bevel.\n *@property {Tee.Format} center Formatting properties for center gauge symbol.\n */\nexport class NumericGauge extends Series {\n\tdeclare bevel: Format\n\tdeclare center: Format\n\tdeclare ticks: Format\n\tdeclare ticksBack: Format\n\tdeclare minor: Format\n\tdeclare minorBack: Format\n\tdeclare back: Format\n\t/** The gauge pointer is a Format. Only CustomSeries have a point marker (`Pointer`). */\n\tdeclare pointer: Format\n\tdeclare units: Annotation\n\tdeclare valueMarker: Format\n\tdeclare unitsMarker: Format\n\tdeclare textMarker: Format\n\tdeclare dragging: boolean\n\tbounds: GaugeBounds\n\tuseAxes = false\n\n\t// Range and value:\n\tmin = 0\n\tmax = 100\n\tstep = 0\n\tvalue = 0\n\tinverted = false\n\tonchange: ((gauge: NumericGauge) => void) | undefined\n\n\t// Rotation options:\n\tangle = 280 // degree\n\trotation = 0 // degree\n\trotateText = false\n\tshape = \"rectangle\" // rectangle, segment\n\n\tdrag = { enabled: true }\n\tmarkers: Format[] = []\n\toldValue = Number.NaN\n\tnewValue = Number.NaN\n\ttick0 = Number.NaN\n\ttick1 = Number.NaN\n\ttickMin = Number.NaN\n\ttickText = Number.NaN\n\tinitRot = Number.NaN\n\tendRot = Number.NaN\n\tcx = Number.NaN\n\tcy = Number.NaN\n\tcex = Number.NaN\n\tcey = Number.NaN\n\tp: GaugePoint = { x: 0, y: 0, value: 0, inTicks: false }\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\t// no axis\n\t\tthis.legend.visible = false\n\n\t\tthis.bevel = new Format(this.chart)\n\t\tthis.bevel.gradient.visible = true\n\t\tthis.bevel.gradient.colors = [\"white\"]\n\t\tthis.bevel.shadow.visible = false\n\t\tthis.bevel.visible = false\n\t\tthis.bevel.stroke.fill = \"\"\n\n\t\tthis.center = new Format(this.chart)\n\t\tthis.center.stroke.fill = \"\"\n\t\tthis.center.gradient.visible = true\n\t\tthis.center.size = 10\n\t\tthis.center.visible = false\n\t\tthis.center.shadow.visible = true\n\t\tthis.center.gradient.offset = { x: 2, y: -2 }\n\t\tthis.center.location = { x: 0, y: 0 } // %\n\n\t\tthis.center.top = new Format(this.chart)\n\t\tthis.center.top.size = 40 // %\n\t\tthis.center.top.visible = true\n\t\tthis.center.top.stroke.fill = \"\"\n\t\tthis.center.top.gradient.colors = [\"silver\", \"white\"]\n\t\tthis.center.top.gradient.visible = true\n\t\tthis.center.top.gradient.direction = \"topbottom\"\n\n\t\tthis.ticks = new Format(this.chart)\n\t\tthis.ticks.length = 6 // %\n\t\tthis.ticks.stroke.fill = \"silver\"\n\t\tthis.ticks.visible = true\n\t\tthis.ticks.outside = true\n\t\tthis.ticks.triangle = false\n\t\tthis.ticks.fill = \"white\"\n\n\t\tthis.ticksBack = new Format(this.chart)\n\t\tthis.ticksBack.stroke.fill = \"\"\n\t\tthis.ticksBack.fill = \"black\"\n\t\tthis.ticksBack.gradient.visible = true\n\t\tthis.ticksBack.gradient.colors = [\"red\", \"yellow\", \"green\"]\n\t\tthis.ticksBack.gradient.direction = \"rightleft\"\n\t\tthis.ticksBack.visible = false\n\t\tthis.ticksBack.radius = 0\n\n\t\tthis.minor = new Format(this.chart)\n\t\tthis.minor.stroke.fill = \"silver\"\n\t\tthis.minor.visible = true\n\t\tthis.minor.count = 4\n\t\tthis.minor.shape = \"\" // ellipse\n\n\t\tthis.minorBack = new Format(this.chart)\n\t\tthis.minorBack.stroke.fill = \"\"\n\t\tthis.minorBack.visible = false\n\t\tthis.minorBack.fill = \"white\"\n\t\tthis.minorBack.gradient.visible = false\n\t\tthis.minorBack.gradient.direction = \"leftright\"\n\t\tthis.minorBack.gradient.colors = [\"green\", \"yellow\", \"red\"]\n\t\tthis.minorBack.radius = 0\n\n\t\t// shape background\n\t\tthis.back = new Format(this.chart)\n\t\tthis.back.fill = \"black\"\n\t\tthis.back.visible = true\n\t\tthis.back.gradient.visible = false\n\t\tthis.back.gradient.colors = [\"rgba(255,126,95,0.8)\", \"rgba(254,180,123,0.8)\"]\n\t\tthis.back.stroke.fill = \"\"\n\n\t\tthis.pointer = new Format(this.chart)\n\t\tthis.pointer.size = 3\n\t\tthis.pointer.fill = \"black\"\n\t\tthis.pointer.stroke.fill = \"\"\n\t\tthis.pointer.visible = false\n\n\t\tthis.marks.format.fill = \"black\"\n\t\tthis.marks.format.font.fill = \"black\"\n\t\tthis.marks.format.gradient.visible = true\n\t\tthis.marks.format.gradient.colors = [\"rgba(255,126,95,0.6)\", \"rgba(254,180,123,0.6)\"]\n\t\tthis.marks.format.shadow.visible = true\n\t\tthis.marks.format.shadow.blur = 8\n\t\tthis.marks.format.shadow.color = \"black\"\n\n\t\tthis.format.visible = true\n\t\tthis.format.gradient.visible = true\n\t\tthis.format.gradient.colors = [\"white\"]\n\t\tthis.format.shadow.visible = true\n\t\tthis.format.font.style = \"12px Verdana\"\n\t\tthis.format.font.fill = \"black\"\n\t\tthis.format.font.visible = true\n\t\tthis.format.size = 2 // %\n\t\tthis.format.round = { x: 6, y: 6 }\n\n\t\tthis.format.padding = 0 // %\n\n\t\tthis.units = new Annotation(this.chart)\n\t\tthis.units.transparent = true\n\t\tthis.units.format.font.fill = \"black\"\n\t\tthis.units.location = { x: 0, y: 24 } // %\n\n\t\tthis.bounds = this.getRect() as GaugeBounds\n\n\t\t// markers (Text, Value and Units)\n\t\tthis.valueMarker = this.addValueMarker()\n\t\tthis.textMarker = this.addTextMarker()\n\t\tthis.unitsMarker = this.addUnitsMarker()\n\n\t\tthis.hover.enabled = true\n\n\t\tthis.animate = new BaseAnimation(this.chart, fAnimation => {\n\t\t\tthis.value = this.oldValue + fAnimation * (this.newValue - this.oldValue)\n\t\t\tthis.chart.draw()\n\t\t})\n\n\t\tthis.animate.duration = 100\n\t\tthis.animate.onstop = () => {\n\t\t\tthis.value = this.newValue\n\n\t\t\tif (this.onchange) this.onchange(this)\n\t\t\tthis._emit(\"change\", this)\n\n\t\t\tthis.chart.draw()\n\t\t}\n\t}\n\n\taddValueMarker(): Format {\n\t\tconst marker = new Format(this.chart)\n\n\t\tmarker.fill = \"white\"\n\t\tmarker.font.fill = \"black\"\n\t\tmarker.font.style = \"82px Arial\"\n\t\tmarker.text = \"0\"\n\n\t\tmarker.location = { x: 38, y: 6 } // %\n\t\tmarker.position = { x: 30, y: 40 } // %\n\t\tmarker.width = 60 // %\n\t\tmarker.height = 88 // %\n\n\t\tmarker.shape = \"rectangle\"\n\n\t\tmarker.visible = true\n\n\t\tthis.markers.push(marker)\n\t\treturn marker\n\t}\n\n\tdestroy(): void {\n\t\tthis.units?.destroy?.()\n\t\tsuper.destroy()\n\t}\n\n\taddTextMarker(): Format {\n\t\tconst marker = new Format(this.chart)\n\n\t\tmarker.fill = \"white\"\n\t\tmarker.font.fill = \"black\"\n\t\tmarker.font.style = \"40px Arial\"\n\t\tmarker.font.textAlign = \"left\"\n\t\tmarker.text = \"FREQ\"\n\n\t\tmarker.location = { x: 1, y: 5 } // %\n\t\tmarker.position = { x: 37, y: 25 } // %\n\t\tmarker.width = 20 // %\n\t\tmarker.height = 20 // %\n\n\t\tmarker.shape = \"rectangle\"\n\n\t\tmarker.visible = true\n\n\t\tthis.markers.push(marker)\n\t\treturn marker\n\t}\n\n\taddUnitsMarker(): Format {\n\t\tconst marker = new Format(this.chart)\n\t\tmarker.fill = \"white\"\n\t\tmarker.font.fill = \"black\"\n\t\tmarker.font.style = \"40px Arial\"\n\t\tmarker.font.textAlign = \"left\"\n\t\tmarker.text = \"Mhz\"\n\n\t\tmarker.location = { x: 1, y: 55 } // %\n\t\tmarker.position = { x: 37, y: 32 } // %\n\t\tmarker.width = 20 // %\n\t\tmarker.height = 41 // %\n\n\t\tmarker.shape = \"rectangle\"\n\n\t\tmarker.visible = true\n\n\t\tthis.markers.push(marker)\n\t\treturn marker\n\t}\n\n\tcalcBounds(): Rectangle {\n\t\treturn this.bounds.custom ? this.bounds : this.cellRect(this.bounds, true)\n\t}\n\n\tdrawMarker(marker: Format, bounds: Rectangle, ctx: CanvasRenderingContext2D): void {\n\t\tif (marker.visible) {\n\t\t\t// marker shape\n\t\t\tconst shapeWidth = (bounds.width * marker.width) / 100\n\t\t\tconst shapeHeight = (bounds.height * marker.height) / 100\n\t\t\tconst shapeLocation = {\n\t\t\t\tx: (bounds.width * percentLocation(marker.location).x) / 100,\n\t\t\t\ty: (bounds.height * percentLocation(marker.location).y) / 100\n\t\t\t}\n\t\t\tctx.fillStyle = marker.fill\n\t\t\tctx.fillRect(shapeLocation.x, shapeLocation.y, shapeWidth, shapeHeight)\n\t\t\tctx.font = marker.font.style\n\t\t\tctx.fillStyle = marker.font.fill\n\n\t\t\t// marker text\n\t\t\tconst lblX = shapeLocation.x + (shapeWidth * marker.position.x) / 100\n\t\t\tconst lblY = shapeLocation.y + (shapeHeight * marker.position.y) / 100\n\t\t\tctx.fillText(marker.text, lblX, lblY)\n\t\t\tctx.save()\n\t\t}\n\t}\n\n\tdraw(): void {\n\t\tconst ctx = this.chart.drawContext\n\n\t\tconst bounds = this.calcBounds()\n\n\t\tif (this.back.visible) {\n\t\t\tctx.fillStyle = this.back.fill\n\t\t\tctx.fillRect(0, 0, bounds.width, bounds.height)\n\t\t\tctx.save()\n\t\t}\n\n\t\tthis.markers.forEach(marker => {\n\t\t\tthis.drawMarker(marker, bounds, ctx)\n\t\t})\n\t}\n\n\tlimitValue(v: number): number {\n\t\treturn Math.min(this.max, Math.max(this.min, v))\n\t}\n\n\tsetValue(v: number): boolean {\n\t\tv = this.limitValue(v)\n\n\t\tconst res = this.value !== v\n\n\t\tif (res) {\n\t\t\tconst animate = this.animate\n\t\t\tif (animate?.active && animate.duration > 0) {\n\t\t\t\tthis.oldValue = this.value\n\t\t\t\tthis.newValue = v\n\t\t\t\tanimate.animate(this.chart)\n\t\t\t} else {\n\t\t\t\tthis.value = v\n\n\t\t\t\tif (this.onchange) this.onchange(this)\n\t\t\t\tthis._emit(\"change\", this)\n\t\t\t}\n\t\t}\n\t\tthis.valueMarker.text = v.toFixed()\n\n\t\treturn res\n\t}\n\n\tonclick(): void {}\n\n\tclicked(): number {\n\t\tthis.dragging = false\n\t\treturn -1\n\t}\n\n\tinValue(p: GaugePoint, r: Rectangle): boolean {\n\t\tif (!r.contains(p)) return false\n\n\t\tconst dx = p.x - this.cex,\n\t\t\tdy = p.y - this.cey,\n\t\t\td = Math.sqrt(dx * dx + dy * dy)\n\n\t\tlet ang = Math.atan2(dy, dx) - Math.PI * 0.5\n\t\twhile (ang < 0) ang += 6.283\n\n\t\tlet rIni: number, rEnd: number, val: boolean\n\n\t\tif (this.initRot > this.endRot) {\n\t\t\trIni = this.endRot\n\t\t\trEnd = this.initRot\n\t\t\tval = ang >= rEnd || ang <= rIni\n\t\t} else {\n\t\t\trEnd = this.endRot\n\t\t\trIni = this.initRot\n\t\t\tval = ang >= rIni && ang <= rEnd\n\t\t}\n\n\t\tif (val) {\n\t\t\tlet res: number\n\n\t\t\tif (this.initRot > this.endRot)\n\t\t\t\tif (ang > rEnd) res = (ang - rEnd) / (6.283 - rEnd + rIni)\n\t\t\t\telse res = (6.283 - rEnd + ang) / (6.283 - rEnd + rIni)\n\t\t\telse res = (ang - rIni) / (rEnd - rIni)\n\n\t\t\tlet v = this.min + (this.max - this.min) * res\n\n\t\t\tif (this.inverted) v = this.min + (this.max - this.min) * (1 - res)\n\n\t\t\tp.value = v\n\n\t\t\tp.inTicks = d >= Math.min(this.tick0, this.tickText) && d <= this.tick1\n\n\t\t\treturn true\n\t\t} else {\n\t\t\tp.inTicks = false\n\t\t\treturn false\n\t\t}\n\t}\n\n\tchangeHover(v: number | null): void {\n\t\tif (this.hover.value !== v) {\n\t\t\tthis.hover.value = v\n\t\t\tthis.hover.valid = v !== null\n\t\t\tthis.chart._scheduleDraw()\n\t\t}\n\t}\n\n\tmousemove(p: GaugePoint): void {\n\t\tconst r = this.calcBounds(),\n\t\t\tok = this.inValue(p, r)\n\t\tif (\n\t\t\tthis.dragging ||\n\t\t\t(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(getNavigator()?.userAgent || \"\") &&\n\t\t\t\tthis.drag.enabled)\n\t\t) {\n\t\t\tif (ok && this.setValue(p.value)) this.chart.draw()\n\n\t\t\tthis.chart.newCursor = \"pointer\"\n\t\t} else if (p.inTicks && this.drag.enabled) {\n\t\t\tthis.changeHover(p.value)\n\t\t\tthis.chart.newCursor = \"pointer\"\n\t\t} else this.changeHover(null)\n\t}\n\n\tmousedown(e: Event): boolean {\n\t\tif (this.drag.enabled) {\n\t\t\tconst r = this.calcBounds()\n\t\t\tthis.chart.calcMouse(e, this.p)\n\n\t\t\tif (this.inValue(this.p, r)) {\n\t\t\t\tthis.dragging = true\n\n\t\t\t\tthis.hover.value = null\n\t\t\t\tthis.hover.valid = false\n\n\t\t\t\tif (this.setValue(this.p.value)) this.chart.draw()\n\t\t\t} else this.dragging = false\n\n\t\t\treturn this.dragging\n\t\t} else return false\n\t}\n\n\t/**\n\t */\n\tsetChart(series: Series, chart: Chart): void {\n\t\tsuper.setChart(series, chart)\n\t\tconst gauge = series as NumericGauge\n\n\t\tthis.chart.panel.margins.bottom = 0\n\t\tthis.chart.panel.margins.right = 0\n\t\tthis.chart.panel.margins.top = 0\n\t\tthis.chart.panel.margins.left = 0\n\n\t\tgauge.back.setChart(chart)\n\t\tgauge.center.setChart(chart)\n\t\tgauge.center.top?.setChart(chart)\n\t\tgauge.ticks.setChart(chart)\n\t\tgauge.ticksBack.setChart(chart)\n\t\tgauge.minor.setChart(chart)\n\t\tgauge.minorBack.setChart(chart)\n\t\tgauge.units.setChart(chart)\n\t\tgauge.pointer.setChart(chart)\n\t\tgauge.bevel.setChart(chart)\n\t}\n}\n","import type { Axis } from \"../core/elements/axis.js\"\nimport type { Point, Rectangle } from \"../core/primitives.js\"\nimport type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { trunc } from \"../utils.js\"\nimport { CustomSeries } from \"./custom-series.js\"\n\n/**\n * @constructor\n * @augments Tee.CustomSeries\n * @class Draws values as Polar / Radar charts.\n * @property {Number} [rotation = 0] Rotates polar points, from 0 to 360 degree.\n * @property {Boolean} [clockwise = true] Direction of Values.\n */\nexport class Polar extends CustomSeries {\n\tdeclare rotation: number\n\tdeclare useOrigin: boolean\n\tdeclare origin: number\n\tdeclare clockwise: boolean\n\tdeclare _polarPoint: { x: number; y: number }\n\tdeclare _polarCenter: { x: number; y: number }\n\tdeclare _polarRadius: number\n\tdeclare _pi180: number\n\tdeclare style: string\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tthis.pointer.visible = true\n\t\tthis.rotation = 0 // degress from 0 to 360\n\n\t\tthis._paintAxes = false\n\t\tthis._paintWalls = false\n\t\tthis.continuous = false\n\t\tthis.useOrigin = false\n\t\tthis.origin = 0\n\t\tthis.clockwise = true\n\n\t\tthis._polarPoint = { x: 0, y: 0 }\n\t\tthis._polarCenter = { x: 0, y: 0 }\n\t\tthis._polarRadius = 0\n\t\tthis._pi180 = Math.PI / 180\n\n\t\tconst f = this.format\n\t\tf.stroke.fill = \"black\"\n\t\tf.z = 0.5\n\t}\n\n\tcalc(index: number, p: Point): void {\n\t\tconst d = this.data\n\t\tconst v = d.values[index]\n\t\tconst mand = this.mandatoryAxis\n\t\tconst x = d.x ? Number(d.x[index]) : (360 * index) / d.values.length\n\t\tconst dif = mand.inverted ? mand.maximum - v : v - mand.minimum\n\t\tconst angle = this.clockwise ? this._pi180 * (this.rotation + x) : -(this._pi180 * (this.rotation + x))\n\t\tconst rad = (dif * this._polarRadius) / (mand.maximum - mand.minimum)\n\t\tconst center = this._polarCenter\n\n\t\tp.x = center.x + Math.cos(angle) * rad\n\t\tp.y = center.y + Math.sin(angle) * rad\n\t}\n\n\ttryDrawAxis(axis: Axis, px: number, py: number): void {\n\t\tif (axis.visible) {\n\t\t\tconst old = axis.axisPos\n\t\t\taxis.axisPos = px\n\t\t\taxis.startPos = py - this._polarRadius\n\t\t\taxis.endPos = py + this._polarRadius\n\n\t\t\tconst oldz = axis.z\n\t\t\taxis.z = 1 - axis.chart.walls.back.size * 0.5 - 0.1\n\n\t\t\taxis.drawAxis()\n\n\t\t\taxis.axisPos = old\n\t\t\taxis.z = oldz\n\t\t}\n\t}\n\n\tcalcCenter(r: Rectangle, axis: Axis): void {\n\t\tconst rw = r.width\n\t\tconst rh = r.height\n\t\tconst center = this._polarCenter\n\n\t\tcenter.x = r.x + 0.5 * rw\n\t\tcenter.y = r.y + 0.5 * rh\n\t\tthis._polarRadius = Math.min(rw, rh) * 0.5\n\n\t\tif (axis.visible && axis.labels.visible) {\n\t\t\tconst textH = axis.labels.format.textHeight(\"W\")\n\t\t\tthis._polarRadius -= textH\n\t\t}\n\t}\n\n\tbeforeDraw(): void {\n\t\tlet oldz: number\n\n\t\tthis.calcCenter(this.chart.chartRect, this.notmandatory)\n\n\t\tconst center = this._polarCenter\n\t\tconst radius = this._polarRadius\n\t\tconst pi180 = this._pi180\n\t\tconst walls = this.chart.walls\n\n\t\tif (walls.visible) {\n\t\t\tconst wall = walls.back\n\n\t\t\tif (wall.visible) {\n\t\t\t\tconst wallFormat = wall.format\n\n\t\t\t\toldz = wallFormat.z\n\t\t\t\twallFormat.z = 1\n\t\t\t\twallFormat.ellipse(center.x, center.y, 2 * radius, 2 * radius)\n\t\t\t\twallFormat.z = oldz\n\t\t\t}\n\t\t}\n\n\t\tif (this.chart.axes.visible) {\n\t\t\tconst nomand = this.notmandatory\n\t\t\tconst nomandgrid = nomand.grid.format.stroke\n\t\t\tconst mand = this.mandatoryAxis\n\t\t\tlet vmin = 0\n\t\t\tconst ctx = this.chart.drawContext\n\t\t\tlet angle: number\n\t\t\tlet labelincrem = 10\n\t\t\tconst nomandrotation = (nomand as { rotation?: number }).rotation || 0\n\n\t\t\tif (nomand.visible && nomand.labels.visible) {\n\t\t\t\tconst rText = { x: 0, y: 0, width: 0, height: 0 }\n\t\t\t\tconst labelsF = nomand.labels.format\n\t\t\t\tconst textH = labelsF.textHeight(\"W\")\n\t\t\t\tconst labelRadius = radius + textH * 0.8\n\n\t\t\t\tlabelincrem = Math.max(10, 90 / trunc(radius / textH))\n\n\t\t\t\toldz = labelsF.z\n\t\t\t\tlabelsF.z = 0.6\n\n\t\t\t\tvmin = 0\n\t\t\t\twhile (vmin < 360) {\n\t\t\t\t\tangle = this.clockwise ? pi180 * (vmin + nomandrotation) : -(pi180 * (vmin + nomandrotation))\n\n\t\t\t\t\trText.x = center.x + Math.cos(angle) * labelRadius\n\t\t\t\t\trText.y = center.y + Math.sin(angle) * labelRadius - textH * 0.5\n\n\t\t\t\t\tlabelsF.drawText(rText, `${vmin}`)\n\n\t\t\t\t\tvmin += labelincrem\n\t\t\t\t}\n\n\t\t\t\tlabelsF.z = oldz\n\t\t\t}\n\n\t\t\tif (nomand.visible && nomand.grid.visible) {\n\t\t\t\tconst gridincrem = nomand.increment || 10\n\n\t\t\t\tctx.z = 1 - walls.back.size * 0.5 - 0.1\n\t\t\t\tctx.beginPath()\n\n\t\t\t\tvmin = 0\n\n\t\t\t\twhile (vmin < 360) {\n\t\t\t\t\tangle = pi180 * (vmin + nomandrotation)\n\n\t\t\t\t\tctx.moveTo(center.x, center.y)\n\t\t\t\t\tctx.lineTo(center.x + Math.cos(angle) * radius, center.y + Math.sin(angle) * radius)\n\n\t\t\t\t\tvmin += gridincrem\n\t\t\t\t}\n\n\t\t\t\tnomandgrid.prepare(nomandgrid.fill, ctx)\n\t\t\t\tctx.stroke()\n\t\t\t}\n\n\t\t\tif (mand.visible && mand.grid.visible) {\n\t\t\t\tvmin = mand.roundMin()\n\n\t\t\t\tlet rad: number\n\t\t\t\tconst mandgrid = mand.grid.format\n\t\t\t\tconst gridstep = (2 * radius) / (mand.maximum - mand.minimum)\n\n\t\t\t\toldz = mandgrid.z\n\n\t\t\t\tmandgrid.z = 1 - walls.back.size * 0.5 - 0.1\n\t\t\t\tctx.z = mandgrid.z\n\n\t\t\t\twhile (vmin < mand.maximum) {\n\t\t\t\t\trad = (vmin - mand.minimum) * gridstep\n\t\t\t\t\tmandgrid.ellipse(center.x, center.y, rad, rad)\n\t\t\t\t\tvmin += mand.increm\n\t\t\t\t}\n\n\t\t\t\tmandgrid.z = oldz\n\t\t\t}\n\n\t\t\tthis.tryDrawAxis(mand, center.x, center.y)\n\t\t\tthis.tryDrawAxis(nomand, center.y, center.x)\n\t\t}\n\t}\n\n\tdraw(): void {\n\t\tthis.calcCenter(this.chart.chartRect, this.notmandatory)\n\n\t\tconst p = this._polarPoint\n\t\tconst pp = []\n\t\tlet len = this.data.values.length\n\t\tlet t: number\n\n\t\tfor (t = 0; t < len; t++)\n\t\t\tif (!this.isNull(t)) {\n\t\t\t\tthis.calc(t, p)\n\t\t\t\tpp.push({ x: p.x, y: p.y })\n\t\t\t}\n\n\t\tlen = pp.length\n\n\t\tif (len > 0) {\n\t\t\tconst center = this._polarCenter\n\n\t\t\tif (this.style === \"bar\") {\n\t\t\t\tconst ctx = this.chart.drawContext\n\t\t\t\tctx.beginPath()\n\n\t\t\t\tfor (t = 0; t < len; t++) {\n\t\t\t\t\tctx.moveTo(center.x, center.y)\n\t\t\t\t\tctx.lineTo(pp[t].x, pp[t].y)\n\t\t\t\t}\n\n\t\t\t\tthis.format.stroke.prepare(this.format.fill, ctx)\n\t\t\t\tctx.stroke()\n\t\t\t} else this.format.polygon(pp)\n\n\t\t\tif (this.pointer.visible) this.drawPointers()\n\t\t}\n\t}\n\n\tminYValue(): number {\n\t\tconst v = this._baseMinYValue()\n\t\treturn this.useOrigin ? Math.min(v, this.origin) : v\n\t}\n\n\tmaxYValue(): number {\n\t\tconst v = this.stackMaxValue()\n\t\treturn this.useOrigin ? Math.max(v, this.origin) : v\n\t}\n}\n","import type { Point } from \"../core/primitives.js\"\nimport { Series, type TooltipParts } from \"../series.js\"\n\n/** A flow of `value` from the node named `source` to the node named `target`. */\nexport interface SankeyLink {\n\tsource: string\n\ttarget: string\n\tvalue: number\n\t/** Overrides the link color, which otherwise follows `Sankey.linkColor`. */\n\tcolor?: string\n}\n\nexport interface SankeyNode {\n\tname: string\n\t/** Overrides the palette color of the node. */\n\tcolor?: string\n}\n\n/**\n * The flow graph of a Sankey series. Nodes are created from the links in order of appearance; list `nodes`\n * to set their colors or to control their vertical order in the first column.\n */\nexport interface SankeyGraph {\n\tlinks: SankeyLink[]\n\tnodes?: Array<string | SankeyNode>\n}\n\nexport type SankeyLinkColor = \"source\" | \"target\" | \"gradient\"\n\ninterface NodeLayout {\n\tindex: number\n\tname: string\n\tcolor: string | undefined\n\tvalue: number\n\tdepth: number\n\tx0: number\n\tx1: number\n\ty0: number\n\ty1: number\n\tout: LinkLayout[]\n\tin: LinkLayout[]\n}\n\ninterface LinkLayout {\n\tsource: NodeLayout\n\ttarget: NodeLayout\n\tvalue: number\n\twidth: number\n\tcolor: string | undefined\n\t/** Vertical center of the link where it leaves the source and where it enters the target. */\n\ty0: number\n\ty1: number\n}\n\nconst labelGap = 6\n\n/**\n * @constructor\n * @augments Tee.Series\n * @class Plots a Sankey diagram: nodes arranged in columns, joined by links whose width is proportional to the\n * flow between them. The data is a graph without cycles; see `SankeyGraph`.\n *\n * Points are the nodes first, then the links: `data.values` holds the node totals and `data.labels` the node\n * names. Hover, tooltips and `clicked` return the node index, or `nodeCount + linkIndex` for a link.\n */\nexport class Sankey extends Series {\n\tuseAxes = false\n\tcolorEach = \"yes\"\n\t/** Width of the node bars in pixels. */\n\tnodeWidth = 16\n\t/** Minimum vertical space between the nodes of a column in pixels. */\n\tnodePadding = 14\n\t/** Opacity of the links, from 0 to 1. */\n\tlinkOpacity = 0.45\n\t/** Link painting: the color of the source node, of the target node, or a gradient between both. */\n\tlinkColor: SankeyLinkColor = \"source\"\n\t/** Number of relaxation passes that move nodes toward the nodes they are linked to. */\n\titerations = 6\n\t/** Draws the node names and values. */\n\tlabels = true\n\t/** Formats the values shown in labels and tooltips. */\n\tformatValue: ((value: number) => string) | undefined\n\n\tprivate nodes: NodeLayout[] = []\n\tprivate links: LinkLayout[] = []\n\tprivate columns: NodeLayout[][] = []\n\t/** The last position passed to `clicked`, which is where the pointer is. */\n\tprivate lastPoint = { x: 0, y: 0 }\n\n\tconstructor(graph?: SankeyGraph | null) {\n\t\tsuper()\n\t\tthis.hover.enabled = true\n\t\tthis.marks.visible = false\n\t\tthis.format.stroke.fill = \"\"\n\t\tif (graph) this.setGraph(graph, false)\n\t}\n\n\t/** Replaces the flow graph. Throws when a link is invalid or the links form a cycle. */\n\tsetGraph(graph: SankeyGraph, redraw = true): this {\n\t\tthis.build(graph)\n\t\tthis.over = -1\n\t\tif (redraw && this.chart) {\n\t\t\tif (this.chart._requestDraw) this.chart._requestDraw()\n\t\t\telse this.chart.draw()\n\t\t}\n\t\treturn this\n\t}\n\n\tprivate build(graph: SankeyGraph): void {\n\t\tconst byName = new Map<string, NodeLayout>()\n\t\tconst nodes: NodeLayout[] = []\n\t\tconst node = (name: string, color?: string): NodeLayout => {\n\t\t\tlet item = byName.get(name)\n\t\t\tif (!item) {\n\t\t\t\titem = {\n\t\t\t\t\tindex: nodes.length,\n\t\t\t\t\tname,\n\t\t\t\t\tcolor,\n\t\t\t\t\tvalue: 0,\n\t\t\t\t\tdepth: 0,\n\t\t\t\t\tx0: 0,\n\t\t\t\t\tx1: 0,\n\t\t\t\t\ty0: 0,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\tout: [],\n\t\t\t\t\tin: []\n\t\t\t\t}\n\t\t\t\tbyName.set(name, item)\n\t\t\t\tnodes.push(item)\n\t\t\t} else if (color !== undefined) item.color = color\n\t\t\treturn item\n\t\t}\n\n\t\tfor (const declared of graph.nodes ?? [])\n\t\t\tif (typeof declared === \"string\") node(declared)\n\t\t\telse node(declared.name, declared.color)\n\n\t\tconst links: LinkLayout[] = []\n\t\tfor (const link of graph.links ?? []) {\n\t\t\tif (!Number.isFinite(link.value) || link.value < 0)\n\t\t\t\tthrow new RangeError(`Sankey link ${link.source} -> ${link.target} needs a value of zero or more`)\n\t\t\tif (link.source === link.target) throw new Error(`Sankey link ${link.source} -> ${link.target} is a cycle`)\n\t\t\tif (link.value === 0) continue\n\t\t\tconst item: LinkLayout = {\n\t\t\t\tsource: node(link.source),\n\t\t\t\ttarget: node(link.target),\n\t\t\t\tvalue: link.value,\n\t\t\t\twidth: 0,\n\t\t\t\tcolor: link.color,\n\t\t\t\ty0: 0,\n\t\t\t\ty1: 0\n\t\t\t}\n\t\t\titem.source.out.push(item)\n\t\t\titem.target.in.push(item)\n\t\t\tlinks.push(item)\n\t\t}\n\n\t\tthis.computeDepths(nodes)\n\n\t\tfor (const item of nodes) {\n\t\t\tconst inValue = item.in.reduce((sum, link) => sum + link.value, 0)\n\t\t\tconst outValue = item.out.reduce((sum, link) => sum + link.value, 0)\n\t\t\titem.value = Math.max(inValue, outValue)\n\t\t}\n\n\t\tthis.nodes = nodes\n\t\tthis.links = links\n\t\tconst columns: NodeLayout[][] = []\n\t\tfor (const item of nodes) {\n\t\t\tconst column = columns[item.depth] ?? []\n\t\t\tcolumn.push(item)\n\t\t\tcolumns[item.depth] = column\n\t\t}\n\t\tthis.columns = columns\n\n\t\tthis.data.values = nodes.map(item => item.value)\n\t\tthis.data.labels = nodes.map(item => item.name)\n\t}\n\n\t/** Column of each node: the longest path from a source; nodes that only receive flow go to the last column. */\n\tprivate computeDepths(nodes: NodeLayout[]): void {\n\t\tconst pending = nodes.map(item => item.in.length)\n\t\tconst queue = nodes.filter(item => pending[item.index] === 0)\n\t\tlet visited = 0\n\t\tlet maxDepth = 0\n\n\t\tfor (let head = 0; head < queue.length; head++) {\n\t\t\tconst item = queue[head]\n\t\t\tvisited++\n\t\t\tmaxDepth = Math.max(maxDepth, item.depth)\n\t\t\tfor (const link of item.out) {\n\t\t\t\tlink.target.depth = Math.max(link.target.depth, item.depth + 1)\n\t\t\t\tif (--pending[link.target.index] === 0) queue.push(link.target)\n\t\t\t}\n\t\t}\n\n\t\tif (visited < nodes.length) throw new Error(\"Sankey links cannot contain cycles\")\n\n\t\tfor (const item of nodes) if (item.out.length === 0 && item.in.length > 0) item.depth = maxDepth\n\t}\n\n\tprivate formatNumber(value: number): string {\n\t\treturn this.formatValue ? this.formatValue(value) : String(Math.round(value * 100) / 100)\n\t}\n\n\tprivate text(index: number): string {\n\t\treturn this.formatNumber(this.data.values[index])\n\t}\n\n\tvalueText(index: number): string {\n\t\tconst link = this.links[index - this.nodes.length]\n\t\treturn link ? this.formatNumber(link.value) : this.text(index)\n\t}\n\n\tlegendColor(index: number): string {\n\t\tconst link = this.links[index - this.nodes.length]\n\t\treturn link ? this.linkStyleColor(link) : this.nodeColor(this.nodes[index])\n\t}\n\n\ttooltipParts(index: number): TooltipParts | undefined {\n\t\tconst link = this.links[index - this.nodes.length]\n\t\tif (link) {\n\t\t\tconst share = (link.value / Math.max(link.source.value, Number.EPSILON)) * 100\n\t\t\treturn {\n\t\t\t\tlabel: `${link.source.name} → ${link.target.name}`,\n\t\t\t\tvalue: this.formatNumber(link.value),\n\t\t\t\tcolor: this.linkStyleColor(link),\n\t\t\t\tdetails: [[`Share of ${link.source.name}`, `${share.toFixed(1)}%`]]\n\t\t\t}\n\t\t}\n\t\tconst node = this.nodes[index]\n\t\tif (!node) return undefined\n\t\tconst total = (links: LinkLayout[]) => links.reduce((sum, item) => sum + item.value, 0)\n\t\tconst details: [string, string][] = []\n\t\tif (node.in.length > 0) details.push([\"Incoming\", this.formatNumber(total(node.in))])\n\t\tif (node.out.length > 0) details.push([\"Outgoing\", this.formatNumber(total(node.out))])\n\t\treturn { label: node.name, value: this.text(index), color: this.nodeColor(node), details }\n\t}\n\n\tlegendCount(): number {\n\t\treturn 0\n\t}\n\n\tprivate font(): { style: string; fill: string } {\n\t\tconst font = this.chart.axes.left.labels.format.font\n\t\treturn { style: font.style, fill: font.fill }\n\t}\n\n\tprivate labelWidth(ctx: CanvasRenderingContext2D, item: NodeLayout, style: string): number {\n\t\tctx.font = `bold ${style}`\n\t\tconst name = ctx.measureText(item.name).width\n\t\tctx.font = style\n\t\treturn Math.max(name, ctx.measureText(this.text(item.index)).width)\n\t}\n\n\t/** Positions nodes and links inside the chart rectangle. */\n\tprivate layout(ctx: CanvasRenderingContext2D, style: string): void {\n\t\tconst columns = this.columns\n\t\tconst rect = this.chart.chartRect\n\t\tconst last = columns.length - 1\n\t\tlet left = rect.x\n\t\tlet right = rect.x + rect.width\n\n\t\tif (this.labels && columns.length > 0) {\n\t\t\tconst widest = (column: NodeLayout[]) =>\n\t\t\t\tcolumn.reduce((max, item) => Math.max(max, this.labelWidth(ctx, item, style)), 0)\n\t\t\tleft += widest(columns[0]) + labelGap\n\t\t\tif (last > 0) right -= widest(columns[last]) + labelGap\n\t\t}\n\n\t\tconst top = rect.y + 4\n\t\tconst bottom = rect.y + rect.height - 4\n\t\tconst width = Math.max(right - left, this.nodeWidth)\n\t\tconst step = last > 0 ? (width - this.nodeWidth) / last : 0\n\n\t\tlet ky = Number.POSITIVE_INFINITY\n\t\tfor (const column of columns) {\n\t\t\tconst total = column.reduce((sum, item) => sum + item.value, 0)\n\t\t\tif (total > 0) ky = Math.min(ky, (bottom - top - (column.length - 1) * this.nodePadding) / total)\n\t\t}\n\t\tif (!Number.isFinite(ky) || ky < 0) ky = 0\n\n\t\tfor (const [depth, column] of columns.entries()) {\n\t\t\tif (!column) continue\n\t\t\tconst total = column.reduce((sum, item) => sum + item.value * ky, 0) + (column.length - 1) * this.nodePadding\n\t\t\tlet y = top + (bottom - top - total) / 2\n\t\t\tfor (const item of column) {\n\t\t\t\titem.x0 = left + depth * step\n\t\t\t\titem.x1 = item.x0 + this.nodeWidth\n\t\t\t\titem.y0 = y\n\t\t\t\titem.y1 = y + item.value * ky\n\t\t\t\ty = item.y1 + this.nodePadding\n\t\t\t}\n\t\t}\n\t\tfor (const link of this.links) link.width = link.value * ky\n\n\t\tfor (let pass = 0; pass < this.iterations; pass++) {\n\t\t\tconst alpha = 0.99 ** pass\n\t\t\tconst beta = Math.max(1 - alpha, (pass + 1) / this.iterations)\n\t\t\tfor (let depth = last - 1; depth >= 0; depth--) this.relax(columns[depth], \"out\", beta, top, bottom)\n\t\t\tfor (let depth = 1; depth <= last; depth++) this.relax(columns[depth], \"in\", alpha, top, bottom)\n\t\t}\n\n\t\tthis.placeLinks()\n\t}\n\n\tprivate relax(column: NodeLayout[] | undefined, side: \"in\" | \"out\", weight: number, top: number, bottom: number) {\n\t\tif (!column) return\n\t\tfor (const item of column) {\n\t\t\tlet sum = 0\n\t\t\tlet total = 0\n\t\t\tfor (const link of item[side]) {\n\t\t\t\tconst other = side === \"out\" ? link.target : link.source\n\t\t\t\tsum += ((other.y0 + other.y1) / 2) * link.value\n\t\t\t\ttotal += link.value\n\t\t\t}\n\t\t\tif (total === 0) continue\n\t\t\tconst dy = (sum / total - (item.y0 + item.y1) / 2) * weight\n\t\t\titem.y0 += dy\n\t\t\titem.y1 += dy\n\t\t}\n\t\tthis.collide(column, top, bottom)\n\t}\n\n\tprivate collide(column: NodeLayout[], top: number, bottom: number): void {\n\t\tconst padding = this.nodePadding\n\t\tcolumn.sort((a, b) => a.y0 - b.y0 || a.index - b.index)\n\n\t\tlet y = top\n\t\tfor (const item of column) {\n\t\t\tconst dy = y - item.y0\n\t\t\tif (dy > 0) {\n\t\t\t\titem.y0 += dy\n\t\t\t\titem.y1 += dy\n\t\t\t}\n\t\t\ty = item.y1 + padding\n\t\t}\n\n\t\tconst overflow = y - padding - bottom\n\t\tif (overflow > 0) {\n\t\t\tconst lastItem = column[column.length - 1]\n\t\t\tlastItem.y0 -= overflow\n\t\t\tlastItem.y1 -= overflow\n\t\t\ty = lastItem.y0\n\t\t\tfor (let i = column.length - 2; i >= 0; i--) {\n\t\t\t\tconst item = column[i]\n\t\t\t\tconst dy = item.y1 + padding - y\n\t\t\t\tif (dy > 0) {\n\t\t\t\t\titem.y0 -= dy\n\t\t\t\t\titem.y1 -= dy\n\t\t\t\t}\n\t\t\t\ty = item.y0\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Orders the links of each node by the position of the other end, to reduce crossings, and stacks them. */\n\tprivate placeLinks(): void {\n\t\tfor (const item of this.nodes) {\n\t\t\titem.out.sort((a, b) => a.target.y0 - b.target.y0 || a.target.index - b.target.index)\n\t\t\titem.in.sort((a, b) => a.source.y0 - b.source.y0 || a.source.index - b.source.index)\n\n\t\t\tlet y = item.y0\n\t\t\tfor (const link of item.out) {\n\t\t\t\tlink.y0 = y + link.width / 2\n\t\t\t\ty += link.width\n\t\t\t}\n\t\t\ty = item.y0\n\t\t\tfor (const link of item.in) {\n\t\t\t\tlink.y1 = y + link.width / 2\n\t\t\t\ty += link.width\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate nodeColor(item: NodeLayout): string {\n\t\treturn item.color ?? this.getFill(item.index)\n\t}\n\n\t/** The solid color of a link, which is the source color for gradient links. */\n\tprivate linkStyleColor(link: LinkLayout): string {\n\t\treturn link.color ?? this.nodeColor(this.linkColor === \"target\" ? link.target : link.source)\n\t}\n\n\tprivate drawLinks(ctx: CanvasRenderingContext2D): void {\n\t\tconst over = this.over\n\t\tconst overLink = over - this.nodes.length\n\t\tconst base = this.linkOpacity\n\n\t\tfor (const [linkIndex, link] of this.links.entries()) {\n\t\t\tconst x0 = link.source.x1\n\t\t\tconst x1 = link.target.x0\n\t\t\tconst mid = (x0 + x1) / 2\n\t\t\tconst connected =\n\t\t\t\tover === -1 ||\n\t\t\t\t(overLink >= 0 ? linkIndex === overLink : link.source.index === over || link.target.index === over)\n\n\t\t\tlet style: string | CanvasGradient\n\t\t\tif (link.color) style = link.color\n\t\t\telse if (this.linkColor === \"target\") style = this.nodeColor(link.target)\n\t\t\telse if (this.linkColor === \"gradient\") {\n\t\t\t\tconst gradient = ctx.createLinearGradient(x0, 0, x1, 0)\n\t\t\t\tgradient.addColorStop(0, this.nodeColor(link.source))\n\t\t\t\tgradient.addColorStop(1, this.nodeColor(link.target))\n\t\t\t\tstyle = gradient\n\t\t\t} else style = this.nodeColor(link.source)\n\n\t\t\tctx.globalAlpha = over === -1 ? base : connected ? Math.min(1, base + 0.3) : base * 0.35\n\t\t\t// A ribbon between two curves: a thick stroke would distort on steep links.\n\t\t\tconst half = Math.max(link.width, 1) / 2\n\t\t\tctx.beginPath()\n\t\t\tctx.moveTo(x0, link.y0 - half)\n\t\t\tctx.bezierCurveTo(mid, link.y0 - half, mid, link.y1 - half, x1, link.y1 - half)\n\t\t\tctx.lineTo(x1, link.y1 + half)\n\t\t\tctx.bezierCurveTo(mid, link.y1 + half, mid, link.y0 + half, x0, link.y0 + half)\n\t\t\tctx.closePath()\n\t\t\tctx.fillStyle = style\n\t\t\tctx.fill()\n\t\t}\n\t\tctx.globalAlpha = 1\n\t}\n\n\tprivate drawNodes(ctx: CanvasRenderingContext2D): void {\n\t\tfor (const item of this.nodes) {\n\t\t\tconst height = Math.max(item.y1 - item.y0, 1)\n\t\t\tctx.fillStyle = this.nodeColor(item)\n\t\t\tctx.fillRect(item.x0, item.y0, item.x1 - item.x0, height)\n\t\t\tif (item.index === this.over && this.hover.stroke.fill) {\n\t\t\t\tctx.strokeStyle = this.hover.stroke.fill\n\t\t\t\tctx.lineWidth = 1.5\n\t\t\t\tctx.strokeRect(item.x0, item.y0, item.x1 - item.x0, height)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate drawLabels(ctx: CanvasRenderingContext2D, style: string, fill: string): void {\n\t\tconst last = this.columns.length - 1\n\t\tconst lineHeight = Number.parseFloat(style) || 11\n\t\tctx.textBaseline = \"middle\"\n\n\t\tfor (const item of this.nodes) {\n\t\t\tconst centered = last === 0 || item.depth === 0 || item.depth === last\n\t\t\tif (!centered && item.y1 - item.y0 < lineHeight) continue\n\n\t\t\tconst name = item.name\n\t\t\tconst value = this.text(item.index)\n\t\t\tconst cy = (item.y0 + item.y1) / 2\n\t\t\tconst alignLeft = item.depth === 0 && last > 0\n\t\t\tconst x = alignLeft ? item.x0 - labelGap : item.x1 + labelGap\n\t\t\tctx.textAlign = alignLeft ? \"right\" : \"left\"\n\n\t\t\tconst width = this.labelWidth(ctx, item, style)\n\n\t\t\tif (!centered) {\n\t\t\t\t// Labels inside the diagram sit over the links, so they get a translucent backdrop.\n\t\t\t\tconst bx = x - 3\n\t\t\t\tctx.fillStyle = this.chart.panel.format.fill || \"white\"\n\t\t\t\tctx.globalAlpha = 0.75\n\t\t\t\tctx.fillRect(bx, cy - lineHeight - 1, width + 6, lineHeight * 2 + 2)\n\t\t\t\tctx.globalAlpha = 1\n\t\t\t}\n\n\t\t\tctx.fillStyle = fill\n\t\t\tctx.font = `bold ${style}`\n\t\t\tctx.fillText(name, x, cy - lineHeight / 2)\n\t\t\tctx.font = style\n\t\t\tctx.fillText(value, x, cy + lineHeight / 2)\n\t\t}\n\t}\n\n\tdraw(): void {\n\t\tif (this.nodes.length === 0) return\n\n\t\tconst ctx = this.chart.drawContext\n\t\tconst { style, fill } = this.font()\n\n\t\tctx.save()\n\t\t// The chart can leave a shadow enabled on the context; it would blur every link and label.\n\t\tctx.shadowColor = \"transparent\"\n\t\tctx.shadowBlur = 0\n\t\tctx.shadowOffsetX = 0\n\t\tctx.shadowOffsetY = 0\n\t\tthis.layout(ctx, style)\n\t\tthis.drawLinks(ctx)\n\t\tthis.drawNodes(ctx)\n\t\tif (this.labels) this.drawLabels(ctx, style, fill)\n\t\tctx.restore()\n\t}\n\n\t/** The node index under `p`, `nodeCount + linkIndex` for a link, or -1. Nodes are on top of links. */\n\tclicked(p: Point): number {\n\t\tthis.lastPoint.x = p.x\n\t\tthis.lastPoint.y = p.y\n\n\t\tfor (const item of this.nodes)\n\t\t\tif (p.x >= item.x0 && p.x <= item.x1 && p.y >= item.y0 && p.y <= Math.max(item.y1, item.y0 + 1)) return item.index\n\n\t\tlet best = -1\n\t\tlet bestDistance = Number.POSITIVE_INFINITY\n\t\tfor (const [linkIndex, link] of this.links.entries()) {\n\t\t\tconst distance = this.linkDistance(link, p)\n\t\t\tif (distance < bestDistance) {\n\t\t\t\tbestDistance = distance\n\t\t\t\tbest = linkIndex\n\t\t\t}\n\t\t}\n\t\treturn best === -1 ? -1 : this.nodes.length + best\n\t}\n\n\t/** Vertical distance from `p` to the center of the link when inside its ribbon, else infinity. */\n\tprivate linkDistance(link: LinkLayout, p: Point): number {\n\t\tconst x0 = link.source.x1\n\t\tconst x1 = link.target.x0\n\t\tif (p.x < x0 || p.x > x1) return Number.POSITIVE_INFINITY\n\n\t\t// x(t) is monotonic, because both inner control points sit at the middle: find t by bisection.\n\t\tconst mid = (x0 + x1) / 2\n\t\tlet low = 0\n\t\tlet high = 1\n\t\tfor (let i = 0; i < 24; i++) {\n\t\t\tconst t = (low + high) / 2\n\t\t\tconst u = 1 - t\n\t\t\tconst x = u * u * u * x0 + 3 * u * u * t * mid + 3 * u * t * t * mid + t * t * t * x1\n\t\t\tif (x < p.x) low = t\n\t\t\telse high = t\n\t\t}\n\t\tconst t = (low + high) / 2\n\t\tconst u = 1 - t\n\t\tconst y = (u * u * u + 3 * u * u * t) * link.y0 + (3 * u * t * t + t * t * t) * link.y1\n\t\tconst distance = Math.abs(p.y - y)\n\t\treturn distance <= Math.max(link.width, 1) / 2 ? distance : Number.POSITIVE_INFINITY\n\t}\n\n\t/** Where tooltips point at: the pointer position, kept inside the node bar for nodes. */\n\tcalc(index: number, p: Point): void {\n\t\tconst item = this.nodes[index]\n\t\tif (item) {\n\t\t\tp.x = (item.x0 + item.x1) / 2\n\t\t\tp.y = Math.min(Math.max(this.lastPoint.y, item.y0), item.y1)\n\t\t} else {\n\t\t\tp.x = this.lastPoint.x\n\t\t\tp.y = this.lastPoint.y\n\t\t}\n\t}\n}\n","import { Series } from \"../series.js\"\nimport type { SeriesInput, SeriesLabels } from \"../series.js\"\n\n/**\n * @constructor\n * @augments Tee.Series\n * plots a Sliced Treemap\n * @class plots a sliced Treemap.\n */\nexport class Sliced extends Series {\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tthis.useAxes = false\n\t\tthis.colorEach = \"yes\"\n\t}\n\n\tdraw(): void {\n\t\tif (this.data?.values && this.data.labels) {\n\t\t\tconst ctx = this.chart.ctx\n\t\t\tif (!ctx) return\n\n\t\t\tthis.calcColorEach()\n\n\t\t\tconst values = this.data.values\n\t\t\tconst labels = this.data.labels\n\t\t\tconst total = values.reduce((total, value) => total + value, 0)\n\n\t\t\tconst sortedMap = values\n\t\t\t\t.map((value, index) => ({\n\t\t\t\t\tvalue: value,\n\t\t\t\t\tlabel: labels[index]\n\t\t\t\t}))\n\t\t\t\t.sort((a, b) => b.value - a.value)\n\n\t\t\tlet y = 0\n\t\t\tconst canvasHeight = this.chart.chartRect.height\n\t\t\tconst canvasWidth = this.chart.chartRect.width\n\n\t\t\tfor (let i = 0; i < sortedMap.length; i++) {\n\t\t\t\tconst item = sortedMap[i]\n\t\t\t\tconst percentage = item.value / total\n\t\t\t\tconst correspondingHeight = percentage * canvasHeight\n\n\t\t\t\tctx.beginPath()\n\t\t\t\tctx.fillStyle = this.getFill(i, this.format)\n\t\t\t\tctx.fillRect(0, y, canvasWidth, y + correspondingHeight)\n\n\t\t\t\tctx.strokeStyle = \"black\"\n\t\t\t\tctx.lineWidth = 2\n\t\t\t\tctx.strokeRect(0, y, canvasWidth, y + correspondingHeight)\n\n\t\t\t\tctx.closePath()\n\n\t\t\t\tctx.fillStyle = \"white\"\n\t\t\t\tctx.font = \"16px Arial\"\n\t\t\t\tctx.textAlign = \"center\"\n\t\t\t\tctx.textBaseline = \"middle\"\n\t\t\t\tctx.fillText(item.label, canvasWidth / 2, y + correspondingHeight / 2)\n\n\t\t\t\tctx.stroke()\n\n\t\t\t\ty += correspondingHeight\n\t\t\t}\n\t\t}\n\t}\n}\n","import { Chart } from \"../chart.js\"\nimport type { Point } from \"../core/primitives.js\"\nimport { Palette } from \"../palette.js\"\nimport { Series, type TooltipParts } from \"../series.js\"\n\n/**\n * A node of a Treemap. A leaf's area is proportional to its `value` (1 when omitted); a branch's area is the sum\n * of its children, so a branch needs no value.\n */\nexport interface TreemapNode {\n\tname?: string\n\tvalue?: number\n\t/** Overrides the color of the node, which otherwise follows `Treemap.colorBy`. */\n\tcolor?: string\n\tchildren?: TreemapNode[]\n}\n\n/**\n * How the children of a node are arranged: `squarify` keeps the tiles close to squares, `slice` stacks them\n * vertically, `dice` side by side, and `sliceDice` alternates both on each level.\n */\nexport type TreemapTiling = \"squarify\" | \"slice\" | \"dice\" | \"sliceDice\"\n\n/**\n * What decides the color of a tile: the top-level branch it belongs to (deeper tiles are lighter), its depth,\n * or the tile itself.\n */\nexport type TreemapColorBy = \"branch\" | \"level\" | \"node\"\n\ninterface TileLayout {\n\tindex: number\n\tnode: TreemapNode\n\tparent: TileLayout | null\n\tdepth: number\n\tvalue: number\n\t/** Index of the top-level branch the tile belongs to, used by `colorBy = \"branch\"`. */\n\tbranch: number\n\tchildren: TileLayout[]\n\tx: number\n\ty: number\n\twidth: number\n\theight: number\n\t/** Height of the title band of a branch, 0 when it has none. */\n\theader: number\n\t/** True when the children of the node are laid out, so the tile is a container. */\n\topen: boolean\n}\n\nconst labelPadding = 6\n\nfunction parseColor(color: string): [number, number, number] | undefined {\n\tconst hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim())\n\tif (hex) {\n\t\tconst digits = hex[1].length === 3 ? [...hex[1]].map(c => c + c).join(\"\") : hex[1]\n\t\tconst n = Number.parseInt(digits, 16)\n\t\treturn [(n >> 16) & 255, (n >> 8) & 255, n & 255]\n\t}\n\tconst rgb = /^rgba?\\(\\s*(\\d+)[\\s,]+(\\d+)[\\s,]+(\\d+)/i.exec(color.trim())\n\treturn rgb ? [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])] : undefined\n}\n\n/** Mixes `color` with white (`amount` > 0) or black (`amount` < 0). Unknown color formats are returned as they are. */\nfunction shade(color: string, amount: number): string {\n\tconst rgb = parseColor(color)\n\tif (!rgb) return color\n\tconst target = amount < 0 ? 0 : 255\n\tconst k = Math.abs(amount)\n\treturn `rgb(${rgb.map(c => Math.round(c + (target - c) * k)).join(\",\")})`\n}\n\n/** Black or white, whichever reads better on `color`. */\nfunction contrastOf(color: string): string {\n\tconst rgb = parseColor(color)\n\tif (!rgb) return \"white\"\n\treturn (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000 > 150 ? \"#1c1917\" : \"white\"\n}\n\n/**\n * @constructor\n * @augments Tee.Series\n * @class Plots a Treemap: nested rectangles whose area is proportional to the `value` of each node. See\n * `TreemapNode` for the data and `tiling`, `colorBy` and the padding properties for the look.\n *\n * Points are the nodes in depth-first order, branches before their children: `data.values` holds the node\n * values and `data.labels` the node names. Hover, tooltips and `clicked` return the node index.\n */\nexport class Treemap extends Series {\n\tfillStyle: string = \"white\"\n\t/** Width of the tile outline in pixels; 0 draws no outline. */\n\tlineWidth: number = 1.5\n\t/** Color of the tile outline; the chart background when omitted, so tiles look separated. */\n\tborderColor: string | undefined\n\tuseAxes: boolean = false\n\troot: TreemapNode | null | undefined\n\n\t/** How the children of a node are arranged. */\n\ttiling: TreemapTiling = \"squarify\"\n\t/** What decides the color of a tile. */\n\tcolorBy: TreemapColorBy = \"branch\"\n\t/** Space between sibling tiles and around the children of a branch, in pixels. */\n\tpadding = 3\n\t/** Height of the title band of branches in pixels; 0 hides the bands and draws only the leaves' labels. */\n\theaderHeight = 22\n\t/** Corner radius of the tiles in pixels. */\n\tcornerRadius = 3\n\t/** Levels drawn below the focused node, 0 for all of them. Deeper nodes are folded into their ancestor. */\n\tmaxDepth = 0\n\t/** Draws the node names. */\n\tlabels = true\n\t/** Draws the values under the names of the tiles that have room for them. */\n\tshowValues = true\n\t/** Orders siblings from the largest to the smallest. */\n\tsortByValue = true\n\t/** Clicking a branch zooms into it; clicking its title band, or `zoomTo(null)`, zooms back out. */\n\tzoomOnClick = true\n\t/** Formats the values shown in labels and tooltips. */\n\tformatValue: ((value: number) => string) | undefined\n\t/** Called after the zoom changes, with the new focus or null for the whole tree. */\n\tonzoom: ((node: TreemapNode | null) => void) | undefined\n\n\tprivate tiles: TileLayout[] = []\n\tprivate tileRoot: TileLayout | null = null\n\tprivate focus: TreemapNode | null = null\n\tprivate lastPoint = { x: 0, y: 0 }\n\n\tconstructor(chartOrRoot: Chart | TreemapNode | null = null, root?: TreemapNode) {\n\t\t// support old constructor style: new Tee.Treemap(chart, root)\n\t\tconst chart = chartOrRoot instanceof Chart ? chartOrRoot : null\n\t\tsuper()\n\t\t// The chart is optional in the old constructor style: it is set when the series is added.\n\t\tthis.chart = chart as Chart\n\t\tif (chart) this.root = root\n\t\telse if (chartOrRoot && !(chartOrRoot instanceof Chart)) this.root = chartOrRoot\n\t\telse this.root = undefined\n\n\t\tthis.hover.enabled = true\n\t\tthis.hover.stroke.fill = \"rgba(0,0,0,0.55)\"\n\t\tthis.marks.visible = false\n\n\t\tconst f = this.format\n\t\tf.font.style = \"13px Arial\"\n\n\t\tthis.palette = new Palette([\n\t\t\t\"#4466a3\",\n\t\t\t\"#f39c35\",\n\t\t\t\"#4e97a8\",\n\t\t\t\"#1d7b63\",\n\t\t\t\"#b3080e\",\n\t\t\t\"#8e5fa8\",\n\t\t\t\"#d9a21b\",\n\t\t\t\"#2b406b\",\n\t\t\t\"#5db79e\",\n\t\t\t\"#707070\",\n\t\t\t\"#e0678a\",\n\t\t\t\"#8a9a2c\"\n\t\t])\n\t}\n\n\t/** Replaces the tree and zooms out. */\n\tsetRoot(root: TreemapNode | null | undefined, redraw = true): this {\n\t\tthis.root = root\n\t\tthis.focus = null\n\t\tthis.over = -1\n\t\tthis.redraw(redraw)\n\t\treturn this\n\t}\n\n\t/** Zooms into `node`, which must belong to the tree, or out to the whole tree with null. */\n\tzoomTo(node: TreemapNode | null, redraw = true): this {\n\t\tthis.focus = node && node !== this.root ? node : null\n\t\tthis.over = -1\n\t\tif (this.onzoom) this.onzoom(this.focus)\n\t\tthis.redraw(redraw)\n\t\treturn this\n\t}\n\n\t/** The nodes from the root to the focused node, for a breadcrumb. */\n\tpath(): TreemapNode[] {\n\t\tconst path: TreemapNode[] = []\n\t\tfor (let tile = this.tileRoot; tile; tile = tile.parent) path.unshift(tile.node)\n\t\treturn this.tileRoot ? path : this.root ? [this.root] : []\n\t}\n\n\tprivate redraw(redraw: boolean): void {\n\t\tif (!redraw || !this.chart) return\n\t\tif (this.chart._requestDraw) this.chart._requestDraw()\n\t\telse this.chart.draw()\n\t}\n\n\tprivate formatNumber(value: number): string {\n\t\treturn this.formatValue ? this.formatValue(value) : String(Math.round(value * 100) / 100)\n\t}\n\n\tprivate build(): void {\n\t\tconst tiles: TileLayout[] = []\n\t\tconst tileOf = (\n\t\t\tnode: TreemapNode,\n\t\t\tparent: TileLayout | null,\n\t\t\tdepth: number,\n\t\t\tbranch: number,\n\t\t\tunfold: boolean\n\t\t): TileLayout | null => {\n\t\t\tconst tile: TileLayout = {\n\t\t\t\tindex: -1,\n\t\t\t\tnode,\n\t\t\t\tparent,\n\t\t\t\tdepth,\n\t\t\t\tvalue: 0,\n\t\t\t\tbranch,\n\t\t\t\tchildren: [],\n\t\t\t\tx: 0,\n\t\t\t\ty: 0,\n\t\t\t\twidth: 0,\n\t\t\t\theight: 0,\n\t\t\t\theader: 0,\n\t\t\t\topen: false\n\t\t\t}\n\t\t\tconst children = Array.isArray(node.children) ? node.children : []\n\t\t\tif (children.length > 0 && unfold) {\n\t\t\t\tfor (const child of children) {\n\t\t\t\t\tconst item = tileOf(child, tile, depth + 1, depth === 0 ? tile.children.length : branch, true)\n\t\t\t\t\tif (item) tile.children.push(item)\n\t\t\t\t}\n\t\t\t\ttile.value = tile.children.reduce((sum, item) => sum + item.value, 0)\n\t\t\t\ttile.open = tile.children.length > 0\n\t\t\t} else if (children.length > 0) {\n\t\t\t\ttile.value = this.sumOf(node)\n\t\t\t} else {\n\t\t\t\tconst value = node.value === undefined ? 1 : node.value\n\t\t\t\ttile.value = Number.isFinite(value) && value > 0 ? value : 0\n\t\t\t}\n\t\t\treturn tile.value > 0 ? tile : null\n\t\t}\n\n\t\tthis.tiles = tiles\n\t\tthis.tileRoot = null\n\t\tconst full = this.root ? tileOf(this.root, null, 0, 0, true) : null\n\t\tif (!full) {\n\t\t\tthis.data.values = []\n\t\t\tthis.data.labels = []\n\t\t\treturn\n\t\t}\n\n\t\t// The focused node becomes the root of the layout, but keeps its ancestors for the breadcrumb.\n\t\tlet layoutRoot = full\n\t\tif (this.focus) {\n\t\t\tconst found = this.find(full, this.focus)\n\t\t\tif (found) layoutRoot = found\n\t\t\telse this.focus = null\n\t\t}\n\t\tthis.tileRoot = layoutRoot\n\n\t\tconst depthLimit = this.maxDepth > 0 ? this.maxDepth : Number.POSITIVE_INFINITY\n\t\tconst collect = (tile: TileLayout, depth: number) => {\n\t\t\ttile.index = tiles.length\n\t\t\ttiles.push(tile)\n\t\t\tif (depth >= depthLimit) {\n\t\t\t\ttile.open = false\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfor (const child of tile.children) collect(child, depth + 1)\n\t\t}\n\t\tcollect(layoutRoot, 0)\n\n\t\tthis.data.values = tiles.map(tile => tile.value)\n\t\tthis.data.labels = tiles.map(tile => tile.node.name ?? \"\")\n\t}\n\n\tprivate sumOf(node: TreemapNode): number {\n\t\tconst children = Array.isArray(node.children) ? node.children : []\n\t\tif (children.length === 0) {\n\t\t\tconst value = node.value === undefined ? 1 : node.value\n\t\t\treturn Number.isFinite(value) && value > 0 ? value : 0\n\t\t}\n\t\treturn children.reduce((sum, child) => sum + this.sumOf(child), 0)\n\t}\n\n\tprivate find(tile: TileLayout, node: TreemapNode): TileLayout | undefined {\n\t\tif (tile.node === node) return tile\n\t\tfor (const child of tile.children) {\n\t\t\tconst found = this.find(child, node)\n\t\t\tif (found) return found\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate layout(tile: TileLayout, x: number, y: number, width: number, height: number): void {\n\t\ttile.x = x\n\t\ttile.y = y\n\t\ttile.width = width\n\t\ttile.height = height\n\t\ttile.header = 0\n\t\tif (!tile.open || tile.children.length === 0) {\n\t\t\tthis.collapse(tile)\n\t\t\treturn\n\t\t}\n\n\t\tconst pad = this.padding\n\t\tlet top = y + pad\n\t\tconst band = tile.depth === this.tileRoot?.depth ? 0 : this.headerHeight\n\t\tif (band > 0 && height > band + pad * 2 + 8 && width > 24) {\n\t\t\ttile.header = band\n\t\t\ttop += band - pad\n\t\t}\n\t\tconst area = { x: x + pad, y: top, width: width - pad * 2, height: y + height - pad - top }\n\t\tif (area.width <= 0 || area.height <= 0) {\n\t\t\ttile.header = 0\n\t\t\tthis.collapse(tile)\n\t\t\treturn\n\t\t}\n\n\t\tconst children = this.sortByValue ? [...tile.children].sort((a, b) => b.value - a.value) : tile.children\n\t\tthis.tile(children, area, tile.depth)\n\t\tconst gap = pad / 2\n\t\tfor (const child of children) {\n\t\t\tconst w = Math.max(child.width - gap * 2, 0)\n\t\t\tconst h = Math.max(child.height - gap * 2, 0)\n\t\t\tthis.layout(child, child.x + gap, child.y + gap, w, h)\n\t\t}\n\t}\n\n\t/** Hides the descendants of a tile that is drawn as a single block, so they are not drawn or hit. */\n\tprivate collapse(tile: TileLayout): void {\n\t\ttile.open = false\n\t\tfor (const child of tile.children) {\n\t\t\tchild.x = child.y = child.width = child.height = 0\n\t\t\tchild.header = 0\n\t\t\tthis.collapse(child)\n\t\t}\n\t}\n\n\tprivate tile(\n\t\tchildren: TileLayout[],\n\t\tarea: { x: number; y: number; width: number; height: number },\n\t\tdepth: number\n\t): void {\n\t\tconst total = children.reduce((sum, item) => sum + item.value, 0)\n\t\tif (total <= 0) return\n\n\t\tconst mode = this.tiling === \"sliceDice\" ? (depth % 2 === 0 ? \"dice\" : \"slice\") : this.tiling\n\t\tif (mode === \"slice\" || mode === \"dice\") {\n\t\t\tlet offset = 0\n\t\t\tfor (const item of children) {\n\t\t\t\tconst share = item.value / total\n\t\t\t\tif (mode === \"slice\") {\n\t\t\t\t\titem.x = area.x\n\t\t\t\t\titem.y = area.y + offset\n\t\t\t\t\titem.width = area.width\n\t\t\t\t\titem.height = area.height * share\n\t\t\t\t\toffset += item.height\n\t\t\t\t} else {\n\t\t\t\t\titem.x = area.x + offset\n\t\t\t\t\titem.y = area.y\n\t\t\t\t\titem.width = area.width * share\n\t\t\t\t\titem.height = area.height\n\t\t\t\t\toffset += item.width\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.squarify(children, area, total)\n\t}\n\n\t/** Bruls, Huizing and van Wijk: grows a row of tiles along the short side while their aspect ratio improves. */\n\tprivate squarify(\n\t\tchildren: TileLayout[],\n\t\tarea: { x: number; y: number; width: number; height: number },\n\t\ttotal: number\n\t): void {\n\t\tlet { x, y, width, height } = area\n\t\tconst scale = (width * height) / total\n\t\tlet start = 0\n\n\t\tconst worst = (sum: number, min: number, max: number, side: number) =>\n\t\t\tMath.max((side * side * max) / (sum * sum), (sum * sum) / (side * side * min))\n\n\t\twhile (start < children.length) {\n\t\t\tconst side = Math.min(width, height)\n\t\t\tlet end = start\n\t\t\tlet sum = 0\n\t\t\tlet min = Number.POSITIVE_INFINITY\n\t\t\tlet max = 0\n\t\t\tlet ratio = Number.POSITIVE_INFINITY\n\n\t\t\twhile (end < children.length) {\n\t\t\t\tconst a = children[end].value * scale\n\t\t\t\tconst nextMin = Math.min(min, a)\n\t\t\t\tconst nextMax = Math.max(max, a)\n\t\t\t\tconst next = worst(sum + a, nextMin, nextMax, side)\n\t\t\t\tif (end > start && next > ratio) break\n\t\t\t\tsum += a\n\t\t\t\tmin = nextMin\n\t\t\t\tmax = nextMax\n\t\t\t\tratio = next\n\t\t\t\tend++\n\t\t\t}\n\n\t\t\tconst row = children.slice(start, end)\n\t\t\tif (width >= height) {\n\t\t\t\tconst rowWidth = Math.min(sum / height, width)\n\t\t\t\tlet offset = 0\n\t\t\t\tfor (const item of row) {\n\t\t\t\t\tconst h = (item.value * scale) / (rowWidth || 1)\n\t\t\t\t\titem.x = x\n\t\t\t\t\titem.y = y + offset\n\t\t\t\t\titem.width = rowWidth\n\t\t\t\t\titem.height = h\n\t\t\t\t\toffset += h\n\t\t\t\t}\n\t\t\t\tx += rowWidth\n\t\t\t\twidth -= rowWidth\n\t\t\t} else {\n\t\t\t\tconst rowHeight = Math.min(sum / width, height)\n\t\t\t\tlet offset = 0\n\t\t\t\tfor (const item of row) {\n\t\t\t\t\tconst w = (item.value * scale) / (rowHeight || 1)\n\t\t\t\t\titem.x = x + offset\n\t\t\t\t\titem.y = y\n\t\t\t\t\titem.width = w\n\t\t\t\t\titem.height = rowHeight\n\t\t\t\t\toffset += w\n\t\t\t\t}\n\t\t\t\ty += rowHeight\n\t\t\t\theight -= rowHeight\n\t\t\t}\n\t\t\tstart = end\n\t\t}\n\t}\n\n\tprivate tileColor(tile: TileLayout): string {\n\t\tif (tile.node.color) return tile.node.color\n\t\tconst rootDepth = this.tileRoot?.depth ?? 0\n\t\tconst level = tile.depth - rootDepth\n\t\tif (this.colorBy === \"node\") return this.getFill(tile.index)\n\t\tif (this.colorBy === \"level\") return this.getFill(level)\n\n\t\t// Branch mode: each top-level branch has a hue, and its descendants get lighter with depth.\n\t\tlet ancestor: TileLayout = tile\n\t\twhile (ancestor.parent && ancestor.parent !== this.tileRoot) ancestor = ancestor.parent\n\t\tconst base = ancestor.node.color ?? this.getFill(ancestor.parent ? tile.branch : 0)\n\t\tif (tile === this.tileRoot) return shade(base, -0.35)\n\t\tconst steps = tile.depth - (this.tileRoot?.depth ?? 0) - 1\n\t\treturn steps <= 0 ? base : shade(base, Math.min(0.2 + (steps - 1) * 0.12, 0.6))\n\t}\n\n\tlegendCount(): number {\n\t\treturn 0\n\t}\n\n\tlegendColor(index: number): string {\n\t\tconst tile = this.tiles[index]\n\t\treturn tile ? this.tileColor(tile) : \"\"\n\t}\n\n\tvalueText(index: number): string {\n\t\treturn this.formatNumber(this.data.values[index])\n\t}\n\n\ttooltipParts(index: number): TooltipParts | undefined {\n\t\tconst tile = this.tiles[index]\n\t\tif (!tile) return undefined\n\n\t\tconst names: string[] = []\n\t\tfor (let item = tile.parent; item && item !== this.tileRoot?.parent; item = item.parent)\n\t\t\tnames.unshift(item.node.name ?? \"\")\n\t\tconst details: [string, string][] = []\n\t\tconst whole = this.tileRoot?.value ?? 0\n\t\tif (whole > 0) details.push([\"Share of total\", `${((tile.value / whole) * 100).toFixed(1)}%`])\n\t\tif (tile.parent && tile.parent !== this.tileRoot && tile.parent.value > 0)\n\t\t\tdetails.push([\n\t\t\t\t`Share of ${tile.parent.node.name ?? \"parent\"}`,\n\t\t\t\t`${((tile.value / tile.parent.value) * 100).toFixed(1)}%`\n\t\t\t])\n\t\tconst count = this.leafCount(tile)\n\t\tif (tile.children.length > 0) details.push([\"Items\", String(count)])\n\t\tif (names.length > 0) details.push([\"Path\", names.filter(Boolean).join(\" › \")])\n\n\t\treturn {\n\t\t\tlabel: tile.node.name || \"(unnamed)\",\n\t\t\tvalue: this.formatNumber(tile.value),\n\t\t\tcolor: this.tileColor(tile),\n\t\t\tdetails\n\t\t}\n\t}\n\n\tprivate leafCount(tile: TileLayout): number {\n\t\treturn tile.children.length === 0 ? 1 : tile.children.reduce((sum, child) => sum + this.leafCount(child), 0)\n\t}\n\n\t/** `text` shortened with an ellipsis to fit `width`; empty when not even one character fits. */\n\tprivate fitText(ctx: CanvasRenderingContext2D, text: string, width: number): string {\n\t\tif (ctx.measureText(text).width <= width) return text\n\t\tlet fitted = \"\"\n\t\tfor (const character of text) {\n\t\t\tif (ctx.measureText(`${fitted}${character}…`).width > width) break\n\t\t\tfitted += character\n\t\t}\n\t\treturn fitted ? `${fitted}…` : \"\"\n\t}\n\n\tprivate roundRect(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number): void {\n\t\tconst r = Math.min(this.cornerRadius, w / 2, h / 2)\n\t\tctx.beginPath()\n\t\tif (r > 0.5 && typeof ctx.roundRect === \"function\") ctx.roundRect(x, y, w, h, r)\n\t\telse ctx.rect(x, y, w, h)\n\t}\n\n\tprivate drawTile(ctx: CanvasRenderingContext2D, tile: TileLayout, fontSize: number, family: string): void {\n\t\tconst { x, y, width, height } = tile\n\t\tif (width < 1 || height < 1) return\n\n\t\tconst over = this.over\n\t\tconst hovered = tile.index === over\n\t\tconst dimmed = over >= 0 && !hovered && !this.isRelated(tile, over)\n\t\tconst color = this.tileColor(tile)\n\t\tconst container = tile.open && tile.children.length > 0\n\t\t// The root of the layout is only a frame around its children.\n\t\tif (container && tile === this.tileRoot) return\n\n\t\tctx.globalAlpha = dimmed ? 0.55 : 1\n\t\tthis.roundRect(ctx, x, y, width, height)\n\t\tctx.fillStyle = container && tile.header === 0 && tile !== this.tileRoot ? shade(color, 0.05) : color\n\t\tctx.fill()\n\n\t\tif (this.lineWidth > 0) {\n\t\t\tctx.lineWidth = this.lineWidth\n\t\t\tctx.strokeStyle =\n\t\t\t\thovered && this.hover.stroke.fill\n\t\t\t\t\t? this.hover.stroke.fill\n\t\t\t\t\t: (this.borderColor ?? (this.chart.panel.format.fill || \"white\"))\n\t\t\t// Containers are filled by their children; the outline is what separates the branches.\n\t\t\tif (!container || hovered) ctx.stroke()\n\t\t}\n\t\tif (hovered) {\n\t\t\tctx.fillStyle = \"rgba(255,255,255,0.14)\"\n\t\t\tthis.roundRect(ctx, x, y, width, height)\n\t\t\tctx.fill()\n\t\t}\n\t\tctx.globalAlpha = 1\n\n\t\tif (!this.labels) return\n\t\tconst name = tile.node.name\n\t\tconst ink = contrastOf(color)\n\t\tctx.textBaseline = \"middle\"\n\t\tctx.textAlign = \"left\"\n\t\tctx.fillStyle = ink\n\n\t\tif (container) {\n\t\t\tif (tile.header > 0 && name) {\n\t\t\t\tctx.font = `bold ${fontSize}px ${family}`\n\t\t\t\tconst value = this.showValues ? this.formatNumber(tile.value) : \"\"\n\t\t\t\tconst valueWidth = value ? ctx.measureText(value).width + labelPadding : 0\n\t\t\t\tconst text = this.fitText(ctx, name, width - labelPadding * 2 - valueWidth)\n\t\t\t\tif (text) ctx.fillText(text, x + labelPadding, y + tile.header / 2 + this.padding / 2)\n\t\t\t\tif (text && value && width > ctx.measureText(text).width + valueWidth + labelPadding * 2) {\n\t\t\t\t\tctx.font = `${fontSize}px ${family}`\n\t\t\t\t\tctx.globalAlpha = 0.85\n\t\t\t\t\tctx.textAlign = \"right\"\n\t\t\t\t\tctx.fillText(value, x + width - labelPadding, y + tile.header / 2 + this.padding / 2)\n\t\t\t\t\tctx.globalAlpha = 1\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tconst lineHeight = fontSize * 1.25\n\t\tif (!name || width < 28 || height < lineHeight + 4) return\n\t\tctx.font = `bold ${fontSize}px ${family}`\n\t\tconst text = this.fitText(ctx, name, width - labelPadding * 2)\n\t\tif (!text) return\n\t\tconst withValue = this.showValues && height >= lineHeight * 2 + 6\n\t\tconst top = y + labelPadding + lineHeight / 2\n\t\tctx.fillText(text, x + labelPadding, top)\n\t\tif (withValue) {\n\t\t\tctx.font = `${fontSize}px ${family}`\n\t\t\tctx.globalAlpha = 0.85\n\t\t\tconst valueText = this.fitText(ctx, this.formatNumber(tile.value), width - labelPadding * 2)\n\t\t\tif (valueText) ctx.fillText(valueText, x + labelPadding, top + lineHeight)\n\t\t\tctx.globalAlpha = 1\n\t\t}\n\t}\n\n\t/** True when `tile` is an ancestor or a descendant of the hovered tile, which stay lit with it. */\n\tprivate isRelated(tile: TileLayout, over: number): boolean {\n\t\tconst hovered = this.tiles[over]\n\t\tif (!hovered) return false\n\t\tfor (let item: TileLayout | null = hovered; item; item = item.parent) if (item === tile) return true\n\t\tfor (let item: TileLayout | null = tile; item; item = item.parent) if (item === hovered) return true\n\t\treturn false\n\t}\n\n\tdraw(): void {\n\t\tthis.build()\n\t\tconst root = this.tileRoot\n\t\tif (!root) return\n\n\t\tconst ctx = this.chart.drawContext\n\t\tconst rect = this.chart.chartRect\n\t\tconst font = this.format.font\n\t\tconst fontSize = Number.parseFloat(font.style) || 13\n\t\tconst family = /\\d+(?:\\.\\d+)?px\\s+(.+)$/.exec(font.style)?.[1] ?? \"Arial\"\n\n\t\tthis.layout(root, rect.x, rect.y, rect.width, rect.height)\n\n\t\tctx.save()\n\t\t// The chart can leave a shadow enabled on the context; it would blur every tile and label.\n\t\tctx.shadowColor = \"transparent\"\n\t\tctx.shadowBlur = 0\n\t\tctx.shadowOffsetX = 0\n\t\tctx.shadowOffsetY = 0\n\t\tctx.lineJoin = \"round\"\n\t\t// Pre-order is the paint order: containers first, their children on top.\n\t\tfor (const tile of this.tiles) this.drawTile(ctx, tile, fontSize, family)\n\t\tctx.restore()\n\t}\n\n\t/** The deepest node under `p`, or -1. */\n\tclicked(p: Point): number {\n\t\tthis.lastPoint.x = p.x\n\t\tthis.lastPoint.y = p.y\n\t\tfor (let i = this.tiles.length - 1; i >= 0; i--) {\n\t\t\tconst tile = this.tiles[i]\n\t\t\tif (p.x >= tile.x && p.x <= tile.x + tile.width && p.y >= tile.y && p.y <= tile.y + tile.height) {\n\t\t\t\t// The root's own area is only the gap between its children: nothing to point at.\n\t\t\t\treturn tile === this.tileRoot && this.tiles.length > 1 ? -1 : tile.index\n\t\t\t}\n\t\t}\n\t\treturn -1\n\t}\n\n\tmousedown(e: unknown): boolean {\n\t\tif (!this.zoomOnClick || !this.chart) return false\n\t\tconst p = { x: 0, y: 0 }\n\t\tthis.chart.calcMouse(e as Event, p)\n\t\tconst tile = this.tiles[this.clicked(p as Point)]\n\t\tif (!tile?.open || tile.children.length === 0 || tile === this.tileRoot) return false\n\t\tthis.zoomTo(tile.node)\n\t\treturn true\n\t}\n\n\t/** Where tooltips point at: the pointer position, kept inside the tile. */\n\tcalc(index: number, p: Point): void {\n\t\tconst tile = this.tiles[index]\n\t\tif (!tile) return\n\t\tp.x = Math.min(Math.max(this.lastPoint.x, tile.x), tile.x + tile.width)\n\t\tp.y = Math.min(Math.max(this.lastPoint.y, tile.y), tile.y + tile.height)\n\t}\n}\n","import type { Point } from \"../core/primitives.js\"\nimport { Series, type TooltipParts } from \"../series.js\"\nimport type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { quantile } from \"../series-utils.js\"\n\n/** One violin: a name and the raw values whose distribution it shows. */\nexport interface ViolinGroup {\n\tname?: string\n\tvalues: number[]\n\t/** Overrides the palette color of the violin. */\n\tcolor?: string\n}\n\n/** How the width of the violins compares: each one as wide as the widest, equal areas, or by number of values. */\nexport type ViolinScale = \"width\" | \"area\" | \"count\"\n\n/** What is drawn inside each violin. */\nexport type ViolinInner = \"median\" | \"box\" | \"none\"\n\n/** Summary of the values of a violin. */\nexport interface ViolinStats {\n\tcount: number\n\tmin: number\n\tq1: number\n\tmedian: number\n\tq3: number\n\tmax: number\n\tmean: number\n\t/** The bandwidth of the density estimate, in data units. */\n\tbandwidth: number\n}\n\ninterface ViolinShape {\n\tname: string\n\tcolor: string | undefined\n\tstats: ViolinStats\n\t/** Positions along the value axis where the density is estimated. */\n\tgrid: number[]\n\tdensity: number[]\n}\n\n/** The outline of a violin in pixels: its center and, for each estimated position, the y and the half width. */\ninterface Outline {\n\tx: number\n\tys: number[]\n\twidths: number[]\n}\n\n/**\n * @constructor\n * @augments Tee.Series\n * @class Draws the distribution of each group of values as a mirrored, smoothed density shape (violin) with the\n * median marked inside. The raw values of every group are given to `setData`; the density is a Gaussian kernel\n * estimate.\n *\n * Points are the groups: `data.values` holds the median of each group and `data.labels` its name.\n * @property {Number} [bandwidth=0] Smoothing of the density, in data units; 0 chooses it for each group (Silverman's rule).\n * @property {Number} [smoothing=1] Multiplies the automatic bandwidth: below 1 follows the values more closely, above 1 smooths more.\n * @property {Number} [cut=0] How far the shapes extend beyond the lowest and highest value, in bandwidths.\n * @property {Number} [resolution=100] Number of positions where the density is estimated for each group.\n * @property {String} [scale=\"width\"] \"width\" gives every violin the same maximum width, \"area\" the same area and\n * \"count\" widths proportional to the number of values.\n * @property {Number} [width=80] Maximum width of a violin, in percent of the space of its category.\n * @property {String} [inner=\"median\"] What is drawn inside: the \"median\" line and dot, a \"box\" with the quartiles or \"none\".\n */\nexport class Violin extends Series {\n\tcolorEach = \"yes\"\n\tbandwidth = 0\n\tsmoothing = 1\n\tcut = 0\n\tresolution = 100\n\tscale: ViolinScale = \"width\"\n\twidth = 80\n\tinner: ViolinInner = \"median\"\n\t/** Opacity of the fill, from 0 to 1. */\n\tfillOpacity = 0.55\n\tlineWidth = 2\n\tmedianColor = \"#111827\"\n\t/** Outline of the median dot. */\n\tdotStroke = \"#ffffff\"\n\tformatValue: ((value: number) => string) | undefined\n\t/** The raw groups. */\n\tsource: ViolinGroup[] = []\n\tviolins: ViolinShape[] = []\n\tcontinuous = false\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\t\tthis.hover.enabled = true\n\t\tthis.format.shadow.visible = false\n\t}\n\n\t/**\n\t * Replaces the groups and estimates their densities. Each item is a `ViolinGroup` or a plain array of values;\n\t * `labels` name the groups that have no name. A flat list of numbers is one group.\n\t */\n\tsetData(\n\t\tgroups: Iterable<number> | Iterable<ViolinGroup | number[]>,\n\t\tlabels?: Iterable<string> | null,\n\t\tredraw = true\n\t): this {\n\t\tif (!groups || typeof groups[Symbol.iterator] !== \"function\") {\n\t\t\tthrow new TypeError(\"Violin.setData requires an iterable collection of groups\")\n\t\t}\n\t\tconst items = Array.from(groups as Iterable<number | number[] | ViolinGroup>)\n\t\tconst names = labels == null ? [] : Array.from(labels)\n\t\tconst list = items.length > 0 && items.every(item => typeof item === \"number\") ? [items as number[]] : items\n\n\t\tthis.source = (list as Array<number[] | ViolinGroup>).map((item, index) => {\n\t\t\tconst group = Array.isArray(item) ? { values: item } : item\n\t\t\treturn { ...group, name: group.name ?? names[index] ?? String(index + 1) }\n\t\t})\n\t\treturn this.rebuild(redraw)\n\t}\n\n\t/** Estimates the densities again; call it after changing `bandwidth`, `smoothing`, `cut` or `resolution`. */\n\trebuild(redraw = true): this {\n\t\tthis.violins = this.source.map(group => this.estimate(group))\n\t\tthis.data.values = this.violins.map(violin => violin.stats.median)\n\t\tthis.data.labels = this.violins.map(violin => violin.name)\n\t\tif (redraw) this.chart?.draw()\n\t\treturn this\n\t}\n\n\t/** The summary of the values of the `index`th violin. */\n\tstatsOf(index: number): ViolinStats | undefined {\n\t\treturn this.violins[index]?.stats\n\t}\n\n\tprivate estimate(group: ViolinGroup): ViolinShape {\n\t\tconst values = group.values.filter(value => Number.isFinite(value)).sort((a, b) => a - b)\n\t\tconst count = values.length\n\t\tconst name = group.name ?? \"\"\n\n\t\tif (count === 0) {\n\t\t\tconst stats = { count, min: 0, q1: 0, median: 0, q3: 0, max: 0, mean: 0, bandwidth: 0 }\n\t\t\treturn { name, color: group.color, stats, grid: [], density: [] }\n\t\t}\n\n\t\tconst mean = values.reduce((sum, value) => sum + value, 0) / count\n\t\tconst q1 = quantile(values, 0.25)\n\t\tconst q3 = quantile(values, 0.75)\n\t\tconst stats: ViolinStats = {\n\t\t\tcount,\n\t\t\tmin: values[0],\n\t\t\tq1,\n\t\t\tmedian: quantile(values, 0.5),\n\t\t\tq3,\n\t\t\tmax: values[count - 1],\n\t\t\tmean,\n\t\t\tbandwidth: this.bandwidth > 0 ? this.bandwidth : silverman(values, mean, q3 - q1) * this.smoothing\n\t\t}\n\n\t\tconst steps = Math.max(2, Math.floor(this.resolution))\n\t\tconst low = stats.min - this.cut * stats.bandwidth\n\t\tconst high = stats.max + this.cut * stats.bandwidth\n\t\tconst grid = Array.from({ length: steps }, (_, index) => low + ((high - low) * index) / (steps - 1))\n\t\tconst factor = 1 / (count * stats.bandwidth * Math.sqrt(2 * Math.PI))\n\t\tconst density = grid.map(position => {\n\t\t\tlet sum = 0\n\t\t\tfor (const value of values) {\n\t\t\t\tconst z = (position - value) / stats.bandwidth\n\t\t\t\t// Beyond about 6 bandwidths a value adds nothing visible.\n\t\t\t\tif (z < 6 && z > -6) sum += Math.exp(-0.5 * z * z)\n\t\t\t}\n\t\t\treturn sum * factor\n\t\t})\n\n\t\treturn { name, color: group.color, stats, grid, density }\n\t}\n\n\t/** The density that corresponds to the full half width of the violins. */\n\tprivate reference(index: number): number {\n\t\tconst peak = (violin: ViolinShape) => Math.max(0, ...violin.density)\n\t\tif (this.scale === \"width\") return peak(this.violins[index])\n\t\tif (this.scale === \"count\") return Math.max(0, ...this.violins.map(violin => peak(violin) * violin.stats.count))\n\t\treturn Math.max(0, ...this.violins.map(peak))\n\t}\n\n\t/** Half the pixel width of a category slot used by a violin at its widest. */\n\tprivate halfWidth(): number {\n\t\tconst axis = this.notmandatory\n\t\treturn (Math.abs(axis.calc(1) - axis.calc(0)) * this.width * 0.01) / 2\n\t}\n\n\tprivate outline(index: number): Outline | undefined {\n\t\tconst violin = this.violins[index]\n\t\tif (!violin || violin.grid.length === 0) return undefined\n\n\t\tconst reference = this.reference(index)\n\t\tconst half = this.halfWidth()\n\t\tconst weight = this.scale === \"count\" ? violin.stats.count : 1\n\t\tconst axis = this.mandatoryAxis\n\t\treturn {\n\t\t\tx: this.notmandatory.calc(index),\n\t\t\tys: violin.grid.map(position => axis.calc(position)),\n\t\t\twidths: violin.density.map(value => (reference > 0 ? (value * weight * half) / reference : 0))\n\t\t}\n\t}\n\n\tprivate trace(ctx: CanvasRenderingContext2D, { x, ys, widths }: Outline): void {\n\t\tctx.beginPath()\n\t\tctx.moveTo(x + widths[0], ys[0])\n\t\tfor (let i = 1; i < ys.length; i++) ctx.lineTo(x + widths[i], ys[i])\n\t\tfor (let i = ys.length - 1; i >= 0; i--) ctx.lineTo(x - widths[i], ys[i])\n\t\tctx.closePath()\n\t}\n\n\tdraw(): void {\n\t\tconst ctx = this.chart.ctx\n\t\tif (!ctx || this.violins.length === 0) return\n\t\tconst rect = this.chart.chartRect\n\n\t\tctx.save()\n\t\tctx.beginPath()\n\t\tctx.rect(rect.x, rect.y, rect.width, rect.height)\n\t\tctx.clip()\n\n\t\tfor (let index = 0; index < this.violins.length; index++) {\n\t\t\tconst outline = this.outline(index)\n\t\t\tif (!outline) continue\n\n\t\t\tconst color = this.violins[index].color ?? this.getFill(index, this.format)\n\t\t\tconst hovered = this.hover.enabled && this.over === index\n\n\t\t\tthis.trace(ctx, outline)\n\t\t\tctx.globalAlpha = Math.min(1, this.fillOpacity + (hovered ? 0.2 : 0))\n\t\t\tctx.fillStyle = color\n\t\t\tctx.fill()\n\t\t\tctx.globalAlpha = 1\n\t\t\tif (this.lineWidth > 0) {\n\t\t\t\tctx.lineJoin = \"round\"\n\t\t\t\tctx.lineWidth = this.lineWidth + (hovered ? 1 : 0)\n\t\t\t\tctx.strokeStyle = color\n\t\t\t\tctx.stroke()\n\t\t\t}\n\n\t\t\tif (this.inner !== \"none\") this.drawInner(ctx, index, outline.x, color)\n\t\t}\n\n\t\tctx.restore()\n\t}\n\n\tprivate drawInner(ctx: CanvasRenderingContext2D, index: number, x: number, color: string): void {\n\t\tconst { stats } = this.violins[index]\n\t\tconst axis = this.mandatoryAxis\n\t\tconst median = axis.calc(stats.median)\n\t\tconst box = this.inner === \"box\"\n\n\t\tctx.strokeStyle = this.medianColor\n\t\tctx.lineCap = \"round\"\n\n\t\tif (box) {\n\t\t\t// The whiskers span the values, the thick line the quartiles.\n\t\t\tctx.lineWidth = 1.5\n\t\t\tctx.beginPath()\n\t\t\tctx.moveTo(x, axis.calc(stats.min))\n\t\t\tctx.lineTo(x, axis.calc(stats.max))\n\t\t\tctx.stroke()\n\t\t\tctx.lineWidth = 6\n\t\t\tctx.beginPath()\n\t\t\tctx.moveTo(x, axis.calc(stats.q1))\n\t\t\tctx.lineTo(x, axis.calc(stats.q3))\n\t\t\tctx.stroke()\n\t\t} else {\n\t\t\tconst half = this.halfWidth() * 0.5\n\t\t\tctx.lineWidth = 2.5\n\t\t\tctx.beginPath()\n\t\t\tctx.moveTo(x - half, median)\n\t\t\tctx.lineTo(x + half, median)\n\t\t\tctx.stroke()\n\t\t}\n\n\t\tctx.beginPath()\n\t\tctx.arc(x, median, 4.5, 0, Math.PI * 2)\n\t\tctx.fillStyle = box ? this.dotStroke : color\n\t\tctx.fill()\n\t\tctx.lineWidth = 1.5\n\t\tctx.strokeStyle = box ? this.medianColor : this.dotStroke\n\t\tctx.stroke()\n\t\tctx.lineCap = \"butt\"\n\t}\n\n\t/** The violin under `p`, or -1. */\n\tclicked(p: Point): number {\n\t\tfor (let index = this.violins.length - 1; index >= 0; index--) {\n\t\t\tconst outline = this.outline(index)\n\t\t\tif (!outline) continue\n\n\t\t\tconst { x, ys, widths } = outline\n\t\t\tfor (let i = 1; i < ys.length; i++) {\n\t\t\t\tconst top = Math.min(ys[i - 1], ys[i])\n\t\t\t\tconst bottom = Math.max(ys[i - 1], ys[i])\n\t\t\t\tif (p.y < top || p.y > bottom) continue\n\n\t\t\t\tconst along = ys[i] === ys[i - 1] ? 0 : (p.y - ys[i - 1]) / (ys[i] - ys[i - 1])\n\t\t\t\tconst width = widths[i - 1] + (widths[i] - widths[i - 1]) * along\n\t\t\t\tif (Math.abs(p.x - x) <= Math.max(width, 2)) return index\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn -1\n\t}\n\n\tprivate formatNumber(value: number): string {\n\t\treturn this.formatValue ? this.formatValue(value) : String(Math.round(value * 100) / 100)\n\t}\n\n\tvalueText(index: number): string {\n\t\tconst stats = this.violins[index]?.stats\n\t\treturn stats ? this.formatNumber(stats.median) : \"0\"\n\t}\n\n\ttooltipParts(index: number): TooltipParts | undefined {\n\t\tconst violin = this.violins[index]\n\t\tif (!violin) return undefined\n\t\tconst { stats } = violin\n\t\treturn {\n\t\t\tlabel: violin.name,\n\t\t\tvalue: this.formatNumber(stats.median),\n\t\t\tcolor: violin.color ?? this.getFill(index),\n\t\t\tdetails: [\n\t\t\t\t[\"Values\", String(stats.count)],\n\t\t\t\t[\"Minimum\", this.formatNumber(stats.min)],\n\t\t\t\t[\"Q1\", this.formatNumber(stats.q1)],\n\t\t\t\t[\"Median\", this.formatNumber(stats.median)],\n\t\t\t\t[\"Q3\", this.formatNumber(stats.q3)],\n\t\t\t\t[\"Maximum\", this.formatNumber(stats.max)],\n\t\t\t\t[\"Mean\", this.formatNumber(stats.mean)]\n\t\t\t]\n\t\t}\n\t}\n\n\tlegendColor(index: number): string {\n\t\treturn this.violins[index]?.color ?? super.legendColor(index)\n\t}\n\n\t/** Room for the outline at the ends of the value axis. */\n\tvertMargins(p: Point): void {\n\t\tp.x = p.y = this.lineWidth + 1\n\t}\n\n\tminXValue(): number {\n\t\treturn -0.5\n\t}\n\n\tmaxXValue(): number {\n\t\treturn Math.max(0, this.violins.length - 1) + 0.5\n\t}\n\n\tminYValue(): number {\n\t\treturn this.violins.length > 0 ? Math.min(...this.violins.map(violin => violin.grid[0] ?? 0)) : 0\n\t}\n\n\tmaxYValue(): number {\n\t\treturn this.violins.length > 0 ? Math.max(...this.violins.map(violin => violin.grid.at(-1) ?? 0)) : 0\n\t}\n}\n\n/** Silverman's rule of thumb for the bandwidth of a Gaussian kernel. */\nfunction silverman(sorted: number[], mean: number, iqr: number): number {\n\tconst count = sorted.length\n\tconst deviation = Math.sqrt(sorted.reduce((sum, value) => sum + (value - mean) ** 2, 0) / Math.max(1, count - 1))\n\tconst spread = iqr > 0 ? Math.min(deviation, iqr / 1.34) : deviation\n\tif (spread > 0) return 0.9 * spread * count ** -0.2\n\t// All values equal: any positive width keeps the shape finite.\n\treturn Math.max(Math.abs(sorted[0]) * 0.05, 1)\n}\n","import type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { Bar } from \"./bar.js\"\n\n/**\n * @constructor\n * @augments Bar\n * @class Draws financial Volume data as thin Bar lines.\n */\nexport class Volume extends Bar {\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tthis.barStyle = \"line\"\n\t\tthis.marks.visible = false\n\t\tthis.colorEach = false\n\n\t\tthis.format.shadow.visible = false\n\t\tthis.format.gradient.visible = false\n\t\tthis.format.stroke.fill = \"\"\n\t}\n}\n","import type { Axis } from \"../core/elements/axis.js\"\nimport type { Stroke } from \"../core/elements/stroke.js\"\nimport type { Point } from \"../core/primitives.js\"\nimport { getDocument } from \"../platform.js\"\nimport { PaletteSeries } from \"./palette-series.js\"\n\n/**\n * @constructor\n * @augments PaletteSeries\n * @class Draws a two dimensional grid of data as a \"grid\" (rows and columns of pixels),\n * using the palette property to calculate each pixel (grid cell) color.\n */\nexport class ColorGrid extends PaletteSeries {\n\tdeclare size: { x: number; y: number }\n\tdeclare _max: number\n\tsmooth = true\n\tdataChanged = true\n\td: number[][] = []\n\twidth = 0\n\theight = 0\n\timage: ImageData | undefined = undefined\n\timageData: Uint8ClampedArray | undefined = undefined\n\tc2: HTMLCanvasElement | null | undefined = undefined\n\tctx2: CanvasRenderingContext2D | null | undefined = undefined\n\t// Set when the grid is drawn.\n\tdeclare axis: Axis\n\tdeclare axis2: Axis\n\tx0 = 0\n\ty0 = 0\n\tx1 = 0\n\ty1 = 0\n\tmin: number | null = null\n\tmax: number | null = null\n\trange = 0\n\tInvRange255 = 1\n\n\taddRandom(rows?: number, cols?: number) {\n\t\trows = rows || 200\n\t\tcols = cols || rows\n\n\t\tthis.data.values = []\n\t\t// A grid stores one array of cell values per row in its values.\n\t\tconst data = this.data.values as unknown as number[][]\n\n\t\tfor (let y = 0; y < rows; y++) {\n\t\t\tconst row = new Array(cols)\n\t\t\tdata[y] = row\n\n\t\t\t// Some sample function\n\t\t\tconst offset = 0.5 * this.square(Math.cos(y / (cols * 0.2)))\n\n\t\t\tfor (let x = 0; x < cols; x++)\n\t\t\t\trow[x] = this.square(Math.cos(x / (rows * 0.2))) - Math.cos(x / (cols * 0.5)) + offset\n\t\t}\n\n\t\tthis.dataChanged = true // <-- force recalculating pixel colors\n\t\treturn this\n\t}\n\n\toptimize(\n\t\tsmooth: boolean,\n\t\tstyle: (CSSStyleDeclaration & { msInterpolationMode?: string }) | null,\n\t\tctx: CanvasRenderingContext2D\n\t) {\n\t\tif (style) {\n\t\t\t// -webkit-optimize-contrast, (-o)(-moz)crisp-edges\n\n\t\t\tif (style.getPropertyValue(\"image-rendering\") !== null)\n\t\t\t\tstyle.setProperty(\"image-rendering\", smooth ? \"optimizeQuality\" : \"optimizeSpeed\", \"\")\n\n\t\t\tif (style.msInterpolationMode !== undefined) style.msInterpolationMode = smooth ? \"bicubic\" : \"nearest-neighbor\"\n\t\t}\n\n\t\tctx.imageSmoothingEnabled = smooth\n\t}\n\n\tsquare(x: number): number {\n\t\treturn x * x\n\t}\n\n\ttryDrawGrid(s: Stroke, c: CanvasRenderingContext2D): void {\n\t\tif (s.fill !== \"\") {\n\t\t\tlet p: number,\n\t\t\t\tx: number,\n\t\t\t\ty: number,\n\t\t\t\txInc = 1,\n\t\t\t\tyInc = 1\n\n\t\t\txInc = Math.max((1 + (4 * this.width) / Math.abs(this.axis2.calc(this.width) - this.axis2.calc(0))) | 0, 1)\n\t\t\tyInc = Math.max((1 + (4 * this.height) / Math.abs(this.axis.calc(this.height) - this.axis.calc(0))) | 0, 1)\n\n\t\t\tc.beginPath()\n\n\t\t\tfor (x = 1; x < this.width; x += xInc) {\n\t\t\t\tp = this.axis2.calc(x - 0.5)\n\t\t\t\tc.moveTo(p, this.y1)\n\t\t\t\tc.lineTo(p, this.y0)\n\t\t\t}\n\n\t\t\tfor (y = 1; y < this.height; y += yInc) {\n\t\t\t\tp = this.axis.calc(y - 0.5)\n\t\t\t\tc.moveTo(this.x0, p)\n\t\t\t\tc.lineTo(this.x1, p)\n\t\t\t}\n\n\t\t\ts.prepare()\n\t\t\tc.stroke()\n\t\t}\n\t}\n\n\tcalcMinMax() {\n\t\tlet min = this.d[0][0] as number | null\n\t\tlet max = min\n\n\t\tfor (let y = 0; y < this.height; y++) {\n\t\t\tconst row = this.d[y]\n\t\t\tfor (let x = 0; x < this.width; x++) {\n\t\t\t\tconst v = row[x]\n\t\t\t\tif (v !== null) {\n\t\t\t\t\tif (min === null) min = v\n\t\t\t\t\tif (max === null) max = v\n\n\t\t\t\t\tif (v < min) min = v\n\t\t\t\t\telse if (v > (max as number)) max = v\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.min = min\n\t\tthis.max = max\n\n\t\t// A grid without values has no range: null counts as zero.\n\t\tconst low = min ?? 0\n\t\tconst high = max ?? 0\n\t\tthis.range = high - low\n\n\t\tthis.InvRange255 = high === low ? 1 : 255 / (high - low)\n\t}\n\n\tfillPixels(alpha: number): void {\n\t\tconst imageData = this.imageData\n\t\tif (!imageData) return\n\n\t\tlet index = 0\n\t\tconst grayscale = this.palette.grayScale\n\t\tconst inverted = this.palette.inverted\n\t\tconst low = this.min ?? 0\n\t\tconst high = this.max ?? 0\n\n\t\t// Fill pixel data\n\t\tfor (let y = 0; y < this.height; y++) {\n\t\t\tconst row = this.d[y]\n\n\t\t\tfor (let x = 0; x < this.width; x++) {\n\t\t\t\tif (grayscale) {\n\t\t\t\t\tconst color = this.InvRange255 * (inverted ? high - row[x] : row[x] - low)\n\n\t\t\t\t\timageData[index++] = color\n\t\t\t\t\timageData[index++] = color\n\t\t\t\t\timageData[index++] = color\n\t\t\t\t} else {\n\t\t\t\t\tconst color = this.getColor(row[x])\n\n\t\t\t\t\timageData[index++] = Number(color.r)\n\t\t\t\t\timageData[index++] = Number(color.g)\n\t\t\t\t\timageData[index++] = Number(color.b)\n\t\t\t\t}\n\n\t\t\t\timageData[index++] = alpha\n\t\t\t}\n\t\t}\n\t}\n\n\tdraw() {\n\t\tconst context = this.chart.ctx\n\t\tif (!context) return\n\n\t\tif (this.width > 0) {\n\t\t\tif (context.__webgl) {\n\t\t\t\tthis.d = this.data.values as unknown as number[][]\n\t\t\t\tthis.axis = this.mandatoryAxis\n\t\t\t\tthis.axis2 = this.notmandatory\n\t\t\t\tconst xStart = this.axis2.calc(-0.5)\n\t\t\t\tconst xEnd = this.axis2.calc(this.width - 0.5)\n\t\t\t\tconst yStart = this.axis.calc(-0.5)\n\t\t\t\tconst yEnd = this.axis.calc(this.height - 0.5)\n\t\t\t\tthis.x0 = Math.min(xStart, xEnd)\n\t\t\t\tthis.x1 = Math.max(xStart, xEnd)\n\t\t\t\tthis.y0 = Math.min(yStart, yEnd)\n\t\t\t\tthis.y1 = Math.max(yStart, yEnd)\n\t\t\t\tfor (let rowIndex = 0; rowIndex < this.height; rowIndex++) {\n\t\t\t\t\tconst top = this.axis.calc(rowIndex - 0.5)\n\t\t\t\t\tconst bottom = this.axis.calc(rowIndex + 0.5)\n\t\t\t\t\tfor (let columnIndex = 0; columnIndex < this.width; columnIndex++) {\n\t\t\t\t\t\tconst value = this.d[rowIndex][columnIndex]\n\t\t\t\t\t\tif (!Number.isFinite(value)) continue\n\t\t\t\t\t\tconst left = this.axis2.calc(columnIndex - 0.5)\n\t\t\t\t\t\tconst right = this.axis2.calc(columnIndex + 0.5)\n\t\t\t\t\t\tconst color = this.range === 0 ? this.palette.colors[0] : this.getColor(value)\n\t\t\t\t\t\tif (!color) continue\n\t\t\t\t\t\tcontext.fillStyle = typeof color === \"string\" ? color : `rgb(${color.r},${color.g},${color.b})`\n\t\t\t\t\t\tcontext.fillRect(\n\t\t\t\t\t\t\tMath.min(left, right),\n\t\t\t\t\t\t\tMath.min(top, bottom),\n\t\t\t\t\t\t\tMath.abs(right - left),\n\t\t\t\t\t\t\tMath.abs(bottom - top)\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (!this.image || !this.c2 || this.c2.width !== this.width || this.c2.height !== this.height) {\n\t\t\t\tif (!this.c2) this.c2 = getDocument()?.createElement(\"canvas\")\n\n\t\t\t\t// IE <9\n\t\t\t\tif (!this.c2?.getContext) return\n\n\t\t\t\tthis.c2.width = this.width\n\t\t\t\tthis.c2.height = this.height\n\n\t\t\t\tthis.ctx2 = this.c2.getContext(\"2d\")\n\t\t\t\tif (!this.ctx2) return\n\n\t\t\t\tthis.image = this.ctx2.getImageData(0, 0, this.width, this.height)\n\t\t\t\tthis.imageData = this.image.data\n\t\t\t}\n\n\t\t\tif (this.dataChanged) {\n\t\t\t\tthis.fillPixels(255 * (1 - this.format.transparency))\n\t\t\t\tthis.dataChanged = false\n\t\t\t}\n\n\t\t\tconst ctx2 = this.ctx2\n\t\t\tif (!ctx2 || !this.image) return\n\n\t\t\tctx2.putImageData(this.image, 0, 0)\n\n\t\t\tthis.optimize(this.smooth, this.chart.canvas.style, context)\n\n\t\t\tthis.axis = this.mandatoryAxis\n\t\t\tthis.axis2 = this.notmandatory\n\n\t\t\tthis.y1 = this.axis.calc(-0.5)\n\t\t\tthis.y0 = this.axis.calc(this.height - 0.5)\n\t\t\tthis.x0 = this.axis2.calc(-0.5)\n\t\t\tthis.x1 = this.axis2.calc(this.width - 0.5)\n\n\t\t\tlet xPos = this.x0,\n\t\t\t\tyPos = this.y0,\n\t\t\t\txScale = 1,\n\t\t\t\tyScale = 1\n\n\t\t\tif (this.axis.inverted) {\n\t\t\t\tyScale = -1\n\t\t\t\tyPos = -this.y1\n\t\t\t}\n\n\t\t\tif (this.axis2.inverted) {\n\t\t\t\txScale = -1\n\t\t\t\txPos = -this.x1 // #2120\n\t\t\t}\n\n\t\t\tcontext.scale(xScale, yScale)\n\t\t\tcontext.drawImage(ctx2.canvas, 0, 0, this.width, this.height, xPos, yPos, this.x1 - this.x0, this.y1 - this.y0)\n\t\t\tcontext.setTransform(1, 0, 0, 1, 0, 0)\n\n\t\t\tthis.tryDrawGrid(this.format.stroke, context)\n\t\t}\n\t}\n\n\t/**\n\t * @returns {String} Returns the palette value of index'th legend symbol.\n\t */\n\tvalueText(index: number): string {\n\t\tconst x = index % this.width\n\t\tconst y = (index / this.width) | 0\n\t\treturn (this.data.values as unknown as number[][])[y][x].toFixed(this.decimals)\n\t}\n\n\tminXValue() {\n\t\treturn -0.5\n\t}\n\n\tmaxXValue() {\n\t\treturn this.width - 0.5\n\t}\n\n\tminYValue() {\n\t\treturn -0.5\n\t}\n\n\tmaxYValue() {\n\t\treturn this.height - 0.5\n\t}\n\n\trecalcAxes() {\n\t\tsuper.recalcAxes()\n\n\t\t// A grid stores one array of cell values per row in its values.\n\t\tthis.d = this.data.values as unknown as number[][]\n\t\tthis.height = this.d.length\n\t\tthis.width = this.height > 0 ? this.d[0].length : 0\n\n\t\tthis.size = { x: this.width, y: this.height }\n\n\t\tif (this.width > 0 && this.dataChanged) {\n\t\t\tthis.calcMinMax()\n\n\t\t\tthis._min = this.min ?? 0\n\t\t\tthis._max = this.max ?? 0\n\t\t\tthis._range = this.range\n\n\t\t\tthis.prepareColors()\n\t\t}\n\t}\n\n\t/**\n\t * @returns {Number} Returns the index of grid xy that contains {@link Tee.Point} p parameter.\n\t */\n\tclicked(p: Point): number {\n\t\tlet x: number\n\t\tlet y: number\n\n\t\tif (p.x >= this.x0 && p.x <= this.x1) {\n\t\t\tx = ((this.width * (p.x - this.x0)) / (this.x1 - this.x0)) | 0\n\n\t\t\tif (p.y >= this.y0 && p.y <= this.y1) {\n\t\t\t\ty = ((this.height * (p.y - this.y0)) / (this.y1 - this.y0)) | 0\n\n\t\t\t\treturn y * this.width + x\n\t\t\t}\n\t\t}\n\n\t\treturn -1\n\t}\n}\n","import type { SeriesInput, SeriesLabels } from \"../series.js\"\nimport { Format } from \"../core/elements/format.js\"\nimport type { Stroke } from \"../core/elements/stroke.js\"\nimport { Rectangle } from \"../core/primitives.js\"\nimport { ColorGrid } from \"./color-series.js\"\n\n/**\n * @constructor\n * @augments ColorGrid\n * @class Draws a two dimensional grid of data as a \"grid\" (rows and columns of pixels),\n * using the palette property to calculate each pixel (grid cell) color.\n */\nexport class Surface extends ColorGrid {\n\td: number[][] = []\n\t_sizeY = 0\n\tgrid: Stroke\n\twireFrame = false\n\tmaxZ = 3\n\n\tconstructor(o?: SeriesInput | null, o2?: SeriesLabels | null) {\n\t\tsuper(o, o2)\n\n\t\tthis.grid = new Format(this.chart).stroke\n\t}\n\n\tgetY(x: number, z: number): number {\n\t\treturn this.d[x][z]\n\t}\n\n\tdraw(): void {\n\t\tif (this.size.x > 0 && this.size.y > 0) {\n\t\t\t// A grid stores one array of cell values per row in its values.\n\t\t\tthis.d = this.data.values as unknown as number[][]\n\n\t\t\tif (this.chart.__webgl) {\n\t\t\t\tconst r = new Rectangle()\n\t\t\t\tthis.bounds(r)\n\n\t\t\t\tthis._sizeY = this.size.y - 1\n\t\t\t\tthis.chart.drawContext.surface?.(\n\t\t\t\t\tthis.size,\n\t\t\t\t\tthis.getY.bind(this),\n\t\t\t\t\tr,\n\t\t\t\t\tthis.wireFrame,\n\t\t\t\t\t// Stroke has no `visible`, so the grid has never been drawn; kept as it was.\n\t\t\t\t\t(this.grid as Stroke & { visible?: boolean }).visible ? this.grid.fill : null,\n\t\t\t\t\tthis.maxZ\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\tminXValue(): number {\n\t\treturn 0\n\t}\n\n\tmaxXValue(): number {\n\t\treturn this.size.y\n\t}\n\n\tminYValue(): number {\n\t\treturn this._min\n\t}\n\n\tmaxYValue(): number {\n\t\treturn this._max\n\t}\n}\n","import type { Chart } from \"../chart.js\"\nimport { Series } from \"../series.js\"\nimport { cancelAnimationFrame, requestAnimationFrame } from \"../platform.js\"\n\n/** A value interval that colors the bar while the gauge value falls inside it. */\nexport interface LinearGaugeRange {\n\tfrom: number\n\tto: number\n\tcolor: string\n}\n\n/**\n * @constructor\n * @augments Tee.Series\n * @class plots a LinearGauge.\n * @property {Number} min default 0, value at the left end of the track\n * @property {Number} max default 100, value at the right end of the track\n * @property {Number} increment default 20 sets label increment\n * @property {String} markSymbol default '%', appended to tick labels and to the value mark\n * @property {Number} decimals default 0, decimals shown in the value mark\n * @property {Number} barHeight default 30, track height in pixels\n * @property {Boolean} showTicks default true, draws tick lines and labels\n * @property {Number} cornerRadius default 0, rounds the track and bar corners\n * @property {String} trackColor default '', optional fill for the empty track\n * @property {LinearGaugeRange[]} ranges default [], when not empty the bar uses the color of the range containing the value\n * @property {string[]} gradientColors default ['red','green']\n * @property {Number} animationIncrement default 1, value units per animation frame (used when animationDuration is 0)\n * @property {Number} animationDuration default 0, when greater than 0 each value change takes this many milliseconds (eased) regardless of distance\n * @property {Number} startValue sets startvalue for animated bar\n * @property {Number} finalValue sets final value for the bar\n */\nexport class LinearGauge extends Series {\n\tdeclare gaugeX: number\n\tdeclare gaugeWidth: number\n\tdeclare gaugeHeight: number\n\tdeclare min: number\n\tdeclare max: number\n\tdeclare value: number\n\t/** Animates the bar from startValue to finalValue when truthy. */\n\tdeclare animation?: boolean\n\tdeclare startValue: number\n\tdeclare finalValue: number\n\tdeclare increment: number\n\tdeclare markSymbol: string\n\tdeclare decimals: number\n\tdeclare barHeight: number\n\tdeclare showTicks: boolean\n\tdeclare cornerRadius: number\n\tdeclare trackColor: string\n\tdeclare ranges: LinearGaugeRange[]\n\tdeclare gradientColors: string[]\n\tdeclare lineFill: string\n\tdeclare txtHeight: number\n\tdeclare animationIncrement: number\n\tdeclare animationDuration: number\n\tdeclare _animStart: number\n\tdeclare _animFrom: number\n\tdeclare _animationFrame: number | ReturnType<typeof setTimeout> | null\n\tdeclare _animationCleanupChart: Chart | null\n\tconstructor(o?: number, o2?: number) {\n\t\tsuper()\n\n\t\tthis.format.stroke.fill = \"black\"\n\t\tthis.format.stroke.size = 1\n\t\tthis.format.font.style = \"16px Arial\"\n\t\tthis.lineFill = \"#000\"\n\t\tthis.txtHeight = this.format.textHeight(\"Wj\")\n\t\tthis.min = 0\n\t\tthis.max = 100\n\t\tthis.increment = 20\n\t\tthis.markSymbol = \"%\"\n\t\tthis.decimals = 0\n\t\tthis.barHeight = 30\n\t\tthis.showTicks = true\n\t\tthis.cornerRadius = 0\n\t\tthis.trackColor = \"\"\n\t\tthis.ranges = []\n\t\tthis.gradientColors = [\"red\", \"green\"]\n\t\tthis.animationIncrement = 1\n\t\tthis.animationDuration = 0\n\t\tthis._animStart = 0\n\t\tthis._animFrom = 0\n\n\t\tthis.startValue = o === undefined ? 0 : o\n\t\tthis.finalValue = o2 === undefined ? 0 : o2\n\t\tthis.value = this.startValue\n\t\tthis._animationFrame = null\n\t\tthis._animationCleanupChart = null\n\t\tthis._cancelGaugeAnimation = () => {\n\t\t\tif (this._animationFrame !== null) cancelAnimationFrame(this._animationFrame)\n\t\t\tthis._animationFrame = null\n\t\t}\n\n\t\tthis.useAxes = false\n\t}\n\n\t/**\n\t * Moves the bar to a new value, optionally animating from the current one, and redraws the chart.\n\t * @param {Number} value new value, clamped to [min, max] when drawn\n\t * @param {Boolean} [animate=true] animate from the current value\n\t */\n\tsetValue(value: number, animate = true): void {\n\t\tthis.startValue = this.value\n\t\tthis.finalValue = value\n\t\tthis.animation = animate\n\t\tthis.chart?.draw()\n\t}\n\n\t_ensureAnimationCleanup(): void {\n\t\tconst chart = this.chart\n\t\tif (!chart || this._animationCleanupChart === chart) return\n\t\tthis._animationCleanupChart = chart\n\t\tconst cancel = this._cancelGaugeAnimation\n\t\tif (cancel) chart._eventCleanups.push(cancel)\n\t}\n\n\t_scheduleGaugeAnimation(callback: () => void): void {\n\t\tthis._animationFrame = requestAnimationFrame(() => {\n\t\t\tthis._animationFrame = null\n\t\t\tcallback()\n\t\t})\n\t}\n\n\t_clamp(value: number): number {\n\t\treturn Math.min(Math.max(value, this.min), this.max)\n\t}\n\n\t_position(value: number): number {\n\t\tconst span = this.max - this.min\n\t\treturn span > 0 ? this.gaugeX + (this.gaugeWidth * (this._clamp(value) - this.min)) / span : this.gaugeX\n\t}\n\n\tdrawAll(\n\t\tvalue: number,\n\t\tctx: CanvasRenderingContext2D,\n\t\tgaugeX: number,\n\t\tgaugeY: number,\n\t\tgradient: CanvasGradient,\n\t\tgaugeWidth: number,\n\t\tgaugeHeight: number\n\t): void {\n\t\tthis.drawBar(value, ctx, gaugeX, gaugeY, gradient, gaugeWidth, gaugeHeight, true)\n\t}\n\n\tdrawBar(\n\t\tvalue: number,\n\t\tctx: CanvasRenderingContext2D,\n\t\t_gaugeX: number,\n\t\tgaugeY: number,\n\t\tgradient: CanvasGradient,\n\t\t_gaugeWidth: number,\n\t\t_gaugeHeight: number,\n\t\tfirst: boolean\n\t): void {\n\t\tconst f = this.format\n\t\tvalue = this._clamp(value)\n\t\tthis.value = value\n\n\t\t// Repaint the track and bar area so animation frames never leave residue behind.\n\t\tctx.clearRect(this.gaugeX - 1, gaugeY - 1, this.gaugeWidth + 2, this.gaugeHeight + 2)\n\t\tconst radius = Math.min(this.cornerRadius, this.gaugeHeight / 2, this.gaugeWidth / 2)\n\t\tconst trackPath = () => {\n\t\t\tctx.beginPath()\n\t\t\tif (radius > 0) ctx.roundRect(this.gaugeX, gaugeY, this.gaugeWidth, this.gaugeHeight, radius)\n\t\t\telse ctx.rect(this.gaugeX, gaugeY, this.gaugeWidth, this.gaugeHeight)\n\t\t}\n\t\tif (this.trackColor) {\n\t\t\tctx.fillStyle = this.trackColor\n\t\t\ttrackPath()\n\t\t\tctx.fill()\n\t\t}\n\n\t\tconst barEnd = this._position(value)\n\t\tconst range = this.ranges.find(r => value >= r.from && value <= r.to)\n\t\tctx.save()\n\t\ttrackPath()\n\t\tctx.clip()\n\t\tctx.fillStyle = range ? range.color : gradient\n\t\tctx.fillRect(this.gaugeX, gaugeY, barEnd - this.gaugeX, this.gaugeHeight)\n\t\tctx.restore()\n\n\t\t//mark: a badge above the bar end showing the current value\n\t\tif (this.marks.visible) {\n\t\t\tconst text = `${value.toFixed(this.decimals)}${this.markSymbol}`\n\t\t\tctx.font = this.marks.format.font.style\n\t\t\tconst textHeight = this.marks.format.textHeight(\"Wj\")\n\t\t\tconst badgeWidth = ctx.measureText(text).width + 16\n\t\t\tconst badgeHeight = Math.max(textHeight, 18) + 10\n\t\t\tconst badgeY = gaugeY - badgeHeight - 9\n\t\t\tconst badgeX = Math.min(\n\t\t\t\tMath.max(barEnd - badgeWidth / 2, this.gaugeX),\n\t\t\t\tthis.gaugeX + this.gaugeWidth - badgeWidth\n\t\t\t)\n\t\t\tconst tip = Math.min(Math.max(barEnd, badgeX + 8), badgeX + badgeWidth - 8)\n\t\t\tctx.clearRect(this.gaugeX - badgeWidth, badgeY - 1, this.gaugeWidth + badgeWidth * 2, badgeHeight + 9)\n\t\t\tctx.fillStyle = range ? range.color : this.gradientColors[1]\n\t\t\tctx.beginPath()\n\t\t\tctx.roundRect(badgeX, badgeY, badgeWidth, badgeHeight, 6)\n\t\t\tctx.moveTo(tip - 5, badgeY + badgeHeight)\n\t\t\tctx.lineTo(tip + 5, badgeY + badgeHeight)\n\t\t\tctx.lineTo(tip, badgeY + badgeHeight + 6)\n\t\t\tctx.closePath()\n\t\t\tctx.fill()\n\t\t\tctx.fillStyle = this.marks.format.font.fill\n\t\t\tctx.textAlign = \"center\"\n\t\t\tctx.textBaseline = \"middle\"\n\t\t\tctx.fillText(text, badgeX + badgeWidth / 2, badgeY + badgeHeight / 2)\n\t\t\tctx.textBaseline = \"alphabetic\"\n\t\t}\n\n\t\tif (f.stroke.size > 0) {\n\t\t\tctx.strokeStyle = f.stroke.fill\n\t\t\tctx.lineWidth = f.stroke.size\n\t\t\ttrackPath()\n\t\t\tctx.stroke()\n\t\t}\n\n\t\tif (first && this.showTicks && this.increment > 0 && this.max > this.min) {\n\t\t\tconst steps = Math.floor((this.max - this.min) / this.increment + 1e-9)\n\t\t\tconst tickTop = gaugeY + this.gaugeHeight + 4\n\t\t\tctx.beginPath()\n\t\t\tctx.strokeStyle = this.lineFill\n\t\t\tctx.lineWidth = 1\n\t\t\tfor (let n = 0; n <= steps; n++) {\n\t\t\t\tconst x = Math.round(this._position(this.min + n * this.increment)) + 0.5\n\t\t\t\tctx.moveTo(x, tickTop)\n\t\t\t\tctx.lineTo(x, tickTop + 6)\n\t\t\t}\n\t\t\tctx.stroke()\n\t\t\tctx.fillStyle = this.lineFill\n\t\t\tctx.font = this.chart.axes.bottom.labels.format.font.style\n\t\t\tfor (let n = 0; n <= steps; n++) {\n\t\t\t\tconst i = this.min + n * this.increment\n\t\t\t\tconst ltext = `${i}${this.markSymbol}`\n\t\t\t\tctx.textAlign = \"center\"\n\t\t\t\tctx.fillText(ltext, this._position(i), tickTop + 8 + this.txtHeight)\n\t\t\t}\n\t\t}\n\t}\n\n\tanimateGauge(\n\t\tcurrentValue: number,\n\t\ttargetValue: number,\n\t\tgradient: CanvasGradient,\n\t\tgaugeX: number,\n\t\tgaugeY: number,\n\t\tgaugeWidth: number,\n\t\tgaugeHeight: number,\n\t\tctx: CanvasRenderingContext2D,\n\t\tfirst: boolean\n\t): void {\n\t\tif (this.chart.destroyed) return\n\t\tif (currentValue !== targetValue) {\n\t\t\tif (this.animationDuration > 0) {\n\t\t\t\tconst t = Math.min((Date.now() - this._animStart) / this.animationDuration, 1)\n\t\t\t\tconst eased = 1 - (1 - t) ** 3\n\t\t\t\tcurrentValue = t >= 1 ? targetValue : this._animFrom + (targetValue - this._animFrom) * eased\n\t\t\t} else {\n\t\t\t\tconst step = this.animationIncrement > 0 ? this.animationIncrement : 1\n\t\t\t\tif (Math.abs(currentValue - targetValue) <= step) currentValue = targetValue\n\t\t\t\telse if (currentValue < targetValue) currentValue += step\n\t\t\t\telse currentValue -= step\n\t\t\t}\n\n\t\t\tthis.drawBar(currentValue, ctx, this.gaugeX, gaugeY, gradient, this.gaugeWidth, this.gaugeHeight, first)\n\t\t\tthis._scheduleGaugeAnimation(() =>\n\t\t\t\tthis.animateGauge(currentValue, targetValue, gradient, gaugeX, gaugeY, gaugeWidth, gaugeHeight, ctx, false)\n\t\t\t)\n\t\t}\n\t}\n\n\tdraw(): void {\n\t\tthis._ensureAnimationCleanup()\n\t\tthis._cancelGaugeAnimation?.()\n\t\tconst value = this._clamp(this.startValue)\n\t\tconst target = this._clamp(this.finalValue)\n\t\tconst ctx = this.chart.drawContext\n\t\tconst height = this.chart.chartRect.height\n\t\tconst width = this.chart.chartRect.width\n\t\tthis.gaugeX = 30 //leave space for 1st label.\n\t\tthis.gaugeWidth = Math.max(width - this.gaugeX * 2, 1)\n\t\tthis.gaugeHeight = this.barHeight\n\t\tconst gaugeY = (height - this.gaugeHeight) / 2 + (this.marks.visible ? 14 : 0) - (this.showTicks ? 12 : 0)\n\n\t\tconst gradient = ctx.createLinearGradient(this.gaugeX, 0, this.gaugeX + this.gaugeWidth, 0)\n\t\tgradient.addColorStop(0, this.gradientColors[0])\n\t\tgradient.addColorStop(1, this.gradientColors[1])\n\n\t\tif (this.animation && value !== target) {\n\t\t\tthis._animStart = Date.now()\n\t\t\tthis._animFrom = value\n\t\t\tthis.animateGauge(value, target, gradient, this.gaugeX, gaugeY, this.gaugeWidth, this.gaugeHeight, ctx, true)\n\t\t} else {\n\t\t\tthis.drawAll(target, ctx, this.gaugeX, gaugeY, gradient, this.gaugeWidth, this.gaugeHeight)\n\t\t}\n\t}\n}\n","import type {\n\tArcGaugeSeriesOptions,\n\tBoxPlotSeriesOptions,\n\tBulletSeriesOptions,\n\tCandleRow,\n\tCandleSeriesOptions,\n\tCircularGaugeSeriesOptions,\n\tGanttSeriesOptions,\n\tGanttTask,\n\tGaugeSeriesOptions,\n\tHighLowRow,\n\tHistogramSeriesOptions,\n\tNumericGaugeSeriesOptions,\n\tSankeySeriesOptions,\n\tTreemapSeriesOptions,\n\tViolinSeriesOptions\n} from \"./chart-options.js\"\nimport { registerSeriesType, type SeriesTypeDefinition } from \"./series-registry.js\"\nimport { ActivityGauge } from \"./series/activity-gauge.js\"\nimport { ArcGauge } from \"./series/arc-gauge.js\"\nimport { BoxPlot, type BoxPlotGroup } from \"./series/box-plot.js\"\nimport { Bullet } from \"./series/bullet.js\"\nimport { Candle } from \"./series/candle.js\"\nimport { CircularGauge } from \"./series/circular-gauge.js\"\nimport { Gantt } from \"./series/gantt.js\"\nimport { HighLowBar } from \"./series/high-low-bar.js\"\nimport { Histogram } from \"./series/histogram.js\"\nimport { HorizArea } from \"./series/horiz-area.js\"\nimport { HorizBar } from \"./series/horiz-bar.js\"\nimport { NumericGauge } from \"./series/numeric-gauge.js\"\nimport { Polar } from \"./series/polar.js\"\nimport { Sankey, type SankeyGraph } from \"./series/sankey.js\"\nimport { Sliced } from \"./series/sliced.js\"\nimport { Treemap, type TreemapNode } from \"./series/treemap.js\"\nimport { Violin, type ViolinGroup } from \"./series/violin.js\"\nimport { Volume } from \"./series/volume.js\"\nimport { ColorGrid } from \"./series/color-series.js\"\nimport { Surface } from \"./series/surface.js\"\nimport { LinearGauge } from \"./series/linear-gauge.js\"\nimport type { LinearGaugeSeriesOptions, SurfaceSeriesOptions } from \"./chart-options.js\"\n\n/** Matrix data is stored as rows by the grid engine. Copy rows to isolate caller-owned options. */\nexport const colorGridSeriesType: SeriesTypeDefinition<number[][]> = {\n\tcreate: () => new ColorGrid(),\n\tsetData(series, rows) {\n\t\tseries.data.values = rows.map(row => [...row]) as unknown as number[]\n\t\t;(series as ColorGrid).dataChanged = true\n\t}\n}\n\nexport const surfaceSeriesType: SeriesTypeDefinition<number[][], SurfaceSeriesOptions> = {\n\t...colorGridSeriesType,\n\tcreate: () => new Surface(),\n\tconfigure(series, options) {\n\t\tif (options.wireFrame !== undefined) (series as Surface).wireFrame = options.wireFrame\n\t}\n}\n\nexport const linearGaugeSeriesType: SeriesTypeDefinition<number, LinearGaugeSeriesOptions> = {\n\tcreate: () => new LinearGauge(),\n\tsetData(series, value) {\n\t\tconst gauge = series as LinearGauge\n\t\tgauge.value = gauge.startValue = gauge.finalValue = value\n\t},\n\tconfigure(series, options) {\n\t\tconst gauge = series as LinearGauge\n\t\tif (options.min !== undefined) gauge.min = options.min\n\t\tif (options.max !== undefined) gauge.max = options.max\n\t}\n}\n\n// This module has no top-level side effects on purpose: importing `Chart` must not pull every series\n// into an application bundle. Types registered here are opt-in, either one by one with\n// `registerSeriesType(name, definition)` or all at once with `registerAllSeriesTypes()`.\n\nexport const candleSeriesType: SeriesTypeDefinition<CandleRow[], CandleSeriesOptions> = {\n\tcreate: () => new Candle(),\n\tsetData(series, rows, labels) {\n\t\tconst data = series.data\n\t\tdata.close = data.values = rows.map(row => row.close)\n\t\tdata.open = rows.map(row => row.open)\n\t\tdata.high = rows.map(row => row.high)\n\t\tdata.low = rows.map(row => row.low)\n\t\tdata.labels = labels ? [...labels] : []\n\t\tif (rows.some(row => row.x !== undefined)) data.x = rows.map((row, index) => row.x ?? index)\n\t\telse delete data.x\n\t},\n\tconfigure(series, options) {\n\t\tif (options.style !== undefined) (series as Candle).style = options.style\n\t}\n}\n\nexport const highLowBarSeriesType: SeriesTypeDefinition<HighLowRow[]> = {\n\tcreate: () => new HighLowBar(),\n\tsetData(series, rows, labels) {\n\t\tconst data = series.data\n\t\tdata.values = rows.map(row => row.high)\n\t\tdata.lows = rows.map(row => row.low)\n\t\tdata.labels = labels ? [...labels] : []\n\t}\n}\n\nexport const histogramSeriesType: SeriesTypeDefinition<number[], HistogramSeriesOptions> = {\n\tcreate: () => new Histogram(),\n\tsetData(series, values) {\n\t\t;(series as Histogram).setData(values, undefined, false)\n\t},\n\tconfigure(series, options) {\n\t\tconst histogram = series as Histogram\n\t\tif (options.bins !== undefined) histogram.bins = options.bins\n\t\tif (options.binWidth !== undefined) histogram.binWidth = options.binWidth\n\t\tif (options.rule !== undefined) histogram.rule = options.rule\n\t\tif (options.normalize !== undefined) histogram.normalize = options.normalize\n\t\thistogram.rebin(false)\n\t}\n}\n\nexport const ganttSeriesType: SeriesTypeDefinition<GanttTask[], GanttSeriesOptions> = {\n\tcreate: () => new Gantt(),\n\tsetData(series, tasks, labels) {\n\t\tconst data = series.data\n\t\t// Gantt keeps its start values in data.values, so both names must reference the same array.\n\t\t// The axis detects a date scale from Date instances in the values, so the dates are kept as given.\n\t\tdata.start = data.values = tasks.map(task => task.start) as number[]\n\t\tdata.end = tasks.map(task => task.end)\n\t\tdata.x = tasks.map((task, index) => task.x ?? index)\n\t\tdata.labels = tasks.map((task, index) => task.label ?? labels?.[index] ?? \"\")\n\t},\n\tconfigure(series, options) {\n\t\tconst gantt = series as Gantt\n\t\tif (options.height !== undefined) gantt.height = options.height\n\t\tif (options.borderRadius !== undefined) {\n\t\t\tgantt.format.round.x = options.borderRadius\n\t\t\tgantt.format.round.y = options.borderRadius\n\t\t}\n\t\tif (options.nextTasks !== undefined) gantt.nextTasks = options.nextTasks.map(([from, to]) => [from, to])\n\t\tif (options.nextTasksStrokeStyle !== undefined) gantt.nextTasksStrokeStyle = options.nextTasksStrokeStyle\n\t\tif (options.nextTasksPosition !== undefined) gantt.nextTasksPosition = options.nextTasksPosition\n\t}\n}\n\nexport const treemapSeriesType: SeriesTypeDefinition<TreemapNode, TreemapSeriesOptions> = {\n\tcreate: () => new Treemap(),\n\tsetData(series, root) {\n\t\tconst treemap = series as Treemap\n\t\t// Style updates carry the same data; keep the user's drill-down until the tree changes.\n\t\tif (treemap.root !== root) treemap.setRoot(root, false)\n\t},\n\tconfigure(series, options) {\n\t\tconst treemap = series as Treemap\n\t\tif (options.tiling !== undefined) treemap.tiling = options.tiling\n\t\tif (options.colorBy !== undefined) treemap.colorBy = options.colorBy\n\t\tif (options.padding !== undefined) treemap.padding = options.padding\n\t\tif (options.headerHeight !== undefined) treemap.headerHeight = options.headerHeight\n\t\tif (options.cornerRadius !== undefined) treemap.cornerRadius = options.cornerRadius\n\t\tif (options.lineWidth !== undefined) treemap.lineWidth = options.lineWidth\n\t\tif (options.borderColor !== undefined) treemap.borderColor = options.borderColor\n\t\tif (options.maxDepth !== undefined) treemap.maxDepth = options.maxDepth\n\t\tif (options.labels !== undefined) treemap.labels = options.labels\n\t\tif (options.showValues !== undefined) treemap.showValues = options.showValues\n\t\tif (options.sortByValue !== undefined) treemap.sortByValue = options.sortByValue\n\t\tif (options.zoomOnClick !== undefined) treemap.zoomOnClick = options.zoomOnClick\n\t\tif (options.formatValue !== undefined) treemap.formatValue = options.formatValue\n\t}\n}\n\nexport const violinSeriesType: SeriesTypeDefinition<Array<ViolinGroup | number[]>, ViolinSeriesOptions> = {\n\tcreate: () => new Violin(),\n\tsetData(series, groups, labels) {\n\t\t;(series as Violin).setData(groups, labels, false)\n\t},\n\tconfigure(series, options) {\n\t\tconst violin = series as Violin\n\t\tif (options.bandwidth !== undefined) violin.bandwidth = options.bandwidth\n\t\tif (options.smoothing !== undefined) violin.smoothing = options.smoothing\n\t\tif (options.cut !== undefined) violin.cut = options.cut\n\t\tif (options.resolution !== undefined) violin.resolution = options.resolution\n\t\tif (options.scale !== undefined) violin.scale = options.scale\n\t\tif (options.width !== undefined) violin.width = options.width\n\t\tif (options.inner !== undefined) violin.inner = options.inner\n\t\tif (options.fillOpacity !== undefined) violin.fillOpacity = options.fillOpacity\n\t\tif (options.lineWidth !== undefined) violin.lineWidth = options.lineWidth\n\t\tif (options.formatValue !== undefined) violin.formatValue = options.formatValue\n\t\tviolin.rebuild(false)\n\t}\n}\n\nexport const boxPlotSeriesType: SeriesTypeDefinition<Array<BoxPlotGroup | number[]>, BoxPlotSeriesOptions> = {\n\tcreate: () => new BoxPlot(),\n\tsetData(series, groups, labels) {\n\t\t;(series as BoxPlot).setData(groups, labels, false)\n\t},\n\tconfigure(series, options) {\n\t\tconst box = series as BoxPlot\n\t\tif (options.whisker !== undefined) box.whisker = options.whisker\n\t\tif (options.whiskerRange !== undefined) box.whiskerRange = options.whiskerRange\n\t\tif (options.whiskerMode !== undefined) box.whiskerMode = options.whiskerMode\n\t\tif (options.quantiles !== undefined) box.quantiles = options.quantiles\n\t\tif (options.minStats !== undefined) box.minStats = options.minStats\n\t\tif (options.maxStats !== undefined) box.maxStats = options.maxStats\n\t\tif (options.showPoints !== undefined) box.showPoints = options.showPoints\n\t\tif (options.pointRadius !== undefined) box.pointRadius = options.pointRadius\n\t\tif (options.jitter !== undefined) box.jitter = options.jitter\n\t\tif (options.width !== undefined) box.width = options.width\n\t\tif (options.showOutliers !== undefined) box.showOutliers = options.showOutliers\n\t\tif (options.showMean !== undefined) box.showMean = options.showMean\n\t\tif (options.fillOpacity !== undefined) box.fillOpacity = options.fillOpacity\n\t\tif (options.lineWidth !== undefined) box.lineWidth = options.lineWidth\n\t\tif (options.formatValue !== undefined) box.formatValue = options.formatValue\n\t\tbox.rebuild(false)\n\t}\n}\n\nexport const sankeySeriesType: SeriesTypeDefinition<SankeyGraph, SankeySeriesOptions> = {\n\tcreate: () => new Sankey(),\n\tsetData(series, graph) {\n\t\t;(series as Sankey).setGraph(graph, false)\n\t},\n\tconfigure(series, options) {\n\t\tconst sankey = series as Sankey\n\t\tif (options.nodeWidth !== undefined) sankey.nodeWidth = options.nodeWidth\n\t\tif (options.nodePadding !== undefined) sankey.nodePadding = options.nodePadding\n\t\tif (options.linkOpacity !== undefined) sankey.linkOpacity = options.linkOpacity\n\t\tif (options.linkColor !== undefined) sankey.linkColor = options.linkColor\n\t\tif (options.labels !== undefined) sankey.labels = options.labels\n\t\tif (options.formatValue !== undefined) sankey.formatValue = options.formatValue\n\t}\n}\n\ntype AnyGauge = ArcGauge | CircularGauge | NumericGauge\n\nfunction gaugeSeriesType<TOptions extends GaugeSeriesOptions>(\n\tcreate: () => AnyGauge,\n\tconfigureGauge?: (gauge: never, options: TOptions) => void\n): SeriesTypeDefinition<number, TOptions> {\n\treturn {\n\t\tcreate,\n\t\tsetData(series, value) {\n\t\t\t;(series as AnyGauge).value = value\n\t\t},\n\t\tconfigure(series, options) {\n\t\t\tconst gauge = series as AnyGauge\n\t\t\tif (options.min !== undefined) gauge.min = options.min\n\t\t\tif (options.max !== undefined) gauge.max = options.max\n\t\t\tif (options.animationDuration !== undefined && gauge.animate) gauge.animate.duration = options.animationDuration\n\t\t\tconfigureGauge?.(gauge as never, options)\n\t\t}\n\t}\n}\n\nexport const circularGaugeSeriesType = gaugeSeriesType<CircularGaugeSeriesOptions>(\n\t() => new CircularGauge(),\n\t(gauge: CircularGauge, options) => {\n\t\tif (options.step !== undefined) gauge.step = options.step\n\t\tif (options.minorTicks !== undefined) {\n\t\t\tgauge.minor.count = options.minorTicks\n\t\t\tgauge.minor.visible = options.minorTicks > 0\n\t\t}\n\t\tif (options.angle !== undefined) gauge.angle = options.angle\n\t\tif (options.rotation !== undefined) gauge.rotation = options.rotation\n\t\tif (options.inverted !== undefined) gauge.inverted = options.inverted\n\t\tif (options.rotateText !== undefined) gauge.rotateText = options.rotateText\n\t\tif (options.shape !== undefined) gauge.shape = options.shape\n\t\tif (options.handShape !== undefined) gauge.hand.shape = options.handShape\n\t\tif (options.ranges !== undefined) gauge.setRanges(options.ranges)\n\t\tif (options.units !== undefined) gauge.units.text = options.units\n\t\tif (options.showValue !== undefined) gauge.marks.visible = options.showValue\n\t\tif (options.draggable !== undefined) gauge.drag.enabled = options.draggable\n\t\tif (options.formatLabel !== undefined) gauge.ongetText = options.formatLabel\n\t\tif (options.formatValue !== undefined) gauge.formatValue = options.formatValue\n\t}\n)\nexport const numericGaugeSeriesType = gaugeSeriesType<NumericGaugeSeriesOptions>(() => new NumericGauge())\nexport const arcGaugeSeriesType = gaugeSeriesType<ArcGaugeSeriesOptions>(\n\t() => new ArcGauge(),\n\t(gauge: ArcGauge, options) => {\n\t\tif (options.angle !== undefined) gauge.angle = options.angle\n\t\tif (options.rotation !== undefined) gauge.rotation = options.rotation\n\t\tif (options.thickness !== undefined) gauge.thickness = options.thickness\n\t\tif (options.roundCaps !== undefined) gauge.roundCaps = options.roundCaps\n\t\tif (options.inverted !== undefined) gauge.inverted = options.inverted\n\t\tif (options.ranges !== undefined) gauge.ranges = options.ranges.map(band => ({ ...band }))\n\t\tif (options.target !== undefined) gauge.target = options.target\n\t\tif (options.caption !== undefined) gauge.caption = options.caption\n\t\tif (options.units !== undefined) gauge.units = options.units\n\t\tif (options.limits !== undefined) gauge.limits = options.limits\n\t\tif (options.showValue !== undefined) gauge.showValue = options.showValue\n\t\tif (options.draggable !== undefined) gauge.drag.enabled = options.draggable\n\t\tif (options.knob !== undefined) gauge.knob = options.knob\n\t\tif (options.step !== undefined) gauge.step = options.step\n\t\tif (options.formatValue !== undefined) gauge.formatValue = options.formatValue\n\t\tif (options.trackColor !== undefined) gauge.trackColor = options.trackColor\n\t\tif (options.textColor !== undefined) gauge.textColor = options.textColor\n\t}\n)\n\nexport const bulletSeriesType: SeriesTypeDefinition<number[], BulletSeriesOptions> = {\n\tcreate: () => new Bullet(),\n\tconfigure(series, options) {\n\t\t// Bullet is horizontal by default; yMandatory switches the value axis to the vertical one.\n\t\tconst bullet = series as Bullet\n\t\tif (options.vertical !== undefined) bullet.yMandatory = options.vertical\n\t\tif (options.target !== undefined) bullet.limit.origin = options.target\n\t\tif (options.ranges !== undefined) bullet.states.values = options.ranges\n\t}\n}\n\n/**\n * Registers every series type that is not available by default in declarative options. Calling it\n * includes all those series in the application bundle; register only the types in use with\n * `registerSeriesType` to keep bundles small.\n */\nexport function registerAllSeriesTypes(): void {\n\tregisterSeriesType(\"colorGrid\", colorGridSeriesType)\n\tregisterSeriesType(\"surface\", surfaceSeriesType)\n\tregisterSeriesType(\"linearGauge\", linearGaugeSeriesType)\n\tregisterSeriesType(\"activityGauge\", ActivityGauge)\n\tregisterSeriesType(\"arcGauge\", arcGaugeSeriesType)\n\tregisterSeriesType(\"bullet\", bulletSeriesType)\n\tregisterSeriesType(\"candle\", candleSeriesType)\n\tregisterSeriesType(\"circularGauge\", circularGaugeSeriesType)\n\tregisterSeriesType(\"gantt\", ganttSeriesType)\n\tregisterSeriesType(\"highLowBar\", highLowBarSeriesType)\n\tregisterSeriesType(\"histogram\", histogramSeriesType)\n\tregisterSeriesType(\"horizArea\", HorizArea)\n\tregisterSeriesType(\"horizBar\", HorizBar)\n\tregisterSeriesType(\"numericGauge\", numericGaugeSeriesType)\n\tregisterSeriesType(\"polar\", Polar)\n\tregisterSeriesType(\"sankey\", sankeySeriesType)\n\tregisterSeriesType(\"sliced\", Sliced)\n\tregisterSeriesType(\"treemap\", treemapSeriesType)\n\tregisterSeriesType(\"violin\", violinSeriesType)\n\tregisterSeriesType(\"boxPlot\", boxPlotSeriesType)\n\tregisterSeriesType(\"volume\", Volume)\n}\n","import { Point } from \"../core/primitives.js\"\nimport type { Series } from \"../series.js\"\nimport { visiblePointRange } from \"../series-utils.js\"\nimport type { SeriesTypeDefinition } from \"../series-registry.js\"\nimport { trunc } from \"../utils.js\"\nimport { CustomSeries } from \"./custom-series.js\"\n\n/**\n * What a composed series sees while it draws: the 2D canvas context and helpers that convert points to\n * pixel positions, so that a series type needs no knowledge of axes, stacking or the series class tree.\n */\nexport interface SeriesDrawContext {\n\treadonly series: Series\n\treadonly canvas: CanvasRenderingContext2D\n\t/** Number of points in the series. */\n\treadonly count: number\n\t/** Half open range `[first, last)` of the points that can be visible with the current axis scales. */\n\treadonly range: readonly [number, number]\n\t/** True when the value axis is the horizontal one. */\n\treadonly horizontal: boolean\n\t/** The pixel position of a point, in a new `Point` or in `into`. */\n\tpoint(index: number, into?: Point): Point\n\t/** The pixel position along the value axis of a value, for example 0 for the base of a bar. */\n\tscale(value: number): number\n\tisNull(index: number): boolean\n\tvalue(index: number): number\n\tlabel(index: number): string\n\t/** The fill color of a point: its own color, the palette color for `colorEach`, or the series fill. */\n\tcolor(index: number): string\n}\n\n/**\n * Describes a series type by functions instead of a class. `draw` is required; everything else falls back\n * to the behavior of a cartesian series: values on the value axis, points at their index (or `x`) on the\n * other axis, hit tests on the pointer, legend and marks.\n *\n * Use it with `registerSeriesType(name, defineSeriesType({ ... }))` to make the type available as `type` in\n * declarative chart options.\n */\nexport interface ComposedSeriesDefinition<TData = number[], TOptions extends { data: TData } = { data: TData }>\n\textends Omit<SeriesTypeDefinition<TData, TOptions>, \"create\"> {\n\t/** Draws all the points of the series. */\n\tdraw(context: SeriesDrawContext): void\n\t/**\n\t * Returns the index of the point at the pixel position `p`, or -1. When omitted, the pointer of the\n\t * series (see `pointer.visible`) is used.\n\t */\n\thitTest?(context: SeriesDrawContext, p: Point): number\n\t/** Draws the series with the value axis along the horizontal axis. */\n\thorizontal?: boolean\n\t/** Sets the initial state of the series, after it is created. */\n\tsetup?(series: Series): void\n}\n\nclass ComposedSeries extends CustomSeries {\n\tprivate readonly definition: ComposedSeriesDefinition<unknown, { data: unknown }>\n\n\tconstructor(definition: ComposedSeriesDefinition<unknown, { data: unknown }>) {\n\t\tsuper()\n\t\tthis.definition = definition\n\t\tif (definition.horizontal) this.yMandatory = false\n\t\tdefinition.setup?.(this)\n\t}\n\n\tprivate context(): SeriesDrawContext {\n\t\tconst len = this.data.values.length\n\t\tconst no = this.notmandatory\n\t\tlet range: [number, number] = [0, len]\n\n\t\tif (this.data.x) {\n\t\t\tconst visible = visiblePointRange(this.data.x, len, no.minimum, no.maximum)\n\t\t\tif (visible) range = visible\n\t\t} else range = [Math.max(0, trunc(no.minimum) - 1), Math.min(len, trunc(no.maximum) + 2)]\n\n\t\treturn {\n\t\t\tseries: this,\n\t\t\tcanvas: this.chart.drawContext,\n\t\t\tcount: len,\n\t\t\trange,\n\t\t\thorizontal: !this.yMandatory,\n\t\t\tpoint: (index, into = new Point()) => {\n\t\t\t\tthis.calc(index, into)\n\t\t\t\treturn into\n\t\t\t},\n\t\t\tscale: value => this.mandatoryAxis.calc(value),\n\t\t\tisNull: index => this.isNull(index),\n\t\t\tvalue: index => this.data.values[index],\n\t\t\tlabel: index => this.data.labels?.[index] ?? \"\",\n\t\t\tcolor: index => this.getFill(index, this.format) || this.format.fill\n\t\t}\n\t}\n\n\tdraw(): void {\n\t\tif (this.data.values.length === 0) return\n\n\t\tthis.isStacked = this.stacked !== \"no\"\n\t\tthis.isStack100 = this.stacked === \"100\"\n\n\t\tthis.definition.draw(this.context())\n\t\tif (this.pointer.visible) this.drawPointers()\n\t}\n\n\tclicked(p: Point): number {\n\t\tconst hitTest = this.definition.hitTest\n\t\tif (hitTest && this.data.values.length > 0) {\n\t\t\tconst index = hitTest(this.context(), p)\n\t\t\tif (index >= 0) return index\n\t\t}\n\t\treturn super.clicked(p)\n\t}\n}\n\n/**\n * Creates a series type definition from drawing functions, without extending a series class.\n *\n * ```js\n * registerSeriesType(\"lollipop\", defineSeriesType({\n * draw({ canvas, range, point, scale, color }) {\n * const base = scale(0)\n * for (let i = range[0]; i < range[1]; i++) {\n * const p = point(i)\n * canvas.beginPath()\n * canvas.moveTo(p.x, base)\n * canvas.lineTo(p.x, p.y)\n * canvas.strokeStyle = color(i)\n * canvas.stroke()\n * }\n * }\n * }))\n * ```\n */\nexport function defineSeriesType<TData = number[], TOptions extends { data: TData } = { data: TData }>(\n\tdefinition: ComposedSeriesDefinition<TData, TOptions>\n): SeriesTypeDefinition<TData, TOptions> {\n\tif (typeof definition?.draw !== \"function\") throw new Error(\"defineSeriesType requires a draw function\")\n\n\treturn {\n\t\tcreate: () => new ComposedSeries(definition as unknown as ComposedSeriesDefinition<unknown, { data: unknown }>),\n\t\tsetData: definition.setData,\n\t\tconfigure: definition.configure\n\t}\n}\n","import type { Chart } from \"../chart.js\"\nimport { getDocument, getPlatformConstructor, getWindow } from \"../platform.js\"\nimport type { Series } from \"../series.js\"\n\nexport type ChartTableRefresh = (cell: HTMLTableCellElement) => void\n\n/** Connects an HTML table to a chart for editing and hover synchronization. */\nexport class ChartTable {\n\theader = 0\n\tfirstCol = 0\n\tbyCols = true\n\tchart: Chart\n\ttable: HTMLTableElement | null\n\n\tprivate refreshCallback: ChartTableRefresh | null = null\n\tprivate readonly handleCellClick = (event: MouseEvent): void => {\n\t\tthis.editCell(event.currentTarget as HTMLTableCellElement)\n\t}\n\tprivate readonly handleInputChange = (event: Event): void => {\n\t\tthis.commitInputValue(event.currentTarget as HTMLInputElement)\n\t}\n\n\tconstructor(table: HTMLTableElement | string, chart: Chart) {\n\t\tthis.chart = chart\n\n\t\tconst TableElement = getPlatformConstructor<HTMLTableElement>(\"HTMLTableElement\")\n\t\tconst runtimeDocument = getDocument()\n\t\tthis.table =\n\t\t\tTableElement && table instanceof TableElement\n\t\t\t\t? table\n\t\t\t\t: typeof table === \"string\"\n\t\t\t\t\t? (runtimeDocument?.getElementById(table) as HTMLTableElement | null)\n\t\t\t\t\t: table\n\t}\n\n\teditCell(cell: HTMLTableCellElement): void {\n\t\tconst CellElement = getPlatformConstructor<HTMLTableCellElement>(\"HTMLTableCellElement\")\n\t\tif (!CellElement || !(cell instanceof CellElement)) return\n\n\t\tcell.onclick = null\n\t\tconst runtimeDocument = getDocument()\n\t\tif (!runtimeDocument) return\n\n\t\tconst input = runtimeDocument.createElement(\"input\")\n\t\tinput.type = \"text\"\n\t\tinput.style.width = `${cell.clientWidth}px`\n\t\tinput.onchange = this.handleInputChange\n\t\tinput.onkeydown = this.handleKeyDown\n\t\tinput.onblur = this.handleInputChange\n\t\tinput.value = cell.innerHTML\n\t\tinput.className = \"inline-editor\"\n\n\t\tcell.innerHTML = \"\"\n\t\tcell.appendChild(input)\n\t\tinput.focus()\n\t}\n\n\thandleKeyDown = (event: KeyboardEvent): boolean => {\n\t\tconst runtimeEvent = getWindow()?.event\n\t\tconst keyCode = (runtimeEvent as KeyboardEvent | undefined)?.keyCode ?? event.which\n\t\tif (!keyCode) return true\n\n\t\tconst input = event.currentTarget as HTMLInputElement\n\t\tconst cell = input.parentElement as HTMLTableCellElement | null\n\t\tconst row = cell?.parentElement as HTMLTableRowElement | null\n\t\tconst tableBody = row?.parentElement as HTMLTableSectionElement | HTMLTableElement | null\n\t\tif (!cell || !row || !tableBody) return true\n\n\t\tif (keyCode === 27 || keyCode === 13) this.commitInputValue(input)\n\n\t\tif (keyCode === 9) {\n\t\t\tif (event.shiftKey) {\n\t\t\t\tif (cell.cellIndex > this.firstCol) {\n\t\t\t\t\tthis.commitInputValue(input)\n\t\t\t\t\tthis.editCell(row.cells[cell.cellIndex - 1])\n\t\t\t\t} else if (row.rowIndex > 1) {\n\t\t\t\t\tthis.commitInputValue(input)\n\t\t\t\t\tconst previousRow = tableBody.rows[row.rowIndex - 1]\n\t\t\t\t\tthis.editCell(previousRow.cells[previousRow.cells.length - 1])\n\t\t\t\t}\n\t\t\t} else if (cell.cellIndex < row.cells.length - 1) {\n\t\t\t\tthis.commitInputValue(input)\n\t\t\t\tthis.editCell(row.cells[cell.cellIndex + 1])\n\t\t\t} else if (row.rowIndex < tableBody.rows.length - 1) {\n\t\t\t\tthis.commitInputValue(input)\n\t\t\t\tthis.editCell(tableBody.rows[row.rowIndex + 1].cells[1])\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\n\t\tif (keyCode === 40 && row.rowIndex < tableBody.rows.length - 1) {\n\t\t\tthis.commitInputValue(input)\n\t\t\tthis.editCell(tableBody.rows[row.rowIndex + 1].cells[cell.cellIndex])\n\t\t} else if (keyCode === 38 && row.rowIndex > this.header) {\n\t\t\tthis.commitInputValue(input)\n\t\t\tthis.editCell(tableBody.rows[row.rowIndex - 1].cells[cell.cellIndex])\n\t\t}\n\n\t\treturn true\n\t}\n\n\tcommitInputValue(input: HTMLInputElement): void {\n\t\tconst InputElement = getPlatformConstructor<HTMLInputElement>(\"HTMLInputElement\")\n\t\tif (!InputElement || !(input instanceof InputElement) || !input.onchange) return\n\n\t\tinput.onchange = null\n\t\tconst cell = input.parentElement as HTMLTableCellElement | null\n\t\tif (!cell) return\n\n\t\tcell.innerHTML = input.value\n\t\tcell.onclick = this.handleCellClick\n\t\tthis.refreshCallback?.(cell)\n\t}\n\n\thighlightRows(color: string, panel: HTMLElement | string | null = null): void {\n\t\tconst panelElement = typeof panel === \"string\" ? getDocument()?.getElementById(panel) : panel\n\t\tif (!this.table) return\n\n\t\tfor (const row of Array.from(this.table.rows)) {\n\t\t\trow.onmouseover = () => {\n\t\t\t\trow.style.backgroundColor = color\n\t\t\t\tif (panelElement) panelElement.style.visibility = \"visible\"\n\t\t\t}\n\t\t\trow.onmouseout = () => {\n\t\t\t\trow.style.backgroundColor = \"#FFFFFF\"\n\t\t\t\tif (panelElement) panelElement.style.visibility = \"hidden\"\n\t\t\t}\n\t\t}\n\t}\n\n\trefreshChartFromCell(cell: HTMLTableCellElement): void {\n\t\tconst rowIndex = this.byCols ? (cell.parentElement as HTMLTableRowElement | null)?.rowIndex : cell.cellIndex\n\t\tconst columnIndex = this.byCols ? cell.cellIndex : (cell.parentElement as HTMLTableRowElement | null)?.rowIndex\n\t\tif (rowIndex == null || columnIndex == null) return\n\n\t\tconst text = cell.innerHTML\n\t\tif (rowIndex === 1) {\n\t\t\tif (columnIndex === 1) {\n\t\t\t\tif (text !== this.chart.footer.text) {\n\t\t\t\t\tthis.chart.footer.text = text\n\t\t\t\t\tthis.chart.draw()\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst series = this.chart.series.items[columnIndex - 2]\n\t\t\tif (series && text !== series.title) {\n\t\t\t\tseries.title = text\n\t\t\t\tthis.chart.draw()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tconst dataRow = rowIndex - 2\n\t\tif (columnIndex === 1) {\n\t\t\tthis.chart.series.each(series => {\n\t\t\t\tseries.data.labels[dataRow] = text\n\t\t\t})\n\t\t\tthis.chart.draw()\n\t\t\treturn\n\t\t}\n\n\t\tconst series = this.chart.series.items[columnIndex - 2]\n\t\tconst value = Number.parseFloat(text)\n\t\tif (series && value !== series.data.values[dataRow]) {\n\t\t\tseries.data.values[dataRow] = value\n\t\t\tthis.chart.draw()\n\t\t}\n\t}\n\n\tenableEditing(enable: boolean, refresh: ChartTableRefresh = this.refreshChartFromCell.bind(this)): void {\n\t\tthis.refreshCallback = refresh\n\t\tif (!this.table) return\n\n\t\tconst clickHandler = enable ? this.handleCellClick : null\n\t\tfor (const row of Array.from(this.table.rows)) {\n\t\t\tfor (const cell of Array.from(row.cells)) cell.onclick = clickHandler\n\t\t}\n\t}\n\n\tsetCellHoverState(cell: HTMLTableCellElement, active: boolean): void {\n\t\tcell.style.backgroundColor = active ? \"gold\" : \"\"\n\t\tcell.style.color = active ? \"white\" : \"\"\n\t}\n\n\tgetCellForPoint(series: Series, index: number): HTMLTableCellElement | null {\n\t\tif (!this.table) return null\n\t\tconst seriesIndex = series.chart.series.items.indexOf(series) + 2\n\t\treturn this.byCols ? this.table.rows[index + 2]?.cells[seriesIndex] : this.table.rows[seriesIndex]?.cells[index + 2]\n\t}\n\n\tupdateHoverCell = (series: Series, index: number): void => {\n\t\tif (series.over !== -1) {\n\t\t\tconst previousCell = this.getCellForPoint(series, series.over)\n\t\t\tif (previousCell) this.setCellHoverState(previousCell, false)\n\t\t}\n\n\t\tif (index !== -1) {\n\t\t\tconst currentCell = this.getCellForPoint(series, index)\n\t\t\tif (currentCell) this.setCellHoverState(currentCell, true)\n\t\t}\n\t}\n\n\tgetVisibleSeriesIndex(index: number): number {\n\t\tlet visibleIndex = -1\n\t\tfor (let seriesIndex = 0; seriesIndex < this.chart.series.count(); seriesIndex++) {\n\t\t\tif (this.chart.series.items[seriesIndex].visible && ++visibleIndex === index) return seriesIndex\n\t\t}\n\t\treturn -1\n\t}\n\n\thandleLegendHover = (previousIndex: number, index: number): void => {\n\t\tlet byColumns = this.byCols\n\t\tlet position = 1\n\t\tconst chart = this.chart\n\t\tif (chart.legend.showValues()) {\n\t\t\tconst firstVisibleSeries = chart.series.items.find(series => series.visible)\n\t\t\tif (!firstVisibleSeries) return\n\t\t\tposition = 2 + chart.series.items.indexOf(firstVisibleSeries)\n\t\t\tbyColumns = !byColumns\n\t\t}\n\n\t\tif (!this.table) return\n\t\tif (byColumns) {\n\t\t\tif (previousIndex !== -1)\n\t\t\t\tthis.setCellHoverState(this.table.rows[position].cells[this.getVisibleSeriesIndex(previousIndex) + 2], false)\n\t\t\tif (index !== -1)\n\t\t\t\tthis.setCellHoverState(this.table.rows[position].cells[this.getVisibleSeriesIndex(index) + 2], true)\n\t\t} else {\n\t\t\tif (previousIndex !== -1) this.setCellHoverState(this.table.rows[previousIndex + 2].cells[position], false)\n\t\t\tif (index !== -1) this.setCellHoverState(this.table.rows[index + 2].cells[position], true)\n\t\t}\n\t}\n}\n"],"names":["CursorTool","Tool","direction","size","followMouse","dragging","format","horizAxis","vertAxis","render","symbol","symbolSize","_pp","_canvasCopy","_ctxCopy","_hitEpsilon","_old","_rect","onchange","constructor","chart","super","this","Point","Format","stroke","fill","axes","bottom","left","Rectangle","getHitTarget","point","result","rectangle","oldPoint","contains","nearVertical","Math","abs","x","nearHorizontal","y","calculateBounds","chartRectangle","chartRect","horizontalAxis","verticalAxis","startPos","width","endPos","height","mousedown","event","calcMouse","clicked","mousemove","followsMouse","draw","restoreCopy","drawContext","b","bounds","clearRect","drawCursor","ctx","_emit","hitTarget","newCursor","setRender","resetCopy","context","copyBitmap","source","save","setTransform","globalAlpha","globalCompositeOperation","shadowColor","filter","drawImage","restore","canvas","canvasCopy","style","position","parentNode","appendChild","setAttribute","offsetLeft","offsetTop","top","zIndex","pointerEvents","removeChild","cloneNode","getContext","bothDirections","beginPath","halfHeight","moveTo","lineTo","halfWidth","strokeStyle","lineWidth","max","setLineDash","prepare","radius","arc","PI","rect","closePath","fillStyle","DragTool","series","target","onchanging","onchanged","index","items","visible","candidate","value","mandatoryAxis","fromPos","yMandatory","data","values","round","Number","isInteger","String","toFixed","replace","describeChart","title","text","parts","push","length","count","map","name","numbers","isFinite","points","minimum","maximum","describeSeries","join","visuallyHidden","margin","padding","overflow","clip","whiteSpace","border","enableKeyboard","seriesPosition","pointIndex","region","document","getDocument","createElement","Object","assign","insertBefore","nextSibling","focusPoint","other","over","doHover","textContent","label","labels","where","undefined","shown","announcement","onKeyDown","list","navigableSeries","min","last","nextSeries","next","key","preventDefault","addEventListener","removeEventListener","removeAttribute","CheckBox","Annotation","check","checked","transparent","margins","cursor","h","onclick","CircularGauge","Series","useAxes","step","angle","rotation","rotateText","shape","inverted","drag","enabled","ongetText","formatValue","ondrawHand","hands","cx","cy","cex","cey","tick0","tick1","tickMin","tickText","initRot","endRot","_oldValue","_newValue","o","o2","bevel","gradient","colors","shadow","center","offset","location","ticks","outside","triangle","ticksBack","minor","minorBack","hand","addHand","back","pointer","marks","font","blur","color","units","getRect","hover","animate","BaseAnimation","f","duration","onstop","destroy","setRanges","bands","ranges","band","to","calcBounds","custom","cellRect","rax","ray","ta","r","tar","xx","ra","drawRange","t","p0","p1","start","end","tryBack","endsx","sx","old","oldg","tartot","difRot","rangeIndex","item","rangeValue","drawShape","fo","ellipse","minAngle","rot0","halfx","halfy","pos","range","fh","textHeight","tickCount","textStep","trunc","cex2","cey2","isHover","p","dif","valid","translate","rotate","roStep","totRot","offY","tickIndex","fTick","ts","rr","st","ppos","decimals","fillText","mit","miStep","nPos","fminTick","resize","percentLocation","u","drawHand","ces","cet","han","limitValue","handRot","hs","rah","rad","raend","quadraticCurveTo","v","setValue","res","active","inValue","rIni","rEnd","val","dx","dy","d","sqrt","ang","atan2","inTicks","changeHover","g","_scheduleDraw","ok","test","getNavigator","userAgent","e","setChart","gauge","Slider","thumb","grip","gripSize","useRange","thumbSize","horizontal","delta","_thumbRectTmp","_mousePointTmp","touchDragging","resizeBegin","resizeEnd","onDrawThumb","invertThumb","lock","onChanging","touchTarget","cleanupChart","chartCleanup","onTouchStart","onTouchEnd","interactionCanvas","_eventCleanups","destroyed","indexOf","splice","thumbRect","gripRect","w","m","th","r1","clickAt","off","s","v2","resized","pp","dif2","v3","ingrip","tmp","mouseout","DataEngine","datasets","onclickseries","addDataset","object","field","id","xmlToJson","DataDimension","dataset","dimensions","engine","removeDataset","findIndex","clear","addJson","json","JSON","parse","applyStyle","panel","groupRemaining","l2","l","code","createSlider","tools","add","xml","obj","nodeType","attributes","j","attribute","nodeName","nodeValue","hasChildNodes","i","childNodes","trim","Array","isArray","loadXmlDocument","url","XMLHttpRequestConstructor","getXMLHttpRequest","ActiveXObjectConstructor","getActiveXObject","xhttp","Error","open","send","responseXML","loadXmlString","DOMParserConstructor","getDOMParser","parseFromString","xmlDoc","async","loadXML","_accumulate","measure","total","queryDim","dim","_child","tot2","lin","dimension","getLinksTo","lin0","totalsById","Map","has","set","initDims","mfunc","traverse","record","consider","hasID","parent","searchAcross","nulls","valo","parseFloat","datetime","datePart","existing","isNaN","get","_sumOfCount","_initTotal","ids","ttt","query","metric","metrics","mt","dimt","totals","oldIds","dl","dim0","dim0sel","selected","anySelected","selectedInclude","getIds","inSelected","oldInclude","oldSelect","select","dimValues","isSelected","selectedValues","valt","master","masterdim","populatedIds","Set","createChart","Chart","tip","ToolTip","ongettext","_tip","la","clickAnimation","totalOf","tt","onstart","animateHover","guessStyle","defaultStyle","Line","Bar","newSeries","_metric","tot","masterTitle","SeriesStyle","addSeries","lc","titles","findLinkInDimension","bdata","onnewseries","animateChanges","setSeriesStyle","newS","St","resolvedStyle","path","root","globalThis","split","reduce","resolvePath","dontRedraw","fillQuery","_onclickseries","legend","textAlign","dim2","dateKeys","sort","sortBy","sortData","order","sortSeries","ss","ssvalues","newValues","slice","a","oldauto","automatic","animateClick","setSeriesPalette","palette","c","ascending","sorted","s0","len","tb","doSort","each","data2","A","B","before","after","toLowerCase","newList","groupOther","maxValues","totalPoints","setPositionPercent","runtimeWindow","getWindow","runtimeDocument","innerHeight","documentElement","clientHeight","body","innerWidth","clientWidth","SeriesAnimation","anim","animation","kind","fade","FadeAnimation","DataMetric","ld","dd","allDims","hasParent","_link","link","search","subDimensions","links","addDimension","addSubDimension","addMetric","addLink","datasetField","date","da","match","yearField","monthField","parseInt","dayField","Date","getDay","getFullYear","getMonth","getDate","getValues","seen","toggleSelected","process","levels","di","traverseLevel","levelIndex","ml","lev","hasSelected","daSel","da2","t2","o3","kk","k","keys","kl","lev2","hasSelected2","doProcess","searchDimension","cache","cached","linkSearch","linkField","linkValues","fields","wanted","needle","haystack","li","lil","need","_this","unshift","annotations","WeakMap","applyToolsOptions","findOrAddTool","options","previous","remove","created","annotation","backgroundColor","borderColor","borderWidth","fontColor","fontSize","setSize","fontFamily","fontStyle","part","endsWith","applyAnimationOptions","mode","fadeAnimation","registerAllOptions","registerOptionSection","description","applied","refresh","stopKeyboard","keyboard","stopRefresh","on","stop","stopDestroy","once","applyAccessibility","Observer","getPlatformConstructor","observer","entries","contentRect","observe","disconnect","observeSize","isMessage","prefix","type","startsWith","startChartWorker","host","port","reply","message","postMessage","listener","pixelRatio","setPixelRatio","setOptions","dispatchPointerEvent","blob","error","toBlob","quality","then","createWorkerChart","worker","init","transferable","transferControlToOffscreen","devicePixelRatio","resolveReady","rejectReady","ready","Promise","resolve","reject","catch","blobs","blobId","pending","delete","transfer","initial","offscreen","forward","getBoundingClientRect","captureWheel","clientX","clientY","button","deltaY","pointerId","listeners","passive","handler","listenerOptions","lastWidth","lastHeight","ResizeObserver","patch","Scroller","scroller","clearTargetTooltip","domTip","aspect","transparency","owner","ondraw","onscroll","mi","minXValue","ma","maxXValue","setMinMax","graphics","cRect","saveAxis","axis","sp","ep","restoreAxis","scale","minYValue","maxYValue","totalRange","seriesItem","pointerOf","oldVisible","setBounds","SliderControl","tmpChart","slider","renderer","CanvasRenderer","getSize","MarksAnimation","current","oldGetText","marksText","_series","bind","doStep","fraction","ActivityGauge","Donut","donutArray","maxWidth","maxDrawWidth","donutCenterSize","tmpDonut","tmpMaxRadius","tmpAngleWidth","maxValue","createDonut","maxRadius","angleWidth","donut","concentric","copyFormat","origin","colorNum","donutFormat","originFormat","baseLine","stops","cap","dash","_i","getFillStyle","linkDonutsToChart","recalcWidth","addRandom","floor","random","fromCharCode","temporaryValue","minValue","DEGREES","FONT_FAMILY","ArcGauge","thickness","roundCaps","knob","caption","limits","showValue","trackColor","textColor","mutedColor","surfaceColor","frame","layout","sweep","colorAt","animated","area","extent","angles","quarter","ceil","xs","cos","ys","sin","minX","maxX","minY","maxY","arcExtent","closed","showLimits","below","lineCap","place","inner","outer","textBaseline","drawValue","room","unitsSize","measureText","captionSize","block","baseline","valueWidth","valueAt","anywhere","distance","hypot","slop","relative","BoxPlot","colorEach","whisker","whiskerRange","whiskerMode","quantiles","minStats","maxStats","showPoints","pointRadius","jitter","showOutliers","showMean","fillOpacity","medianColor","dotStroke","boxes","continuous","setData","groups","redraw","Symbol","iterator","TypeError","from","names","every","group","rebuild","stats","summarize","box","median","statsOf","fromValues","q1","q3","outliers","mean","low","high","raw","quartiles","fenceLow","fenceHigh","inside","sum","method","at","half","fivenum","pick","quantile","notmandatory","calc","geometry","getFill","hovered","lineJoin","yLow","yHigh","fillRect","strokeRect","spread","jitterSequence","marker","diamond","formatNumber","valueText","tooltipParts","details","legendColor","vertMargins","lowest","highest","seed","state","HorizBar","CustomBar","maxMarkWidth","drawEvery","isNull","textWidth","markText","horizMargins","hasNegativeValues","arrow","right","initOffsets","_margin","stacked","countAll","useOrigin","stackMaxValue","calcBarBounds","bar","originPos","_horizAxis","Bullet","limit","states","barSize","gradientVisible","_rangeFormat","_limitFormat","_row","rangesAt","targetAt","_baseMinXValue","_baseMaxXValue","_baseMinYValue","_baseMaxYValue","rowCount","upToThis","rowLabel","row","rowSize","calcSize","prepareFormat","z","depth","span","minSize","drawRanges","cube","drawTarget","eachRow","callback","calcStackPos","Candle","CustomSeries","drawLine","hi","higher","lo","lower","prototype","pointCount","cylinder","ArrayMin","ArrayMax","close","notMandatoryAxis","Gantt","dateFormat","nextTasks","nextTasksStrokeStyle","nextTasksPosition","_h","addNextTask","point1","point2","month","day","year","indexOrRectangle","DateUtils","startText","endText","days","oldFill","drawLines","punts","HighLowBar","closeArea","maxmin","beveled","lows","calcLows","isStacked","calcStack","NaN","nm","isY","isStack100","smop","begin","doStack","smooth","maxP","minP","idx","spline","drawSpline","stairs","rects","lowPY","nextPx","__webgl","drawPointers","Histogram","bins","binWidth","rule","normalize","edges","_labels","rebin","resolveWidth","counts","_","amount","ruleBins","log2","calcBarOffset","axisSize","bin","offsetPoint","customBarSize","HorizArea","Area","NumericGauge","markers","oldValue","newValue","valueMarker","addValueMarker","textMarker","addTextMarker","unitsMarker","addUnitsMarker","fAnimation","drawMarker","shapeWidth","shapeHeight","shapeLocation","lblX","lblY","forEach","Polar","_paintAxes","_paintWalls","clockwise","_polarPoint","_polarCenter","_polarRadius","_pi180","mand","tryDrawAxis","px","py","axisPos","oldz","walls","drawAxis","calcCenter","rw","rh","textH","beforeDraw","pi180","wall","wallFormat","nomand","nomandgrid","grid","vmin","labelincrem","nomandrotation","rText","labelsF","labelRadius","drawText","gridincrem","increment","roundMin","mandgrid","gridstep","increm","polygon","Sankey","nodeWidth","nodePadding","linkOpacity","linkColor","iterations","nodes","columns","lastPoint","graph","setGraph","build","_requestDraw","byName","node","x0","x1","y0","y1","out","in","declared","RangeError","computeDepths","outValue","column","queue","visited","maxDepth","head","linkStyleColor","nodeColor","share","EPSILON","legendCount","labelWidth","widest","ky","POSITIVE_INFINITY","pass","alpha","beta","relax","placeLinks","side","weight","collide","lastItem","drawLinks","overLink","base","linkIndex","mid","connected","createLinearGradient","addColorStop","bezierCurveTo","drawNodes","drawLabels","lineHeight","centered","alignLeft","bx","shadowBlur","shadowOffsetX","shadowOffsetY","best","bestDistance","linkDistance","Sliced","calcColorEach","sortedMap","canvasHeight","canvasWidth","correspondingHeight","parseColor","hex","exec","digits","n","rgb","shade","Treemap","tiling","colorBy","headerHeight","cornerRadius","showValues","sortByValue","zoomOnClick","onzoom","tiles","tileRoot","focus","chartOrRoot","Palette","setRoot","zoomTo","tile","tileOf","branch","unfold","children","header","child","sumOf","full","layoutRoot","found","find","depthLimit","collect","collapse","pad","gap","squarify","worst","ratio","nextMin","nextMax","rowWidth","rowHeight","tileColor","rootDepth","level","ancestor","steps","whole","leafCount","Boolean","fitText","fitted","character","roundRect","drawTile","family","dimmed","isRelated","container","ink","contrastOf","labelPadding","withValue","Violin","bandwidth","smoothing","cut","resolution","violins","estimate","violin","density","silverman","factor","exp","reference","peak","outline","widths","trace","drawInner","along","iqr","deviation","Volume","barStyle","ColorGrid","PaletteSeries","dataChanged","image","imageData","c2","ctx2","InvRange255","rows","cols","square","optimize","getPropertyValue","setProperty","msInterpolationMode","imageSmoothingEnabled","tryDrawGrid","xInc","yInc","axis2","calcMinMax","fillPixels","grayscale","grayScale","getColor","xStart","xEnd","yStart","yEnd","rowIndex","columnIndex","getImageData","putImageData","xPos","yPos","xScale","yScale","recalcAxes","_min","_max","_range","prepareColors","Surface","_sizeY","wireFrame","maxZ","getY","surface","LinearGauge","lineFill","txtHeight","markSymbol","barHeight","showTicks","gradientColors","animationIncrement","animationDuration","_animStart","_animFrom","startValue","finalValue","_animationFrame","_animationCleanupChart","_cancelGaugeAnimation","cancelAnimationFrame","_ensureAnimationCleanup","cancel","_scheduleGaugeAnimation","requestAnimationFrame","_clamp","_position","gaugeX","gaugeWidth","drawAll","gaugeY","gaugeHeight","drawBar","_gaugeX","_gaugeWidth","_gaugeHeight","first","trackPath","barEnd","badgeWidth","badgeHeight","badgeY","badgeX","tickTop","ltext","animateGauge","currentValue","targetValue","now","eased","colorGridSeriesType","create","surfaceSeriesType","configure","linearGaugeSeriesType","candleSeriesType","some","highLowBarSeriesType","histogramSeriesType","histogram","ganttSeriesType","tasks","task","gantt","borderRadius","treemapSeriesType","treemap","violinSeriesType","boxPlotSeriesType","sankeySeriesType","sankey","gaugeSeriesType","configureGauge","circularGaugeSeriesType","minorTicks","handShape","draggable","formatLabel","numericGaugeSeriesType","arcGaugeSeriesType","bulletSeriesType","bullet","vertical","registerAllSeriesTypes","registerSeriesType","ComposedSeries","definition","setup","no","visiblePointRange","into","hitTest","defineSeriesType","ChartTable","firstCol","byCols","table","refreshCallback","handleCellClick","editCell","currentTarget","handleInputChange","commitInputValue","TableElement","getElementById","cell","CellElement","input","onkeydown","handleKeyDown","onblur","innerHTML","className","runtimeEvent","keyCode","which","parentElement","tableBody","shiftKey","cellIndex","cells","previousRow","InputElement","highlightRows","panelElement","onmouseover","visibility","onmouseout","refreshChartFromCell","footer","dataRow","enableEditing","enable","clickHandler","setCellHoverState","getCellForPoint","seriesIndex","updateHoverCell","previousCell","currentCell","getVisibleSeriesIndex","visibleIndex","handleLegendHover","previousIndex","byColumns","firstVisibleSeries"],"mappings":";;;;;;;;;;;;;;yiCAoBM,MAAOA,WAAmBC,EAC/BC,UACAC,KACAC,YACAC,SACAC,OACAC,UACAC,SACAC,OACAC,OACAC,WACQC,IACAC,YACAC,SACAC,YACAC,KACAC,MACRC,SAEA,WAAAC,CAAYC,GACXC,MAAMD,GACNE,KAAKpB,UAAY,OACjBoB,KAAKnB,KAAO,IAAIoB,EAAM,EAAG,GACzBD,KAAKlB,aAAc,EACnBkB,KAAKjB,UAAW,EAChBiB,KAAKhB,OAAS,IAAIkB,EAAOJ,GACzBE,KAAKhB,OAAOmB,OAAOC,KAAO,UAC1BJ,KAAKhB,OAAOmB,OAAOtB,KAAO,IAC1BmB,KAAKf,UAAYa,EAAQA,EAAMO,KAAKC,OAAS,KAC7CN,KAAKd,SAAWY,EAAQA,EAAMO,KAAKE,KAAO,KAC1CP,KAAKb,OAAS,OACda,KAAKZ,OAAS,SACdY,KAAKX,WAAa,EAClBW,KAAKP,YAAc,EACnBO,KAAKN,KAAO,KACZM,KAAKL,MAAQ,IAAIa,EACjBR,KAAKV,IAAM,IAAIW,EAAM,EAAG,GACxBD,KAAKT,YAAc,KACnBS,KAAKR,SAAW,IACjB,CAEA,YAAAiB,CAAaC,GACZ,IAAIC,GAAS,EACb,MAAMC,EAAYZ,KAAKL,MACjBkB,EAAWb,KAAKN,KAEtB,GAAIkB,EAAUE,SAASJ,IAAUG,EAAU,CAC1C,MAAME,EAAeC,KAAKC,IAAIJ,EAASK,EAAIR,EAAMQ,GAAKlB,KAAKP,YACrD0B,EAAiBH,KAAKC,IAAIJ,EAASO,EAAIV,EAAMU,GAAKpB,KAAKP,YACvDb,EAAYoB,KAAKpB,UACL,SAAdA,GAAwBmC,GAAgBI,EAAgBR,EAAS,GAC5DI,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