@d3plus/core 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +374 -296
- package/es/src/charts/Geomap/emit.js +44 -4
- package/es/src/charts/Geomap/emit.js.map +1 -1
- package/es/src/charts/Geomap/index.js +30 -1
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +77 -2
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +24 -3
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/features/shapeEmit.js +3 -1
- package/es/src/charts/features/shapeEmit.js.map +1 -1
- package/es/src/charts/viz/Viz.js +63 -10
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/interactionOpacity.js +4 -1
- package/es/src/charts/viz/interactionOpacity.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +4 -1
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizRender.js +7 -3
- package/es/src/charts/viz/vizRender.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/shapes/Shape.js +12 -10
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/hitAreaNode.js +31 -5
- package/es/src/shapes/hitAreaNode.js.map +1 -1
- package/es/src/shapes/interactionPoints.js +30 -0
- package/es/src/shapes/interactionPoints.js.map +1 -0
- package/package.json +9 -9
- package/types/src/charts/Plot/index.d.ts +22 -1
- package/types/src/charts/Plot/pipeline.d.ts +2 -1
- package/types/src/charts/viz/Viz.d.ts +31 -1
- package/types/src/charts/viz/vizTypes.d.ts +18 -0
- package/types/src/shapes/Shape.d.ts +2 -2
- package/types/src/shapes/hitAreaNode.d.ts +5 -4
- package/types/src/shapes/interactionPoints.d.ts +15 -0
- package/umd/d3plus-core.full.js +954 -275
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +1285 -1099
- package/umd/d3plus-core.js +267 -39
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +266 -170
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/features/shapeEmit.ts"],"sourcesContent":["/**\n Per-shape emit registry for the Plot paint phase.\n\n The Plot paint loop walks the grouped `shapeData` and, for each shape\n key, produces the scene nodes for that shape's data. Most shapes follow\n the same path (instantiate compute-mode → wire events → apply user\n config → render → collect). Bar and Line carry extra geometry — bar\n spacing/grouping, line confidence bands + end-labels + markers — so they\n get dedicated emitters. Everything else (and stacked Area) flows through\n the generic emitter.\n\n A chart \"uses only some shapes\" purely by which keys appear in its\n `shapeData` (driven by the chart's `shape` accessor default). The\n registry stays complete; the dispatch only ever calls the emitters whose\n keys are present.\n\n @module\n*/\n\nimport {groups, max, merge} from \"d3-array\";\nimport * as scales from \"d3-scale\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport {assign} from \"@d3plus/dom\";\nimport {formatAbbreviate} from \"@d3plus/format\";\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {Shape} from \"../../shapes/index.js\";\n\nimport {collectComputed, makeShape, shapeConfigFor} from \"./emitHelpers.js\";\nimport type {LabelWidth, PlotAxisFn, PlotDatum} from \"./plotPaint.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\n/**\n The cross-phase locals a shape emitter reads. Assembled once per draw by\n the Plot paint loop and passed to each emitter alongside the shape key.\n The stack math (`stackData`/`stackKeyIndex`/`discreteKeyIndex`) is\n computed upstream once per draw — emitters consume it, never recompute.\n*/\nexport interface ShapeEmitContext {\n viz: Viz;\n /** The data rows for this shape group. */\n values: DataPoint[];\n /** The base shape config shared across every shape in the loop. */\n shapeConfig: Record<string, unknown>;\n /** Event names registered on the viz (`Object.keys(viz.schema.on)`). */\n events: string[];\n\n // Scales + accessors (x/y reassigned to the production-axis closures).\n x: PlotAxisFn;\n y: PlotAxisFn;\n xScale: string;\n yScale: string;\n xDomain: number[];\n yDomain: number[];\n xRange: number[];\n yRange: number[];\n\n // Stacking inputs (computed once upstream).\n opp: \"x\" | \"y\" | undefined;\n domains: Record<string, number[]>;\n stackData: number[][][];\n stackKeyIndex: Map<unknown, number>;\n discreteKeyIndex: Map<unknown, number>;\n\n // Line-label inputs.\n showLineLabels: boolean;\n labelWidths: LabelWidth[];\n largestLabel: number;\n labelPositions: Record<string, number>;\n\n width: number;\n}\n\n/** An emitter: produces the scene nodes for one shape group. */\nexport type ShapeEmitter = (ctx: ShapeEmitContext, key: string) => SceneNode[];\n\n/**\n Clone the base shape config and, for stacked Area/Bar, inject the\n stacking-aware opp/opp0/opp1 accessors that read the precomputed\n `stackData` cube.\n*/\nfunction buildInner(ctx: ShapeEmitContext, key: string): Record<string, unknown> {\n const {viz, opp, x, y, stackData, domains, stackKeyIndex, discreteKeyIndex} = ctx;\n const inner: Record<string, unknown> = Object.assign({}, ctx.shapeConfig);\n // Bubble plots: when a `size` accessor is set, default to layering circles\n // largest-behind so smaller marks stay visible under bigger ones. This is a\n // default — `finishShape` applies the user's `shapeConfig` afterwards, so an\n // explicit `sort` (or `sort: null` to disable) still wins.\n if (key === \"Circle\" && viz._size) {\n const size = viz._size;\n inner.sort = (a: DataPoint, b: DataPoint) =>\n (Number(size(b)) || 0) - (Number(size(a)) || 0);\n }\n if (viz.schema.stacked && [\"Area\", \"Bar\"].includes(key)) {\n const scale = opp === \"x\" ? x : y;\n inner[`${opp}`] = inner[`${opp}0`] = (d: PlotDatum) => {\n const dataIndex = stackKeyIndex.get(d.id) ?? -1;\n const discreteIndex = discreteKeyIndex.get(d.discrete) ?? -1;\n const scaleIndex = (d[opp!] as number) < 0 ? 1 : 0;\n return dataIndex >= 0\n ? scale(stackData[dataIndex][discreteIndex][scaleIndex])\n : scale(domains[opp!][opp === \"x\" ? 0 : 1]);\n };\n inner[`${opp}1`] = (d: PlotDatum) => {\n const dataIndex = stackKeyIndex.get(d.id) ?? -1;\n const discreteIndex = discreteKeyIndex.get(d.discrete) ?? -1;\n const scaleIndex = (d[opp!] as number) < 0 ? 0 : 1;\n return dataIndex >= 0\n ? scale(stackData[dataIndex][discreteIndex][scaleIndex])\n : scale(domains[opp!][opp === \"x\" ? 0 : 1]);\n };\n }\n return inner;\n}\n\n/**\n Shared tail: wire shape events, apply the user's shapeConfig, render in\n compute mode, and collect the resulting scene nodes.\n*/\nfunction finishShape(ctx: ShapeEmitContext, key: string, s: Shape): SceneNode[] {\n const {viz, events} = ctx;\n viz._wirePlotShapeEvents!(s, key, events);\n const userConfig = shapeConfigFor(viz, key);\n if (viz.schema.shapeConfig.duration === undefined) delete userConfig.duration;\n s.config(userConfig).render();\n return collectComputed(s);\n}\n\n/** Generic path — every shape key without a dedicated emitter (incl. stacked Area). */\nconst genericEmit: ShapeEmitter = (ctx, key) => {\n const s = makeShape(key)\n .renderMode(\"compute\")\n .config(buildInner(ctx, key))\n .data(ctx.values);\n return finishShape(ctx, key, s);\n};\n\n/** Bar — discrete-axis spacing + multi-series grouping offsets. */\nconst barEmit: ShapeEmitter = ctx => {\n const {viz, x, y, xScale, yScale, xDomain, yDomain, xRange, yRange, values} = ctx;\n const s = makeShape(\"Bar\")\n .renderMode(\"compute\")\n .config(buildInner(ctx, \"Bar\"))\n .data(values);\n\n let space;\n const scale = viz.schema.discrete === \"x\" ? x : y;\n const scaleType = viz.schema.discrete === \"x\" ? xScale : yScale;\n const vals = viz.schema.discrete === \"x\" ? xDomain : yDomain;\n const range = viz.schema.discrete === \"x\" ? xRange : yRange;\n if (scaleType !== \"Point\" && vals.length === 2) {\n const allPositions = Array.from(\n new Set(values.map((d: DataPoint) => scale(d[viz.schema.discrete as string]))),\n );\n allPositions.unshift(\n (range[0] as number) -\n (allPositions[0] as number) -\n (range[0] as number),\n );\n allPositions.push(\n (range[1] as number) +\n (range[1] as number) -\n (allPositions[allPositions.length - 1] as number),\n );\n space = allPositions.reduce((n: number, d, i, arr) => {\n if (i) {\n const dist = Math.abs((d as number) - (arr[i - 1] as number));\n if (dist < n) n = dist;\n }\n return n;\n }, Infinity);\n } else if (vals.length > 1) space = scale(vals[1]) - scale(vals[0]);\n else space = range[range.length - 1] - range[0];\n if (viz._groupPadding! < space) space -= viz._groupPadding!;\n\n let barSize = space || 1;\n\n const barGroups = groups(\n values,\n (d: DataPoint) => d[viz.schema.discrete as string],\n (d: DataPoint) => d.group,\n );\n\n const ids = merge(\n barGroups.map(([, innerEntries]) => innerEntries.map(([k]) => k)),\n );\n const uniqueIds = Array.from(new Set(ids));\n\n const discreteKey = viz.schema.discrete as string;\n const discreteFn = ctx.shapeConfig[discreteKey] as (d: PlotDatum, i: number) => number;\n if (max(barGroups.map(([, innerEntries]) => innerEntries.length)) === 1) {\n s[discreteKey]((d: PlotDatum, i: number) => discreteFn(d, i));\n } else {\n barSize =\n (barSize - viz.schema.barPadding * uniqueIds.length - 1) /\n uniqueIds.length;\n\n const offset = space / 2 - barSize / 2;\n\n const xMod = scales\n .scaleLinear()\n .domain([0, uniqueIds.length - 1])\n .range([-offset, offset]);\n\n s[discreteKey](\n (d: PlotDatum, i: number) =>\n discreteFn(d, i) + xMod(uniqueIds.indexOf(d.group)),\n );\n }\n\n s.width(barSize);\n s.height(barSize);\n\n return finishShape(ctx, \"Bar\", s);\n};\n\n/** Line — duration, optional confidence band, end-labels, and point markers. */\nconst lineEmit: ShapeEmitter = ctx => {\n const {\n viz, x, y, values, width, showLineLabels,\n labelWidths, largestLabel, labelPositions,\n } = ctx;\n const out: SceneNode[] = [];\n\n const s = makeShape(\"Line\")\n .renderMode(\"compute\")\n .config(buildInner(ctx, \"Line\"))\n .data(values);\n\n s.duration(width * 1.5);\n\n if (viz._confidence) {\n const confidence = viz._confidence;\n const areaConfig: Record<string, unknown> = Object.assign({}, ctx.shapeConfig);\n const discrete = viz.schema.discrete || \"x\";\n const key = discrete === \"x\" ? \"y\" : \"x\";\n const scaleFunction = discrete === \"x\" ? y : x;\n areaConfig[`${key}0`] = (d: PlotDatum) =>\n scaleFunction(confidence[0] ? d.lci : d[key]);\n areaConfig[`${key}1`] = (d: PlotDatum) =>\n scaleFunction(confidence[1] ? d.hci : d[key]);\n\n const area = makeShape(\"Area\")\n .renderMode(\"compute\")\n .config(areaConfig)\n .data(values);\n const confidenceConfig = Object.assign(\n viz.schema.shapeConfig,\n viz._confidenceConfig,\n );\n\n area\n .config(\n assign(\n shapeConfigFor(viz, \"Line\", confidenceConfig),\n shapeConfigFor(viz, \"Area\", confidenceConfig),\n ),\n )\n .render();\n\n out.push(...collectComputed(area));\n }\n\n s.config({\n discrete: ctx.shapeConfig.discrete || \"x\",\n label: showLineLabels\n ? (d: PlotDatum, i: number) => {\n const visible =\n typeof viz.schema.lineLabels === \"function\"\n ? viz.schema.lineLabels(d.data, d.i)\n : true;\n if (!visible) return false;\n const labelData = labelWidths.find(l => l.id === d.id);\n if (labelData) {\n const yPos = labelData.newY || labelData.defaultY;\n const allLabels = labelWidths.filter(l => l.newY === yPos);\n if (allLabels.length > 1)\n return allLabels[0].id !== d.id\n ? false\n : `+${formatAbbreviate(\n allLabels.length,\n viz.schema.locale,\n )} ${viz.schema.translate(\"more\")}`;\n return viz._drawLabel(d as unknown as DataPoint, i);\n }\n return false;\n }\n : false,\n labelBounds: showLineLabels\n ? (d: PlotDatum, i: number, s: {points: number[][]}) => {\n const [firstX, firstY] = s.points[0];\n const [lastX, lastY] = s.points[s.points.length - 1];\n const height = viz.schema.height / 4;\n const mod = labelPositions[d.id]\n ? lastY - labelPositions[d.id]\n : 0;\n return {\n x: lastX - firstX,\n y: lastY - firstY - height / 2 - mod,\n width: largestLabel,\n height,\n };\n }\n : false,\n });\n\n out.push(...finishShape(ctx, \"Line\", s));\n\n const markers = makeShape(\"Circle\")\n .renderMode(\"compute\")\n .data(viz._lineMarkers ? values : [])\n .config(ctx.shapeConfig)\n .config(viz._lineMarkerConfig)\n .id((d: PlotDatum) => `${d.id}_${d.discrete}`);\n\n viz._wirePlotShapeEvents!(markers, \"Circle\", ctx.events);\n markers.render();\n out.push(...collectComputed(markers));\n\n return out;\n};\n\n/** Shape key → dedicated emitter. Keys absent here use `genericEmit`. */\nexport const shapeEmitters: Record<string, ShapeEmitter> = {\n Bar: barEmit,\n Line: lineEmit,\n};\n\n/** Dispatch a shape group to its emitter (falling back to the generic path). */\nexport function emitShape(ctx: ShapeEmitContext, key: string): SceneNode[] {\n return (shapeEmitters[key] ?? genericEmit)(ctx, key);\n}\n"],"names":["groups","max","merge","scales","assign","formatAbbreviate","collectComputed","makeShape","shapeConfigFor","buildInner","ctx","key","viz","opp","x","y","stackData","domains","stackKeyIndex","discreteKeyIndex","inner","Object","shapeConfig","_size","size","sort","a","b","Number","schema","stacked","includes","scale","d","dataIndex","get","id","discreteIndex","discrete","scaleIndex","finishShape","s","events","_wirePlotShapeEvents","userConfig","duration","undefined","config","render","genericEmit","renderMode","data","values","barEmit","xScale","yScale","xDomain","yDomain","xRange","yRange","space","scaleType","vals","range","length","allPositions","Array","from","Set","map","unshift","push","reduce","n","i","arr","dist","Math","abs","Infinity","_groupPadding","barSize","barGroups","group","ids","innerEntries","k","uniqueIds","discreteKey","discreteFn","barPadding","offset","xMod","scaleLinear","domain","indexOf","width","height","lineEmit","out","showLineLabels","labelWidths","largestLabel","labelPositions","_confidence","confidence","areaConfig","scaleFunction","lci","hci","area","confidenceConfig","_confidenceConfig","label","visible","lineLabels","labelData","find","l","yPos","newY","defaultY","allLabels","filter","locale","translate","_drawLabel","labelBounds","points","firstX","firstY","lastX","lastY","mod","markers","_lineMarkers","_lineMarkerConfig","shapeEmitters","Bar","Line","emitShape"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;AAiBA,GAEA,SAAQA,MAAM,EAAEC,GAAG,EAAEC,KAAK,QAAO,WAAW;AAC5C,YAAYC,YAAY,WAAW;AAGnC,SAAQC,MAAM,QAAO,cAAc;AACnC,SAAQC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;AAEA,uEAAuE,GACvE,OAAO,IAAMsC,gBAA8C;IACzDC,KAAKrF;IACLsF,MAAMzC;AACR,EAAE;AAEF,8EAA8E,GAC9E,OAAO,SAAS0C,UAAUlI,GAAqB,EAAEC,GAAW;QAClD8H;IAAR,OAAO,EAACA,qBAAAA,aAAa,CAAC9H,IAAI,cAAlB8H,gCAAAA,qBAAsBxF,aAAavC,KAAKC;AAClD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/features/shapeEmit.ts"],"sourcesContent":["/**\n Per-shape emit registry for the Plot paint phase.\n\n The Plot paint loop walks the grouped `shapeData` and, for each shape\n key, produces the scene nodes for that shape's data. Most shapes follow\n the same path (instantiate compute-mode → wire events → apply user\n config → render → collect). Bar and Line carry extra geometry — bar\n spacing/grouping, line confidence bands + end-labels + markers — so they\n get dedicated emitters. Everything else (and stacked Area) flows through\n the generic emitter.\n\n A chart \"uses only some shapes\" purely by which keys appear in its\n `shapeData` (driven by the chart's `shape` accessor default). The\n registry stays complete; the dispatch only ever calls the emitters whose\n keys are present.\n\n @module\n*/\n\nimport {groups, max, merge} from \"d3-array\";\nimport * as scales from \"d3-scale\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport {assign} from \"@d3plus/dom\";\nimport {formatAbbreviate} from \"@d3plus/format\";\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {Shape} from \"../../shapes/index.js\";\n\nimport {collectComputed, makeShape, shapeConfigFor} from \"./emitHelpers.js\";\nimport type {LabelWidth, PlotAxisFn, PlotDatum} from \"./plotPaint.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\n/**\n The cross-phase locals a shape emitter reads. Assembled once per draw by\n the Plot paint loop and passed to each emitter alongside the shape key.\n The stack math (`stackData`/`stackKeyIndex`/`discreteKeyIndex`) is\n computed upstream once per draw — emitters consume it, never recompute.\n*/\nexport interface ShapeEmitContext {\n viz: Viz;\n /** The data rows for this shape group. */\n values: DataPoint[];\n /** The base shape config shared across every shape in the loop. */\n shapeConfig: Record<string, unknown>;\n /** Event names registered on the viz (`Object.keys(viz.schema.on)`). */\n events: string[];\n\n // Scales + accessors (x/y reassigned to the production-axis closures).\n x: PlotAxisFn;\n y: PlotAxisFn;\n xScale: string;\n yScale: string;\n xDomain: number[];\n yDomain: number[];\n xRange: number[];\n yRange: number[];\n\n // Stacking inputs (computed once upstream).\n opp: \"x\" | \"y\" | undefined;\n domains: Record<string, number[]>;\n stackData: number[][][];\n stackKeyIndex: Map<unknown, number>;\n discreteKeyIndex: Map<unknown, number>;\n\n // Line-label inputs.\n showLineLabels: boolean;\n labelWidths: LabelWidth[];\n largestLabel: number;\n labelPositions: Record<string, number>;\n\n width: number;\n}\n\n/** An emitter: produces the scene nodes for one shape group. */\nexport type ShapeEmitter = (ctx: ShapeEmitContext, key: string) => SceneNode[];\n\n/**\n Clone the base shape config and, for stacked Area/Bar, inject the\n stacking-aware opp/opp0/opp1 accessors that read the precomputed\n `stackData` cube.\n*/\nfunction buildInner(ctx: ShapeEmitContext, key: string): Record<string, unknown> {\n const {viz, opp, x, y, stackData, domains, stackKeyIndex, discreteKeyIndex} = ctx;\n const inner: Record<string, unknown> = Object.assign({}, ctx.shapeConfig);\n // Bubble plots: when a `size` accessor is set, default to layering circles\n // largest-behind so smaller marks stay visible under bigger ones. This is a\n // default — `finishShape` applies the user's `shapeConfig` afterwards, so an\n // explicit `sort` (or `sort: null` to disable) still wins.\n if (key === \"Circle\" && viz._size) {\n const size = viz._size;\n inner.sort = (a: DataPoint, b: DataPoint) =>\n (Number(size(b)) || 0) - (Number(size(a)) || 0);\n }\n if (viz.schema.stacked && [\"Area\", \"Bar\"].includes(key)) {\n const scale = opp === \"x\" ? x : y;\n inner[`${opp}`] = inner[`${opp}0`] = (d: PlotDatum) => {\n const dataIndex = stackKeyIndex.get(d.id) ?? -1;\n const discreteIndex = discreteKeyIndex.get(d.discrete) ?? -1;\n const scaleIndex = (d[opp!] as number) < 0 ? 1 : 0;\n return dataIndex >= 0\n ? scale(stackData[dataIndex][discreteIndex][scaleIndex])\n : scale(domains[opp!][opp === \"x\" ? 0 : 1]);\n };\n inner[`${opp}1`] = (d: PlotDatum) => {\n const dataIndex = stackKeyIndex.get(d.id) ?? -1;\n const discreteIndex = discreteKeyIndex.get(d.discrete) ?? -1;\n const scaleIndex = (d[opp!] as number) < 0 ? 0 : 1;\n return dataIndex >= 0\n ? scale(stackData[dataIndex][discreteIndex][scaleIndex])\n : scale(domains[opp!][opp === \"x\" ? 0 : 1]);\n };\n }\n return inner;\n}\n\n/**\n Shared tail: wire shape events, apply the user's shapeConfig, render in\n compute mode, and collect the resulting scene nodes.\n*/\nfunction finishShape(ctx: ShapeEmitContext, key: string, s: Shape): SceneNode[] {\n const {viz, events} = ctx;\n viz._wirePlotShapeEvents!(s, key, events);\n const userConfig = shapeConfigFor(viz, key);\n if (viz.schema.shapeConfig.duration === undefined) delete userConfig.duration;\n s.config(userConfig).render();\n return collectComputed(s);\n}\n\n/** Generic path — every shape key without a dedicated emitter (incl. stacked Area). */\nconst genericEmit: ShapeEmitter = (ctx, key) => {\n const s = makeShape(key)\n .renderMode(\"compute\")\n .config(buildInner(ctx, key))\n .data(ctx.values);\n return finishShape(ctx, key, s);\n};\n\n/** Bar — discrete-axis spacing + multi-series grouping offsets. */\nconst barEmit: ShapeEmitter = ctx => {\n const {viz, x, y, xScale, yScale, xDomain, yDomain, xRange, yRange, values} = ctx;\n const s = makeShape(\"Bar\")\n .renderMode(\"compute\")\n .config(buildInner(ctx, \"Bar\"))\n .data(values);\n\n let space;\n const scale = viz.schema.discrete === \"x\" ? x : y;\n const scaleType = viz.schema.discrete === \"x\" ? xScale : yScale;\n const vals = viz.schema.discrete === \"x\" ? xDomain : yDomain;\n const range = viz.schema.discrete === \"x\" ? xRange : yRange;\n if (scaleType !== \"Point\" && vals.length === 2) {\n const allPositions = Array.from(\n new Set(values.map((d: DataPoint) => scale(d[viz.schema.discrete as string]))),\n );\n allPositions.unshift(\n (range[0] as number) -\n (allPositions[0] as number) -\n (range[0] as number),\n );\n allPositions.push(\n (range[1] as number) +\n (range[1] as number) -\n (allPositions[allPositions.length - 1] as number),\n );\n space = allPositions.reduce((n: number, d, i, arr) => {\n if (i) {\n const dist = Math.abs((d as number) - (arr[i - 1] as number));\n if (dist < n) n = dist;\n }\n return n;\n }, Infinity);\n } else if (vals.length > 1) space = scale(vals[1]) - scale(vals[0]);\n else space = range[range.length - 1] - range[0];\n if (viz._groupPadding! < space) space -= viz._groupPadding!;\n\n let barSize = space || 1;\n\n const barGroups = groups(\n values,\n (d: DataPoint) => d[viz.schema.discrete as string],\n (d: DataPoint) => d.group,\n );\n\n const ids = merge(\n barGroups.map(([, innerEntries]) => innerEntries.map(([k]) => k)),\n );\n const uniqueIds = Array.from(new Set(ids));\n\n const discreteKey = viz.schema.discrete as string;\n const discreteFn = ctx.shapeConfig[discreteKey] as (d: PlotDatum, i: number) => number;\n if (max(barGroups.map(([, innerEntries]) => innerEntries.length)) === 1) {\n s[discreteKey]((d: PlotDatum, i: number) => discreteFn(d, i));\n } else {\n barSize =\n (barSize - viz.schema.barPadding * uniqueIds.length - 1) /\n uniqueIds.length;\n\n const offset = space / 2 - barSize / 2;\n\n const xMod = scales\n .scaleLinear()\n .domain([0, uniqueIds.length - 1])\n .range([-offset, offset]);\n\n s[discreteKey](\n (d: PlotDatum, i: number) =>\n discreteFn(d, i) + xMod(uniqueIds.indexOf(d.group)),\n );\n }\n\n s.width(barSize);\n s.height(barSize);\n\n return finishShape(ctx, \"Bar\", s);\n};\n\n/** Line — duration, optional confidence band, end-labels, and point markers. */\nconst lineEmit: ShapeEmitter = ctx => {\n const {\n viz, x, y, values, width, showLineLabels,\n labelWidths, largestLabel, labelPositions,\n } = ctx;\n const out: SceneNode[] = [];\n\n const s = makeShape(\"Line\")\n .renderMode(\"compute\")\n .config(buildInner(ctx, \"Line\"))\n .data(values);\n\n s.duration(width * 1.5);\n\n if (viz._confidence) {\n const confidence = viz._confidence;\n const areaConfig: Record<string, unknown> = Object.assign({}, ctx.shapeConfig);\n const discrete = viz.schema.discrete || \"x\";\n const key = discrete === \"x\" ? \"y\" : \"x\";\n const scaleFunction = discrete === \"x\" ? y : x;\n areaConfig[`${key}0`] = (d: PlotDatum) =>\n scaleFunction(confidence[0] ? d.lci : d[key]);\n areaConfig[`${key}1`] = (d: PlotDatum) =>\n scaleFunction(confidence[1] ? d.hci : d[key]);\n\n const area = makeShape(\"Area\")\n .renderMode(\"compute\")\n .config(areaConfig)\n .data(values);\n // Fresh object — must NOT mutate the shared `shapeConfig`, or the confidence\n // fill/fillOpacity leak onto every other shape and every later render.\n const confidenceConfig = Object.assign(\n {},\n viz.schema.shapeConfig,\n viz._confidenceConfig,\n );\n\n area\n .config(\n assign(\n shapeConfigFor(viz, \"Line\", confidenceConfig),\n shapeConfigFor(viz, \"Area\", confidenceConfig),\n ),\n )\n .render();\n\n out.push(...collectComputed(area));\n }\n\n s.config({\n discrete: ctx.shapeConfig.discrete || \"x\",\n label: showLineLabels\n ? (d: PlotDatum, i: number) => {\n const visible =\n typeof viz.schema.lineLabels === \"function\"\n ? viz.schema.lineLabels(d.data, d.i)\n : true;\n if (!visible) return false;\n const labelData = labelWidths.find(l => l.id === d.id);\n if (labelData) {\n const yPos = labelData.newY || labelData.defaultY;\n const allLabels = labelWidths.filter(l => l.newY === yPos);\n if (allLabels.length > 1)\n return allLabels[0].id !== d.id\n ? false\n : `+${formatAbbreviate(\n allLabels.length,\n viz.schema.locale,\n )} ${viz.schema.translate(\"more\")}`;\n return viz._drawLabel(d as unknown as DataPoint, i);\n }\n return false;\n }\n : false,\n labelBounds: showLineLabels\n ? (d: PlotDatum, i: number, s: {points: number[][]}) => {\n const [firstX, firstY] = s.points[0];\n const [lastX, lastY] = s.points[s.points.length - 1];\n const height = viz.schema.height / 4;\n const mod = labelPositions[d.id]\n ? lastY - labelPositions[d.id]\n : 0;\n return {\n x: lastX - firstX,\n y: lastY - firstY - height / 2 - mod,\n width: largestLabel,\n height,\n };\n }\n : false,\n });\n\n out.push(...finishShape(ctx, \"Line\", s));\n\n const markers = makeShape(\"Circle\")\n .renderMode(\"compute\")\n .data(viz._lineMarkers ? values : [])\n .config(ctx.shapeConfig)\n .config(viz._lineMarkerConfig)\n .id((d: PlotDatum) => `${d.id}_${d.discrete}`);\n\n viz._wirePlotShapeEvents!(markers, \"Circle\", ctx.events);\n markers.render();\n out.push(...collectComputed(markers));\n\n return out;\n};\n\n/** Shape key → dedicated emitter. Keys absent here use `genericEmit`. */\nexport const shapeEmitters: Record<string, ShapeEmitter> = {\n Bar: barEmit,\n Line: lineEmit,\n};\n\n/** Dispatch a shape group to its emitter (falling back to the generic path). */\nexport function emitShape(ctx: ShapeEmitContext, key: string): SceneNode[] {\n return (shapeEmitters[key] ?? genericEmit)(ctx, key);\n}\n"],"names":["groups","max","merge","scales","assign","formatAbbreviate","collectComputed","makeShape","shapeConfigFor","buildInner","ctx","key","viz","opp","x","y","stackData","domains","stackKeyIndex","discreteKeyIndex","inner","Object","shapeConfig","_size","size","sort","a","b","Number","schema","stacked","includes","scale","d","dataIndex","get","id","discreteIndex","discrete","scaleIndex","finishShape","s","events","_wirePlotShapeEvents","userConfig","duration","undefined","config","render","genericEmit","renderMode","data","values","barEmit","xScale","yScale","xDomain","yDomain","xRange","yRange","space","scaleType","vals","range","length","allPositions","Array","from","Set","map","unshift","push","reduce","n","i","arr","dist","Math","abs","Infinity","_groupPadding","barSize","barGroups","group","ids","innerEntries","k","uniqueIds","discreteKey","discreteFn","barPadding","offset","xMod","scaleLinear","domain","indexOf","width","height","lineEmit","out","showLineLabels","labelWidths","largestLabel","labelPositions","_confidence","confidence","areaConfig","scaleFunction","lci","hci","area","confidenceConfig","_confidenceConfig","label","visible","lineLabels","labelData","find","l","yPos","newY","defaultY","allLabels","filter","locale","translate","_drawLabel","labelBounds","points","firstX","firstY","lastX","lastY","mod","markers","_lineMarkers","_lineMarkerConfig","shapeEmitters","Bar","Line","emitShape"],"mappings":";;;;;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E,CAAC,SAACH;eAAiB,AAAC,GAAUA,OAARA,EAAEG,EAAE,EAAC,KAAc,OAAXH,EAAEK,QAAQ;;IAE7C1B,IAAI+B,oBAAoB,CAAE2F,SAAS,UAAU5H,IAAIgC,MAAM;IACvD4F,QAAQtF,MAAM;IACdmD,CAAAA,QAAAA,KAAI5B,IAAI,OAAR4B,OAAS,qBAAG7F,gBAAgBgI;IAE5B,OAAOnC;AACT;AAEA,uEAAuE,GACvE,OAAO,IAAMsC,gBAA8C;IACzDC,KAAKrF;IACLsF,MAAMzC;AACR,EAAE;AAEF,8EAA8E,GAC9E,OAAO,SAAS0C,UAAUlI,GAAqB,EAAEC,GAAW;QAClD8H;IAAR,OAAO,EAACA,qBAAAA,aAAa,CAAC9H,IAAI,cAAlB8H,gCAAAA,qBAAsBxF,aAAavC,KAAKC;AAClD"}
|
package/es/src/charts/viz/Viz.js
CHANGED
|
@@ -621,6 +621,32 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
621
621
|
return vizRender(this, callback);
|
|
622
622
|
}
|
|
623
623
|
},
|
|
624
|
+
{
|
|
625
|
+
/**
|
|
626
|
+
Serializes the most recently rendered output to an SVG string. Returns
|
|
627
|
+
`""` if the chart has not been rendered yet. Both backends support this:
|
|
628
|
+
the SVG backend returns its live `<svg>`, the canvas backend re-renders the
|
|
629
|
+
retained scene through a throwaway SVG backend. Primarily used for
|
|
630
|
+
server-side rendering (see `@d3plus/ssr`).
|
|
631
|
+
*/ key: "toSVGString",
|
|
632
|
+
value: function toSVGString() {
|
|
633
|
+
var _ref;
|
|
634
|
+
var _this__sceneRenderer_toSVGString, _this__sceneRenderer;
|
|
635
|
+
return (_ref = (_this__sceneRenderer = this._sceneRenderer) === null || _this__sceneRenderer === void 0 ? void 0 : (_this__sceneRenderer_toSVGString = _this__sceneRenderer.toSVGString) === null || _this__sceneRenderer_toSVGString === void 0 ? void 0 : _this__sceneRenderer_toSVGString.call(_this__sceneRenderer)) !== null && _ref !== void 0 ? _ref : "";
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
/**
|
|
640
|
+
Returns the underlying canvas element of the most recent render when the
|
|
641
|
+
canvas backend is active (`renderer("canvas")`), or `undefined` otherwise.
|
|
642
|
+
Server-side callers cast this to their native canvas to encode a raster
|
|
643
|
+
(see `@d3plus/ssr`).
|
|
644
|
+
*/ key: "toCanvas",
|
|
645
|
+
value: function toCanvas() {
|
|
646
|
+
var _this__sceneRenderer_toCanvas, _this__sceneRenderer;
|
|
647
|
+
return this._renderer === "canvas" ? (_this__sceneRenderer = this._sceneRenderer) === null || _this__sceneRenderer === void 0 ? void 0 : (_this__sceneRenderer_toCanvas = _this__sceneRenderer.toCanvas) === null || _this__sceneRenderer_toCanvas === void 0 ? void 0 : _this__sceneRenderer_toCanvas.call(_this__sceneRenderer) : undefined;
|
|
648
|
+
}
|
|
649
|
+
},
|
|
624
650
|
{
|
|
625
651
|
key: "renderer",
|
|
626
652
|
value: function renderer(_) {
|
|
@@ -719,10 +745,14 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
719
745
|
if (this._sceneRenderer && typeof this._sceneRenderer.destroy === "function") this._sceneRenderer.destroy();
|
|
720
746
|
var Ctor = kind === "canvas" ? CanvasRenderer : SvgRenderer;
|
|
721
747
|
this._sceneRenderer = new Ctor();
|
|
748
|
+
// `_scenePixelRatio`, when set (e.g. by @d3plus/ssr for hi-res PNG output),
|
|
749
|
+
// fixes the canvas backing-store scale; otherwise the renderer falls back
|
|
750
|
+
// to `devicePixelRatio`.
|
|
722
751
|
this._sceneRenderer.mount({
|
|
723
752
|
container: mountTarget,
|
|
724
753
|
width: w,
|
|
725
|
-
height: h
|
|
754
|
+
height: h,
|
|
755
|
+
pixelRatio: this._scenePixelRatio
|
|
726
756
|
});
|
|
727
757
|
// Bridge renderer pointer events → viz.schema.on handlers. Without this,
|
|
728
758
|
// tooltips never fire on the v4 scene-rendered path because
|
|
@@ -813,6 +843,29 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
813
843
|
},
|
|
814
844
|
{
|
|
815
845
|
/**
|
|
846
|
+
Resolves the `(d, i, x)` a picked scene node reports to interaction
|
|
847
|
+
handlers (tooltip, click, user `on` handlers). `pick.datum` is the raw
|
|
848
|
+
scene datum; for a Plot shape that's the wrapped record `{data, i}`, which
|
|
849
|
+
handlers expect unwrapped to `(d.data, d.i, wrapped)`. The base does that
|
|
850
|
+
unwrap; Plot overrides this to report the point nearest the cursor for
|
|
851
|
+
multi-point shapes (Line/Area) so a series tooltip reflects the hovered
|
|
852
|
+
x rather than the whole-series aggregate.
|
|
853
|
+
@private
|
|
854
|
+
*/ key: "_interactionDatum",
|
|
855
|
+
value: function _interactionDatum(pick, _event) {
|
|
856
|
+
var _pick_index;
|
|
857
|
+
var rawDatum = pick.datum;
|
|
858
|
+
var sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;
|
|
859
|
+
var sourceIndex = rawDatum && typeof rawDatum.i === "number" ? rawDatum.i : (_pick_index = pick.index) !== null && _pick_index !== void 0 ? _pick_index : 0;
|
|
860
|
+
return {
|
|
861
|
+
d: sourceDatum,
|
|
862
|
+
i: sourceIndex,
|
|
863
|
+
x: rawDatum
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
/**
|
|
816
869
|
Routes a renderer pointer event to the matching `viz.schema.on` handlers.
|
|
817
870
|
Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where
|
|
818
871
|
compute-mode shapes mount no per-shape DOM, so `shape.on(evt, fn)`
|
|
@@ -824,7 +877,6 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
824
877
|
*/ key: "_routeSceneEvent",
|
|
825
878
|
value: function _routeSceneEvent(event) {
|
|
826
879
|
var _this = this;
|
|
827
|
-
var _pick_index;
|
|
828
880
|
// Ignore all pointer interaction while an animated transition (zoom,
|
|
829
881
|
// re-center, drill-down, entrance) is in flight. Hovering or clicking a
|
|
830
882
|
// shape mid-transition would fire a handler that schedules a duration-0
|
|
@@ -886,12 +938,12 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
886
938
|
var isLegendNode = nodeAny.interactionGroup === "legend" || (target && typeof target.closest === "function" ? !!target.closest('[data-key="viz-legend"]') : false);
|
|
887
939
|
var suffix = isLegendNode ? "legend" : "shape";
|
|
888
940
|
var handlerKey = "".concat(event.type, ".").concat(suffix);
|
|
889
|
-
// Resolve the
|
|
890
|
-
//
|
|
891
|
-
//
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
var
|
|
941
|
+
// Resolve the datum + index this pick reports to handlers, ONCE, and reuse
|
|
942
|
+
// it for every handler fired below so tooltip/click/user handlers agree on
|
|
943
|
+
// which datum the pointer is over. The base unwraps the node's raw datum to
|
|
944
|
+
// its source row; Plot overrides `_interactionDatum` to report the point
|
|
945
|
+
// nearest the cursor for multi-point shapes (Line/Area).
|
|
946
|
+
var _this__interactionDatum = this._interactionDatum(pick, event), sourceDatum = _this__interactionDatum.d, sourceIndex = _this__interactionDatum.i, rawDatum = _this__interactionDatum.x;
|
|
895
947
|
var shapeType = typeof nodeAny.shapeType === "string" ? nodeAny.shapeType : null;
|
|
896
948
|
this._lastScenePick = {
|
|
897
949
|
d: sourceDatum,
|
|
@@ -944,7 +996,8 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
944
996
|
Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
|
|
945
997
|
*/ key: "destroy",
|
|
946
998
|
value: function destroy() {
|
|
947
|
-
|
|
999
|
+
var _this__resizeObserver;
|
|
1000
|
+
(_this__resizeObserver = this._resizeObserver) === null || _this__resizeObserver === void 0 ? void 0 : _this__resizeObserver.disconnect();
|
|
948
1001
|
this._tooltipClass.data([]).render();
|
|
949
1002
|
select("body").on("touchstart.".concat(this._uuid), null);
|
|
950
1003
|
// Clear the visibility/resize/scroll poll timers + scroll listener
|
|
@@ -965,7 +1018,7 @@ var Viz = /*#__PURE__*/ function(VizBase) {
|
|
|
965
1018
|
if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(this._sceneRepaintRAF);
|
|
966
1019
|
this._sceneRepaintRAF = undefined;
|
|
967
1020
|
}
|
|
968
|
-
select(this.schema.scrollContainer).on("scroll.".concat(this._uuid), null);
|
|
1021
|
+
if (this.schema.scrollContainer) select(this.schema.scrollContainer).on("scroll.".concat(this._uuid), null);
|
|
969
1022
|
// Destroy the active scene renderer (clears its own pointer-rect
|
|
970
1023
|
// listeners, overlay host, canvas/svg DOM, timers).
|
|
971
1024
|
if (this._sceneRenderer && typeof this._sceneRenderer.destroy === "function") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/viz/Viz.ts"],"sourcesContent":["import {select} from \"d3-selection\";\n\nimport {date, getSize} from \"@d3plus/dom\";\n\nimport {computeTrailCatchup} from \"./trailCatchup.js\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {CanvasRenderer, SvgRenderer} from \"@d3plus/render\";\nimport type {Renderer, Scene, SceneEvent, SceneNode, Transform} from \"@d3plus/render\";\n\nimport VizBase from \"./VizBase.js\";\nimport type {ColorScale, Legend, Timeline} from \"../../components/index.js\";\nimport type Shape from \"../../shapes/Shape.js\";\nimport {applyColorScaleBucketOpacity, applyInteractionOpacity} from \"./interactionOpacity.js\";\nimport {initVizDefaults} from \"./vizDefaults.js\";\nimport {vizRender} from \"./vizRender.js\";\nimport {vizDraw} from \"../pipeline/vizDraw.js\";\nimport {vizPreDraw} from \"../pipeline/vizPreDraw.js\";\nimport type {VizInstance} from \"./vizTypes.js\";\n\n/**\n Stamps `interactionGroup` onto a component's scene subtree so the pointer\n bridge can route its nodes to component-scoped handlers (e.g. legend) on\n every backend — including Canvas, where there is no per-shape DOM to walk.\n*/\nfunction tagInteractionGroup(node: SceneNode, group: string): void {\n (node as {interactionGroup?: string}).interactionGroup = group;\n const kids = (node as {children?: SceneNode[]}).children;\n if (kids) for (const child of kids) tagInteractionGroup(child, group);\n}\n\n/**\n Resolves the element a renderer mounts into. A `<canvas>` cannot paint inside\n an `<svg>`, so when the scene target is the compute svg, the canvas mounts\n into that svg's parent (the user's element); the emptied, position:absolute\n compute svg overlays the same top-left box. SVG mounts into the target as-is.\n*/\nfunction mountTargetFor(kind: string, target: Element): Element {\n if (\n kind === \"canvas\" &&\n typeof Element !== \"undefined\" &&\n target instanceof Element &&\n target.tagName.toLowerCase() === \"svg\"\n )\n return (target.parentNode as Element | null) ?? target;\n return target;\n}\n\n/**\n Creates an x/y plot based on an array of data. See [this example](https://d3plus.org/examples/d3plus-treemap/getting-started/) for help getting started using the treemap generator.\n*/\nexport default class Viz extends VizBase {\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n */\n constructor() {\n super();\n initVizDefaults(this);\n }\n\n /**\n Called by draw before anything is drawn. Formats the data and performs preparations for draw.\n @private\n */\n _preDraw(): void {\n vizPreDraw(this as unknown as VizInstance);\n }\n\n /**\n Composes a backend-agnostic scene graph from the shapes/features produced\n by the most recent render. Combines:\n - `_chartScene` (cells from `chartDef.emit`, or `Plot._paint` for the\n paint-driven Plot family) wrapped in viz-chart-cells\n - `_shapes` (still used by some charts) — each shape's toScene\n - chart-level components (Legend/ColorScale/Timeline) via their toScene\n - `_featurePanels` (from FeatureModule layouts) wrapped in viz-features\n */\n toScene(): Scene {\n const children: SceneNode[] = [];\n // Chart cells stashed on _chartScene — via `chartDef.emit(ctx)` for\n // data-driven charts, or `Plot._paint` for the paint-driven Plot family.\n // Wraps in two groups when a zoom transform is active:\n // viz-chart-cells (chart-positioning transform)\n // viz-zoom (zoom transform — pan/scale from d3-zoom)\n // … chart scene children\n // This lets zoom apply to the chart content WITHOUT moving legend/\n // title/total/etc. (which live in sibling viz-* groups, not under\n // viz-chart-cells).\n if (this._chartScene && this._chartScene.length) {\n const sliced = applyInteractionOpacity(\n this._chartScene,\n this as unknown as VizInstance,\n );\n // Always emit the viz-zoom group (identity transform when no zoom is\n // active) so its key is stable across the first zoom. Otherwise the first\n // zoom adds a brand-new group → the renderer treats the chart cells as\n // exit+enter (teardown/rebuild) instead of tweening the group transform,\n // so the zoom snaps in instead of animating.\n const zoomNode = [{\n type: \"group\" as const,\n key: \"viz-zoom\",\n transform: this._zoomTransform ?? {x: 0, y: 0, scale: 1},\n children: sliced,\n }];\n children.push({\n type: \"group\",\n key: \"viz-chart-cells\",\n ...(this._chartTransform ? {transform: this._chartTransform} : {}),\n // Fixed clip window (e.g. Geomap's map rect): stays put in scene space\n // while the viz-zoom child transform pans/scales content beneath it.\n ...(this._chartClip ? {clip: this._chartClip} : {}),\n children: zoomNode,\n });\n }\n // `_shapes` collection (Treemap/Pack/etc. route through `_chartScene`\n // instead, as does Plot's `absorbShapeIntoChartScene`). Any caller\n // pushing into `_shapes` gets its `toScene()` walked here; we read the\n // shape's `_select` transform via d3's transform baseVal if present,\n // otherwise emit without a transform.\n (this._shapes || []).forEach((shape: Shape, si: number) => {\n if (!shape || typeof shape.toScene !== \"function\") return;\n const group = shape.toScene();\n let transform: Transform | undefined;\n const sel = shape._select;\n if (sel && typeof sel.attr === \"function\") {\n // Parse `translate(x, y)` from the selection's transform attr.\n // Falls back to undefined for non-translate transforms — the\n // `_shapes` path only uses translate.\n const t = sel.attr(\"transform\");\n if (typeof t === \"string\") {\n const m = t.match(/translate\\(\\s*(-?[\\d.]+)[, ]\\s*(-?[\\d.]+)\\s*\\)/);\n if (m) transform = {x: parseFloat(m[1]), y: parseFloat(m[2])};\n }\n }\n children.push({\n type: \"group\",\n key: `${group.key || \"shape\"}-${si}`,\n ...(transform ? {transform} : {}),\n children: group.children,\n });\n });\n // Chart-level components that have their own toScene.\n const components: [string, Legend | ColorScale | Timeline | undefined][] = [\n [\"legend\", this._legendClass],\n [\"colorScale\", this._colorScaleClass],\n [\"timeline\", this._timelineClass],\n ];\n for (const [name, comp] of components) {\n if (\n comp &&\n typeof comp.toScene === \"function\" &&\n comp._select &&\n typeof comp._select.node === \"function\" &&\n comp._select.node()\n ) {\n let compScene: SceneNode = comp.toScene();\n // Tag the legend subtree so its swatches route to legend handlers via\n // the node stamp (renderer-independent), not just SVG DOM ancestry.\n if (name === \"legend\") {\n tagInteractionGroup(compScene, \"legend\");\n // Hovering a legend swatch dims the others, like the chart marks:\n // run the legend subtree through the same interaction-opacity pass\n // (a no-op when no hover/active predicate is set).\n compScene = applyInteractionOpacity(\n [compScene],\n this as unknown as VizInstance,\n )[0];\n }\n // Hovering a colorScale swatch (or a data shape) dims the sibling\n // swatches by bucket color — leaving the colorScale title/axis/gradient\n // untouched. Not tagged \"legend\": colorScale swatches keep the shape\n // event path (range-based tooltip + hover), unlike groupBy legend items.\n else if (name === \"colorScale\") {\n compScene = applyColorScaleBucketOpacity(\n [compScene],\n this as unknown as VizInstance,\n )[0];\n }\n // Tag the timeline subtree so its ticks/labels are exempt from shape\n // tooltips and hover/active dimming (it's chrome, not data marks).\n else if (name === \"timeline\") tagInteractionGroup(compScene, \"timeline\");\n children.push({\n type: \"group\",\n key: `viz-${name}`,\n children: [compScene],\n });\n }\n }\n // E2: FeatureModule.layout() panels (title/subtitle/total/back).\n if (this._featurePanels && this._featurePanels.length) {\n const panels = this._featurePanels.slice();\n // Tag the back-button panel so the pointer bridge can route its click.\n for (const panel of panels) {\n if (\n panel &&\n typeof (panel as {key?: string}).key === \"string\" &&\n (panel as {key: string}).key.toLowerCase().includes(\"back\")\n )\n tagInteractionGroup(panel as SceneNode, \"back\");\n }\n children.push({type: \"group\", key: \"viz-features\", children: panels});\n }\n return {\n width: this.schema.width,\n height: this.schema.height,\n root: {type: \"group\", key: \"viz-root\", children},\n };\n }\n\n /**\n Called by render once all checks are passed.\n @private\n */\n _draw(): void {\n vizDraw(this as unknown as VizInstance);\n }\n\n /**\n * Applies the threshold algorithm according to the type of chart used.\n * @param {Array} data The data to process.\n * @private\n */\n _thresholdFunction(data: DataPoint[], _tree?: unknown): DataPoint[] {\n return data;\n }\n\n /**\n * Detects width and height and sets SVG properties\n * @private\n */\n _setSVGSize(width?: number, height?: number): void {\n let [w, h] =\n width && height\n ? [width, height]\n : getSize(this._select.node().parentNode);\n w! -= parseFloat(this._select.style(\"border-left-width\"));\n w! -= parseFloat(this._select.style(\"border-right-width\"));\n h! -= parseFloat(this._select.style(\"border-top-width\"));\n h! -= parseFloat(this._select.style(\"border-bottom-width\"));\n \n if (this._autoWidth && this.schema.width !== w) {\n this.width(w);\n this._select\n .style(\"width\", `${this.schema.width}px`)\n .attr(\"width\", `${this.schema.width}px`);\n }\n if (this._autoHeight && this.schema.height !== h) {\n this.height(h);\n this._select\n .style(\"height\", `${this.schema.height}px`)\n .attr(\"height\", `${this.schema.height}px`);\n }\n }\n\n /**\n Draws the visualization given the specified configuration.\n @param callback Optional callback invoked after rendering completes.\n */\n render(callback?: () => void): this {\n return vizRender(this, callback) as this;\n }\n\n /**\n Selects which @d3plus/render backend paints the visible output.\n `\"svg\"` = SvgRenderer (default), `\"canvas\"` = CanvasRenderer.\n Boolean arguments both normalize to `\"svg\"`.\n */\n renderer(): \"svg\" | \"canvas\";\n renderer(_: \"svg\" | \"canvas\" | true | false): this;\n renderer(_?: \"svg\" | \"canvas\" | true | false): \"svg\" | \"canvas\" | this {\n if (!arguments.length) return this._renderer;\n this._renderer = _ === \"canvas\" ? \"canvas\" : \"svg\";\n return this;\n }\n\n /**\n \"full\" runs the DOM enter/update/exit for every shape; \"compute\"\n skips DOM work and only populates the scene data (`_textData`,\n `_shapes[i]._select`, etc.) for `toScene()` to read. Set automatically by\n `renderScene` callers; users can also opt-in.\n */\n renderMode(): \"full\" | \"compute\";\n renderMode(_: \"full\" | \"compute\"): this;\n renderMode(_?: \"full\" | \"compute\"): \"full\" | \"compute\" | this {\n if (!arguments.length) return this._renderMode || \"full\";\n this._renderMode = _!;\n return this;\n }\n\n /**\n Public entry point that renders this chart through the @d3plus/render\n pluggable backends. The compute pass happens via render() (in an svg\n auto-created inside the target div); SvgRenderer/CanvasRenderer paints\n the scene to the target. Returns `{renderer, scene}` so callers can\n interact with the renderer (e.g. for picking) or read the scene data.\n */\n async renderScene(\n target: Element,\n opts?: {kind?: \"svg\" | \"canvas\"},\n ): Promise<{renderer: Renderer; scene: Scene}> {\n const kind = opts?.kind || (this._renderer === \"canvas\" ? \"canvas\" : \"svg\");\n this._sceneTarget = target;\n this._renderer = kind;\n this.select(target as HTMLElement);\n await new Promise<void>(resolve => this.render(() => resolve()));\n return {\n renderer: this._sceneRenderer as Renderer,\n scene: this._lastSceneRendered as Scene,\n };\n }\n\n /**\n Renders this chart through the @d3plus/render pluggable backends. Called\n automatically by `render()`. The compute pass draws into `this._select`\n (an auto-created svg INSIDE the user's target div) — that svg is the\n off-stage detached compute svg. SvgRenderer mounts to the user's target\n div (the parent), as a sibling to the detached compute svg. The compute\n svg's children get cleared so only the scene output is visible.\n */\n _drawSceneToTarget(durationOverride?: number): void {\n const kind = this._renderer === \"canvas\" ? \"canvas\" : \"svg\";\n const computeSvg = this._select && this._select.node ? this._select.node() : null;\n if (!computeSvg) return;\n // Mount renderer INSIDE the user's `_select` (svg or div). Tests like\n // `svgA.querySelector('[data-key=\"viz-legend\"]')` need the scene output\n // to live inside the user's container, not as a sibling.\n const userTarget = this._sceneTarget || computeSvg;\n if (!userTarget) return;\n const mountTarget = mountTargetFor(kind, userTarget as Element);\n const scene = this.toScene();\n const w = this.schema.width || 400;\n const h = this.schema.height || 300;\n // Reuse the renderer instance if it matches the kind, to avoid mount\n // churn. `target()` is the public Renderer-interface method (no\n // reaching into renderer-private slots). It's optional on the\n // interface; third-party renderers without it fall through to\n // remount on every draw — correct but with mount churn.\n const currentContainer = this._sceneRenderer?.target\n ? this._sceneRenderer.target()?.container\n : undefined;\n const containerChanged = this._sceneRenderer?.target\n ? currentContainer !== mountTarget\n : false;\n if (\n !this._sceneRenderer ||\n this._sceneRenderer.kind !== kind ||\n containerChanged\n ) {\n // Tear down the outgoing renderer before mounting a fresh one. It owns\n // its own DOM (canvas/svg + overlay host), pointer listeners, and\n // transition timers; without this, switching kind (svg<->canvas) or\n // container orphans that DOM in the user's element, stacking the old\n // mode's output behind the new one and accumulating on every switch.\n if (this._sceneRenderer && typeof this._sceneRenderer.destroy === \"function\")\n this._sceneRenderer.destroy();\n const Ctor = kind === \"canvas\" ? CanvasRenderer : SvgRenderer;\n this._sceneRenderer = new Ctor();\n this._sceneRenderer.mount({container: mountTarget, width: w, height: h});\n // Bridge renderer pointer events → viz.schema.on handlers. Without this,\n // tooltips never fire on the v4 scene-rendered path because\n // `shape.on(evt, fn)` in plotPaint only wires d3-selection\n // listeners on DOM nodes the scene renderer doesn't create.\n // Renderer events carry the picked scene node; the routing lives in\n // `_routeSceneEvent` (kept out of this method so the mount path stays\n // readable). `_lastScenePick` remembers the most recently hovered node\n // so `mouseleave` — fired with a null pick — can still tell the matching\n // handlers which shape/legend item was left (so the tooltip clears).\n this._lastScenePick = null;\n this._sceneRenderer.on((event: SceneEvent) => this._routeSceneEvent(event));\n } else {\n this._sceneRenderer.resize(w, h);\n }\n // `durationOverride` defaults to the chart's `_duration` for normal\n // re-renders. Interaction handlers (zoomed, hover, etc.) pass 0 to\n // skip the transition machinery — animating every wheel/drag tick\n // accumulates `setTimeout(duration+10)` per event.\n const drawDuration =\n durationOverride !== undefined ? durationOverride : this.schema.duration;\n // A duration>0 render (drill-down, zoom, re-center) must win over any\n // pending coalesced duration-0 repaint — otherwise that repaint fires on\n // the next frame and interrupts this transition, snapping shapes to their\n // final geometry.\n if (drawDuration > 0 && this._sceneRepaintRAF != null) {\n cancelAnimationFrame(this._sceneRepaintRAF);\n this._sceneRepaintRAF = undefined;\n }\n // Mark the window during which an animated transition is in flight, so the\n // pointer bridge can ignore interaction until it settles. A hover/click\n // mid-transition would schedule a duration-0 repaint that interrupts the\n // running transition and snaps it to its end (the glitchy jump). Matches\n // the SvgRenderer/CanvasRenderer `duration + 10` end timer, plus a small\n // buffer so events re-enable just after the paint completes.\n if (drawDuration > 0)\n this._transitionEndsAt = Date.now() + drawDuration + 30;\n // Order persistent motion trails in time by the current timeline period, so\n // they grow only as playback moves forward and rewind when it steps back.\n // Only when the timeline selects a single period (`brushing: false`): a range\n // selection has no single \"current time\", which would scramble the step\n // logic, so we withhold the sequence and trails fall back to ephemeral.\n // Normalize to milliseconds via `date()` — the selection mixes Date objects\n // (brush/initial) and raw period numbers (playback), which compare on wildly\n // different scales otherwise, scrambling the forward/backward test.\n const sel = this._timelineSelection;\n const brushing = this._timelineClass\n ? (this._timelineClass.schema as {brushing?: boolean}).brushing !== false\n : true;\n const sequence = !brushing && Array.isArray(sel) && sel.length\n ? Math.max(...sel.map(v => Number(date(Number(v)))))\n : undefined;\n // A forward jump that skips periods (manual click, not single-step play) draws\n // one coarse segment; compute the marks' real positions at the skipped periods\n // so the trail bends through them (see render commitTrailCatchups).\n const trailCatchup =\n sequence !== undefined && this._trailSeq !== undefined && sequence > this._trailSeq\n ? computeTrailCatchup(this as unknown as VizInstance, scene, this._trailSeq, sequence)\n : undefined;\n if (sequence !== undefined) this._trailSeq = sequence;\n this._sceneRenderer.drawScene(scene, {duration: drawDuration, sequence, trailCatchup});\n this._lastSceneRendered = scene;\n\n // Canvas backend: the compute <svg> (`_select`) is an emptied overlay\n // sitting on top of the <canvas>. An svg root hit-tests its whole box, so\n // even empty it swallows the pointer events the canvas needs for\n // tooltip/hover/legend picking — the symptom being \"renders fine, no\n // tooltips.\" Make the overlay transparent to pointer events so the canvas\n // is the sole interaction surface. The only interactive DOM that still\n // lives in this svg is the timeline's d3-brush (the canvas can't host the\n // native brush handles), so re-enable events on just that group. On the\n // SVG backend `_select` IS the scene host, so events must stay enabled.\n if (this._select) {\n this._select.style(\"pointer-events\", kind === \"canvas\" ? \"none\" : null);\n if (this._container)\n this._container.style(\"pointer-events\", kind === \"canvas\" ? \"none\" : null);\n if (kind === \"canvas\")\n this._select\n .select(\"g.d3plus-viz-timeline\")\n .style(\"pointer-events\", \"auto\");\n }\n\n // The timeline brush (d3-brush DOM, mounted in `g.d3plus-viz-timeline` in\n // the outer svg) must paint above the scene-rendered timeline buttons/ticks\n // so its selection tint + handles sit on top of them (matching v3). The\n // renderer appends its scene <svg> last, so without this the brush layer\n // ends up behind it — the selection's translucent fill is then hidden by\n // the opaque buttons and only the edge handles peek out.\n if (kind === \"svg\") {\n const host =\n userTarget && typeof (userTarget as Element).querySelector === \"function\"\n ? (userTarget as Element)\n : null;\n const tlGroup = host\n ? host.querySelector(\":scope > g.d3plus-viz-timeline\")\n : null;\n if (tlGroup) host!.appendChild(tlGroup);\n }\n }\n\n /**\n Routes a renderer pointer event to the matching `viz.schema.on` handlers.\n Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where\n compute-mode shapes mount no per-shape DOM, so `shape.on(evt, fn)`\n listeners never fire. We look up the appropriate `on` key from the picked\n scene node: legend swatches route to legend handlers, chart shapes to\n shape (+ shape-class-scoped) handlers, and chrome (axis/timeline/back) is\n excluded. Split out of `_drawSceneToTarget` to keep that method small.\n @private\n */\n _routeSceneEvent(event: SceneEvent): void {\n // Ignore all pointer interaction while an animated transition (zoom,\n // re-center, drill-down, entrance) is in flight. Hovering or clicking a\n // shape mid-transition would fire a handler that schedules a duration-0\n // repaint, interrupting the running transition and snapping it to its end\n // — the glitchy jump. `_transitionEndsAt` is stamped by `_drawSceneToTarget`\n // for the transition's duration; it lapses on its own, so interaction\n // resumes the instant the transition settles.\n if (this._transitionEndsAt && Date.now() < this._transitionEndsAt) return;\n const pick = event.pick;\n // Dispatch helper shared by the live-pick path and the leave path.\n const fire = (\n key: string,\n d: unknown,\n i: number,\n x: unknown,\n ): void => {\n const fn = this.schema.on && this.schema.on[key];\n if (typeof fn === \"function\") {\n try {\n fn.call(this, d, i, x, event.nativeEvent);\n } catch {\n // swallow per-event errors so one bad handler doesn't\n // break subsequent events.\n }\n }\n };\n if (event.type === \"mouseleave\") {\n const lastPick = this._lastScenePick;\n if (lastPick) {\n fire(\n `mouseleave.${lastPick.isLegend ? \"legend\" : \"shape\"}`,\n lastPick.d,\n lastPick.i,\n lastPick.x,\n );\n if (!lastPick.isLegend && lastPick.shapeType)\n fire(`mouseleave.${lastPick.shapeType}`, lastPick.d, lastPick.i, lastPick.x);\n fire(\"mouseleave\", lastPick.d, lastPick.i, lastPick.x);\n }\n this._lastScenePick = null;\n // Cleared here, then re-set by the enter/move the renderer fires\n // synchronously when the pointer crosses to an adjacent node — so a\n // shape→label hand-off leaves `_hoverDatum` pointing at the new node\n // (same datum), which `mouseleave` reads to suppress a flicker.\n this._hoverDatum = null;\n return;\n }\n if (!pick || !pick.node) return;\n // Scene nodes carry interaction metadata stamped by Viz.toScene.\n const nodeAny = pick.node as {\n interactionGroup?: string;\n shapeType?: string;\n };\n // Back-button panel: its d3-selection click listener never fires in the\n // scene path (it's a plain text node), so route its click here to pop\n // the drill-down history / step up a level.\n if (nodeAny.interactionGroup === \"back\") {\n if (event.type === \"click\") {\n const self = this;\n if (self._history.length) self.config(self._history.pop()).render();\n else self.depth(self._drawDepth - 1).filter(false).render();\n }\n return;\n }\n // Axis ticks/labels and the timeline are chrome — they carry data but\n // are not chart shapes, so they must not fire shape tooltips/handlers.\n if (\n nodeAny.interactionGroup === \"axis\" ||\n nodeAny.interactionGroup === \"timeline\"\n )\n return;\n // Prefer the node's stamped interaction group (set by Viz.toScene), so\n // legend swatches route to legend handlers on Canvas too — where the\n // single canvas element has no per-shape DOM to walk. Fall back to SVG\n // DOM ancestry for nodes the stamp didn't reach.\n const target =\n event.nativeEvent && (event.nativeEvent as Event).target;\n const isLegendNode =\n nodeAny.interactionGroup === \"legend\" ||\n (target && typeof (target as Element).closest === \"function\"\n ? !!(target as Element).closest('[data-key=\"viz-legend\"]')\n : false);\n const suffix = isLegendNode ? \"legend\" : \"shape\";\n const handlerKey = `${event.type}.${suffix}`;\n // Resolve the source datum + index. `pick.datum` is the raw scene datum\n // (which Shape._sceneXxx populated). For Plot shapes that's the wrapped\n // record; the handlers expect `(d.data, d.i, x, event)`.\n const rawDatum = pick.datum as\n | {data?: unknown; i?: number}\n | null\n | undefined;\n const sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;\n const sourceIndex =\n rawDatum && typeof rawDatum.i === \"number\" ? rawDatum.i : pick.index ?? 0;\n const shapeType =\n typeof nodeAny.shapeType === \"string\" ? nodeAny.shapeType : null;\n this._lastScenePick = {\n d: sourceDatum, i: sourceIndex, x: rawDatum, isLegend: isLegendNode, shapeType,\n };\n this._hoverDatum = rawDatum;\n fire(handlerKey, sourceDatum, sourceIndex, rawDatum);\n // Shape-class-scoped handlers (`\"click.Bar\"`, `\"mousemove.Circle\"`). The\n // emitting shape stamps its type onto the node; on the scene path this is\n // the only place these fire (compute-mode shapes wire no DOM listeners).\n // Legend nodes are excluded so a legend swatch's shape type can't\n // masquerade as a chart-shape handler.\n if (!isLegendNode && shapeType) {\n fire(`${event.type}.${shapeType}`, sourceDatum, sourceIndex, rawDatum);\n }\n // Also fire the un-suffixed handler (e.g. \"mousemove\") so user-registered\n // global handlers see the event too.\n fire(event.type, sourceDatum, sourceIndex, rawDatum);\n }\n\n /**\n Coalesces interaction-driven scene repaints (hover/active dimming) into a\n single paint per animation frame. A fast pointer sweep across a dense\n chart fires a hover transition per shape crossed; painting each one\n synchronously rebuilt the whole scene back-to-back, saturating the main\n thread (~200ms stalls) so the tooltip couldn't reposition and appeared\n stuck at its last spot. Only the latest hover state is visible, so the\n intermediate paints are wasted — collapse them to one rAF-scheduled draw.\n */\n _scheduleSceneRepaint(): void {\n if (!this._sceneRenderer) return;\n if (typeof requestAnimationFrame !== \"function\") {\n this._drawSceneToTarget(0);\n return;\n }\n if (this._sceneRepaintRAF != null) return;\n this._sceneRepaintRAF = requestAnimationFrame(() => {\n this._sceneRepaintRAF = undefined;\n this._drawSceneToTarget(0);\n });\n }\n\n /**\n Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.\n */\n destroy(): this {\n this._resizeObserver.disconnect();\n this._tooltipClass.data([]).render();\n select(\"body\").on(`touchstart.${this._uuid}`, null);\n // Clear the visibility/resize/scroll poll timers + scroll listener\n // so a destroyed chart doesn't keep firing intervals/timeouts that\n // hold the entire viz instance alive. Without this, an SPA that\n // mounts/unmounts charts on tab switches leaks the scene tree +\n // a 200ms-interval timer per leaked chart.\n if (this._visiblePoll) {\n this._visiblePoll = clearInterval(this._visiblePoll) as never;\n }\n if (this._resizePoll) {\n this._resizePoll = clearTimeout(this._resizePoll) as never;\n }\n if (this._scrollPoll) {\n this._scrollPoll = clearTimeout(this._scrollPoll) as never;\n }\n if (this._sceneRepaintRAF != null) {\n if (typeof cancelAnimationFrame === \"function\")\n cancelAnimationFrame(this._sceneRepaintRAF);\n this._sceneRepaintRAF = undefined;\n }\n select(this.schema.scrollContainer).on(`scroll.${this._uuid}`, null);\n // Destroy the active scene renderer (clears its own pointer-rect\n // listeners, overlay host, canvas/svg DOM, timers).\n if (this._sceneRenderer && typeof this._sceneRenderer.destroy === \"function\") {\n this._sceneRenderer.destroy();\n this._sceneRenderer = undefined;\n }\n return this;\n }\n\n}\n"],"names":["select","date","getSize","computeTrailCatchup","CanvasRenderer","SvgRenderer","VizBase","applyColorScaleBucketOpacity","applyInteractionOpacity","initVizDefaults","vizRender","vizDraw","vizPreDraw","tagInteractionGroup","node","group","interactionGroup","kids","children","child","mountTargetFor","kind","target","Element","tagName","toLowerCase","parentNode","Viz","_preDraw","toScene","_chartScene","length","sliced","zoomNode","type","key","transform","_zoomTransform","x","y","scale","push","_chartTransform","_chartClip","clip","_shapes","forEach","shape","si","sel","_select","attr","t","m","match","parseFloat","components","_legendClass","_colorScaleClass","_timelineClass","name","comp","compScene","_featurePanels","panels","slice","panel","includes","width","schema","height","root","_draw","_thresholdFunction","data","_tree","_setSVGSize","w","h","style","_autoWidth","_autoHeight","render","callback","renderer","_","arguments","_renderer","renderMode","_renderMode","renderScene","opts","_sceneTarget","Promise","resolve","_sceneRenderer","scene","_lastSceneRendered","_drawSceneToTarget","durationOverride","Math","computeSvg","userTarget","mountTarget","currentContainer","container","undefined","containerChanged","destroy","Ctor","mount","_lastScenePick","on","event","_routeSceneEvent","resize","drawDuration","duration","_sceneRepaintRAF","cancelAnimationFrame","_transitionEndsAt","Date","now","_timelineSelection","brushing","sequence","Array","isArray","max","map","v","Number","trailCatchup","_trailSeq","drawScene","_container","host","querySelector","tlGroup","appendChild","pick","fire","d","i","fn","call","nativeEvent","lastPick","isLegend","shapeType","_hoverDatum","nodeAny","self","_history","config","pop","depth","_drawDepth","filter","isLegendNode","closest","suffix","handlerKey","rawDatum","datum","sourceDatum","sourceIndex","index","_scheduleSceneRepaint","requestAnimationFrame","_resizeObserver","disconnect","_tooltipClass","_uuid","_visiblePoll","clearInterval","_resizePoll","clearTimeout","_scrollPoll","scrollContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQA,MAAM,QAAO,eAAe;AAEpC,SAAQC,IAAI,EAAEC,OAAO,QAAO,cAAc;AAE1C,SAAQC,mBAAmB,QAAO,oBAAoB;AAEtD,SAAQC,cAAc,EAAEC,WAAW,QAAO,iBAAiB;AAG3D,OAAOC,aAAa,eAAe;AAGnC,SAAQC,4BAA4B,EAAEC,uBAAuB,QAAO,0BAA0B;AAC9F,SAAQC,eAAe,QAAO,mBAAmB;AACjD,SAAQC,SAAS,QAAO,iBAAiB;AACzC,SAAQC,OAAO,QAAO,yBAAy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,gBAAgB;oBAC5C,IAAI,CAACA,gBAAgB,GAAGZ;gBAC1B;gBACA1G,OAAO,IAAI,CAACqE,MAAM,CAAC8G,eAAe,EAAEnE,EAAE,CAAC,AAAC,UAAoB,OAAX,IAAI,CAAC6D,KAAK,GAAI;gBAC/D,iEAAiE;gBACjE,oDAAoD;gBACpD,IAAI,IAAI,CAAC9E,cAAc,IAAI,OAAO,IAAI,CAACA,cAAc,CAACa,OAAO,KAAK,YAAY;oBAC5E,IAAI,CAACb,cAAc,CAACa,OAAO;oBAC3B,IAAI,CAACb,cAAc,GAAGW;gBACxB;gBACA,OAAO,IAAI;YACb;;;WA7kBmB/E;EAAYrB;AAHjC;;AAEA,GACA,SAAqBqB,iBA+kBpB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/viz/Viz.ts"],"sourcesContent":["import {select} from \"d3-selection\";\n\nimport {date, getSize} from \"@d3plus/dom\";\n\nimport {computeTrailCatchup} from \"./trailCatchup.js\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {CanvasRenderer, SvgRenderer} from \"@d3plus/render\";\nimport type {PickResult, Renderer, Scene, SceneEvent, SceneNode, Transform} from \"@d3plus/render\";\n\nimport VizBase from \"./VizBase.js\";\nimport type {ColorScale, Legend, Timeline} from \"../../components/index.js\";\nimport type Shape from \"../../shapes/Shape.js\";\nimport {applyColorScaleBucketOpacity, applyInteractionOpacity} from \"./interactionOpacity.js\";\nimport {initVizDefaults} from \"./vizDefaults.js\";\nimport {vizRender} from \"./vizRender.js\";\nimport {vizDraw} from \"../pipeline/vizDraw.js\";\nimport {vizPreDraw} from \"../pipeline/vizPreDraw.js\";\nimport type {VizInstance} from \"./vizTypes.js\";\n\n/**\n Stamps `interactionGroup` onto a component's scene subtree so the pointer\n bridge can route its nodes to component-scoped handlers (e.g. legend) on\n every backend — including Canvas, where there is no per-shape DOM to walk.\n*/\nfunction tagInteractionGroup(node: SceneNode, group: string): void {\n (node as {interactionGroup?: string}).interactionGroup = group;\n const kids = (node as {children?: SceneNode[]}).children;\n if (kids) for (const child of kids) tagInteractionGroup(child, group);\n}\n\n/**\n Resolves the element a renderer mounts into. A `<canvas>` cannot paint inside\n an `<svg>`, so when the scene target is the compute svg, the canvas mounts\n into that svg's parent (the user's element); the emptied, position:absolute\n compute svg overlays the same top-left box. SVG mounts into the target as-is.\n*/\nfunction mountTargetFor(kind: string, target: Element): Element {\n if (\n kind === \"canvas\" &&\n typeof Element !== \"undefined\" &&\n target instanceof Element &&\n target.tagName.toLowerCase() === \"svg\"\n )\n return (target.parentNode as Element | null) ?? target;\n return target;\n}\n\n/**\n Creates an x/y plot based on an array of data. See [this example](https://d3plus.org/examples/d3plus-treemap/getting-started/) for help getting started using the treemap generator.\n*/\nexport default class Viz extends VizBase {\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n */\n constructor() {\n super();\n initVizDefaults(this);\n }\n\n /**\n Called by draw before anything is drawn. Formats the data and performs preparations for draw.\n @private\n */\n _preDraw(): void {\n vizPreDraw(this as unknown as VizInstance);\n }\n\n /**\n Composes a backend-agnostic scene graph from the shapes/features produced\n by the most recent render. Combines:\n - `_chartScene` (cells from `chartDef.emit`, or `Plot._paint` for the\n paint-driven Plot family) wrapped in viz-chart-cells\n - `_shapes` (still used by some charts) — each shape's toScene\n - chart-level components (Legend/ColorScale/Timeline) via their toScene\n - `_featurePanels` (from FeatureModule layouts) wrapped in viz-features\n */\n toScene(): Scene {\n const children: SceneNode[] = [];\n // Chart cells stashed on _chartScene — via `chartDef.emit(ctx)` for\n // data-driven charts, or `Plot._paint` for the paint-driven Plot family.\n // Wraps in two groups when a zoom transform is active:\n // viz-chart-cells (chart-positioning transform)\n // viz-zoom (zoom transform — pan/scale from d3-zoom)\n // … chart scene children\n // This lets zoom apply to the chart content WITHOUT moving legend/\n // title/total/etc. (which live in sibling viz-* groups, not under\n // viz-chart-cells).\n if (this._chartScene && this._chartScene.length) {\n const sliced = applyInteractionOpacity(\n this._chartScene,\n this as unknown as VizInstance,\n );\n // Always emit the viz-zoom group (identity transform when no zoom is\n // active) so its key is stable across the first zoom. Otherwise the first\n // zoom adds a brand-new group → the renderer treats the chart cells as\n // exit+enter (teardown/rebuild) instead of tweening the group transform,\n // so the zoom snaps in instead of animating.\n const zoomNode = [{\n type: \"group\" as const,\n key: \"viz-zoom\",\n transform: this._zoomTransform ?? {x: 0, y: 0, scale: 1},\n children: sliced,\n }];\n children.push({\n type: \"group\",\n key: \"viz-chart-cells\",\n ...(this._chartTransform ? {transform: this._chartTransform} : {}),\n // Fixed clip window (e.g. Geomap's map rect): stays put in scene space\n // while the viz-zoom child transform pans/scales content beneath it.\n ...(this._chartClip ? {clip: this._chartClip} : {}),\n children: zoomNode,\n });\n }\n // `_shapes` collection (Treemap/Pack/etc. route through `_chartScene`\n // instead, as does Plot's `absorbShapeIntoChartScene`). Any caller\n // pushing into `_shapes` gets its `toScene()` walked here; we read the\n // shape's `_select` transform via d3's transform baseVal if present,\n // otherwise emit without a transform.\n (this._shapes || []).forEach((shape: Shape, si: number) => {\n if (!shape || typeof shape.toScene !== \"function\") return;\n const group = shape.toScene();\n let transform: Transform | undefined;\n const sel = shape._select;\n if (sel && typeof sel.attr === \"function\") {\n // Parse `translate(x, y)` from the selection's transform attr.\n // Falls back to undefined for non-translate transforms — the\n // `_shapes` path only uses translate.\n const t = sel.attr(\"transform\");\n if (typeof t === \"string\") {\n const m = t.match(/translate\\(\\s*(-?[\\d.]+)[, ]\\s*(-?[\\d.]+)\\s*\\)/);\n if (m) transform = {x: parseFloat(m[1]), y: parseFloat(m[2])};\n }\n }\n children.push({\n type: \"group\",\n key: `${group.key || \"shape\"}-${si}`,\n ...(transform ? {transform} : {}),\n children: group.children,\n });\n });\n // Chart-level components that have their own toScene.\n const components: [string, Legend | ColorScale | Timeline | undefined][] = [\n [\"legend\", this._legendClass],\n [\"colorScale\", this._colorScaleClass],\n [\"timeline\", this._timelineClass],\n ];\n for (const [name, comp] of components) {\n if (\n comp &&\n typeof comp.toScene === \"function\" &&\n comp._select &&\n typeof comp._select.node === \"function\" &&\n comp._select.node()\n ) {\n let compScene: SceneNode = comp.toScene();\n // Tag the legend subtree so its swatches route to legend handlers via\n // the node stamp (renderer-independent), not just SVG DOM ancestry.\n if (name === \"legend\") {\n tagInteractionGroup(compScene, \"legend\");\n // Hovering a legend swatch dims the others, like the chart marks:\n // run the legend subtree through the same interaction-opacity pass\n // (a no-op when no hover/active predicate is set).\n compScene = applyInteractionOpacity(\n [compScene],\n this as unknown as VizInstance,\n )[0];\n }\n // Hovering a colorScale swatch (or a data shape) dims the sibling\n // swatches by bucket color — leaving the colorScale title/axis/gradient\n // untouched. Not tagged \"legend\": colorScale swatches keep the shape\n // event path (range-based tooltip + hover), unlike groupBy legend items.\n else if (name === \"colorScale\") {\n compScene = applyColorScaleBucketOpacity(\n [compScene],\n this as unknown as VizInstance,\n )[0];\n }\n // Tag the timeline subtree so its ticks/labels are exempt from shape\n // tooltips and hover/active dimming (it's chrome, not data marks).\n else if (name === \"timeline\") tagInteractionGroup(compScene, \"timeline\");\n children.push({\n type: \"group\",\n key: `viz-${name}`,\n children: [compScene],\n });\n }\n }\n // E2: FeatureModule.layout() panels (title/subtitle/total/back).\n if (this._featurePanels && this._featurePanels.length) {\n const panels = this._featurePanels.slice();\n // Tag the back-button panel so the pointer bridge can route its click.\n for (const panel of panels) {\n if (\n panel &&\n typeof (panel as {key?: string}).key === \"string\" &&\n (panel as {key: string}).key.toLowerCase().includes(\"back\")\n )\n tagInteractionGroup(panel as SceneNode, \"back\");\n }\n children.push({type: \"group\", key: \"viz-features\", children: panels});\n }\n return {\n width: this.schema.width,\n height: this.schema.height,\n root: {type: \"group\", key: \"viz-root\", children},\n };\n }\n\n /**\n Called by render once all checks are passed.\n @private\n */\n _draw(): void {\n vizDraw(this as unknown as VizInstance);\n }\n\n /**\n * Applies the threshold algorithm according to the type of chart used.\n * @param {Array} data The data to process.\n * @private\n */\n _thresholdFunction(data: DataPoint[], _tree?: unknown): DataPoint[] {\n return data;\n }\n\n /**\n * Detects width and height and sets SVG properties\n * @private\n */\n _setSVGSize(width?: number, height?: number): void {\n let [w, h] =\n width && height\n ? [width, height]\n : getSize(this._select.node().parentNode);\n w! -= parseFloat(this._select.style(\"border-left-width\"));\n w! -= parseFloat(this._select.style(\"border-right-width\"));\n h! -= parseFloat(this._select.style(\"border-top-width\"));\n h! -= parseFloat(this._select.style(\"border-bottom-width\"));\n \n if (this._autoWidth && this.schema.width !== w) {\n this.width(w);\n this._select\n .style(\"width\", `${this.schema.width}px`)\n .attr(\"width\", `${this.schema.width}px`);\n }\n if (this._autoHeight && this.schema.height !== h) {\n this.height(h);\n this._select\n .style(\"height\", `${this.schema.height}px`)\n .attr(\"height\", `${this.schema.height}px`);\n }\n }\n\n /**\n Draws the visualization given the specified configuration.\n @param callback Optional callback invoked after rendering completes.\n */\n render(callback?: () => void): this {\n return vizRender(this, callback) as this;\n }\n\n /**\n Serializes the most recently rendered output to an SVG string. Returns\n `\"\"` if the chart has not been rendered yet. Both backends support this:\n the SVG backend returns its live `<svg>`, the canvas backend re-renders the\n retained scene through a throwaway SVG backend. Primarily used for\n server-side rendering (see `@d3plus/ssr`).\n */\n toSVGString(): string {\n return this._sceneRenderer?.toSVGString?.() ?? \"\";\n }\n\n /**\n Returns the underlying canvas element of the most recent render when the\n canvas backend is active (`renderer(\"canvas\")`), or `undefined` otherwise.\n Server-side callers cast this to their native canvas to encode a raster\n (see `@d3plus/ssr`).\n */\n toCanvas(): unknown {\n return this._renderer === \"canvas\"\n ? this._sceneRenderer?.toCanvas?.()\n : undefined;\n }\n\n /**\n Selects which @d3plus/render backend paints the visible output.\n `\"svg\"` = SvgRenderer (default), `\"canvas\"` = CanvasRenderer.\n Boolean arguments both normalize to `\"svg\"`.\n */\n renderer(): \"svg\" | \"canvas\";\n renderer(_: \"svg\" | \"canvas\" | true | false): this;\n renderer(_?: \"svg\" | \"canvas\" | true | false): \"svg\" | \"canvas\" | this {\n if (!arguments.length) return this._renderer;\n this._renderer = _ === \"canvas\" ? \"canvas\" : \"svg\";\n return this;\n }\n\n /**\n \"full\" runs the DOM enter/update/exit for every shape; \"compute\"\n skips DOM work and only populates the scene data (`_textData`,\n `_shapes[i]._select`, etc.) for `toScene()` to read. Set automatically by\n `renderScene` callers; users can also opt-in.\n */\n renderMode(): \"full\" | \"compute\";\n renderMode(_: \"full\" | \"compute\"): this;\n renderMode(_?: \"full\" | \"compute\"): \"full\" | \"compute\" | this {\n if (!arguments.length) return this._renderMode || \"full\";\n this._renderMode = _!;\n return this;\n }\n\n /**\n Public entry point that renders this chart through the @d3plus/render\n pluggable backends. The compute pass happens via render() (in an svg\n auto-created inside the target div); SvgRenderer/CanvasRenderer paints\n the scene to the target. Returns `{renderer, scene}` so callers can\n interact with the renderer (e.g. for picking) or read the scene data.\n */\n async renderScene(\n target: Element,\n opts?: {kind?: \"svg\" | \"canvas\"},\n ): Promise<{renderer: Renderer; scene: Scene}> {\n const kind = opts?.kind || (this._renderer === \"canvas\" ? \"canvas\" : \"svg\");\n this._sceneTarget = target;\n this._renderer = kind;\n this.select(target as HTMLElement);\n await new Promise<void>(resolve => this.render(() => resolve()));\n return {\n renderer: this._sceneRenderer as Renderer,\n scene: this._lastSceneRendered as Scene,\n };\n }\n\n /**\n Renders this chart through the @d3plus/render pluggable backends. Called\n automatically by `render()`. The compute pass draws into `this._select`\n (an auto-created svg INSIDE the user's target div) — that svg is the\n off-stage detached compute svg. SvgRenderer mounts to the user's target\n div (the parent), as a sibling to the detached compute svg. The compute\n svg's children get cleared so only the scene output is visible.\n */\n _drawSceneToTarget(durationOverride?: number): void {\n const kind = this._renderer === \"canvas\" ? \"canvas\" : \"svg\";\n const computeSvg = this._select && this._select.node ? this._select.node() : null;\n if (!computeSvg) return;\n // Mount renderer INSIDE the user's `_select` (svg or div). Tests like\n // `svgA.querySelector('[data-key=\"viz-legend\"]')` need the scene output\n // to live inside the user's container, not as a sibling.\n const userTarget = this._sceneTarget || computeSvg;\n if (!userTarget) return;\n const mountTarget = mountTargetFor(kind, userTarget as Element);\n const scene = this.toScene();\n const w = this.schema.width || 400;\n const h = this.schema.height || 300;\n // Reuse the renderer instance if it matches the kind, to avoid mount\n // churn. `target()` is the public Renderer-interface method (no\n // reaching into renderer-private slots). It's optional on the\n // interface; third-party renderers without it fall through to\n // remount on every draw — correct but with mount churn.\n const currentContainer = this._sceneRenderer?.target\n ? this._sceneRenderer.target()?.container\n : undefined;\n const containerChanged = this._sceneRenderer?.target\n ? currentContainer !== mountTarget\n : false;\n if (\n !this._sceneRenderer ||\n this._sceneRenderer.kind !== kind ||\n containerChanged\n ) {\n // Tear down the outgoing renderer before mounting a fresh one. It owns\n // its own DOM (canvas/svg + overlay host), pointer listeners, and\n // transition timers; without this, switching kind (svg<->canvas) or\n // container orphans that DOM in the user's element, stacking the old\n // mode's output behind the new one and accumulating on every switch.\n if (this._sceneRenderer && typeof this._sceneRenderer.destroy === \"function\")\n this._sceneRenderer.destroy();\n const Ctor = kind === \"canvas\" ? CanvasRenderer : SvgRenderer;\n this._sceneRenderer = new Ctor();\n // `_scenePixelRatio`, when set (e.g. by @d3plus/ssr for hi-res PNG output),\n // fixes the canvas backing-store scale; otherwise the renderer falls back\n // to `devicePixelRatio`.\n this._sceneRenderer.mount({\n container: mountTarget,\n width: w,\n height: h,\n pixelRatio: this._scenePixelRatio,\n });\n // Bridge renderer pointer events → viz.schema.on handlers. Without this,\n // tooltips never fire on the v4 scene-rendered path because\n // `shape.on(evt, fn)` in plotPaint only wires d3-selection\n // listeners on DOM nodes the scene renderer doesn't create.\n // Renderer events carry the picked scene node; the routing lives in\n // `_routeSceneEvent` (kept out of this method so the mount path stays\n // readable). `_lastScenePick` remembers the most recently hovered node\n // so `mouseleave` — fired with a null pick — can still tell the matching\n // handlers which shape/legend item was left (so the tooltip clears).\n this._lastScenePick = null;\n this._sceneRenderer.on((event: SceneEvent) => this._routeSceneEvent(event));\n } else {\n this._sceneRenderer.resize(w, h);\n }\n // `durationOverride` defaults to the chart's `_duration` for normal\n // re-renders. Interaction handlers (zoomed, hover, etc.) pass 0 to\n // skip the transition machinery — animating every wheel/drag tick\n // accumulates `setTimeout(duration+10)` per event.\n const drawDuration =\n durationOverride !== undefined ? durationOverride : this.schema.duration;\n // A duration>0 render (drill-down, zoom, re-center) must win over any\n // pending coalesced duration-0 repaint — otherwise that repaint fires on\n // the next frame and interrupts this transition, snapping shapes to their\n // final geometry.\n if (drawDuration > 0 && this._sceneRepaintRAF != null) {\n cancelAnimationFrame(this._sceneRepaintRAF);\n this._sceneRepaintRAF = undefined;\n }\n // Mark the window during which an animated transition is in flight, so the\n // pointer bridge can ignore interaction until it settles. A hover/click\n // mid-transition would schedule a duration-0 repaint that interrupts the\n // running transition and snaps it to its end (the glitchy jump). Matches\n // the SvgRenderer/CanvasRenderer `duration + 10` end timer, plus a small\n // buffer so events re-enable just after the paint completes.\n if (drawDuration > 0)\n this._transitionEndsAt = Date.now() + drawDuration + 30;\n // Order persistent motion trails in time by the current timeline period, so\n // they grow only as playback moves forward and rewind when it steps back.\n // Only when the timeline selects a single period (`brushing: false`): a range\n // selection has no single \"current time\", which would scramble the step\n // logic, so we withhold the sequence and trails fall back to ephemeral.\n // Normalize to milliseconds via `date()` — the selection mixes Date objects\n // (brush/initial) and raw period numbers (playback), which compare on wildly\n // different scales otherwise, scrambling the forward/backward test.\n const sel = this._timelineSelection;\n const brushing = this._timelineClass\n ? (this._timelineClass.schema as {brushing?: boolean}).brushing !== false\n : true;\n const sequence = !brushing && Array.isArray(sel) && sel.length\n ? Math.max(...sel.map(v => Number(date(Number(v)))))\n : undefined;\n // A forward jump that skips periods (manual click, not single-step play) draws\n // one coarse segment; compute the marks' real positions at the skipped periods\n // so the trail bends through them (see render commitTrailCatchups).\n const trailCatchup =\n sequence !== undefined && this._trailSeq !== undefined && sequence > this._trailSeq\n ? computeTrailCatchup(this as unknown as VizInstance, scene, this._trailSeq, sequence)\n : undefined;\n if (sequence !== undefined) this._trailSeq = sequence;\n this._sceneRenderer.drawScene(scene, {duration: drawDuration, sequence, trailCatchup});\n this._lastSceneRendered = scene;\n\n // Canvas backend: the compute <svg> (`_select`) is an emptied overlay\n // sitting on top of the <canvas>. An svg root hit-tests its whole box, so\n // even empty it swallows the pointer events the canvas needs for\n // tooltip/hover/legend picking — the symptom being \"renders fine, no\n // tooltips.\" Make the overlay transparent to pointer events so the canvas\n // is the sole interaction surface. The only interactive DOM that still\n // lives in this svg is the timeline's d3-brush (the canvas can't host the\n // native brush handles), so re-enable events on just that group. On the\n // SVG backend `_select` IS the scene host, so events must stay enabled.\n if (this._select) {\n this._select.style(\"pointer-events\", kind === \"canvas\" ? \"none\" : null);\n if (this._container)\n this._container.style(\"pointer-events\", kind === \"canvas\" ? \"none\" : null);\n if (kind === \"canvas\")\n this._select\n .select(\"g.d3plus-viz-timeline\")\n .style(\"pointer-events\", \"auto\");\n }\n\n // The timeline brush (d3-brush DOM, mounted in `g.d3plus-viz-timeline` in\n // the outer svg) must paint above the scene-rendered timeline buttons/ticks\n // so its selection tint + handles sit on top of them (matching v3). The\n // renderer appends its scene <svg> last, so without this the brush layer\n // ends up behind it — the selection's translucent fill is then hidden by\n // the opaque buttons and only the edge handles peek out.\n if (kind === \"svg\") {\n const host =\n userTarget && typeof (userTarget as Element).querySelector === \"function\"\n ? (userTarget as Element)\n : null;\n const tlGroup = host\n ? host.querySelector(\":scope > g.d3plus-viz-timeline\")\n : null;\n if (tlGroup) host!.appendChild(tlGroup);\n }\n }\n\n /**\n Resolves the `(d, i, x)` a picked scene node reports to interaction\n handlers (tooltip, click, user `on` handlers). `pick.datum` is the raw\n scene datum; for a Plot shape that's the wrapped record `{data, i}`, which\n handlers expect unwrapped to `(d.data, d.i, wrapped)`. The base does that\n unwrap; Plot overrides this to report the point nearest the cursor for\n multi-point shapes (Line/Area) so a series tooltip reflects the hovered\n x rather than the whole-series aggregate.\n @private\n */\n _interactionDatum(\n pick: PickResult,\n _event: SceneEvent,\n ): {d: unknown; i: number; x: unknown} {\n const rawDatum = pick.datum as {data?: unknown; i?: number} | null | undefined;\n const sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;\n const sourceIndex =\n rawDatum && typeof rawDatum.i === \"number\" ? rawDatum.i : pick.index ?? 0;\n return {d: sourceDatum, i: sourceIndex, x: rawDatum};\n }\n\n /**\n Routes a renderer pointer event to the matching `viz.schema.on` handlers.\n Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where\n compute-mode shapes mount no per-shape DOM, so `shape.on(evt, fn)`\n listeners never fire. We look up the appropriate `on` key from the picked\n scene node: legend swatches route to legend handlers, chart shapes to\n shape (+ shape-class-scoped) handlers, and chrome (axis/timeline/back) is\n excluded. Split out of `_drawSceneToTarget` to keep that method small.\n @private\n */\n _routeSceneEvent(event: SceneEvent): void {\n // Ignore all pointer interaction while an animated transition (zoom,\n // re-center, drill-down, entrance) is in flight. Hovering or clicking a\n // shape mid-transition would fire a handler that schedules a duration-0\n // repaint, interrupting the running transition and snapping it to its end\n // — the glitchy jump. `_transitionEndsAt` is stamped by `_drawSceneToTarget`\n // for the transition's duration; it lapses on its own, so interaction\n // resumes the instant the transition settles.\n if (this._transitionEndsAt && Date.now() < this._transitionEndsAt) return;\n const pick = event.pick;\n // Dispatch helper shared by the live-pick path and the leave path.\n const fire = (\n key: string,\n d: unknown,\n i: number,\n x: unknown,\n ): void => {\n const fn = this.schema.on && this.schema.on[key];\n if (typeof fn === \"function\") {\n try {\n fn.call(this, d, i, x, event.nativeEvent);\n } catch {\n // swallow per-event errors so one bad handler doesn't\n // break subsequent events.\n }\n }\n };\n if (event.type === \"mouseleave\") {\n const lastPick = this._lastScenePick;\n if (lastPick) {\n fire(\n `mouseleave.${lastPick.isLegend ? \"legend\" : \"shape\"}`,\n lastPick.d,\n lastPick.i,\n lastPick.x,\n );\n if (!lastPick.isLegend && lastPick.shapeType)\n fire(`mouseleave.${lastPick.shapeType}`, lastPick.d, lastPick.i, lastPick.x);\n fire(\"mouseleave\", lastPick.d, lastPick.i, lastPick.x);\n }\n this._lastScenePick = null;\n // Cleared here, then re-set by the enter/move the renderer fires\n // synchronously when the pointer crosses to an adjacent node — so a\n // shape→label hand-off leaves `_hoverDatum` pointing at the new node\n // (same datum), which `mouseleave` reads to suppress a flicker.\n this._hoverDatum = null;\n return;\n }\n if (!pick || !pick.node) return;\n // Scene nodes carry interaction metadata stamped by Viz.toScene.\n const nodeAny = pick.node as {\n interactionGroup?: string;\n shapeType?: string;\n };\n // Back-button panel: its d3-selection click listener never fires in the\n // scene path (it's a plain text node), so route its click here to pop\n // the drill-down history / step up a level.\n if (nodeAny.interactionGroup === \"back\") {\n if (event.type === \"click\") {\n const self = this;\n if (self._history.length) self.config(self._history.pop()).render();\n else self.depth(self._drawDepth - 1).filter(false).render();\n }\n return;\n }\n // Axis ticks/labels and the timeline are chrome — they carry data but\n // are not chart shapes, so they must not fire shape tooltips/handlers.\n if (\n nodeAny.interactionGroup === \"axis\" ||\n nodeAny.interactionGroup === \"timeline\"\n )\n return;\n // Prefer the node's stamped interaction group (set by Viz.toScene), so\n // legend swatches route to legend handlers on Canvas too — where the\n // single canvas element has no per-shape DOM to walk. Fall back to SVG\n // DOM ancestry for nodes the stamp didn't reach.\n const target =\n event.nativeEvent && (event.nativeEvent as Event).target;\n const isLegendNode =\n nodeAny.interactionGroup === \"legend\" ||\n (target && typeof (target as Element).closest === \"function\"\n ? !!(target as Element).closest('[data-key=\"viz-legend\"]')\n : false);\n const suffix = isLegendNode ? \"legend\" : \"shape\";\n const handlerKey = `${event.type}.${suffix}`;\n // Resolve the datum + index this pick reports to handlers, ONCE, and reuse\n // it for every handler fired below so tooltip/click/user handlers agree on\n // which datum the pointer is over. The base unwraps the node's raw datum to\n // its source row; Plot overrides `_interactionDatum` to report the point\n // nearest the cursor for multi-point shapes (Line/Area).\n const {d: sourceDatum, i: sourceIndex, x: rawDatum} = this._interactionDatum(\n pick,\n event,\n );\n const shapeType =\n typeof nodeAny.shapeType === \"string\" ? nodeAny.shapeType : null;\n this._lastScenePick = {\n d: sourceDatum, i: sourceIndex, x: rawDatum, isLegend: isLegendNode, shapeType,\n };\n this._hoverDatum = rawDatum;\n fire(handlerKey, sourceDatum, sourceIndex, rawDatum);\n // Shape-class-scoped handlers (`\"click.Bar\"`, `\"mousemove.Circle\"`). The\n // emitting shape stamps its type onto the node; on the scene path this is\n // the only place these fire (compute-mode shapes wire no DOM listeners).\n // Legend nodes are excluded so a legend swatch's shape type can't\n // masquerade as a chart-shape handler.\n if (!isLegendNode && shapeType) {\n fire(`${event.type}.${shapeType}`, sourceDatum, sourceIndex, rawDatum);\n }\n // Also fire the un-suffixed handler (e.g. \"mousemove\") so user-registered\n // global handlers see the event too.\n fire(event.type, sourceDatum, sourceIndex, rawDatum);\n }\n\n /**\n Coalesces interaction-driven scene repaints (hover/active dimming) into a\n single paint per animation frame. A fast pointer sweep across a dense\n chart fires a hover transition per shape crossed; painting each one\n synchronously rebuilt the whole scene back-to-back, saturating the main\n thread (~200ms stalls) so the tooltip couldn't reposition and appeared\n stuck at its last spot. Only the latest hover state is visible, so the\n intermediate paints are wasted — collapse them to one rAF-scheduled draw.\n */\n _scheduleSceneRepaint(): void {\n if (!this._sceneRenderer) return;\n if (typeof requestAnimationFrame !== \"function\") {\n this._drawSceneToTarget(0);\n return;\n }\n if (this._sceneRepaintRAF != null) return;\n this._sceneRepaintRAF = requestAnimationFrame(() => {\n this._sceneRepaintRAF = undefined;\n this._drawSceneToTarget(0);\n });\n }\n\n /**\n Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.\n */\n destroy(): this {\n this._resizeObserver?.disconnect();\n this._tooltipClass.data([]).render();\n select(\"body\").on(`touchstart.${this._uuid}`, null);\n // Clear the visibility/resize/scroll poll timers + scroll listener\n // so a destroyed chart doesn't keep firing intervals/timeouts that\n // hold the entire viz instance alive. Without this, an SPA that\n // mounts/unmounts charts on tab switches leaks the scene tree +\n // a 200ms-interval timer per leaked chart.\n if (this._visiblePoll) {\n this._visiblePoll = clearInterval(this._visiblePoll) as never;\n }\n if (this._resizePoll) {\n this._resizePoll = clearTimeout(this._resizePoll) as never;\n }\n if (this._scrollPoll) {\n this._scrollPoll = clearTimeout(this._scrollPoll) as never;\n }\n if (this._sceneRepaintRAF != null) {\n if (typeof cancelAnimationFrame === \"function\")\n cancelAnimationFrame(this._sceneRepaintRAF);\n this._sceneRepaintRAF = undefined;\n }\n if (this.schema.scrollContainer)\n select(this.schema.scrollContainer).on(`scroll.${this._uuid}`, null);\n // Destroy the active scene renderer (clears its own pointer-rect\n // listeners, overlay host, canvas/svg DOM, timers).\n if (this._sceneRenderer && typeof this._sceneRenderer.destroy === \"function\") {\n this._sceneRenderer.destroy();\n this._sceneRenderer = undefined;\n }\n return this;\n }\n\n}\n"],"names":["select","date","getSize","computeTrailCatchup","CanvasRenderer","SvgRenderer","VizBase","applyColorScaleBucketOpacity","applyInteractionOpacity","initVizDefaults","vizRender","vizDraw","vizPreDraw","tagInteractionGroup","node","group","interactionGroup","kids","children","child","mountTargetFor","kind","target","Element","tagName","toLowerCase","parentNode","Viz","_preDraw","toScene","_chartScene","length","sliced","zoomNode","type","key","transform","_zoomTransform","x","y","scale","push","_chartTransform","_chartClip","clip","_shapes","forEach","shape","si","sel","_select","attr","t","m","match","parseFloat","components","_legendClass","_colorScaleClass","_timelineClass","name","comp","compScene","_featurePanels","panels","slice","panel","includes","width","schema","height","root","_draw","_thresholdFunction","data","_tree","_setSVGSize","w","h","style","_autoWidth","_autoHeight","render","callback","toSVGString","_sceneRenderer","toCanvas","_renderer","undefined","renderer","_","arguments","renderMode","_renderMode","renderScene","opts","_sceneTarget","Promise","resolve","scene","_lastSceneRendered","_drawSceneToTarget","durationOverride","Math","computeSvg","userTarget","mountTarget","currentContainer","container","containerChanged","destroy","Ctor","mount","pixelRatio","_scenePixelRatio","_lastScenePick","on","event","_routeSceneEvent","resize","drawDuration","duration","_sceneRepaintRAF","cancelAnimationFrame","_transitionEndsAt","Date","now","_timelineSelection","brushing","sequence","Array","isArray","max","map","v","Number","trailCatchup","_trailSeq","drawScene","_container","host","querySelector","tlGroup","appendChild","_interactionDatum","pick","_event","rawDatum","datum","sourceDatum","sourceIndex","i","index","d","fire","fn","call","nativeEvent","lastPick","isLegend","shapeType","_hoverDatum","nodeAny","self","_history","config","pop","depth","_drawDepth","filter","isLegendNode","closest","suffix","handlerKey","_scheduleSceneRepaint","requestAnimationFrame","_resizeObserver","disconnect","_tooltipClass","_uuid","_visiblePoll","clearInterval","_resizePoll","clearTimeout","_scrollPoll","scrollContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQA,MAAM,QAAO,eAAe;AAEpC,SAAQC,IAAI,EAAEC,OAAO,QAAO,cAAc;AAE1C,SAAQC,mBAAmB,QAAO,oBAAoB;AAEtD,SAAQC,cAAc,EAAEC,WAAW,QAAO,iBAAiB;AAG3D,OAAOC,aAAa,eAAe;AAGnC,SAAQC,4BAA4B,EAAEC,uBAAuB,QAAO,0BAA0B;AAC9F,SAAQC,eAAe,QAAO,mBAAmB;AACjD,SAAQC,SAAS,QAAO,iBAAiB;AACzC,SAAQC,OAAO,QAAO,yBAAyB;AAC/C,SAAQC,UAAU,QAAO,4BAA4B;AAGrD;;;;AAIA,GACA,SAASC,oBAAoBC,IAAe,EAAEC,KAAa;IACxDD,KAAqCE,gBAAgB,GAAGD;IACzD,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"}
|
|
@@ -93,7 +93,10 @@ import { activeBucketColors } from "../features/colorScaleBucket.js";
|
|
|
93
93
|
var paint = _object_spread({}, (_node_paint = node.paint) !== null && _node_paint !== void 0 ? _node_paint : {});
|
|
94
94
|
var base = typeof paint.fill === "string" ? paint.fill : undefined;
|
|
95
95
|
if (!base || base === "transparent" || base === "none") base = typeof paint.stroke === "string" ? paint.stroke : undefined;
|
|
96
|
-
|
|
96
|
+
// No visible paint to emphasize (e.g. an invisible hit-area node): leave it
|
|
97
|
+
// untouched — darkening `transparent`/`none` would format to opaque black.
|
|
98
|
+
if (!base || base === "transparent" || base === "none") return node;
|
|
99
|
+
var c = color(base);
|
|
97
100
|
if (c) paint.stroke = c.darker(darken).formatHex();
|
|
98
101
|
var w = typeof paint.strokeWidth === "number" && paint.strokeWidth ? paint.strokeWidth : 1;
|
|
99
102
|
paint.strokeWidth = w * widthMult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/viz/interactionOpacity.ts"],"sourcesContent":["/**\n `applyInteractionOpacity` — recomputes node alpha for hover/active state.\n\n v4 expresses hover/active dimming as `paint.opacity` on the scene node\n (see the `Paint` docs in @d3plus/render), not via DOM surgery. When a\n hover or active predicate is set, this walks the chart-cell nodes and\n returns clones of the non-matching ones with a reduced opacity, leaving\n the originals (and the un-dimmed nodes) untouched. With no predicate set\n it returns the input array unchanged, so normal renders pay nothing.\n*/\n\nimport {color, hsl} from \"d3-color\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport {activeBucketColors} from \"../features/colorScaleBucket.js\";\nimport type {VizInstance} from \"./vizTypes.js\";\n\ntype Predicate = (d: DataPoint, i: number) => boolean;\n\n/** z value that floats a hovered/highlighted node above its (z-less, i.e. 0) siblings. */\nconst HOVER_RAISE_Z = 1e6;\n\n/**\n De-emphasizes a paint color for `highlight` by stripping its chroma while\n keeping its lightness and alpha — so the highlighted series is the only\n color on the chart. Keeping lightness (rather than flattening to one gray)\n means a mark's label keeps the same contrast it was given, and a transparent\n fill (e.g. a legend hit-area rect) stays transparent instead of becoming a\n solid gray box. Unparseable values (`\"none\"`) are left untouched.\n*/\nfunction deemphasize(c: string): string {\n const h = hsl(c);\n if (Number.isNaN(h.l)) return c;\n h.s = 0;\n return `${h}`;\n}\n\n/** Scene mark types that carry a fill/stroke a hover/active emphasis applies to. */\nconst MARK_TYPES = new Set([\"rect\", \"circle\", \"line\", \"area\", \"path\"]);\n\n/**\n Emphasizes a matched mark's stroke on hover/active — the v3 `hoverStyle` /\n `activeStyle` look (a thicker, darker outline). v4 paints from the scene\n graph, so this reapplies it here: darken the fill by `darken` for the stroke\n and multiply the stroke width by `widthMult` (treating a 0/absent width as 1,\n matching the shape defaults). Non-mark nodes (labels, groups) are untouched.\n*/\nfunction emphasizeStroke(node: SceneNode, darken: number, widthMult: number): SceneNode {\n const paint = {...((node.paint ?? {}) as Record<string, unknown>)};\n let base = typeof paint.fill === \"string\" ? paint.fill : undefined;\n if (!base || base === \"transparent\" || base === \"none\")\n base = typeof paint.stroke === \"string\" ? paint.stroke : undefined;\n const c = base ? color(base) : null;\n if (c) paint.stroke = c.darker(darken).formatHex();\n const w = typeof paint.strokeWidth === \"number\" && paint.strokeWidth ? paint.strokeWidth : 1;\n paint.strokeWidth = w * widthMult;\n return {...node, paint} as SceneNode;\n}\n\n/**\n Reads the interaction predicate + treatment off a viz, or null when nothing\n is set. Precedence: transient `hover`, then `active`, then the standing\n `highlight`. `hover`/`active` dim non-matching marks by opacity; `highlight`\n grays them (the emphasis form), signalled by `gray`.\n*/\nfunction dimSettings(viz: VizInstance): {\n predicate: Predicate;\n dimOpacity: number;\n isHover: boolean;\n gray: boolean;\n kind: \"hover\" | \"active\" | \"highlight\";\n activePredicate: Predicate | null;\n} | null {\n const hover = typeof viz._hover === \"function\" ? (viz._hover as Predicate) : null;\n const active = typeof viz._active === \"function\" ? (viz._active as Predicate) : null;\n const highlight =\n typeof viz._highlight === \"function\" ? (viz._highlight as Predicate) : null;\n if (!hover && !active && !highlight) return null;\n const sc = (viz.schema.shapeConfig ?? {}) as Record<string, unknown>;\n let hoverOpacity = typeof sc.hoverOpacity === \"number\" ? sc.hoverOpacity : 0.5;\n const activeOpacity = typeof sc.activeOpacity === \"number\" ? sc.activeOpacity : 0.25;\n const gray = !hover && !active;\n // A colorScale bucket hover must dim the non-matching marks to read as a\n // highlight, even on charts (Geomap) that set hoverOpacity:1 to keep a plain\n // shape hover from dimming the map. Fall back to the default dim there.\n if (hover && viz._hoverBucket && hoverOpacity >= 1) hoverOpacity = 0.5;\n return {\n predicate: (hover ?? active ?? highlight) as Predicate,\n dimOpacity: hover ? hoverOpacity : active ? activeOpacity : 1,\n isHover: !!hover,\n gray,\n kind: hover ? \"hover\" : active ? \"active\" : \"highlight\",\n // The active predicate is exposed even when hover wins the dim pass, so a\n // node that is BOTH active and hovered keeps its (stronger) active stroke\n // instead of dropping to the thinner hover stroke.\n activePredicate: active,\n };\n}\n\n/**\n `applyColorScaleBucketOpacity` — dims the colorScale's sibling swatches on\n hover, the way `applyInteractionOpacity` dims chart marks and legend\n swatches. A swatch (and its label) is a `_isColorScaleBucket` node matched\n by its bucket COLOR, not by id/value — so this only touches those nodes and\n leaves the colorScale title/axis/gradient at full opacity. A swatch stays\n bright when its color is \"active\" (its range contains a datum matching the\n current hover); every other swatch dims. No-op when nothing is hovered.\n*/\nexport function applyColorScaleBucketOpacity(\n nodes: SceneNode[],\n viz: VizInstance,\n): SceneNode[] {\n const settings = dimSettings(viz);\n if (!settings) return nodes;\n const activeColors = activeBucketColors(viz, settings.predicate);\n if (!activeColors) return nodes;\n\n const walk = (node: SceneNode): SceneNode => {\n let next = node;\n // Unwrap the node's datum to the source row: the swatch label is a\n // double-wrapped TextBox node (label → shape-row → bucket).\n let src = node.datum as\n | (DataPoint & {__d3plus__?: boolean; data?: DataPoint; _isColorScaleBucket?: boolean; color?: unknown})\n | undefined;\n while (src && src.__d3plus__ && src.data) src = src.data as typeof src;\n if (src && src._isColorScaleBucket && !activeColors.has(src.color)) {\n const base =\n node.paint && typeof node.paint.opacity === \"number\" ? node.paint.opacity : 1;\n next = {...node, paint: {...(node.paint ?? {}), opacity: base * settings.dimOpacity}};\n }\n const kids = (next as {children?: SceneNode[]}).children;\n if (kids && kids.length) next = {...next, children: kids.map(walk)} as SceneNode;\n return next;\n };\n return nodes.map(walk);\n}\n\nexport function applyInteractionOpacity(\n nodes: SceneNode[],\n viz: VizInstance,\n): SceneNode[] {\n // Precedence (hover → active → highlight) and the dim-vs-gray treatment are\n // resolved once in dimSettings; picking one source avoids ambiguous\n // compounding when several are momentarily set.\n const settings = dimSettings(viz);\n if (!settings) return nodes;\n const {predicate, dimOpacity, isHover, gray, kind, activePredicate} = settings;\n\n const walk = (node: SceneNode): SceneNode => {\n // Axes and the timeline are chrome, not data marks — they keep full\n // opacity when a shape is hovered/selected (the whole subtree is tagged).\n const group = (node as {interactionGroup?: string}).interactionGroup;\n if (group === \"axis\" || group === \"timeline\") return node;\n let next = node;\n const datum = node.datum as (DataPoint & {data?: DataPoint; i?: number}) | undefined;\n if (datum) {\n // Mirror the renderer→handler bridge's one-level unwrap\n // (`rawDatum.data ?? rawDatum`) so the predicate sees the same row the\n // hover predicate was built from — for shape nodes the datum is already\n // the row; for label nodes it's the layout node whose `.data` is the row.\n const row = (datum.data ?? datum) as DataPoint;\n const i =\n typeof node.index === \"number\"\n ? node.index\n : typeof (row as {i?: number}).i === \"number\"\n ? (row as {i: number}).i\n : 0;\n if (!predicate!(row, i)) {\n const paint = (node.paint ?? {}) as Record<string, unknown>;\n if (gray) {\n // highlight: recolor the mark to the de-emphasis gray so the\n // highlighted series keeps the only color on the chart.\n const next2: Record<string, unknown> = {...paint};\n if (typeof paint.fill === \"string\") next2.fill = deemphasize(paint.fill);\n if (typeof paint.stroke === \"string\") next2.stroke = deemphasize(paint.stroke);\n next = {...node, paint: next2} as SceneNode;\n } else {\n const base = typeof paint.opacity === \"number\" ? paint.opacity : 1;\n next = {...node, paint: {...paint, opacity: base * dimOpacity}};\n }\n } else {\n // Matched (hovered / active / highlighted) mark. Restore the v3\n // hover/active emphasis — a thicker, darker stroke — on the mark shapes\n // (not labels/groups). Highlight keeps its color-vs-gray treatment and\n // adds no outline. An active node keeps the stronger active stroke even\n // while hovered, rather than dropping to the thinner hover stroke.\n if (kind !== \"highlight\" && MARK_TYPES.has(node.type)) {\n const active = kind === \"active\" || (activePredicate?.(row, i) ?? false);\n next = active ? emphasizeStroke(node, 1, 3) : emphasizeStroke(node, 0.5, 2);\n }\n if (isHover) {\n // Raise the hovered node above its siblings. Both renderers paint by\n // ascending `z`; restore is automatic — the next repaint rebuilds the\n // scene with no `z`. Only for hover: a matched mark's data label is a\n // separate (un-raised) node, so raising the mark would paint it over\n // its own label. Highlight relies on color-vs-gray, not z-order.\n next = {...next, z: HOVER_RAISE_Z} as SceneNode;\n }\n }\n }\n const kids = (next as {children?: SceneNode[]}).children;\n if (kids && kids.length) {\n next = {...next, children: kids.map(walk)} as SceneNode;\n }\n return next;\n };\n\n return nodes.map(walk);\n}\n"],"names":["color","hsl","activeBucketColors","HOVER_RAISE_Z","deemphasize","c","h","Number","isNaN","l","s","MARK_TYPES","Set","emphasizeStroke","node","darken","widthMult","paint","base","fill","undefined","stroke","darker","formatHex","w","strokeWidth","dimSettings","viz","hover","_hover","active","_active","highlight","_highlight","sc","schema","shapeConfig","hoverOpacity","activeOpacity","gray","_hoverBucket","predicate","dimOpacity","isHover","kind","activePredicate","applyColorScaleBucketOpacity","nodes","settings","activeColors","walk","next","src","datum","__d3plus__","data","_isColorScaleBucket","has","opacity","kids","children","length","map","applyInteractionOpacity","group","interactionGroup","row","i","index","next2","type","z"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;AASA,GAEA,SAAQA,KAAK,EAAEC,GAAG,QAAO,WAAW;AAKpC,SAAQC,kBAAkB,QA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AAIA;gBAAMS,UAAUD,KAAKG,GAAG,CAACZ;;QACtC;QACA,OAAOC;IACT;IAEA,OAAOJ,MAAMe,GAAG,CAACZ;AACnB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/viz/interactionOpacity.ts"],"sourcesContent":["/**\n `applyInteractionOpacity` — recomputes node alpha for hover/active state.\n\n v4 expresses hover/active dimming as `paint.opacity` on the scene node\n (see the `Paint` docs in @d3plus/render), not via DOM surgery. When a\n hover or active predicate is set, this walks the chart-cell nodes and\n returns clones of the non-matching ones with a reduced opacity, leaving\n the originals (and the un-dimmed nodes) untouched. With no predicate set\n it returns the input array unchanged, so normal renders pay nothing.\n*/\n\nimport {color, hsl} from \"d3-color\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport {activeBucketColors} from \"../features/colorScaleBucket.js\";\nimport type {VizInstance} from \"./vizTypes.js\";\n\ntype Predicate = (d: DataPoint, i: number) => boolean;\n\n/** z value that floats a hovered/highlighted node above its (z-less, i.e. 0) siblings. */\nconst HOVER_RAISE_Z = 1e6;\n\n/**\n De-emphasizes a paint color for `highlight` by stripping its chroma while\n keeping its lightness and alpha — so the highlighted series is the only\n color on the chart. Keeping lightness (rather than flattening to one gray)\n means a mark's label keeps the same contrast it was given, and a transparent\n fill (e.g. a legend hit-area rect) stays transparent instead of becoming a\n solid gray box. Unparseable values (`\"none\"`) are left untouched.\n*/\nfunction deemphasize(c: string): string {\n const h = hsl(c);\n if (Number.isNaN(h.l)) return c;\n h.s = 0;\n return `${h}`;\n}\n\n/** Scene mark types that carry a fill/stroke a hover/active emphasis applies to. */\nconst MARK_TYPES = new Set([\"rect\", \"circle\", \"line\", \"area\", \"path\"]);\n\n/**\n Emphasizes a matched mark's stroke on hover/active — the v3 `hoverStyle` /\n `activeStyle` look (a thicker, darker outline). v4 paints from the scene\n graph, so this reapplies it here: darken the fill by `darken` for the stroke\n and multiply the stroke width by `widthMult` (treating a 0/absent width as 1,\n matching the shape defaults). Non-mark nodes (labels, groups) are untouched.\n*/\nfunction emphasizeStroke(node: SceneNode, darken: number, widthMult: number): SceneNode {\n const paint = {...((node.paint ?? {}) as Record<string, unknown>)};\n let base = typeof paint.fill === \"string\" ? paint.fill : undefined;\n if (!base || base === \"transparent\" || base === \"none\")\n base = typeof paint.stroke === \"string\" ? paint.stroke : undefined;\n // No visible paint to emphasize (e.g. an invisible hit-area node): leave it\n // untouched — darkening `transparent`/`none` would format to opaque black.\n if (!base || base === \"transparent\" || base === \"none\") return node;\n const c = color(base);\n if (c) paint.stroke = c.darker(darken).formatHex();\n const w = typeof paint.strokeWidth === \"number\" && paint.strokeWidth ? paint.strokeWidth : 1;\n paint.strokeWidth = w * widthMult;\n return {...node, paint} as SceneNode;\n}\n\n/**\n Reads the interaction predicate + treatment off a viz, or null when nothing\n is set. Precedence: transient `hover`, then `active`, then the standing\n `highlight`. `hover`/`active` dim non-matching marks by opacity; `highlight`\n grays them (the emphasis form), signalled by `gray`.\n*/\nfunction dimSettings(viz: VizInstance): {\n predicate: Predicate;\n dimOpacity: number;\n isHover: boolean;\n gray: boolean;\n kind: \"hover\" | \"active\" | \"highlight\";\n activePredicate: Predicate | null;\n} | null {\n const hover = typeof viz._hover === \"function\" ? (viz._hover as Predicate) : null;\n const active = typeof viz._active === \"function\" ? (viz._active as Predicate) : null;\n const highlight =\n typeof viz._highlight === \"function\" ? (viz._highlight as Predicate) : null;\n if (!hover && !active && !highlight) return null;\n const sc = (viz.schema.shapeConfig ?? {}) as Record<string, unknown>;\n let hoverOpacity = typeof sc.hoverOpacity === \"number\" ? sc.hoverOpacity : 0.5;\n const activeOpacity = typeof sc.activeOpacity === \"number\" ? sc.activeOpacity : 0.25;\n const gray = !hover && !active;\n // A colorScale bucket hover must dim the non-matching marks to read as a\n // highlight, even on charts (Geomap) that set hoverOpacity:1 to keep a plain\n // shape hover from dimming the map. Fall back to the default dim there.\n if (hover && viz._hoverBucket && hoverOpacity >= 1) hoverOpacity = 0.5;\n return {\n predicate: (hover ?? active ?? highlight) as Predicate,\n dimOpacity: hover ? hoverOpacity : active ? activeOpacity : 1,\n isHover: !!hover,\n gray,\n kind: hover ? \"hover\" : active ? \"active\" : \"highlight\",\n // The active predicate is exposed even when hover wins the dim pass, so a\n // node that is BOTH active and hovered keeps its (stronger) active stroke\n // instead of dropping to the thinner hover stroke.\n activePredicate: active,\n };\n}\n\n/**\n `applyColorScaleBucketOpacity` — dims the colorScale's sibling swatches on\n hover, the way `applyInteractionOpacity` dims chart marks and legend\n swatches. A swatch (and its label) is a `_isColorScaleBucket` node matched\n by its bucket COLOR, not by id/value — so this only touches those nodes and\n leaves the colorScale title/axis/gradient at full opacity. A swatch stays\n bright when its color is \"active\" (its range contains a datum matching the\n current hover); every other swatch dims. No-op when nothing is hovered.\n*/\nexport function applyColorScaleBucketOpacity(\n nodes: SceneNode[],\n viz: VizInstance,\n): SceneNode[] {\n const settings = dimSettings(viz);\n if (!settings) return nodes;\n const activeColors = activeBucketColors(viz, settings.predicate);\n if (!activeColors) return nodes;\n\n const walk = (node: SceneNode): SceneNode => {\n let next = node;\n // Unwrap the node's datum to the source row: the swatch label is a\n // double-wrapped TextBox node (label → shape-row → bucket).\n let src = node.datum as\n | (DataPoint & {__d3plus__?: boolean; data?: DataPoint; _isColorScaleBucket?: boolean; color?: unknown})\n | undefined;\n while (src && src.__d3plus__ && src.data) src = src.data as typeof src;\n if (src && src._isColorScaleBucket && !activeColors.has(src.color)) {\n const base =\n node.paint && typeof node.paint.opacity === \"number\" ? node.paint.opacity : 1;\n next = {...node, paint: {...(node.paint ?? {}), opacity: base * settings.dimOpacity}};\n }\n const kids = (next as {children?: SceneNode[]}).children;\n if (kids && kids.length) next = {...next, children: kids.map(walk)} as SceneNode;\n return next;\n };\n return nodes.map(walk);\n}\n\nexport function applyInteractionOpacity(\n nodes: SceneNode[],\n viz: VizInstance,\n): SceneNode[] {\n // Precedence (hover → active → highlight) and the dim-vs-gray treatment are\n // resolved once in dimSettings; picking one source avoids ambiguous\n // compounding when several are momentarily set.\n const settings = dimSettings(viz);\n if (!settings) return nodes;\n const {predicate, dimOpacity, isHover, gray, kind, activePredicate} = settings;\n\n const walk = (node: SceneNode): SceneNode => {\n // Axes and the timeline are chrome, not data marks — they keep full\n // opacity when a shape is hovered/selected (the whole subtree is tagged).\n const group = (node as {interactionGroup?: string}).interactionGroup;\n if (group === \"axis\" || group === \"timeline\") return node;\n let next = node;\n const datum = node.datum as (DataPoint & {data?: DataPoint; i?: number}) | undefined;\n if (datum) {\n // Mirror the renderer→handler bridge's one-level unwrap\n // (`rawDatum.data ?? rawDatum`) so the predicate sees the same row the\n // hover predicate was built from — for shape nodes the datum is already\n // the row; for label nodes it's the layout node whose `.data` is the row.\n const row = (datum.data ?? datum) as DataPoint;\n const i =\n typeof node.index === \"number\"\n ? node.index\n : typeof (row as {i?: number}).i === \"number\"\n ? (row as {i: number}).i\n : 0;\n if (!predicate!(row, i)) {\n const paint = (node.paint ?? {}) as Record<string, unknown>;\n if (gray) {\n // highlight: recolor the mark to the de-emphasis gray so the\n // highlighted series keeps the only color on the chart.\n const next2: Record<string, unknown> = {...paint};\n if (typeof paint.fill === \"string\") next2.fill = deemphasize(paint.fill);\n if (typeof paint.stroke === \"string\") next2.stroke = deemphasize(paint.stroke);\n next = {...node, paint: next2} as SceneNode;\n } else {\n const base = typeof paint.opacity === \"number\" ? paint.opacity : 1;\n next = {...node, paint: {...paint, opacity: base * dimOpacity}};\n }\n } else {\n // Matched (hovered / active / highlighted) mark. Restore the v3\n // hover/active emphasis — a thicker, darker stroke — on the mark shapes\n // (not labels/groups). Highlight keeps its color-vs-gray treatment and\n // adds no outline. An active node keeps the stronger active stroke even\n // while hovered, rather than dropping to the thinner hover stroke.\n if (kind !== \"highlight\" && MARK_TYPES.has(node.type)) {\n const active = kind === \"active\" || (activePredicate?.(row, i) ?? false);\n next = active ? emphasizeStroke(node, 1, 3) : emphasizeStroke(node, 0.5, 2);\n }\n if (isHover) {\n // Raise the hovered node above its siblings. Both renderers paint by\n // ascending `z`; restore is automatic — the next repaint rebuilds the\n // scene with no `z`. Only for hover: a matched mark's data label is a\n // separate (un-raised) node, so raising the mark would paint it over\n // its own label. Highlight relies on color-vs-gray, not z-order.\n next = {...next, z: HOVER_RAISE_Z} as SceneNode;\n }\n }\n }\n const kids = (next as {children?: SceneNode[]}).children;\n if (kids && kids.length) {\n next = {...next, children: kids.map(walk)} as SceneNode;\n }\n return next;\n };\n\n return nodes.map(walk);\n}\n"],"names":["color","hsl","activeBucketColors","HOVER_RAISE_Z","deemphasize","c","h","Number","isNaN","l","s","MARK_TYPES","Set","emphasizeStroke","node","darken","widthMult","paint","base","fill","undefined","stroke","darker","formatHex","w","strokeWidth","dimSettings","viz","hover","_hover","active","_active","highlight","_highlight","sc","schema","shapeConfig","hoverOpacity","activeOpacity","gray","_hoverBucket","predicate","dimOpacity","isHover","kind","activePredicate","applyColorScaleBucketOpacity","nodes","settings","activeColors","walk","next","src","datum","__d3plus__","data","_isColorScaleBucket","has","opacity","kids","children","length","map","applyInteractionOpacity","group","interactionGroup","row","i","index","next2","type","z"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;AASA,GAEA,SAAQA,KAAK,EAAEC,GAAG,QAAO,WAAW;AAKpC,SAAQC,kBAAkB,QAAO,kCAAkC;AAKnE,wFAAwF,GACxF,IAAMC,gBAAgB;AAEtB;;;;;;;AAOA,GACA,SAASC,YAAYC,CAAS;IAC5B,IAAMC,IAAIL,IAAII;IACd,IAAIE,OAAOC,KAAK,CAACF,EAAEG,CAAC,GAAG,OAAOJ;IAC9BC,EAAEI,CAAC,GAAG;IACN,OAAO,AAAC,GAAI,OAAFJ;AACZ;AAEA,kFAAkF,GAClF,IAAMK,aAAa,IAAIC,IAAI;IAAC;IAAQ;IAAU;IAAQ;IAAQ;CAAO;AAErE;;;;;;AAMA,GACA,SAASC,gBAAgBC,I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AAK,UAAUkD,MAAMlD,IAAI,GAAGf,YAAYa,MAAME,IAAI;oBACvE,IAAI,OAAOF,MAAMI,MAAM,KAAK,UAAUgD,MAAMhD,MAAM,GAAGjB,YAAYa,MAAMI,MAAM;oBAC7E8B,OAAO,wCAAIrC;wBAAMG,OAAOoD;;gBAC1B,OAAO;oBACL,IAAMnD,OAAO,OAAOD,MAAMyC,OAAO,KAAK,WAAWzC,MAAMyC,OAAO,GAAG;oBACjEP,OAAO,wCAAIrC;wBAAMG,OAAO,wCAAIA;4BAAOyC,SAASxC,OAAOwB;;;gBACrD;YACF,OAAO;gBACL,gEAAgE;gBAChE,wEAAwE;gBACxE,uEAAuE;gBACvE,wEAAwE;gBACxE,mEAAmE;gBACnE,IAAIE,SAAS,eAAejC,WAAW8C,GAAG,CAAC3C,KAAKwD,IAAI,GAAG;;oBACrD,IAAMxC,SAASc,SAAS,qBAAaC,4BAAAA,sCAAAA,gBAAkBqB,KAAKC,yCAAM;oBAClEhB,OAAOrB,SAASjB,gBAAgBC,MAAM,GAAG,KAAKD,gBAAgBC,MAAM,KAAK;gBAC3E;gBACA,IAAI6B,SAAS;oBACX,qEAAqE;oBACrE,sEAAsE;oBACtE,sEAAsE;oBACtE,qEAAqE;oBACrE,iEAAiE;oBACjEQ,OAAO,wCAAIA;wBAAMoB,GAAGpE;;gBACtB;YACF;QACF;QACA,IAAMwD,OAAO,AAACR,KAAkCS,QAAQ;QACxD,IAAID,QAAQA,KAAKE,MAAM,EAAE;YACvBV,OAAO,wCAAIA;gBAAMS,UAAUD,KAAKG,GAAG,CAACZ;;QACtC;QACA,OAAOC;IACT;IAEA,OAAOJ,MAAMe,GAAG,CAACZ;AACnB"}
|
|
@@ -400,7 +400,10 @@ var vizSchema = [
|
|
|
400
400
|
}
|
|
401
401
|
};
|
|
402
402
|
var debouncedResize = debounce(applyResize, viz.schema.detectResizeDelay);
|
|
403
|
-
|
|
403
|
+
// Guarded so a chart can be constructed in an environment without a DOM (e.g.
|
|
404
|
+
// before `@d3plus/ssr` installs one). Auto-resize is a browser-only feature;
|
|
405
|
+
// when absent, `_resizeObserver` stays undefined and its call sites skip it.
|
|
406
|
+
viz._resizeObserver = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(function(entries) {
|
|
404
407
|
// The first real-size notification after `observe()` reports the
|
|
405
408
|
// container's settled layout size, which on an auto-sized chart often
|
|
406
409
|
// differs from the size the chart just measured pre-layout (the
|