@d3plus/core 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +947 -921
- package/es/src/charts/AreaPlot/index.js +2 -1
- package/es/src/charts/AreaPlot/index.js.map +1 -1
- package/es/src/charts/BarChart/index.js +3 -1
- package/es/src/charts/BarChart/index.js.map +1 -1
- package/es/src/charts/BoxWhisker/index.js +2 -1
- package/es/src/charts/BoxWhisker/index.js.map +1 -1
- package/es/src/charts/BumpChart/index.js +2 -1
- package/es/src/charts/BumpChart/index.js.map +1 -1
- package/es/src/charts/Geomap/index.js +2 -1
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/LinePlot/index.js +2 -1
- package/es/src/charts/LinePlot/index.js.map +1 -1
- package/es/src/charts/Matrix/index.js +1 -0
- package/es/src/charts/Matrix/index.js.map +1 -1
- package/es/src/charts/Network/index.js +2 -1
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/index.js +1 -0
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/index.js +1 -0
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +22 -12
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipelineDomains.js +3 -3
- package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
- package/es/src/charts/Plot/stackHelpers.js +128 -9
- package/es/src/charts/Plot/stackHelpers.js.map +1 -1
- package/es/src/charts/Radar/index.js +2 -1
- package/es/src/charts/Radar/index.js.map +1 -1
- package/es/src/charts/RadialMatrix/index.js +1 -0
- package/es/src/charts/RadialMatrix/index.js.map +1 -1
- package/es/src/charts/Rings/index.js +2 -1
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Sankey/index.js +2 -1
- package/es/src/charts/Sankey/index.js.map +1 -1
- package/es/src/charts/Tree/index.js +2 -1
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/index.js +1 -0
- package/es/src/charts/Treemap/index.js.map +1 -1
- package/es/src/charts/events/click.legend.js +1 -1
- package/es/src/charts/events/click.legend.js.map +1 -1
- package/es/src/charts/events/mousemove.legend.js +1 -1
- package/es/src/charts/events/mousemove.legend.js.map +1 -1
- package/es/src/charts/features/features.js +3 -3
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +1 -1
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/components/TextBox.js +21 -5
- package/es/src/components/TextBox.js.map +1 -1
- package/es/src/shapes/Circle.js +12 -4
- package/es/src/shapes/Circle.js.map +1 -1
- package/es/src/shapes/Image.js +2 -3
- package/es/src/shapes/Image.js.map +1 -1
- package/es/src/shapes/Shape.js +35 -36
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/buildLabelData.js +59 -4
- package/es/src/shapes/buildLabelData.js.map +1 -1
- package/es/src/shapes/sceneSort.js +304 -24
- package/es/src/shapes/sceneSort.js.map +1 -1
- package/es/src/shapes/shapeConfig.js.map +1 -1
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +10 -10
- package/types/src/charts/Plot/index.d.ts +22 -6
- package/types/src/charts/Plot/stackHelpers.d.ts +62 -4
- package/types/src/charts/viz/VizBase.d.ts +4 -4
- package/types/src/charts/viz/VizBaseConfig.d.ts +4 -3
- package/types/src/shapes/Image.d.ts +2 -3
- package/types/src/shapes/Shape.d.ts +0 -2
- package/types/src/shapes/sceneSort.d.ts +83 -8
- package/types/src/shapes/shapeConfig.d.ts +7 -0
- package/types/src/utils/D3plusConfig.d.ts +59 -14
- package/umd/d3plus-core.full.js +1911 -640
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +1192 -942
- package/umd/d3plus-core.js +585 -239
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +495 -367
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/viz/VizBaseConfig.ts"],"sourcesContent":["import {merge as arrayMerge} from \"d3-array\";\n\nimport {addToQueue, unique} from \"@d3plus/data\";\nimport {assign} from \"@d3plus/dom\";\nimport {fontFamilyStringify} from \"@d3plus/text\";\nimport type {DataPoint} from \"@d3plus/data\";\n\nimport {accessor, BaseClass, constant} from \"../../utils/index.js\";\n\n/**\n First half of the fluent config accessors shared by every Viz chart\n (`active` through `legendTooltip`). Split from `VizBase` purely so each\n file stays under the `max-lines` budget; the methods remain real prototype\n methods, so `BaseClass.config()` reflection and polymorphic `this` chaining\n are unchanged.\n*/\nexport default class VizBaseConfig extends BaseClass {\n // installFluent generates the config accessors (data, sum, x, …) and the\n // pipeline stamps derived `_`-prefixed state at runtime; the index signature\n // lets the chart code reach both through the type (same rationale as the\n // shape/component classes).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n\n /**\n The active callback function for highlighting shapes.\n*/\n active(\n _?: ((d: DataPoint, i: number) => boolean) | false,\n ): this | ((d: DataPoint, i: number) => boolean) | false {\n this._active = _;\n\n if (this.schema.shapeConfig.activeOpacity !== 1) {\n this._shapes.forEach((s: {active: (...args: unknown[]) => unknown}) => s.active(_));\n if (this.schema.legend) this._legendClass.active(_);\n // See hover(): scene-rendered charts dim via the scene's\n // interaction-opacity pass, so repaint to apply/clear active state.\n if (this._sceneRenderer) this._scheduleSceneRepaint();\n }\n\n return this;\n }\n\n /**\n Custom aggregation methods for each data key.\n*/\n aggs(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.aggs = assign(this.schema.aggs, _!)), this)\n : this.schema.aggs;\n }\n\n /**\n Sets text to be shown positioned absolute on top of the visualization in the bottom-right corner. This is most often used in Geomaps to display the copyright of map tiles. The text is rendered as HTML, so any valid HTML string will render as expected (eg. anchor links work).\n*/\n attribution(_?: string | boolean): this | string | boolean {\n return arguments.length\n ? ((this.schema.attribution = _), this)\n : this.schema.attribution;\n }\n\n /**\n Configuration object for the attribution style.\n*/\n attributionStyle(\n _?: Record<string, unknown>,\n ): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.attributionStyle = assign(this.schema.attributionStyle, _!)), this)\n : this.schema.attributionStyle;\n }\n\n /**\n Configuration object for the back button.\n*/\n backConfig(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.backConfig = assign(this.schema.backConfig, _!)), this)\n : this.schema.backConfig;\n }\n\n /**\n Defines the main color to be used for each data point in a visualization. Can be either an accessor function or a string key to reference in each data point. If a color value is returned, it will be used as is. If a string is returned, a unique color will be assigned based on the string.\n*/\n color(\n _?:\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | false,\n ):\n | this\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | false {\n return arguments.length\n ? ((this.schema.color = !_ || typeof _ === \"function\" ? _ : accessor(_)), this)\n : this.schema.color;\n }\n\n /**\n Defines the value to be used for a color scale. Can be either an accessor function or a string key to reference in each data point.\n*/\n colorScale(\n _?:\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | false,\n ):\n | this\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | false {\n return arguments.length\n ? ((this.schema.colorScale = !_ || typeof _ === \"function\" ? _ : accessor(_)),\n this)\n : this.schema.colorScale;\n }\n\n /**\n A pass-through to the config method of ColorScale.\n*/\n colorScaleConfig(\n _?: Record<string, unknown>,\n ): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.colorScaleConfig = assign(this.schema.colorScaleConfig, _!)), this)\n : this.schema.colorScaleConfig;\n }\n\n /**\n Tells the colorScale whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the colorScale appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.\n*/\n colorScalePadding(\n _?: boolean | (() => boolean),\n ): this | boolean | (() => boolean) {\n return arguments.length\n ? ((this.schema.colorScalePadding = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.colorScalePadding;\n }\n\n /**\n Defines which side of the visualization to anchor the color scale. Acceptable values are `\"top\"`, `\"bottom\"`, `\"left\"`, `\"right\"`, and `false`. A `false` value will cause the color scale to not be displayed, but will still color shapes based on the scale.\n*/\n colorScalePosition(\n _?: string | boolean | (() => string | boolean),\n ): this | string | boolean | (() => string | boolean) {\n return arguments.length\n ? ((this.schema.colorScalePosition = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.colorScalePosition;\n }\n\n /**\n The maximum pixel size for drawing the color scale: width for horizontal scales and height for vertical scales.\n*/\n colorScaleMaxSize(_?: number): this | number {\n return arguments.length\n ? ((this.schema.colorScaleMaxSize = _), this)\n : this.schema.colorScaleMaxSize;\n }\n\n /**\n The primary data array used to draw the visualization. The value passed should be an *Array* of objects or a *String* representing a filepath or URL to be loaded. The following filetypes are supported: `csv`, `tsv`, `txt`, and `json`.\n\nIf your data URL needs specific headers to be set, an Object with \"url\" and \"headers\" keys may also be passed.\n\nAdditionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final array of obejcts to be used as the primary data array. For example, some JSON APIs return the headers split from the data values to save bandwidth. These would need be joined using a custom formatter.\n\nIf you would like to specify certain configuration options based on the yet-to-be-loaded data, you can also return a full `config` object from the data formatter (including the new `data` array as a key in the object).\n\nDefaults to an empty array (`[]`).\n @param f The data array or a URL string to load data from.\n */\n data(\n _?: DataPoint[] | string | {url: string; headers: Record<string, string>},\n f?: (data: DataPoint[]) => DataPoint[] | Record<string, unknown>,\n ): this | DataPoint[] {\n if (arguments.length) {\n addToQueue.bind(this as unknown as ThisParameterType<typeof addToQueue>)(\n _!,\n f,\n \"data\",\n );\n this._hidden = [];\n this._solo = [];\n if (\n this._userData &&\n JSON.stringify(_) !== JSON.stringify(this._userData)\n ) {\n this.schema.timeFilter = false;\n this._timelineSelection = false;\n }\n this._userData = _;\n return this;\n }\n return this._data;\n }\n\n /**\n If the width and/or height of a Viz is not user-defined, it is determined by the size of it's parent element. When this method is set to `true`, the Viz will listen for the `window.onresize` event and adjust it's dimensions accordingly.\n*/\n detectResize(_?: boolean): this | boolean {\n return arguments.length\n ? ((this.schema.detectResize = _), this)\n : this.schema.detectResize;\n }\n\n /**\n When resizing the browser window, this is the millisecond delay to trigger the resize event.\n*/\n detectResizeDelay(_?: number): this | number {\n return arguments.length\n ? ((this.schema.detectResizeDelay = _), this)\n : this.schema.detectResizeDelay;\n }\n\n /**\n Toggles whether or not the Viz should try to detect if it visible in the current viewport. When this method is set to `true`, the Viz will only be rendered when it has entered the viewport either through scrolling or if it's display or visibility is changed.\n*/\n detectVisible(_?: boolean): this | boolean {\n return arguments.length\n ? ((this.schema.detectVisible = _), this)\n : this.schema.detectVisible;\n }\n\n /**\n The interval, in milliseconds, for checking if the visualization is visible on the page.\n*/\n detectVisibleInterval(_?: number): this | number {\n return arguments.length\n ? ((this.schema.detectVisibleInterval = _), this)\n : this.schema.detectVisibleInterval;\n }\n\n /**\n Shows a button that allows for downloading the current visualization.\n*/\n downloadButton(_?: boolean): this | boolean {\n return arguments.length\n ? ((this.schema.downloadButton = _), this)\n : this.schema.downloadButton;\n }\n\n /**\n Sets specific options of the saveElement function used when downloading the visualization.\n*/\n downloadConfig(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.downloadConfig = assign(this.schema.downloadConfig, _!)), this)\n : this.schema.downloadConfig;\n }\n\n /**\n Defines which control group to add the download button into.\n*/\n downloadPosition(_?: string): this | string {\n return arguments.length\n ? ((this.schema.downloadPosition = _), this)\n : this.schema.downloadPosition;\n }\n\n /**\n The font family used throughout the visualization.\n*/\n fontFamily(_?: string | string[]): this | string | string[] {\n if (arguments.length) {\n const labelConfig = {fontFamily: _};\n\n const axisConfig = {titleConfig: labelConfig, shapeConfig: {labelConfig}};\n\n this.shapeConfig({labelConfig});\n this.colorScaleConfig({axisConfig});\n\n [\"axis\", \"column\", \"row\", \"timeline\", \"x\", \"y\", \"x2\", \"y2\"].forEach(\n (axis: string) => {\n const method = `${axis}Config`;\n if (this[method]) this[method](axisConfig);\n },\n );\n [\"back\", \"title\", \"total\", \"subtitle\"].forEach((label: string) => {\n const method = `${label}Config`;\n if (this[method]) this[method](labelConfig);\n });\n\n this.tooltipConfig({\n tooltipStyle: {\"font-family\": fontFamilyStringify(_!)},\n });\n\n this.schema.fontFamily = _;\n return this;\n }\n return this.schema.fontFamily;\n }\n\n /**\n Defines the mapping between data and shape. The value can be a String matching a key in each data point (default is \"id\"), or an accessor Function that returns a unique value for each data point. Additionally, an Array of these values may be provided if the visualization supports nested hierarchies.\n*/\n groupBy(\n _?:\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | (string | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint]))[],\n ): this | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])[] {\n if (!arguments.length) return this.schema.groupBy;\n this._groupByRaw = _;\n const arr: (string | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint]))[] =\n _ instanceof Array ? _ : [_!];\n return (\n (this.schema.groupBy = arr.map(\n (\n k: string | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint]),\n ) => {\n if (typeof k === \"function\") return k;\n else {\n if (!this.schema.aggs[k]) {\n this.schema.aggs[k] = (\n a: DataPoint[],\n c: (d: DataPoint) => DataPoint[keyof DataPoint],\n ) => {\n const v = unique(a.map(c));\n return v.length === 1 ? v[0] : v;\n };\n }\n return accessor(k);\n }\n },\n )),\n this\n );\n }\n\n /**\n Defines the color used for legend shapes when the corresponding grouping is hidden from display (by clicking on the legend).\n*/\n hiddenColor(\n _?: string | ((d: DataPoint, i: number) => string),\n ): this | string | ((d: DataPoint, i: number) => string) {\n return arguments.length\n ? ((this.schema.hiddenColor = typeof _ === \"function\" ? _ : constant(_)), this)\n : this.schema.hiddenColor;\n }\n\n /**\n Defines the opacity used for legend labels when the corresponding grouping is hidden from display (by clicking on the legend).\n*/\n hiddenOpacity(\n _?: number | ((d: DataPoint, i: number) => number),\n ): this | number | ((d: DataPoint, i: number) => number) {\n return arguments.length\n ? ((this.schema.hiddenOpacity = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.hiddenOpacity;\n }\n\n /**\n The hover callback function for highlighting shapes on mouseover.\n*/\n hover(_?: ((d: DataPoint, i: number) => boolean) | false): this {\n let hoverFunction = (this._hover = _);\n\n if (this.schema.shapeConfig.hoverOpacity !== 1 && _ !== undefined) {\n if (typeof _ === \"function\") {\n let shapeData = arrayMerge(\n this._shapes.map((s: {data: () => DataPoint[]}) => s.data()),\n );\n shapeData = shapeData.concat(this._legendClass.data());\n const activeData = _ ? (shapeData as DataPoint[]).filter(_ as (d: DataPoint) => boolean) : [];\n\n // Build a Set<string> of activeIds for O(1) membership lookup.\n // Previously `activeIds.filter((id, i) => activeIds.indexOf(id) === i)`\n // was O(N²) dedup, and the hover predicate did `activeIds.includes(...)`\n // — also O(N) per datum per repaint. With ~5k segments, hover\n // dispatch was ~250 ms on a 2023 laptop; Set drops it to <5 ms.\n const activeIds = new Set<string>();\n (activeData.map(this._ids) as string[][]).forEach((ids: string[]) => {\n for (let x = 1; x <= ids.length; x++) {\n activeIds.add(JSON.stringify(ids.slice(0, x)));\n }\n });\n\n if (activeIds.size)\n hoverFunction = (d: DataPoint, i: number) =>\n activeIds.has(JSON.stringify(this._ids(d, i)));\n }\n\n this._shapes.forEach((s: {hover: (...args: unknown[]) => unknown}) => s.hover(hoverFunction));\n if (this.schema.legend) this._legendClass.hover(hoverFunction);\n }\n\n // Scene-rendered charts emit into `_chartScene` (not `_shapes`), so the\n // forEach above is a no-op for them. Repaint so the scene's\n // interaction-opacity pass re-reads `_hover` and dims the non-matching\n // nodes (or restores them when `_` is `false`). Also repaint for a\n // colorScale-bucket hover even when per-shape dimming is off\n // (`hoverOpacity: 1`, e.g. Geomap): the bucket highlight is applied by that\n // same pass, so without a repaint the map would never re-compose. Coalesced\n // to one paint per frame so a fast pointer sweep doesn't saturate the main\n // thread.\n if (\n this._sceneRenderer &&\n _ !== undefined &&\n (this.schema.shapeConfig.hoverOpacity !== 1 || this._hoverBucket)\n )\n this._scheduleSceneRepaint();\n\n return this;\n }\n\n /**\n Persistently emphasizes the data points matching the given predicate: the\n matching marks keep their color while every other mark is de-emphasized to\n a neutral gray (the \"emphasis\" form — highlight one series, gray the rest).\n Unlike `hover`/`active` (transient, opacity-based), `highlight` is a\n standing state that survives pointer movement. Pass `false` to clear it.\n*/\n highlight(\n _?: ((d: DataPoint, i: number) => boolean) | false,\n ): this | ((d: DataPoint, i: number) => boolean) | false | undefined {\n if (!arguments.length) return this._highlight;\n this._highlight = _;\n // Scene-rendered charts express de-emphasis via the scene's\n // interaction-opacity pass, so repaint to apply/clear the gray treatment.\n if (this._sceneRenderer) this._scheduleSceneRepaint();\n return this;\n }\n\n /**\n Accessor function or string key for the label of each data point.\n*/\n label(\n _?: string | ((d: DataPoint, i: number) => string),\n ): this | string | ((d: DataPoint, i: number) => string) {\n return arguments.length\n ? ((this.schema.label = typeof _ === \"function\" ? _ : constant(_)), this)\n : this.schema.label;\n }\n\n /**\n Whether to display the legend.\n*/\n legend(\n _?:\n | boolean\n | ((config: Record<string, unknown>, arr: DataPoint[]) => boolean),\n ):\n | this\n | boolean\n | ((config: Record<string, unknown>, arr: DataPoint[]) => boolean) {\n return arguments.length\n ? ((this.schema.legend = typeof _ === \"function\" ? _ : constant(_)), this)\n : this.schema.legend;\n }\n\n /**\n Configuration object passed to the legend's config method.\n*/\n legendConfig(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.legendConfig = assign(this.schema.legendConfig, _!)), this)\n : this.schema.legendConfig;\n }\n\n /**\n Defines the click functionality of categorical legend squares. When set to false, clicking will hide that category and shift+clicking will solo that category. When set to true, clicking with solo that category and shift+clicking will hide that category.\n*/\n legendFilterInvert(\n _?: boolean | (() => boolean),\n ): this | boolean | (() => boolean) {\n return arguments.length\n ? ((this.schema.legendFilterInvert = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.legendFilterInvert;\n }\n\n /**\n Tells the legend whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the legend appears centered underneath the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.\n*/\n legendPadding(\n _?: boolean | (() => boolean),\n ): this | boolean | (() => boolean) {\n return arguments.length\n ? ((this.schema.legendPadding = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.legendPadding;\n }\n\n /**\n Defines which side of the visualization to anchor the legend. Expected values are `\"top\"`, `\"bottom\"`, `\"left\"`, and `\"right\"`.\n*/\n legendPosition(_?: string | (() => string)): this | string | (() => string) {\n return arguments.length\n ? ((this.schema.legendPosition = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.legendPosition;\n }\n\n /**\n Configuration object for the legend tooltip.\n*/\n legendTooltip(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.legendTooltip = assign(this.schema.legendTooltip, _!)), this)\n : this.schema.legendTooltip;\n }\n}\n"],"names":["merge","arrayMerge","addToQueue","unique","assign","fontFamilyStringify","accessor","BaseClass","constant","VizBaseConfig","active","_","_active","schema","shapeConfig","activeOpacity","_shapes","forEach","s","legend","_legendClass","_sceneRenderer","_scheduleSceneRepaint","aggs","arguments","length","attribution","attributionStyle","backConfig","color","colorScale","colorScaleConfig","colorScalePadding","colorScalePosition","colorScaleMaxSize","data","f","bind","_hidden","_solo","_userData","JSON","stringify","timeFilter","_timelineSelection","_data","detectResize","detectResizeDelay","detectVisible","detectVisibleInterval","downloadButton","downloadConfig","downloadPosition","fontFamily","labelConfig","axisConfig","titleConfig","axis","method","label","tooltipConfig","tooltipStyle","groupBy","_groupByRaw","arr","Array","map","k","a","c","v","hiddenColor","hiddenOpacity","hover","hoverFunction","_hover","hoverOpacity","undefined","shapeData","concat","activeData","filter","activeIds","Set","_ids","ids","x","add","slice","size","d","i","has","_hoverBucket","highlight","_highlight","legendConfig","legendFilterInvert","legendPadding","legendPosition","legendTooltip"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQA,SAASC,UAAU,QAAO,WAAW;AAE7C,SAAQC,UAAU,EAAEC,MAAM,QAAO,eAAe;AAChD,SAAQC,MAAM,QAAO,cAAc;AACnC,SAAQC,mBAAmB,QAAO,eAAe;AAGjD,SAAQC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAO,uBAAuB;AASpD,IAAA,AAAMC,8BAAN;;cAAMA;aAAAA;gCAAAA;QAAN,OAAA,kBAAMA;;kBAAAA;;YAQnB;;AAEF,GACEC,KAAAA;mBAAAA,SAAAA,OACEC,CAAkD;gBAElD,IAAI,CAACC,OAAO,GAAGD;gBAEf,IAAI,IAAI,CAACE,MAAM,CAACC,WAAW,CAACC,aAAa,KAAK,GAAG;oBAC/C,IAAI,CAACC,OAAO,CAACC,OAAO,CAAC,SAACC;+BAAiDA,EAAER,MAAM,CAACC;;oBAChF,IAAI,IAAI,CAACE,MAAM,CAACM,MAAM,EAAE,IAAI,CAACC,YAAY,CAACV,MAAM,CAACC;oBACjD,yDAAyD;oBACzD,oEAAoE;oBACpE,IAAI,IAAI,CAACU,cAAc,EAAE,IAAI,CAACC,qBAAqB;gBACrD;gBAEA,OAAO,IAAI;YACb;;;YAEA;;AAEF,GACEC,KAAAA;mBAAAA,SAAAA,KAAKZ,CAA2B;gBAC9B,OAAOa,UAAUC,MAAM,GAClB,CAAA,AAAC,IAAI,CAACZ,MAAM,CAACU,IAAI,GAAGnB,OAAO,IAAI,CAACS,MAAM,CAACU,IAAI,EAAEZ,IAAM,IAAI,AAAD,IACvD,IAAI,CAACE,MAAM,CAACU,IAAI;Y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;;WAxemB3F;EAAsBF;AAP3C;;;;;;AAMA,GACA,SAAqBE,2BAyepB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/viz/VizBaseConfig.ts"],"sourcesContent":["import {merge as arrayMerge} from \"d3-array\";\n\nimport {addToQueue, unique} from \"@d3plus/data\";\nimport {assign} from \"@d3plus/dom\";\nimport {fontFamilyStringify} from \"@d3plus/text\";\nimport type {DataPoint} from \"@d3plus/data\";\n\nimport {accessor, BaseClass, constant} from \"../../utils/index.js\";\nimport type VizBase from \"./VizBase.js\";\n\n/**\n First half of the fluent config accessors shared by every Viz chart\n (`active` through `legendTooltip`). Split from `VizBase` purely so each\n file stays under the `max-lines` budget; the methods remain real prototype\n methods, so `BaseClass.config()` reflection and polymorphic `this` chaining\n are unchanged.\n*/\nexport default class VizBaseConfig extends BaseClass {\n // installFluent generates the config accessors (data, sum, x, …) and the\n // pipeline stamps derived `_`-prefixed state at runtime; the index signature\n // lets the chart code reach both through the type (same rationale as the\n // shape/component classes).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n\n /**\n The active callback function for highlighting shapes.\n*/\n active(\n _?: ((d: DataPoint, i: number) => boolean) | false,\n ): this | ((d: DataPoint, i: number) => boolean) | false {\n this._active = _;\n\n if (this.schema.shapeConfig.activeOpacity !== 1) {\n this._shapes.forEach((s: {active: (...args: unknown[]) => unknown}) => s.active(_));\n if (this.schema.legend) this._legendClass.active(_);\n // See hover(): scene-rendered charts dim via the scene's\n // interaction-opacity pass, so repaint to apply/clear active state.\n if (this._sceneRenderer) this._scheduleSceneRepaint();\n }\n\n return this;\n }\n\n /**\n Custom aggregation methods for each data key.\n*/\n aggs(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.aggs = assign(this.schema.aggs, _!)), this)\n : this.schema.aggs;\n }\n\n /**\n Sets text to be shown positioned absolute on top of the visualization in the bottom-right corner. This is most often used in Geomaps to display the copyright of map tiles. The text is rendered as HTML, so any valid HTML string will render as expected (eg. anchor links work).\n*/\n attribution(_?: string | boolean): this | string | boolean {\n return arguments.length\n ? ((this.schema.attribution = _), this)\n : this.schema.attribution;\n }\n\n /**\n Configuration object for the attribution style.\n*/\n attributionStyle(\n _?: Record<string, unknown>,\n ): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.attributionStyle = assign(this.schema.attributionStyle, _!)), this)\n : this.schema.attributionStyle;\n }\n\n /**\n Configuration object for the back button.\n*/\n backConfig(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.backConfig = assign(this.schema.backConfig, _!)), this)\n : this.schema.backConfig;\n }\n\n /**\n Defines the main color to be used for each data point in a visualization. Can be either an accessor function or a string key to reference in each data point. If a color value is returned, it will be used as is. If a string is returned, a unique color will be assigned based on the string.\n*/\n color(\n _?:\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | false,\n ):\n | this\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | false {\n return arguments.length\n ? ((this.schema.color = !_ || typeof _ === \"function\" ? _ : accessor(_)), this)\n : this.schema.color;\n }\n\n /**\n Defines the value to be used for a color scale. Can be either an accessor function or a string key to reference in each data point.\n*/\n colorScale(\n _?:\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | false,\n ):\n | this\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | false {\n return arguments.length\n ? ((this.schema.colorScale = !_ || typeof _ === \"function\" ? _ : accessor(_)),\n this)\n : this.schema.colorScale;\n }\n\n /**\n A pass-through to the config method of ColorScale.\n*/\n colorScaleConfig(\n _?: Record<string, unknown>,\n ): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.colorScaleConfig = assign(this.schema.colorScaleConfig, _!)), this)\n : this.schema.colorScaleConfig;\n }\n\n /**\n Tells the colorScale whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the colorScale appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.\n*/\n colorScalePadding(\n _?: boolean | ((viz: VizBase) => boolean),\n ): this | boolean | ((viz: VizBase) => boolean) {\n return arguments.length\n ? ((this.schema.colorScalePadding = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.colorScalePadding;\n }\n\n /**\n Defines which side of the visualization to anchor the color scale. Acceptable values are `\"top\"`, `\"bottom\"`, `\"left\"`, `\"right\"`, and `false`. A `false` value will cause the color scale to not be displayed, but will still color shapes based on the scale.\n*/\n colorScalePosition(\n _?: string | boolean | (() => string | boolean),\n ): this | string | boolean | (() => string | boolean) {\n return arguments.length\n ? ((this.schema.colorScalePosition = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.colorScalePosition;\n }\n\n /**\n The maximum pixel size for drawing the color scale: width for horizontal scales and height for vertical scales.\n*/\n colorScaleMaxSize(_?: number): this | number {\n return arguments.length\n ? ((this.schema.colorScaleMaxSize = _), this)\n : this.schema.colorScaleMaxSize;\n }\n\n /**\n The primary data array used to draw the visualization. The value passed should be an *Array* of objects or a *String* representing a filepath or URL to be loaded. The following filetypes are supported: `csv`, `tsv`, `txt`, and `json`.\n\nIf your data URL needs specific headers to be set, an Object with \"url\" and \"headers\" keys may also be passed.\n\nAdditionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final array of obejcts to be used as the primary data array. For example, some JSON APIs return the headers split from the data values to save bandwidth. These would need be joined using a custom formatter.\n\nIf you would like to specify certain configuration options based on the yet-to-be-loaded data, you can also return a full `config` object from the data formatter (including the new `data` array as a key in the object).\n\nDefaults to an empty array (`[]`).\n @param f The data array or a URL string to load data from.\n */\n data(\n _?: DataPoint[] | string | {url: string; headers: Record<string, string>},\n f?: (data: DataPoint[]) => DataPoint[] | Record<string, unknown>,\n ): this | DataPoint[] {\n if (arguments.length) {\n addToQueue.bind(this as unknown as ThisParameterType<typeof addToQueue>)(\n _!,\n f,\n \"data\",\n );\n this._hidden = [];\n this._solo = [];\n if (\n this._userData &&\n JSON.stringify(_) !== JSON.stringify(this._userData)\n ) {\n this.schema.timeFilter = false;\n this._timelineSelection = false;\n }\n this._userData = _;\n return this;\n }\n return this._data;\n }\n\n /**\n If the width and/or height of a Viz is not user-defined, it is determined by the size of it's parent element. When this method is set to `true`, the Viz will listen for the `window.onresize` event and adjust it's dimensions accordingly.\n*/\n detectResize(_?: boolean): this | boolean {\n return arguments.length\n ? ((this.schema.detectResize = _), this)\n : this.schema.detectResize;\n }\n\n /**\n When resizing the browser window, this is the millisecond delay to trigger the resize event.\n*/\n detectResizeDelay(_?: number): this | number {\n return arguments.length\n ? ((this.schema.detectResizeDelay = _), this)\n : this.schema.detectResizeDelay;\n }\n\n /**\n Toggles whether or not the Viz should try to detect if it visible in the current viewport. When this method is set to `true`, the Viz will only be rendered when it has entered the viewport either through scrolling or if it's display or visibility is changed.\n*/\n detectVisible(_?: boolean): this | boolean {\n return arguments.length\n ? ((this.schema.detectVisible = _), this)\n : this.schema.detectVisible;\n }\n\n /**\n The interval, in milliseconds, for checking if the visualization is visible on the page.\n*/\n detectVisibleInterval(_?: number): this | number {\n return arguments.length\n ? ((this.schema.detectVisibleInterval = _), this)\n : this.schema.detectVisibleInterval;\n }\n\n /**\n Shows a button that allows for downloading the current visualization.\n*/\n downloadButton(_?: boolean): this | boolean {\n return arguments.length\n ? ((this.schema.downloadButton = _), this)\n : this.schema.downloadButton;\n }\n\n /**\n Sets specific options of the saveElement function used when downloading the visualization.\n*/\n downloadConfig(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.downloadConfig = assign(this.schema.downloadConfig, _!)), this)\n : this.schema.downloadConfig;\n }\n\n /**\n Defines which control group to add the download button into.\n*/\n downloadPosition(_?: string): this | string {\n return arguments.length\n ? ((this.schema.downloadPosition = _), this)\n : this.schema.downloadPosition;\n }\n\n /**\n The font family used throughout the visualization.\n*/\n fontFamily(_?: string | string[]): this | string | string[] {\n if (arguments.length) {\n const labelConfig = {fontFamily: _};\n\n const axisConfig = {titleConfig: labelConfig, shapeConfig: {labelConfig}};\n\n this.shapeConfig({labelConfig});\n this.colorScaleConfig({axisConfig});\n\n [\"axis\", \"column\", \"row\", \"timeline\", \"x\", \"y\", \"x2\", \"y2\"].forEach(\n (axis: string) => {\n const method = `${axis}Config`;\n if (this[method]) this[method](axisConfig);\n },\n );\n [\"back\", \"title\", \"total\", \"subtitle\"].forEach((label: string) => {\n const method = `${label}Config`;\n if (this[method]) this[method](labelConfig);\n });\n\n this.tooltipConfig({\n tooltipStyle: {\"font-family\": fontFamilyStringify(_!)},\n });\n\n this.schema.fontFamily = _;\n return this;\n }\n return this.schema.fontFamily;\n }\n\n /**\n Defines the mapping between data and shape. The value can be a String matching a key in each data point (default is \"id\"), or an accessor Function that returns a unique value for each data point. Additionally, an Array of these values may be provided if the visualization supports nested hierarchies.\n*/\n groupBy(\n _?:\n | string\n | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])\n | (string | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint]))[],\n ): this | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint])[] {\n if (!arguments.length) return this.schema.groupBy;\n this._groupByRaw = _;\n const arr: (string | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint]))[] =\n _ instanceof Array ? _ : [_!];\n return (\n (this.schema.groupBy = arr.map(\n (\n k: string | ((d: DataPoint, i: number) => DataPoint[keyof DataPoint]),\n ) => {\n if (typeof k === \"function\") return k;\n else {\n if (!this.schema.aggs[k]) {\n this.schema.aggs[k] = (\n a: DataPoint[],\n c: (d: DataPoint) => DataPoint[keyof DataPoint],\n ) => {\n const v = unique(a.map(c));\n return v.length === 1 ? v[0] : v;\n };\n }\n return accessor(k);\n }\n },\n )),\n this\n );\n }\n\n /**\n Defines the color used for legend shapes when the corresponding grouping is hidden from display (by clicking on the legend).\n*/\n hiddenColor(\n _?: string | ((d: DataPoint, i: number) => string),\n ): this | string | ((d: DataPoint, i: number) => string) {\n return arguments.length\n ? ((this.schema.hiddenColor = typeof _ === \"function\" ? _ : constant(_)), this)\n : this.schema.hiddenColor;\n }\n\n /**\n Defines the opacity used for legend labels when the corresponding grouping is hidden from display (by clicking on the legend).\n*/\n hiddenOpacity(\n _?: number | ((d: DataPoint, i: number) => number),\n ): this | number | ((d: DataPoint, i: number) => number) {\n return arguments.length\n ? ((this.schema.hiddenOpacity = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.hiddenOpacity;\n }\n\n /**\n The hover callback function for highlighting shapes on mouseover.\n*/\n hover(_?: ((d: DataPoint, i: number) => boolean) | false): this {\n let hoverFunction = (this._hover = _);\n\n if (this.schema.shapeConfig.hoverOpacity !== 1 && _ !== undefined) {\n if (typeof _ === \"function\") {\n let shapeData = arrayMerge(\n this._shapes.map((s: {data: () => DataPoint[]}) => s.data()),\n );\n shapeData = shapeData.concat(this._legendClass.data());\n const activeData = _ ? (shapeData as DataPoint[]).filter(_ as (d: DataPoint) => boolean) : [];\n\n // Build a Set<string> of activeIds for O(1) membership lookup.\n // Previously `activeIds.filter((id, i) => activeIds.indexOf(id) === i)`\n // was O(N²) dedup, and the hover predicate did `activeIds.includes(...)`\n // — also O(N) per datum per repaint. With ~5k segments, hover\n // dispatch was ~250 ms on a 2023 laptop; Set drops it to <5 ms.\n const activeIds = new Set<string>();\n (activeData.map(this._ids) as string[][]).forEach((ids: string[]) => {\n for (let x = 1; x <= ids.length; x++) {\n activeIds.add(JSON.stringify(ids.slice(0, x)));\n }\n });\n\n if (activeIds.size)\n hoverFunction = (d: DataPoint, i: number) =>\n activeIds.has(JSON.stringify(this._ids(d, i)));\n }\n\n this._shapes.forEach((s: {hover: (...args: unknown[]) => unknown}) => s.hover(hoverFunction));\n if (this.schema.legend) this._legendClass.hover(hoverFunction);\n }\n\n // Scene-rendered charts emit into `_chartScene` (not `_shapes`), so the\n // forEach above is a no-op for them. Repaint so the scene's\n // interaction-opacity pass re-reads `_hover` and dims the non-matching\n // nodes (or restores them when `_` is `false`). Also repaint for a\n // colorScale-bucket hover even when per-shape dimming is off\n // (`hoverOpacity: 1`, e.g. Geomap): the bucket highlight is applied by that\n // same pass, so without a repaint the map would never re-compose. Coalesced\n // to one paint per frame so a fast pointer sweep doesn't saturate the main\n // thread.\n if (\n this._sceneRenderer &&\n _ !== undefined &&\n (this.schema.shapeConfig.hoverOpacity !== 1 || this._hoverBucket)\n )\n this._scheduleSceneRepaint();\n\n return this;\n }\n\n /**\n Persistently emphasizes the data points matching the given predicate: the\n matching marks keep their color while every other mark is de-emphasized to\n a neutral gray (the \"emphasis\" form — highlight one series, gray the rest).\n Unlike `hover`/`active` (transient, opacity-based), `highlight` is a\n standing state that survives pointer movement. Pass `false` to clear it.\n*/\n highlight(\n _?: ((d: DataPoint, i: number) => boolean) | false,\n ): this | ((d: DataPoint, i: number) => boolean) | false | undefined {\n if (!arguments.length) return this._highlight;\n this._highlight = _;\n // Scene-rendered charts express de-emphasis via the scene's\n // interaction-opacity pass, so repaint to apply/clear the gray treatment.\n if (this._sceneRenderer) this._scheduleSceneRepaint();\n return this;\n }\n\n /**\n Accessor function or string key for the label of each data point.\n*/\n label(\n _?: string | ((d: DataPoint, i: number) => string),\n ): this | string | ((d: DataPoint, i: number) => string) {\n return arguments.length\n ? ((this.schema.label = typeof _ === \"function\" ? _ : constant(_)), this)\n : this.schema.label;\n }\n\n /**\n Whether to display the legend.\n*/\n legend(\n _?:\n | boolean\n | ((config: Record<string, unknown>, arr: DataPoint[]) => boolean),\n ):\n | this\n | boolean\n | ((config: Record<string, unknown>, arr: DataPoint[]) => boolean) {\n return arguments.length\n ? ((this.schema.legend = typeof _ === \"function\" ? _ : constant(_)), this)\n : this.schema.legend;\n }\n\n /**\n Configuration object passed to the legend's config method.\n*/\n legendConfig(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.legendConfig = assign(this.schema.legendConfig, _!)), this)\n : this.schema.legendConfig;\n }\n\n /**\n Defines the click functionality of categorical legend squares. When set to false, clicking will hide that category and shift+clicking will solo that category. When set to true, clicking with solo that category and shift+clicking will hide that category.\n*/\n legendFilterInvert(\n _?: boolean | ((viz: VizBase) => boolean),\n ): this | boolean | ((viz: VizBase) => boolean) {\n return arguments.length\n ? ((this.schema.legendFilterInvert = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.legendFilterInvert;\n }\n\n /**\n Tells the legend whether or not to use the internal padding defined by the visualization in it's positioning. For example, d3plus-plot will add padding on the left so that the legend appears centered underneath the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.\n*/\n legendPadding(\n _?: boolean | ((viz: VizBase) => boolean),\n ): this | boolean | ((viz: VizBase) => boolean) {\n return arguments.length\n ? ((this.schema.legendPadding = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.legendPadding;\n }\n\n /**\n Defines which side of the visualization to anchor the legend. Expected values are `\"top\"`, `\"bottom\"`, `\"left\"`, and `\"right\"`.\n*/\n legendPosition(_?: string | (() => string)): this | string | (() => string) {\n return arguments.length\n ? ((this.schema.legendPosition = typeof _ === \"function\" ? _ : constant(_)),\n this)\n : this.schema.legendPosition;\n }\n\n /**\n Configuration object for the legend tooltip.\n*/\n legendTooltip(_?: Record<string, unknown>): this | Record<string, unknown> {\n return arguments.length\n ? ((this.schema.legendTooltip = assign(this.schema.legendTooltip, _!)), this)\n : this.schema.legendTooltip;\n }\n}\n"],"names":["merge","arrayMerge","addToQueue","unique","assign","fontFamilyStringify","accessor","BaseClass","constant","VizBaseConfig","active","_","_active","schema","shapeConfig","activeOpacity","_shapes","forEach","s","legend","_legendClass","_sceneRenderer","_scheduleSceneRepaint","aggs","arguments","length","attribution","attributionStyle","backConfig","color","colorScale","colorScaleConfig","colorScalePadding","colorScalePosition","colorScaleMaxSize","data","f","bind","_hidden","_solo","_userData","JSON","stringify","timeFilter","_timelineSelection","_data","detectResize","detectResizeDelay","detectVisible","detectVisibleInterval","downloadButton","downloadConfig","downloadPosition","fontFamily","labelConfig","axisConfig","titleConfig","axis","method","label","tooltipConfig","tooltipStyle","groupBy","_groupByRaw","arr","Array","map","k","a","c","v","hiddenColor","hiddenOpacity","hover","hoverFunction","_hover","hoverOpacity","undefined","shapeData","concat","activeData","filter","activeIds","Set","_ids","ids","x","add","slice","size","d","i","has","_hoverBucket","highlight","_highlight","legendConfig","legendFilterInvert","legendPadding","legendPosition","legendTooltip"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQA,SAASC,UAAU,QAAO,WAAW;AAE7C,SAAQC,UAAU,EAAEC,MAAM,QAAO,eAAe;AAChD,SAAQC,MAAM,QAAO,cAAc;AACnC,SAAQC,mBAAmB,QAAO,eAAe;AAGjD,SAAQC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAO,uBAAuB;AAUpD,IAAA,AAAMC,8BAAN;;cAAMA;aAAAA;gCAAAA;QAAN,OAAA,kBAAMA;;kBAAAA;;YAQnB;;AAEF,GACEC,KAAAA;mBAAAA,SAAAA,OACEC,CAAkD;gBAElD,IAAI,CAACC,OAAO,GAAGD;gBAEf,IAAI,IAAI,CAACE,MAAM,CAACC,WAAW,CAACC,aAAa,KAAK,GAAG;oBAC/C,IAAI,CAACC,OAAO,CAACC,OAAO,CAAC,SAACC;+BAAiDA,EAAER,MAAM,CAACC;;oBAChF,IAAI,IAAI,CAACE,MAAM,CAACM,MAAM,EAAE,IAAI,CAACC,YAAY,CAACV,MAAM,CAACC;oBACjD,yDAAyD;oBACzD,oEAAoE;oBACpE,IAAI,IAAI,CAACU,cAAc,EAAE,IAAI,CAACC,qBAAqB;gBACrD;gBAEA,OAAO,IAAI;YACb;;;YAEA;;AAEF,GACEC,KAAAA;mBAAAA,SAAAA,KAAKZ,CAA2B;gBAC9B,OAAOa,UAAUC,MAAM,GAClB,CAAA,AAAC,IAAI,CAACZ,MAAM,CAACU,IAAI,GAAGn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IAAI,CAACS,MAAM,CAACuF,aAAa,EAAEzF,IAAM,IAAI,AAAD,IACzE,IAAI,CAACE,MAAM,CAACuF,aAAa;YAC/B;;;WAxemB3F;EAAsBF;AAP3C;;;;;;AAMA,GACA,SAAqBE,2BAyepB"}
|
|
@@ -288,9 +288,11 @@ var defaultHtmlLookup = {
|
|
|
288
288
|
}
|
|
289
289
|
return lineRuns;
|
|
290
290
|
}
|
|
291
|
-
/** Pre-scales the font size to fit the box area before wrapping (resize mode). */ function resizeFontSize(fS, w, h, lH, words, style) {
|
|
291
|
+
/** Pre-scales the font size to fit the box area before wrapping (resize mode). */ function resizeFontSize(fS, w, h, lH, words, style, shape) {
|
|
292
292
|
var sizes = textWidth(words, style);
|
|
293
|
-
var areaMod = 1.165 + w / h * 0.1,
|
|
293
|
+
var areaMod = 1.165 + w / h * 0.1, // A circle fills only ~π/4 of its bounding box, so scale the usable area
|
|
294
|
+
// down to keep the initial font-size guess from overshooting.
|
|
295
|
+
boxArea = w * h * (shape === "circle" ? Math.PI / 4 : 1), maxWidth = max(sizes), textArea = sum(sizes, function(d) {
|
|
294
296
|
return d * lH;
|
|
295
297
|
}) * areaMod;
|
|
296
298
|
if (maxWidth > w || textArea > boxArea) {
|
|
@@ -362,8 +364,8 @@ var defaultHtmlLookup = {
|
|
|
362
364
|
"line-height": lH
|
|
363
365
|
};
|
|
364
366
|
var padding = parseSides(box.schema.padding(d, i));
|
|
365
|
-
var h = box.schema.height(d, i) - (padding.top + padding.bottom), w = box.schema.width(d, i) - (padding.left + padding.right);
|
|
366
|
-
var wrapper = textWrap().fontFamily(style["font-family"]).fontSize(fS).fontWeight(style["font-weight"]).lineHeight(lH).maxLines(box.schema.maxLines(d, i)).height(h).overflow(box.schema.overflow(d, i)).width(w).split(box.schema.split);
|
|
367
|
+
var h = box.schema.height(d, i) - (padding.top + padding.bottom), w = box.schema.width(d, i) - (padding.left + padding.right), shape = box.schema.shape(d, i);
|
|
368
|
+
var wrapper = textWrap().fontFamily(style["font-family"]).fontSize(fS).fontWeight(style["font-weight"]).lineHeight(lH).maxLines(box.schema.maxLines(d, i)).height(h).overflow(box.schema.overflow(d, i)).shape(shape).width(w).split(box.schema.split);
|
|
367
369
|
var fMax = box.schema.fontMax(d, i), fMin = box.schema.fontMin(d, i), vA = box.schema.verticalAlign(d, i), words = box.schema.split(t, i);
|
|
368
370
|
/**
|
|
369
371
|
Figures out the lineData to be used for wrapping.
|
|
@@ -407,7 +409,7 @@ var defaultHtmlLookup = {
|
|
|
407
409
|
}
|
|
408
410
|
}
|
|
409
411
|
if (w > fMin && (h > lH || resize && h > fMin * lHRatio)) {
|
|
410
|
-
if (resize) fS = resizeFontSize(fS, w, h, lH, words, style);
|
|
412
|
+
if (resize) fS = resizeFontSize(fS, w, h, lH, words, style, shape);
|
|
411
413
|
checkSize();
|
|
412
414
|
}
|
|
413
415
|
if (!lineData.length) return null;
|
|
@@ -553,6 +555,20 @@ var defaultHtmlLookup = {
|
|
|
553
555
|
];
|
|
554
556
|
}
|
|
555
557
|
},
|
|
558
|
+
// Bounding shape for wrapping: "square" (default) fills the full width on
|
|
559
|
+
// every line; "circle" treats width/height as the diameter and shortens
|
|
560
|
+
// lines near the top and bottom to keep text inside the circle. Defaults to
|
|
561
|
+
// the label record's namespaced `__d3plusWrapShape__` (stamped from a shape's
|
|
562
|
+
// `labelBounds`) so Circle labels wrap to the circle without callers
|
|
563
|
+
// configuring anything, while a caller's own `shape` data field is ignored.
|
|
564
|
+
{
|
|
565
|
+
key: "shape",
|
|
566
|
+
coerce: "const",
|
|
567
|
+
default: function _default(d) {
|
|
568
|
+
var _d___d3plusWrapShape__;
|
|
569
|
+
return (_d___d3plusWrapShape__ = d.__d3plusWrapShape__) !== null && _d___d3plusWrapShape__ !== void 0 ? _d___d3plusWrapShape__ : "square";
|
|
570
|
+
}
|
|
571
|
+
},
|
|
556
572
|
{
|
|
557
573
|
key: "split",
|
|
558
574
|
coerce: "identity",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TextBox.ts"],"sourcesContent":["import {max, min, sum} from \"d3-array\";\nimport {select} from \"d3-selection\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport {fontExists, parseSides, rtl as detectRTL, textWidth} from \"@d3plus/dom\";\nimport type {D3Selection} from \"@d3plus/dom\";\nimport {\n fontFamily,\n strip,\n textSplit,\n textWrap,\n} from \"@d3plus/text\";\nimport {SvgRenderer} from \"@d3plus/render\";\nimport type {GroupNode, SceneNode} from \"@d3plus/render\";\n\nimport {accessor, BaseClass, constant} from \"../utils/index.js\";\nimport {installFluent} from \"../fluent.js\";\nimport type {ConfigField} from \"../fluent.js\";\n\nconst defaultHtmlLookup: Record<string, string> = {\n i: \"font-style: italic;\",\n em: \"font-style: italic;\",\n b: \"font-weight: bold;\",\n strong: \"font-weight: bold;\",\n};\n\n/** A parsed inline run (segment of a wrapped line with optional bold/italic). */\ninterface LineRun {\n text: string;\n style?: {weight?: number | string; style?: \"normal\" | \"italic\"};\n}\n\n/** Internal shape produced by the data reduce in render(). */\ninterface TextBoxDatum {\n aH: string;\n data: DataPoint;\n i: number;\n lines: string[];\n /** Per-line parsed runs when `_html` is configured; null when plain text. */\n lineRuns: LineRun[][] | null;\n fC: string;\n fStroke: string;\n fSW: number;\n fF: string;\n fO: number;\n fW: number | string;\n id: string;\n pE: string;\n tA: string;\n vA: string;\n widths: number[];\n fS: number;\n lH: number;\n w: number;\n h: number;\n r: number;\n x: number;\n y: number;\n}\n\n/** Parses a \"style: foo; …\" string from defaultHtmlLookup into TextRun style. */\nfunction parseStyleString(\n styleStr: string,\n): {weight?: number | string; style?: \"normal\" | \"italic\"} | undefined {\n const out: {weight?: number | string; style?: \"normal\" | \"italic\"} = {};\n for (const decl of styleStr.split(\";\")) {\n const [k, v] = decl.split(\":\").map(s => s.trim());\n if (!k || !v) continue;\n if (k === \"font-weight\") out.weight = /^\\d+$/.test(v) ? Number(v) : v;\n else if (k === \"font-style\") out.style = v === \"italic\" ? \"italic\" : \"normal\";\n }\n return out.weight === undefined && out.style === undefined ? undefined : out;\n}\n\n/**\n Walks one wrapped line, applies the regex cleanup (closing dangling\n open tags, opening trailing closing tags), then splits it into runs by the\n configured htmlLookup. Returns the new openTag state for the next line so a\n multi-line bold/italic continues to style subsequent lines.\n*/\nfunction lineToRuns(\n raw: string,\n htmlLookup: Record<string, string>,\n openTag: string | false,\n): {runs: LineRun[]; openTag: string | false} {\n // textContent escaping: keep entity escaping in sync with render()\n // so SVG output stays identical.\n let cleaned = raw\n .trimEnd()\n .replace(/&([^;&]*)/g, (str, a) => (a === \"amp\" ? str : `&${a}`))\n .replace(/<([^A-z^/]+)/g, (_str, a) => `<${a}`)\n .replace(/<$/g, \"<\")\n .replace(\n /(<[^>^/]+>)([^<^>]+)$/g,\n (_str, a, b) => `${a}${b}${a.replace(\"<\", \"</\")}`,\n )\n .replace(\n /^([^<^>]+)(<\\/[^>]+>)/g,\n (_str, a, b) => `${b.replace(\"</\", \"<\")}${a}${b}`,\n );\n\n // If we're already inside an open tag from a previous line, prefix this\n // line with the opening tag so the same tag closes within the line.\n let nextOpenTag: string | false = openTag;\n if (nextOpenTag && !cleaned.startsWith(\"<\")) {\n cleaned = `<${nextOpenTag}>${cleaned}`;\n if (!cleaned.includes(`</${nextOpenTag}>`)) cleaned += `</${nextOpenTag}>`;\n }\n\n const tagRegex = /<([A-z]+)[^>]*>([^<^>]+)<\\/[^>]+>/g;\n const runs: LineRun[] = [];\n let lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = tagRegex.exec(cleaned)) !== null) {\n if (m.index > lastIndex) runs.push({text: cleaned.slice(lastIndex, m.index)});\n const tag = m[1];\n const inner = m[2];\n const styleStr = htmlLookup[tag];\n if (styleStr) {\n // If the original raw line contains a closing tag, the tag has terminated.\n if (raw.includes(`</${tag}>`)) nextOpenTag = false;\n else nextOpenTag = tag;\n runs.push({text: inner, style: parseStyleString(styleStr)});\n } else {\n runs.push({text: inner});\n }\n lastIndex = m.index + m[0].length;\n }\n if (lastIndex < cleaned.length) runs.push({text: cleaned.slice(lastIndex)});\n\n // If the raw line never opened a tag but we already had openTag set, the\n // line is fully inside that tag — wrap it.\n if (!runs.length && cleaned) runs.push({text: cleaned});\n\n return {runs, openTag: nextOpenTag};\n}\n\n/** Builds the per-line LineRun arrays from wrapped lines, carrying open-tag state. */\nfunction buildLineRuns(\n box: TextBox,\n lineData: string[],\n): LineRun[][] | null {\n let lineRuns: LineRun[][] | null = null;\n if (box.schema.html) {\n const lookup = box.schema.html as Record<string, string>;\n let openTag: string | false = false;\n const out: LineRun[][] = [];\n let hasStyle = false;\n for (const ln of lineData) {\n const {runs, openTag: next} = lineToRuns(ln, lookup, openTag);\n out.push(runs);\n openTag = next;\n if (runs.some(r => r.style)) hasStyle = true;\n }\n // Only emit runs when at least one line carries a style; otherwise\n // leave runs unset so the renderer emits a single text node.\n if (hasStyle) lineRuns = out;\n }\n return lineRuns;\n}\n\n/** Pre-scales the font size to fit the box area before wrapping (resize mode). */\nfunction resizeFontSize(\n fS: number,\n w: number,\n h: number,\n lH: number,\n words: string[],\n style: Record<string, string | number>,\n): number {\n const sizes = textWidth(words, style) as unknown as number[];\n\n const areaMod = 1.165 + (w / h) * 0.1,\n boxArea = w * h,\n maxWidth = max(sizes) as number,\n textArea = sum(sizes, (d: number) => d * lH) * areaMod;\n\n if (maxWidth > w || textArea > boxArea) {\n const areaRatio = Math.sqrt(boxArea / textArea),\n widthRatio = w / maxWidth;\n const sizeRatio = min([areaRatio, widthRatio])!;\n fS = Math.floor(fS * sizeRatio);\n }\n\n const heightMax = Math.floor(h * 0.8);\n if (fS > heightMax) fS = heightMax;\n return fS;\n}\n\n/** Assembles the final TextBoxDatum from the resolved layout values. */\nfunction assembleTextBoxDatum(\n box: TextBox,\n d: DataPoint,\n i: number,\n layout: {\n lineData: string[];\n line: number;\n fS: number;\n lH: number;\n w: number;\n h: number;\n vA: string;\n style: Record<string, string | number>;\n widths: number[];\n padding: {top: number; right: number; bottom: number; left: number};\n },\n): TextBoxDatum {\n const {lineData, line, fS, lH, w, h, vA, style, widths, padding} = layout;\n const tH = line * lH;\n const r = box.schema.rotate(d, i);\n let yP =\n r === 0\n ? vA === \"top\"\n ? 0\n : vA === \"middle\"\n ? h / 2 - tH / 2\n : h - tH\n : 0;\n yP -= lH * 0.1;\n\n // Pre-compute per-line runs from HTML markup, carrying open-tag state\n // across lines so a multi-line <b> continues to bold subsequent lines.\n const lineRuns = buildLineRuns(box, lineData);\n\n return {\n aH: box.schema.ariaHidden(d, i),\n data: d,\n i,\n lines: lineData,\n lineRuns,\n fC: box.schema.fontColor(d, i),\n fStroke: box.schema.fontStroke(d, i),\n fSW: box.schema.fontStrokeWidth(d, i),\n fF: style[\"font-family\"] as string,\n fO: box.schema.fontOpacity(d, i),\n fW: style[\"font-weight\"],\n id: box.schema.id(d, i),\n pE: box.schema.pointerEvents(d, i),\n tA: box.schema.textAnchor(d, i),\n vA: box.schema.verticalAlign(d, i),\n widths,\n fS,\n lH,\n w,\n h,\n r,\n x: box.schema.x(d, i) + padding.left,\n y: box.schema.y(d, i) + yP + padding.top,\n };\n}\n\n/**\n Computes the laid-out text box for a single data point, or null when the\n text is undefined or wraps to no visible lines.\n*/\nfunction computeTextBoxDatum(\n box: TextBox,\n d: DataPoint,\n i: number,\n): TextBoxDatum | null {\n const that = box;\n let t = box.schema.text(d, i);\n if (t === void 0) return null;\n t = `${t}`.trim();\n\n const resize = box.schema.fontResize(d, i);\n const lHRatio = box.schema.lineHeight(d, i) / box.schema.fontSize(d, i);\n\n let fS = resize ? box.schema.fontMax(d, i) : box.schema.fontSize(d, i),\n lH = resize ? fS * lHRatio : box.schema.lineHeight(d, i),\n line = 1,\n lineData: string[] = [],\n wrapResults: { lines: string[]; truncated: boolean; widths: number[] } = { lines: [], truncated: false, widths: [] };\n\n const style: Record<string, string | number> = {\n \"font-family\": fontExists(box.schema.fontFamily(d, i)) as string,\n \"font-size\": fS,\n \"font-weight\": box.schema.fontWeight(d, i),\n \"line-height\": lH,\n };\n\n const padding = parseSides(box.schema.padding(d, i));\n\n const h = box.schema.height(d, i) - (padding.top + padding.bottom),\n w = box.schema.width(d, i) - (padding.left + padding.right);\n\n const wrapper = textWrap()\n .fontFamily(style[\"font-family\"] as string)\n .fontSize(fS)\n .fontWeight(style[\"font-weight\"])\n .lineHeight(lH)\n .maxLines(box.schema.maxLines(d, i))\n .height(h)\n .overflow(box.schema.overflow(d, i))\n .width(w)\n .split(box.schema.split);\n\n const fMax = box.schema.fontMax(d, i),\n fMin = box.schema.fontMin(d, i),\n vA = box.schema.verticalAlign(d, i),\n words = box.schema.split(t, i);\n\n /**\n Figures out the lineData to be used for wrapping.\n @private\n*/\n function checkSize(): void {\n const truncate = () => {\n if (line < 1) lineData = [that.schema.ellipsis(\"\", line)];\n else lineData[line - 1] = that.schema.ellipsis(lineData[line - 1], line);\n };\n\n // Constraint the font size\n fS = max([fS, fMin])!;\n fS = min([fS, fMax])!;\n\n if (resize) {\n lH = fS * lHRatio;\n wrapper.fontSize(fS).lineHeight(lH);\n style[\"font-size\"] = fS;\n style[\"line-height\"] = lH;\n }\n\n wrapResults = wrapper(t!);\n lineData = wrapResults.lines.filter((l: string) => l !== \"\");\n line = lineData.length;\n\n if (wrapResults.truncated) {\n if (resize) {\n fS--;\n if (fS < fMin) {\n fS = fMin;\n truncate();\n return;\n } else checkSize();\n } else truncate();\n }\n }\n\n if (w > fMin && (h > lH || (resize && h > fMin * lHRatio))) {\n if (resize) fS = resizeFontSize(fS, w, h, lH, words, style);\n checkSize();\n }\n\n if (!lineData.length) return null;\n\n return assembleTextBoxDatum(box, d, i, {\n lineData,\n line,\n fS,\n lH,\n w,\n h,\n vA,\n style,\n widths: wrapResults.widths,\n padding,\n });\n}\n\n/** TextBox's fluent accessor schema. Config storage lives on `this.schema.<key>`. */\nconst textBoxSchema: ConfigField[] = [\n {key: \"ariaHidden\", coerce: \"const\", default: constant(\"false\")},\n {key: \"delay\", coerce: \"identity\", default: 0},\n {key: \"duration\", coerce: \"identity\", default: 0},\n {key: \"ellipsis\", coerce: \"const\", default: (text: string, line: number) => line ? `${text.replace(/\\.|,$/g, \"\")}...` : \"\"},\n {key: \"fontColor\", coerce: \"const\", default: constant(\"black\")},\n {key: \"fontFamily\", coerce: \"const\", default: constant(fontFamily)},\n {key: \"fontMax\", coerce: \"const\", default: constant(50)},\n {key: \"fontMin\", coerce: \"const\", default: constant(8)},\n {key: \"fontOpacity\", coerce: \"const\", default: constant(1)},\n {key: \"fontResize\", coerce: \"const\", default: constant(false)},\n {key: \"fontSize\", coerce: \"const\", default: constant(10)},\n {key: \"fontStroke\", coerce: \"const\", default: constant(\"transparent\")},\n {key: \"fontStrokeWidth\", coerce: \"const\", default: constant(0)},\n {key: \"fontWeight\", coerce: \"const\", default: constant(400)},\n {key: \"height\", coerce: \"const\", default: accessor(\"height\", 200)},\n {key: \"id\", coerce: \"const\", default: (d: DataPoint, i: number) => (d.id as string) || `${i}`},\n {key: \"lineHeight\", coerce: \"const\"},\n {key: \"maxLines\", coerce: \"const\", default: constant(null)},\n {key: \"overflow\", coerce: \"const\", default: constant(false)},\n {key: \"padding\", coerce: \"const\", default: constant(0)},\n {key: \"pointerEvents\", coerce: \"const\", default: constant(\"auto\")},\n {key: \"renderMode\", coerce: \"identity\", default: \"full\"},\n {key: \"rotate\", coerce: \"const\", default: constant(0)},\n {key: \"rotateAnchor\", coerce: \"const\", default: (d: TextBoxDatum) => [d.w / 2, d.h / 2]},\n {key: \"split\", coerce: \"identity\", default: textSplit},\n {key: \"text\", coerce: \"const\", default: accessor(\"text\")},\n {key: \"textAnchor\", coerce: \"const\", default: constant(\"start\")},\n {key: \"verticalAlign\", coerce: \"const\", default: constant(\"top\")},\n {key: \"width\", coerce: \"const\", default: accessor(\"width\", 200)},\n {key: \"x\", coerce: \"const\", default: accessor(\"x\", 0)},\n {key: \"y\", coerce: \"const\", default: accessor(\"y\", 0)},\n];\n\n/**\n Creates a wrapped text box for each point in an array of data. See [this example](https://d3plus.org/examples/d3plus-text/getting-started/) for help getting started using the TextBox class.\n*/\nexport default class TextBox extends BaseClass {\n // installFluent generates the config accessors (text, fontSize, x, …) at\n // runtime; the index signature lets callers reach them through the type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n _select!: D3Selection;\n _data!: DataPoint[];\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n*/\n constructor() {\n super();\n installFluent(this, textBoxSchema);\n this.schema.lineHeight = (d: DataPoint, i?: number) => this.schema.fontSize(d, i) * 1.2;\n this.schema.html = defaultHtmlLookup;\n }\n\n /**\n Computes the laid-out text boxes (wrapping, font sizing, per-box position)\n for the current data. Shared by render() and toScene() so both produce\n identical layout.\n @private\n*/\n _textData(): TextBoxDatum[] {\n return this._data.reduce((arr: TextBoxDatum[], d: DataPoint, i: number) => {\n const datum = computeTextBoxDatum(this, d, i);\n if (datum) arr.push(datum);\n return arr;\n }, []);\n }\n\n /**\n Produces a backend-agnostic scene graph for the text boxes, reusing the same\n layout (_textData) and per-line positioning render() applies to the DOM.\n*/\n toScene(): GroupNode {\n const rtl = detectRTL();\n const children: SceneNode[] = this._textData().map(d => {\n const anchor = d.tA === \"middle\" ? \"middle\" : d.tA === \"end\" ? \"end\" : \"start\";\n const lineX =\n d.tA === \"middle\"\n ? d.w / 2\n : rtl\n ? d.tA === \"start\"\n ? d.w\n : 0\n : d.tA === \"end\"\n ? d.w\n : 2 * Math.sin((Math.PI * d.r) / 180);\n const lines = d.lines.map((text, i) => {\n const y =\n d.r === 0 || d.vA === \"top\"\n ? (i + 1) * d.lH - (d.lH - d.fS)\n : d.vA === \"middle\"\n ? (d.h + d.fS) / 2 - (d.lH - d.fS) + (i - d.lines.length / 2 + 0.5) * d.lH\n : d.h - 2 * (d.lH - d.fS) - (d.lines.length - (i + 1)) * d.lH + 2 * Math.cos((Math.PI * d.r) / 180);\n const width = d.widths ? d.widths[i] ?? 0 : 0;\n const runs = d.lineRuns ? d.lineRuns[i] : undefined;\n return runs ? {text, x: lineX, y, width, runs} : {text, x: lineX, y, width};\n });\n const rotateAnchor = this.schema.rotateAnchor(d, d.i);\n const ariaHidden = d.aH === \"true\" || (d.aH as unknown) === true;\n const interactive = d.pE !== \"none\";\n return {\n type: \"text\",\n key: d.id,\n id: `d3plus-textBox-${strip(d.id)}`,\n datum: d.data,\n index: d.i,\n x: 0,\n y: 0,\n width: d.w,\n height: d.h,\n lines,\n font: {\n family: d.fF,\n size: d.fS,\n weight: d.fW,\n anchor,\n baseline: \"alphabetic\",\n dir: rtl ? \"rtl\" : \"ltr\",\n },\n paint: {\n fill: d.fC,\n opacity: d.fO,\n ...(d.fStroke && d.fStroke !== \"transparent\" ? {stroke: d.fStroke} : {}),\n ...(d.fSW ? {strokeWidth: d.fSW} : {}),\n },\n transform: {x: d.x, y: d.y, rotate: d.r, rotateAnchor},\n aria: ariaHidden ? {hidden: true} : undefined,\n interactive,\n } as SceneNode;\n });\n return {type: \"group\", key: \"textBox-group\", children};\n }\n\n /**\n Renders the text boxes. If a *callback* is specified, it will be called once the shapes are done drawing.\n @param callback Optional callback invoked after rendering completes.\n*/\n render(callback?: (...args: unknown[]) => unknown): this {\n if (this.schema.renderMode === \"compute\") {\n // A Viz pipeline (or parent shape) is driving this TextBox — it will\n // compose the scene itself, so we only need _textData to be reachable.\n if (callback) setTimeout(callback, 0);\n return this;\n }\n\n // Standalone use: route toScene() through SvgRenderer. Mirrors Shape.render\n // so `new TextBox().render()` works without a d3-selection body.\n if (this._select === undefined && typeof document !== \"undefined\") {\n const svgNode = select(\"body\")\n .append(\"svg\")\n .style(\"width\", `${window.innerWidth}px`)\n .style(\"height\", `${window.innerHeight}px`)\n .node() as unknown as HTMLElement;\n this.select(svgNode);\n }\n\n if (this._select) {\n const sel = this._select;\n const node: Element | null =\n sel && typeof sel.node === \"function\"\n ? (sel.node() as Element | null)\n : (sel as unknown as Element | null);\n if (node) {\n const root = this.toScene();\n // `width`/`height`/`x` are per-box accessors, not canvas dimensions, so\n // size the surface to the laid-out content extent (max box edge) — and\n // also to the container's rendered box, so it fills a sized container.\n // `getBoundingClientRect` is used because the React wrapper sets\n // `width`/`height=\"100%\"`, which `Number(\"100%\")` can't parse (→ NaN,\n // which previously fell back to a hard-coded 400 and cropped boxes).\n type Edge = {transform?: {x?: number; y?: number}; width?: number; height?: number};\n const contentW = root.children.reduce(\n (m, c) => Math.max(m, ((c as Edge).transform?.x ?? 0) + ((c as Edge).width ?? 0)),\n 0,\n );\n const contentH = root.children.reduce(\n (m, c) => Math.max(m, ((c as Edge).transform?.y ?? 0) + ((c as Edge).height ?? 0)),\n 0,\n );\n const rect =\n typeof node.getBoundingClientRect === \"function\"\n ? node.getBoundingClientRect()\n : null;\n const boxW =\n (rect && rect.width) ||\n Number(node.getAttribute(\"width\")) ||\n (node as HTMLElement).clientWidth ||\n 0;\n const boxH =\n (rect && rect.height) ||\n Number(node.getAttribute(\"height\")) ||\n (node as HTMLElement).clientHeight ||\n 0;\n const width = Math.max(boxW, contentW) || 400;\n const height = Math.max(boxH, contentH) || 300;\n while (node.firstChild) node.removeChild(node.firstChild);\n const scene = {root, width, height};\n const renderer = new SvgRenderer();\n renderer.mount({container: node, width, height});\n renderer.drawScene(scene);\n (this as unknown as {_sceneRenderer?: SvgRenderer})._sceneRenderer = renderer;\n }\n }\n\n if (callback) setTimeout(callback, 0);\n return this;\n }\n\n /**\n The data array used to draw text boxes. A text box will be drawn for each object in the array.\n*/\n data(): DataPoint[];\n data(_: DataPoint[]): this;\n data(_?: DataPoint[]): DataPoint[] | this {\n return arguments.length ? ((this._data = _!), this) : this._data;\n }\n\n /**\n Configures the ability to render simple HTML tags. Defaults to supporting `<b>`, `<strong>`, `<i>`, and `<em>`, set to false to disable or provide a mapping of tags to svg styles\n*/\n html(): Record<string, string> | false;\n html(_: Record<string, string> | boolean): this;\n html(_?: Record<string, string> | boolean): unknown {\n return arguments.length\n ? ((this.schema.html =\n typeof _ === \"boolean\" ? (_ ? defaultHtmlLookup : false) : _!),\n this)\n : this.schema.html;\n }\n\n /**\n The SVG container element as a d3 selector or DOM element. If not specified, an SVG element will be added to the page.\n*/\n select(): D3Selection;\n select(_: string | HTMLElement): this;\n select(_?: string | HTMLElement): unknown {\n return arguments.length\n ? ((this._select = select(_ as never) as unknown as D3Selection), this)\n : this._select;\n }\n}\n"],"names":["max","min","sum","select","fontExists","parseSides","rtl","detectRTL","textWidth","fontFamily","strip","textSplit","textWrap","SvgRenderer","accessor","BaseClass","constant","installFluent","defaultHtmlLookup","i","em","b","strong","parseStyleString","styleStr","out","split","decl","map","s","trim","k","v","weight","test","Number","style","undefined","lineToRuns","raw","htmlLookup","openTag","cleaned","trimEnd","replace","str","a","_str","nextOpenTag","startsWith","includes","tagRegex","runs","lastIndex","m","exec","index","push","text","slice","tag","inner","length","buildLineRuns","box","lineData","lineRuns","schema","html","lookup","hasStyle","ln","next","some","r","resizeFontSize","fS","w","h","lH","words","sizes","areaMod","boxArea","maxWidth","textArea","d","areaRatio","Math","sqrt","widthRatio","sizeRatio","floor","heightMax","assembleTextBoxDatum","layout","line","vA","widths","padding","tH","rotate","yP","aH","ariaHidden","data","lines","fC","fontColor","fStroke","fontStroke","fSW","fontStrokeWidth","fF","fO","fontOpacity","fW","id","pE","pointerEvents","tA","textAnchor","verticalAlign","x","left","y","top","computeTextBoxDatum","that","t","resize","fontResize","lHRatio","lineHeight","fontSize","fontMax","wrapResults","truncated","fontWeight","height","bottom","width","right","wrapper","maxLines","overflow","fMax","fMin","fontMin","checkSize","truncate","ellipsis","filter","l","textBoxSchema","key","coerce","default","TextBox","_select","_data","_textData","reduce","arr","datum","toScene","children","anchor","lineX","sin","PI","cos","rotateAnchor","interactive","type","font","family","size","baseline","dir","paint","fill","opacity","stroke","strokeWidth","transform","aria","hidden","render","callback","renderMode","setTimeout","document","svgNode","append","window","innerWidth","innerHeight","node","sel","root","contentW","c","contentH","rect","getBoundingClientRect","boxW","getAttribute","clientWidth","boxH","clientHeight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B,QAASyM,GAC7D,IAAI,AAAD,IACH,IAAI,CAACxJ,MAAM,CAACC,IAAI;YACtB;;;YAOAjE,KAAAA;mBAAAA,SAAAA,QAAOwN,CAAwB;gBAC7B,OAAOC,UAAU9J,MAAM,GAClB,CAAA,AAAC,IAAI,CAACiG,OAAO,GAAG5J,OAAOwN,IAAwC,IAAI,AAAD,IACnE,IAAI,CAAC5D,OAAO;YAClB;;;WA5MmBD;EAAgB/I;AAHrC;;AAEA,GACA,SAAqB+I,qBA6MpB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TextBox.ts"],"sourcesContent":["import {max, min, sum} from \"d3-array\";\nimport {select} from \"d3-selection\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport {fontExists, parseSides, rtl as detectRTL, textWidth} from \"@d3plus/dom\";\nimport type {D3Selection} from \"@d3plus/dom\";\nimport {\n fontFamily,\n strip,\n textSplit,\n textWrap,\n} from \"@d3plus/text\";\nimport {SvgRenderer} from \"@d3plus/render\";\nimport type {GroupNode, SceneNode} from \"@d3plus/render\";\n\nimport {accessor, BaseClass, constant} from \"../utils/index.js\";\nimport {installFluent} from \"../fluent.js\";\nimport type {ConfigField} from \"../fluent.js\";\n\nconst defaultHtmlLookup: Record<string, string> = {\n i: \"font-style: italic;\",\n em: \"font-style: italic;\",\n b: \"font-weight: bold;\",\n strong: \"font-weight: bold;\",\n};\n\n/** A parsed inline run (segment of a wrapped line with optional bold/italic). */\ninterface LineRun {\n text: string;\n style?: {weight?: number | string; style?: \"normal\" | \"italic\"};\n}\n\n/** Internal shape produced by the data reduce in render(). */\ninterface TextBoxDatum {\n aH: string;\n data: DataPoint;\n i: number;\n lines: string[];\n /** Per-line parsed runs when `_html` is configured; null when plain text. */\n lineRuns: LineRun[][] | null;\n fC: string;\n fStroke: string;\n fSW: number;\n fF: string;\n fO: number;\n fW: number | string;\n id: string;\n pE: string;\n tA: string;\n vA: string;\n widths: number[];\n fS: number;\n lH: number;\n w: number;\n h: number;\n r: number;\n x: number;\n y: number;\n}\n\n/** Parses a \"style: foo; …\" string from defaultHtmlLookup into TextRun style. */\nfunction parseStyleString(\n styleStr: string,\n): {weight?: number | string; style?: \"normal\" | \"italic\"} | undefined {\n const out: {weight?: number | string; style?: \"normal\" | \"italic\"} = {};\n for (const decl of styleStr.split(\";\")) {\n const [k, v] = decl.split(\":\").map(s => s.trim());\n if (!k || !v) continue;\n if (k === \"font-weight\") out.weight = /^\\d+$/.test(v) ? Number(v) : v;\n else if (k === \"font-style\") out.style = v === \"italic\" ? \"italic\" : \"normal\";\n }\n return out.weight === undefined && out.style === undefined ? undefined : out;\n}\n\n/**\n Walks one wrapped line, applies the regex cleanup (closing dangling\n open tags, opening trailing closing tags), then splits it into runs by the\n configured htmlLookup. Returns the new openTag state for the next line so a\n multi-line bold/italic continues to style subsequent lines.\n*/\nfunction lineToRuns(\n raw: string,\n htmlLookup: Record<string, string>,\n openTag: string | false,\n): {runs: LineRun[]; openTag: string | false} {\n // textContent escaping: keep entity escaping in sync with render()\n // so SVG output stays identical.\n let cleaned = raw\n .trimEnd()\n .replace(/&([^;&]*)/g, (str, a) => (a === \"amp\" ? str : `&${a}`))\n .replace(/<([^A-z^/]+)/g, (_str, a) => `<${a}`)\n .replace(/<$/g, \"<\")\n .replace(\n /(<[^>^/]+>)([^<^>]+)$/g,\n (_str, a, b) => `${a}${b}${a.replace(\"<\", \"</\")}`,\n )\n .replace(\n /^([^<^>]+)(<\\/[^>]+>)/g,\n (_str, a, b) => `${b.replace(\"</\", \"<\")}${a}${b}`,\n );\n\n // If we're already inside an open tag from a previous line, prefix this\n // line with the opening tag so the same tag closes within the line.\n let nextOpenTag: string | false = openTag;\n if (nextOpenTag && !cleaned.startsWith(\"<\")) {\n cleaned = `<${nextOpenTag}>${cleaned}`;\n if (!cleaned.includes(`</${nextOpenTag}>`)) cleaned += `</${nextOpenTag}>`;\n }\n\n const tagRegex = /<([A-z]+)[^>]*>([^<^>]+)<\\/[^>]+>/g;\n const runs: LineRun[] = [];\n let lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = tagRegex.exec(cleaned)) !== null) {\n if (m.index > lastIndex) runs.push({text: cleaned.slice(lastIndex, m.index)});\n const tag = m[1];\n const inner = m[2];\n const styleStr = htmlLookup[tag];\n if (styleStr) {\n // If the original raw line contains a closing tag, the tag has terminated.\n if (raw.includes(`</${tag}>`)) nextOpenTag = false;\n else nextOpenTag = tag;\n runs.push({text: inner, style: parseStyleString(styleStr)});\n } else {\n runs.push({text: inner});\n }\n lastIndex = m.index + m[0].length;\n }\n if (lastIndex < cleaned.length) runs.push({text: cleaned.slice(lastIndex)});\n\n // If the raw line never opened a tag but we already had openTag set, the\n // line is fully inside that tag — wrap it.\n if (!runs.length && cleaned) runs.push({text: cleaned});\n\n return {runs, openTag: nextOpenTag};\n}\n\n/** Builds the per-line LineRun arrays from wrapped lines, carrying open-tag state. */\nfunction buildLineRuns(\n box: TextBox,\n lineData: string[],\n): LineRun[][] | null {\n let lineRuns: LineRun[][] | null = null;\n if (box.schema.html) {\n const lookup = box.schema.html as Record<string, string>;\n let openTag: string | false = false;\n const out: LineRun[][] = [];\n let hasStyle = false;\n for (const ln of lineData) {\n const {runs, openTag: next} = lineToRuns(ln, lookup, openTag);\n out.push(runs);\n openTag = next;\n if (runs.some(r => r.style)) hasStyle = true;\n }\n // Only emit runs when at least one line carries a style; otherwise\n // leave runs unset so the renderer emits a single text node.\n if (hasStyle) lineRuns = out;\n }\n return lineRuns;\n}\n\n/** Pre-scales the font size to fit the box area before wrapping (resize mode). */\nfunction resizeFontSize(\n fS: number,\n w: number,\n h: number,\n lH: number,\n words: string[],\n style: Record<string, string | number>,\n shape: string,\n): number {\n const sizes = textWidth(words, style) as unknown as number[];\n\n const areaMod = 1.165 + (w / h) * 0.1,\n // A circle fills only ~π/4 of its bounding box, so scale the usable area\n // down to keep the initial font-size guess from overshooting.\n boxArea = w * h * (shape === \"circle\" ? Math.PI / 4 : 1),\n maxWidth = max(sizes) as number,\n textArea = sum(sizes, (d: number) => d * lH) * areaMod;\n\n if (maxWidth > w || textArea > boxArea) {\n const areaRatio = Math.sqrt(boxArea / textArea),\n widthRatio = w / maxWidth;\n const sizeRatio = min([areaRatio, widthRatio])!;\n fS = Math.floor(fS * sizeRatio);\n }\n\n const heightMax = Math.floor(h * 0.8);\n if (fS > heightMax) fS = heightMax;\n return fS;\n}\n\n/** Assembles the final TextBoxDatum from the resolved layout values. */\nfunction assembleTextBoxDatum(\n box: TextBox,\n d: DataPoint,\n i: number,\n layout: {\n lineData: string[];\n line: number;\n fS: number;\n lH: number;\n w: number;\n h: number;\n vA: string;\n style: Record<string, string | number>;\n widths: number[];\n padding: {top: number; right: number; bottom: number; left: number};\n },\n): TextBoxDatum {\n const {lineData, line, fS, lH, w, h, vA, style, widths, padding} = layout;\n const tH = line * lH;\n const r = box.schema.rotate(d, i);\n let yP =\n r === 0\n ? vA === \"top\"\n ? 0\n : vA === \"middle\"\n ? h / 2 - tH / 2\n : h - tH\n : 0;\n yP -= lH * 0.1;\n\n // Pre-compute per-line runs from HTML markup, carrying open-tag state\n // across lines so a multi-line <b> continues to bold subsequent lines.\n const lineRuns = buildLineRuns(box, lineData);\n\n return {\n aH: box.schema.ariaHidden(d, i),\n data: d,\n i,\n lines: lineData,\n lineRuns,\n fC: box.schema.fontColor(d, i),\n fStroke: box.schema.fontStroke(d, i),\n fSW: box.schema.fontStrokeWidth(d, i),\n fF: style[\"font-family\"] as string,\n fO: box.schema.fontOpacity(d, i),\n fW: style[\"font-weight\"],\n id: box.schema.id(d, i),\n pE: box.schema.pointerEvents(d, i),\n tA: box.schema.textAnchor(d, i),\n vA: box.schema.verticalAlign(d, i),\n widths,\n fS,\n lH,\n w,\n h,\n r,\n x: box.schema.x(d, i) + padding.left,\n y: box.schema.y(d, i) + yP + padding.top,\n };\n}\n\n/**\n Computes the laid-out text box for a single data point, or null when the\n text is undefined or wraps to no visible lines.\n*/\nfunction computeTextBoxDatum(\n box: TextBox,\n d: DataPoint,\n i: number,\n): TextBoxDatum | null {\n const that = box;\n let t = box.schema.text(d, i);\n if (t === void 0) return null;\n t = `${t}`.trim();\n\n const resize = box.schema.fontResize(d, i);\n const lHRatio = box.schema.lineHeight(d, i) / box.schema.fontSize(d, i);\n\n let fS = resize ? box.schema.fontMax(d, i) : box.schema.fontSize(d, i),\n lH = resize ? fS * lHRatio : box.schema.lineHeight(d, i),\n line = 1,\n lineData: string[] = [],\n wrapResults: { lines: string[]; truncated: boolean; widths: number[] } = { lines: [], truncated: false, widths: [] };\n\n const style: Record<string, string | number> = {\n \"font-family\": fontExists(box.schema.fontFamily(d, i)) as string,\n \"font-size\": fS,\n \"font-weight\": box.schema.fontWeight(d, i),\n \"line-height\": lH,\n };\n\n const padding = parseSides(box.schema.padding(d, i));\n\n const h = box.schema.height(d, i) - (padding.top + padding.bottom),\n w = box.schema.width(d, i) - (padding.left + padding.right),\n shape = box.schema.shape(d, i) as string;\n\n const wrapper = textWrap()\n .fontFamily(style[\"font-family\"] as string)\n .fontSize(fS)\n .fontWeight(style[\"font-weight\"])\n .lineHeight(lH)\n .maxLines(box.schema.maxLines(d, i))\n .height(h)\n .overflow(box.schema.overflow(d, i))\n .shape(shape as \"square\" | \"circle\")\n .width(w)\n .split(box.schema.split);\n\n const fMax = box.schema.fontMax(d, i),\n fMin = box.schema.fontMin(d, i),\n vA = box.schema.verticalAlign(d, i),\n words = box.schema.split(t, i);\n\n /**\n Figures out the lineData to be used for wrapping.\n @private\n*/\n function checkSize(): void {\n const truncate = () => {\n if (line < 1) lineData = [that.schema.ellipsis(\"\", line)];\n else lineData[line - 1] = that.schema.ellipsis(lineData[line - 1], line);\n };\n\n // Constraint the font size\n fS = max([fS, fMin])!;\n fS = min([fS, fMax])!;\n\n if (resize) {\n lH = fS * lHRatio;\n wrapper.fontSize(fS).lineHeight(lH);\n style[\"font-size\"] = fS;\n style[\"line-height\"] = lH;\n }\n\n wrapResults = wrapper(t!);\n lineData = wrapResults.lines.filter((l: string) => l !== \"\");\n line = lineData.length;\n\n if (wrapResults.truncated) {\n if (resize) {\n fS--;\n if (fS < fMin) {\n fS = fMin;\n truncate();\n return;\n } else checkSize();\n } else truncate();\n }\n }\n\n if (w > fMin && (h > lH || (resize && h > fMin * lHRatio))) {\n if (resize) fS = resizeFontSize(fS, w, h, lH, words, style, shape);\n checkSize();\n }\n\n if (!lineData.length) return null;\n\n return assembleTextBoxDatum(box, d, i, {\n lineData,\n line,\n fS,\n lH,\n w,\n h,\n vA,\n style,\n widths: wrapResults.widths,\n padding,\n });\n}\n\n/** TextBox's fluent accessor schema. Config storage lives on `this.schema.<key>`. */\nconst textBoxSchema: ConfigField[] = [\n {key: \"ariaHidden\", coerce: \"const\", default: constant(\"false\")},\n {key: \"delay\", coerce: \"identity\", default: 0},\n {key: \"duration\", coerce: \"identity\", default: 0},\n {key: \"ellipsis\", coerce: \"const\", default: (text: string, line: number) => line ? `${text.replace(/\\.|,$/g, \"\")}...` : \"\"},\n {key: \"fontColor\", coerce: \"const\", default: constant(\"black\")},\n {key: \"fontFamily\", coerce: \"const\", default: constant(fontFamily)},\n {key: \"fontMax\", coerce: \"const\", default: constant(50)},\n {key: \"fontMin\", coerce: \"const\", default: constant(8)},\n {key: \"fontOpacity\", coerce: \"const\", default: constant(1)},\n {key: \"fontResize\", coerce: \"const\", default: constant(false)},\n {key: \"fontSize\", coerce: \"const\", default: constant(10)},\n {key: \"fontStroke\", coerce: \"const\", default: constant(\"transparent\")},\n {key: \"fontStrokeWidth\", coerce: \"const\", default: constant(0)},\n {key: \"fontWeight\", coerce: \"const\", default: constant(400)},\n {key: \"height\", coerce: \"const\", default: accessor(\"height\", 200)},\n {key: \"id\", coerce: \"const\", default: (d: DataPoint, i: number) => (d.id as string) || `${i}`},\n {key: \"lineHeight\", coerce: \"const\"},\n {key: \"maxLines\", coerce: \"const\", default: constant(null)},\n {key: \"overflow\", coerce: \"const\", default: constant(false)},\n {key: \"padding\", coerce: \"const\", default: constant(0)},\n {key: \"pointerEvents\", coerce: \"const\", default: constant(\"auto\")},\n {key: \"renderMode\", coerce: \"identity\", default: \"full\"},\n {key: \"rotate\", coerce: \"const\", default: constant(0)},\n {key: \"rotateAnchor\", coerce: \"const\", default: (d: TextBoxDatum) => [d.w / 2, d.h / 2]},\n // Bounding shape for wrapping: \"square\" (default) fills the full width on\n // every line; \"circle\" treats width/height as the diameter and shortens\n // lines near the top and bottom to keep text inside the circle. Defaults to\n // the label record's namespaced `__d3plusWrapShape__` (stamped from a shape's\n // `labelBounds`) so Circle labels wrap to the circle without callers\n // configuring anything, while a caller's own `shape` data field is ignored.\n {key: \"shape\", coerce: \"const\", default: (d: DataPoint) => (d.__d3plusWrapShape__ as string) ?? \"square\"},\n {key: \"split\", coerce: \"identity\", default: textSplit},\n {key: \"text\", coerce: \"const\", default: accessor(\"text\")},\n {key: \"textAnchor\", coerce: \"const\", default: constant(\"start\")},\n {key: \"verticalAlign\", coerce: \"const\", default: constant(\"top\")},\n {key: \"width\", coerce: \"const\", default: accessor(\"width\", 200)},\n {key: \"x\", coerce: \"const\", default: accessor(\"x\", 0)},\n {key: \"y\", coerce: \"const\", default: accessor(\"y\", 0)},\n];\n\n/**\n Creates a wrapped text box for each point in an array of data. See [this example](https://d3plus.org/examples/d3plus-text/getting-started/) for help getting started using the TextBox class.\n*/\nexport default class TextBox extends BaseClass {\n // installFluent generates the config accessors (text, fontSize, x, …) at\n // runtime; the index signature lets callers reach them through the type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n _select!: D3Selection;\n _data!: DataPoint[];\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n*/\n constructor() {\n super();\n installFluent(this, textBoxSchema);\n this.schema.lineHeight = (d: DataPoint, i?: number) => this.schema.fontSize(d, i) * 1.2;\n this.schema.html = defaultHtmlLookup;\n }\n\n /**\n Computes the laid-out text boxes (wrapping, font sizing, per-box position)\n for the current data. Shared by render() and toScene() so both produce\n identical layout.\n @private\n*/\n _textData(): TextBoxDatum[] {\n return this._data.reduce((arr: TextBoxDatum[], d: DataPoint, i: number) => {\n const datum = computeTextBoxDatum(this, d, i);\n if (datum) arr.push(datum);\n return arr;\n }, []);\n }\n\n /**\n Produces a backend-agnostic scene graph for the text boxes, reusing the same\n layout (_textData) and per-line positioning render() applies to the DOM.\n*/\n toScene(): GroupNode {\n const rtl = detectRTL();\n const children: SceneNode[] = this._textData().map(d => {\n const anchor = d.tA === \"middle\" ? \"middle\" : d.tA === \"end\" ? \"end\" : \"start\";\n const lineX =\n d.tA === \"middle\"\n ? d.w / 2\n : rtl\n ? d.tA === \"start\"\n ? d.w\n : 0\n : d.tA === \"end\"\n ? d.w\n : 2 * Math.sin((Math.PI * d.r) / 180);\n const lines = d.lines.map((text, i) => {\n const y =\n d.r === 0 || d.vA === \"top\"\n ? (i + 1) * d.lH - (d.lH - d.fS)\n : d.vA === \"middle\"\n ? (d.h + d.fS) / 2 - (d.lH - d.fS) + (i - d.lines.length / 2 + 0.5) * d.lH\n : d.h - 2 * (d.lH - d.fS) - (d.lines.length - (i + 1)) * d.lH + 2 * Math.cos((Math.PI * d.r) / 180);\n const width = d.widths ? d.widths[i] ?? 0 : 0;\n const runs = d.lineRuns ? d.lineRuns[i] : undefined;\n return runs ? {text, x: lineX, y, width, runs} : {text, x: lineX, y, width};\n });\n const rotateAnchor = this.schema.rotateAnchor(d, d.i);\n const ariaHidden = d.aH === \"true\" || (d.aH as unknown) === true;\n const interactive = d.pE !== \"none\";\n return {\n type: \"text\",\n key: d.id,\n id: `d3plus-textBox-${strip(d.id)}`,\n datum: d.data,\n index: d.i,\n x: 0,\n y: 0,\n width: d.w,\n height: d.h,\n lines,\n font: {\n family: d.fF,\n size: d.fS,\n weight: d.fW,\n anchor,\n baseline: \"alphabetic\",\n dir: rtl ? \"rtl\" : \"ltr\",\n },\n paint: {\n fill: d.fC,\n opacity: d.fO,\n ...(d.fStroke && d.fStroke !== \"transparent\" ? {stroke: d.fStroke} : {}),\n ...(d.fSW ? {strokeWidth: d.fSW} : {}),\n },\n transform: {x: d.x, y: d.y, rotate: d.r, rotateAnchor},\n aria: ariaHidden ? {hidden: true} : undefined,\n interactive,\n } as SceneNode;\n });\n return {type: \"group\", key: \"textBox-group\", children};\n }\n\n /**\n Renders the text boxes. If a *callback* is specified, it will be called once the shapes are done drawing.\n @param callback Optional callback invoked after rendering completes.\n*/\n render(callback?: (...args: unknown[]) => unknown): this {\n if (this.schema.renderMode === \"compute\") {\n // A Viz pipeline (or parent shape) is driving this TextBox — it will\n // compose the scene itself, so we only need _textData to be reachable.\n if (callback) setTimeout(callback, 0);\n return this;\n }\n\n // Standalone use: route toScene() through SvgRenderer. Mirrors Shape.render\n // so `new TextBox().render()` works without a d3-selection body.\n if (this._select === undefined && typeof document !== \"undefined\") {\n const svgNode = select(\"body\")\n .append(\"svg\")\n .style(\"width\", `${window.innerWidth}px`)\n .style(\"height\", `${window.innerHeight}px`)\n .node() as unknown as HTMLElement;\n this.select(svgNode);\n }\n\n if (this._select) {\n const sel = this._select;\n const node: Element | null =\n sel && typeof sel.node === \"function\"\n ? (sel.node() as Element | null)\n : (sel as unknown as Element | null);\n if (node) {\n const root = this.toScene();\n // `width`/`height`/`x` are per-box accessors, not canvas dimensions, so\n // size the surface to the laid-out content extent (max box edge) — and\n // also to the container's rendered box, so it fills a sized container.\n // `getBoundingClientRect` is used because the React wrapper sets\n // `width`/`height=\"100%\"`, which `Number(\"100%\")` can't parse (→ NaN,\n // which previously fell back to a hard-coded 400 and cropped boxes).\n type Edge = {transform?: {x?: number; y?: number}; width?: number; height?: number};\n const contentW = root.children.reduce(\n (m, c) => Math.max(m, ((c as Edge).transform?.x ?? 0) + ((c as Edge).width ?? 0)),\n 0,\n );\n const contentH = root.children.reduce(\n (m, c) => Math.max(m, ((c as Edge).transform?.y ?? 0) + ((c as Edge).height ?? 0)),\n 0,\n );\n const rect =\n typeof node.getBoundingClientRect === \"function\"\n ? node.getBoundingClientRect()\n : null;\n const boxW =\n (rect && rect.width) ||\n Number(node.getAttribute(\"width\")) ||\n (node as HTMLElement).clientWidth ||\n 0;\n const boxH =\n (rect && rect.height) ||\n Number(node.getAttribute(\"height\")) ||\n (node as HTMLElement).clientHeight ||\n 0;\n const width = Math.max(boxW, contentW) || 400;\n const height = Math.max(boxH, contentH) || 300;\n while (node.firstChild) node.removeChild(node.firstChild);\n const scene = {root, width, height};\n const renderer = new SvgRenderer();\n renderer.mount({container: node, width, height});\n renderer.drawScene(scene);\n (this as unknown as {_sceneRenderer?: SvgRenderer})._sceneRenderer = renderer;\n }\n }\n\n if (callback) setTimeout(callback, 0);\n return this;\n }\n\n /**\n The data array used to draw text boxes. A text box will be drawn for each object in the array.\n*/\n data(): DataPoint[];\n data(_: DataPoint[]): this;\n data(_?: DataPoint[]): DataPoint[] | this {\n return arguments.length ? ((this._data = _!), this) : this._data;\n }\n\n /**\n Configures the ability to render simple HTML tags. Defaults to supporting `<b>`, `<strong>`, `<i>`, and `<em>`, set to false to disable or provide a mapping of tags to svg styles\n*/\n html(): Record<string, string> | false;\n html(_: Record<string, string> | boolean): this;\n html(_?: Record<string, string> | boolean): unknown {\n return arguments.length\n ? ((this.schema.html =\n typeof _ === \"boolean\" ? (_ ? defaultHtmlLookup : false) : _!),\n this)\n : this.schema.html;\n }\n\n /**\n The SVG container element as a d3 selector or DOM element. If not specified, an SVG element will be added to the page.\n*/\n select(): D3Selection;\n select(_: string | HTMLElement): this;\n select(_?: string | HTMLElement): unknown {\n return arguments.length\n ? ((this._select = select(_ as never) as unknown as D3Selection), this)\n : this._select;\n }\n}\n"],"names":["max","min","sum","select","fontExists","parseSides","rtl","detectRTL","textWidth","fontFamily","strip","textSplit","textWrap","SvgRenderer","accessor","BaseClass","constant","installFluent","defaultHtmlLookup","i","em","b","strong","parseStyleString","styleStr","out","split","decl","map","s","trim","k","v","weight","test","Number","style","undefined","lineToRuns","raw","htmlLookup","openTag","cleaned","trimEnd","replace","str","a","_str","nextOpenTag","startsWith","includes","tagRegex","runs","lastIndex","m","exec","index","push","text","slice","tag","inner","length","buildLineRuns","box","lineData","lineRuns","schema","html","lookup","hasStyle","ln","next","some","r","resizeFontSize","fS","w","h","lH","words","shape","sizes","areaMod","boxArea","Math","PI","maxWidth","textArea","d","areaRatio","sqrt","widthRatio","sizeRatio","floor","heightMax","assembleTextBoxDatum","layout","line","vA","widths","padding","tH","rotate","yP","aH","ariaHidden","data","lines","fC","fontColor","fStroke","fontStroke","fSW","fontStrokeWidth","fF","fO","fontOpacity","fW","id","pE","pointerEvents","tA","textAnchor","verticalAlign","x","left","y","top","computeTextBoxDatum","that","t","resize","fontResize","lHRatio","lineHeight","fontSize","fontMax","wrapResults","truncated","fontWeight","height","bottom","width","right","wrapper","maxLines","overflow","fMax","fMin","fontMin","checkSize","truncate","ellipsis","filter","l","textBoxSchema","key","coerce","default","__d3plusWrapShape__","TextBox","_select","_data","_textData","reduce","arr","datum","toScene","children","anchor","lineX","sin","cos","rotateAnchor","interactive","type","font","family","size","baseline","dir","paint","fill","opacity","stroke","strokeWidth","transform","aria","hidden","render","callback","renderMode","setTimeout","document","svgNode","append","window","innerWidth","innerHeight","node","sel","root","contentW","c","contentH","rect","getBoundingClientRect","boxW","getAttribute","clientWidth","boxH","clientHeight","firstChild","removeChild","scene","renderer","mount","container","drawScene","_sceneRenderer","_","arguments"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQA,GAAG,EAAEC,GAAG,EAAEC,GAAG,QAAO,WAAW;AACvC,SAAQC,MAAM,QAAO,eAAe;AAGpC,SAAQC,UAAU,EAAEC,UAAU,EAAEC,OAAOC,SAAS,EAAEC,SAAS,QAAO,cAAc;AAEhF,SACEC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,QAAQ,QAC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AAC1J,MAAM,CAACC,IAAI;YACtB;;;YAOAjE,KAAAA;mBAAAA,SAAAA,QAAO0N,CAAwB;gBAC7B,OAAOC,UAAUhK,MAAM,GAClB,CAAA,AAAC,IAAI,CAACoG,OAAO,GAAG/J,OAAO0N,IAAwC,IAAI,AAAD,IACnE,IAAI,CAAC3D,OAAO;YAClB;;;WA5MmBD;EAAgBlJ;AAHrC;;AAEA,GACA,SAAqBkJ,qBA6MpB"}
|
package/es/src/shapes/Circle.js
CHANGED
|
@@ -162,12 +162,20 @@ var Circle = /*#__PURE__*/ function(Shape) {
|
|
|
162
162
|
]);
|
|
163
163
|
installFluent(_this, circleSchema);
|
|
164
164
|
_this._name = "Circle";
|
|
165
|
+
// Bound the label to the full circle (diameter box) and tag it
|
|
166
|
+
// `shape: "circle"`, so the label TextBox flows text as circle chords —
|
|
167
|
+
// lines fill the interior, shorter near the top and bottom and full width
|
|
168
|
+
// through the middle — rather than being capped to a square inscribed in
|
|
169
|
+
// the circle. The `shape` hint rides on the bounds (not `labelConfig`) so a
|
|
170
|
+
// chart that repositions the label with its own `labelBounds` (e.g. Tree's
|
|
171
|
+
// external node labels) gets ordinary rectangular wrapping.
|
|
165
172
|
_this.schema.labelBounds = function(_d, _i, s) {
|
|
166
173
|
return {
|
|
167
|
-
width: s.r *
|
|
168
|
-
height: s.r *
|
|
169
|
-
x: -s.r
|
|
170
|
-
y: -s.r
|
|
174
|
+
width: s.r * 2,
|
|
175
|
+
height: s.r * 2,
|
|
176
|
+
x: -s.r,
|
|
177
|
+
y: -s.r,
|
|
178
|
+
shape: "circle"
|
|
171
179
|
};
|
|
172
180
|
};
|
|
173
181
|
_this.schema.labelConfig = assign(_this.schema.labelConfig, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/shapes/Circle.ts"],"sourcesContent":["import type {BaseType, Selection} from \"d3-selection\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport {assign} from \"@d3plus/dom\";\nimport type {D3Selection} from \"@d3plus/dom\";\nimport {accessor} from \"../utils/index.js\";\nimport {installFluent} from \"../fluent.js\";\nimport type {ConfigField} from \"../fluent.js\";\n\nimport type {CircleConfig} from \"./shapeConfig.js\";\nimport Shape, {type ShapeAes} from \"./Shape.js\";\n\n/** Circle's own fluent accessor schema, layered on top of Shape's. */\nconst circleSchema: ConfigField[] = [\n {key: \"r\", coerce: \"accessor\", default: accessor(\"r\")},\n // Motion-trail toggle: when true, the animate layer sweeps a tapering cone\n // behind each point as it moves between frames (Timeline play), on both the\n // SVG and Canvas backends.\n {key: \"trail\", coerce: \"identity\", default: false},\n // Persistent-trail length: 0 keeps the ephemeral single-move trail; a positive\n // number keeps that many past step-segments (fading older ones out); `true`\n // keeps a long slowly-fading tail. Requires `trail: true`. Setting it also\n // makes the chart use a single-period timeline + fixed axes automatically\n // (see vizPreDraw) — the conditions a persistent trail needs to stay coherent.\n {key: \"trailPersist\", coerce: \"identity\", default: 0},\n];\n\n/**\n Creates SVG circles based on an array of data.\n*/\nexport default class Circle extends Shape {\n /**\n Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.\n @private\n*/\n constructor() {\n super(\"circle\");\n installFluent(this, circleSchema);\n this._name = \"Circle\";\n this.schema.labelBounds = (_d: DataPoint, _i: number, s: ShapeAes) => ({\n width: (s.r as number) *
|
|
1
|
+
{"version":3,"sources":["../../../src/shapes/Circle.ts"],"sourcesContent":["import type {BaseType, Selection} from \"d3-selection\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport {assign} from \"@d3plus/dom\";\nimport type {D3Selection} from \"@d3plus/dom\";\nimport {accessor} from \"../utils/index.js\";\nimport {installFluent} from \"../fluent.js\";\nimport type {ConfigField} from \"../fluent.js\";\n\nimport type {CircleConfig} from \"./shapeConfig.js\";\nimport Shape, {type ShapeAes} from \"./Shape.js\";\n\n/** Circle's own fluent accessor schema, layered on top of Shape's. */\nconst circleSchema: ConfigField[] = [\n {key: \"r\", coerce: \"accessor\", default: accessor(\"r\")},\n // Motion-trail toggle: when true, the animate layer sweeps a tapering cone\n // behind each point as it moves between frames (Timeline play), on both the\n // SVG and Canvas backends.\n {key: \"trail\", coerce: \"identity\", default: false},\n // Persistent-trail length: 0 keeps the ephemeral single-move trail; a positive\n // number keeps that many past step-segments (fading older ones out); `true`\n // keeps a long slowly-fading tail. Requires `trail: true`. Setting it also\n // makes the chart use a single-period timeline + fixed axes automatically\n // (see vizPreDraw) — the conditions a persistent trail needs to stay coherent.\n {key: \"trailPersist\", coerce: \"identity\", default: 0},\n];\n\n/**\n Creates SVG circles based on an array of data.\n*/\nexport default class Circle extends Shape {\n /**\n Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.\n @private\n*/\n constructor() {\n super(\"circle\");\n installFluent(this, circleSchema);\n this._name = \"Circle\";\n // Bound the label to the full circle (diameter box) and tag it\n // `shape: \"circle\"`, so the label TextBox flows text as circle chords —\n // lines fill the interior, shorter near the top and bottom and full width\n // through the middle — rather than being capped to a square inscribed in\n // the circle. The `shape` hint rides on the bounds (not `labelConfig`) so a\n // chart that repositions the label with its own `labelBounds` (e.g. Tree's\n // external node labels) gets ordinary rectangular wrapping.\n this.schema.labelBounds = (_d: DataPoint, _i: number, s: ShapeAes) => ({\n width: (s.r as number) * 2,\n height: (s.r as number) * 2,\n x: -(s.r as number),\n y: -(s.r as number),\n shape: \"circle\",\n });\n this.schema.labelConfig = assign(this.schema.labelConfig, {\n textAnchor: \"middle\",\n verticalAlign: \"middle\",\n });\n }\n\n /**\n Provides the default positioning to the <rect> elements.\n @private\n*/\n _applyPosition(elem: D3Selection): void {\n (elem as unknown as Selection<BaseType, DataPoint, BaseType, unknown>)\n .attr(\"r\", (d: DataPoint, i: number) => this.schema.r(d, i))\n .attr(\"x\", (d: DataPoint, i: number) => -(this.schema.r(d, i) as number) / 2)\n .attr(\"y\", (d: DataPoint, i: number) => -(this.schema.r(d, i) as number) / 2);\n }\n\n // v4: render() is inherited from Shape — the scene path handles drawing.\n\n /**\n Returns the circle geometry for a data point. The circle is centered on the\n transform origin (cx/cy = 0); the group transform positions it.\n @private\n*/\n _sceneGeometry(d: DataPoint, i: number): Record<string, unknown> {\n return {\n type: \"circle\",\n cx: 0,\n cy: 0,\n r: Number(this.schema.r(d, i)),\n ...(this.schema.trail ? {trail: true} : {}),\n ...(this.schema.trailPersist ? {trailPersist: this.schema.trailPersist} : {}),\n };\n }\n\n /**\n Given a specific data point and index, returns the aesthetic properties of the shape.\n @param data point*\n @param index @private\n*/\n _aes(d: DataPoint, i: number): ShapeAes {\n return {r: this.schema.r(d, i) as number};\n }\n\n /**\n Narrowed `.config()` for Circle. Inherited surface from\n `BaseClass.config()`; the override exists only to surface per-shape\n keys (e.g. `width`/`height` for Rect) in autocomplete + type checks.\n */\n config(): CircleConfig;\n config(_: Partial<CircleConfig>): this;\n config(_?: Partial<CircleConfig>): CircleConfig | this {\n if (!arguments.length) return super.config() as CircleConfig;\n super.config(_!);\n return this;\n }\n}\n"],"names":["assign","accessor","installFluent","Shape","circleSchema","key","coerce","default","Circle","_name","schema","labelBounds","_d","_i","s","width","r","height","x","y","shape","labelConfig","textAnchor","verticalAlign","_applyPosition","elem","attr","d","i","_sceneGeometry","type","cx","cy","Number","trail","trailPersist","_aes","config","_","arguments","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAQA,MAAM,QAAO,cAAc;AAEnC,SAAQC,QAAQ,QAAO,oBAAoB;AAC3C,SAAQC,aAAa,QAAO,eAAe;AAI3C,OAAOC,WAA4B,aAAa;AAEhD,oEAAoE,GACpE,IAAMC,eAA8B;IAClC;QAACC,KAAK;QAAKC,QAAQ;QAAYC,SAASN,SAAS;IAAI;IACrD,2EAA2E;IAC3E,4EAA4E;IAC5E,2BAA2B;IAC3B;QAACI,KAAK;QAASC,QAAQ;Q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BACJC,IAAI;oBACJhB,GAAGiB,OAAO,IAAI,CAACvB,MAAM,CAACM,CAAC,CAACW,GAAGC;mBACvB,IAAI,CAAClB,MAAM,CAACwB,KAAK,GAAG;oBAACA,OAAO;gBAAI,IAAI,CAAC,GACrC,IAAI,CAACxB,MAAM,CAACyB,YAAY,GAAG;oBAACA,cAAc,IAAI,CAACzB,MAAM,CAACyB,YAAY;gBAAA,IAAI,CAAC;YAE/E;;;YAEA;;;;AAIF,GACEC,KAAAA;mBAAAA,SAAAA,KAAKT,CAAY,EAAEC,CAAS;gBAC1B,OAAO;oBAACZ,GAAG,IAAI,CAACN,MAAM,CAACM,CAAC,CAACW,GAAGC;gBAAY;YAC1C;;;YASAS,KAAAA;mBAAAA,SAAAA,OAAOC,CAAyB;gBAC9B,IAAI,CAACC,UAAUC,MAAM,EAAE,OAAO,uBA3EbhC,mBA2EmB6B,UAAN,IAAK;gBACnC,uBA5EiB7B,mBA4EX6B,UAAN,IAAK,aAAQC;gBACb,OAAO,IAAI;YACb;;;WA9EmB9B;EAAeL;AAHpC;;AAEA,GACA,SAAqBK,oBA+EpB"}
|
package/es/src/shapes/Image.js
CHANGED
|
@@ -222,9 +222,8 @@ var Image = /*#__PURE__*/ function() {
|
|
|
222
222
|
/**
|
|
223
223
|
Compute-mode scene emission. Mirrors Shape.toScene's shape — a
|
|
224
224
|
keyed GroupNode wrapping per-datum ImageNodes. Used by chart
|
|
225
|
-
compositors (
|
|
226
|
-
|
|
227
|
-
d3-selection DOM.
|
|
225
|
+
compositors (e.g. plotPaint) that need Image to participate in the
|
|
226
|
+
scene graph rather than emit d3-selection DOM.
|
|
228
227
|
*/ key: "toScene",
|
|
229
228
|
value: function toScene() {
|
|
230
229
|
var _this = this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/shapes/Image.ts"],"sourcesContent":["import {select} from \"d3-selection\";\nimport {transition} from \"d3-transition\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {D3Selection} from \"@d3plus/dom\";\nimport type {GroupNode, ImageNode, SceneNode} from \"@d3plus/render\";\n\nimport {accessor, constant} from \"../utils/index.js\";\nimport {installFluent} from \"../fluent.js\";\nimport type {ConfigField} from \"../fluent.js\";\n\n/** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */\nconst imageSchema: ConfigField[] = [\n {key: \"duration\", coerce: \"identity\", default: 600},\n {key: \"height\", coerce: \"accessor\", default: accessor(\"height\")},\n {key: \"id\", coerce: \"identity\", default: accessor(\"id\")},\n {key: \"opacity\", coerce: \"const\", default: constant(1)},\n {key: \"pointerEvents\", coerce: \"const\", default: constant(\"auto\")},\n {key: \"renderMode\", coerce: \"identity\", default: \"full\"},\n {key: \"url\", coerce: \"identity\", default: accessor(\"url\")},\n {key: \"width\", coerce: \"accessor\", default: accessor(\"width\")},\n {key: \"x\", coerce: \"const\", default: accessor(\"x\", 0)},\n {key: \"y\", coerce: \"const\", default: accessor(\"y\", 0)},\n];\n\n/**\n Creates SVG images based on an array of data.\n @example <caption>a sample row of data</caption>\nvar data = {\"url\": \"file.png\", \"width\": \"100\", \"height\": \"50\"};\n@example <caption>passed to the generator</caption>\nnew Image().data([data]).render();\n@example <caption>creates the following</caption>\n<image class=\"d3plus-Image\" opacity=\"1\" href=\"file.png\" width=\"100\" height=\"50\" x=\"0\" y=\"0\"></image>\n@example <caption>this is shorthand for the following</caption>\nimage().data([data])();\n@example <caption>which also allows a post-draw callback function</caption>\nimage().data([data])(function() { alert(\"draw complete!\"); })\n*/\nexport default class Image {\n // installFluent generates the config accessors (width, x, url, …) at\n // runtime; the index signature lets callers reach them through the type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema!: Record<string, any>;\n _select!: D3Selection;\n _data!: DataPoint[];\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n*/\n constructor() {\n installFluent(this, imageSchema);\n }\n\n /**\n Get/set multiple config values at once. Mirrors the `BaseClass.config()`\n contract used by the other shapes (and relied on by the React wrapper):\n each patch key is routed through its matching fluent accessor (or\n `data`/`select`), with unknown keys stored on `schema` verbatim.\n */\n config(): Record<string, unknown>;\n config(_: Record<string, unknown>): this;\n config(_?: Record<string, unknown>): Record<string, unknown> | this {\n if (!arguments.length)\n return {...this.schema, data: this._data, select: this._select};\n const patch = _ as Record<string, unknown>;\n for (const k in patch) {\n if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;\n // `this[k]` resolves the fluent accessor via the index signature.\n if (typeof this[k] === \"function\") this[k](patch[k]);\n else this.schema[k] = patch[k];\n }\n return this;\n }\n\n /**\n Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.\n @param callback Optional callback invoked after rendering completes.\n*/\n render(callback?: () => void): this {\n // Compute mode is a no-op for DOM emission — the caller will read\n // `toScene()` to get a SceneNode tree, no need to mount.\n if (this.schema.renderMode === \"compute\") {\n if (callback) setTimeout(callback, 0);\n return this;\n }\n if (this._select === void 0)\n this.select(\n select(\"body\")\n .append(\"svg\")\n .style(\"width\", `${window.innerWidth}px`)\n .style(\"height\", `${window.innerHeight}px`)\n .style(\"display\", \"block\")\n .node(),\n );\n\n const images = this._select\n .selectAll<SVGImageElement, DataPoint>(\".d3plus-Image\")\n .data(this._data, this.schema.id);\n\n const enter = images\n .enter()\n .append(\"image\")\n .attr(\"class\", \"d3plus-Image\")\n .attr(\"opacity\", 0)\n .attr(\"width\", 0)\n .attr(\"height\", 0)\n .attr(\n \"x\",\n (d: DataPoint, i: number) =>\n (this.schema.x(d, i) as number) + (this.schema.width(d, i) as number) / 2,\n )\n .attr(\n \"y\",\n (d: DataPoint, i: number) =>\n (this.schema.y(d, i) as number) + (this.schema.height(d, i) as number) / 2,\n );\n\n const t = transition().duration(this.schema.duration),\n that = this,\n update = enter.merge(images);\n\n update\n .attr(\"xlink:href\", this.schema.url)\n .style(\"pointer-events\", this.schema.pointerEvents)\n .transition(t)\n .attr(\"opacity\", this.schema.opacity)\n .attr(\"width\", (d: DataPoint, i: number) => this.schema.width(d, i))\n .attr(\"height\", (d: DataPoint, i: number) => this.schema.height(d, i))\n .attr(\"x\", (d: DataPoint, i: number) => this.schema.x(d, i))\n .attr(\"y\", (d: DataPoint, i: number) => this.schema.y(d, i))\n .each(function (this: Element, d: DataPoint, i: number) {\n const image = select(this),\n link = that.schema.url(d, i) as string;\n const fullAddress =\n link.indexOf(\"http://\") === 0 || link.indexOf(\"https://\") === 0;\n if (!fullAddress || link.indexOf(window.location.hostname) === 0) {\n const img = new (\n window as unknown as Record<string, unknown> & {\n Image: new () => HTMLImageElement;\n }\n ).Image();\n img.src = link;\n img.crossOrigin = \"Anonymous\";\n img.onload = function () {\n const canvas = document.createElement(\"canvas\");\n canvas.width = img.width;\n canvas.height = img.height;\n const context = canvas.getContext(\"2d\")!;\n context.drawImage(img, 0, 0);\n image.attr(\"xlink:href\", canvas.toDataURL(\"image/png\"));\n };\n }\n });\n\n images\n .exit<DataPoint>()\n .transition(t)\n .attr(\"width\", (d: DataPoint, i: number) => this.schema.width(d, i))\n .attr(\"height\", (d: DataPoint, i: number) => this.schema.height(d, i))\n .attr(\"x\", (d: DataPoint, i: number) => this.schema.x(d, i))\n .attr(\"y\", (d: DataPoint, i: number) => this.schema.y(d, i))\n .attr(\"opacity\", 0)\n .remove();\n\n if (callback) setTimeout(callback, this.schema.duration + 100);\n\n return this;\n }\n\n /**\n The data array used to create image shapes. An <image> tag will be drawn for each object in the array.\n*/\n data(): DataPoint[];\n data(_: DataPoint[]): this;\n data(_?: DataPoint[]): DataPoint[] | this {\n return arguments.length ? ((this._data = _!), this) : this._data;\n }\n\n /**\n Compute-mode scene emission. Mirrors Shape.toScene's shape — a\n keyed GroupNode wrapping per-datum ImageNodes. Used by chart\n compositors (Shape._backgroundImageClass, plotPaint) that need\n Image to participate in the scene graph rather than emit\n d3-selection DOM.\n */\n toScene(): GroupNode {\n const children: SceneNode[] = (this._data || []).map(\n (d: DataPoint, i: number) => {\n const node: ImageNode = {\n type: \"image\",\n key: `${this.schema.id(d, i)}`,\n x: this.schema.x(d, i) as number,\n y: this.schema.y(d, i) as number,\n width: this.schema.width(d, i) as number,\n height: this.schema.height(d, i) as number,\n href: this.schema.url(d, i) as string,\n paint: {opacity: this.schema.opacity(d, i) as number},\n datum: d,\n index: i,\n };\n return node;\n },\n );\n return {type: \"group\", key: \"d3plus-Image\", children};\n }\n\n /**\n The SVG container element as a d3 selector or DOM element.\n*/\n select(): D3Selection;\n select(_: string | HTMLElement | SVGElement | null): this;\n select(_?: string | HTMLElement | SVGElement | null): D3Selection | this {\n return arguments.length\n ? ((this._select = select(_ as string) as unknown as D3Selection), this)\n : this._select;\n }\n}\n"],"names":["select","transition","accessor","constant","installFluent","imageSchema","key","coerce","default","Image","schema","_select","_data","config","_","arguments","length","data","patch","k","Object","prototype","hasOwnProperty","call","render","callback","renderMode","setTimeout","append","style","window","innerWidth","innerHeight","node","images","selectAll","id","enter","attr","d","i","x","width","y","height","t","duration","that","update","merge","url","pointerEvents","opacity","each","image","link","fullAddress","indexOf","location","hostname","img","src","crossOrigin","onload","canvas","document","createElement","context","getContext","drawImage","toDataURL","exit","remove","toScene","children","map","type","href","paint","datum","index"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQA,MAAM,QAAO,eAAe;AACpC,SAAQC,UAAU,QAAO,gBAAgB;AAMzC,SAAQC,QAAQ,EAAEC,QAAQ,QAAO,oBAAoB;AACrD,SAAQC,aAAa,QAAO,eAAe;AAG3C,iFAAiF,GACjF,IAAMC,cAA6B;IACjC;QAACC,KAAK;QAAYC,QAAQ;QAAYC,SAAS;IAAG;IAClD;QAACF,KAAK;QAAUC,QAAQ;QAAYC,SAASN,SAAS;IAAS;IAC/D;QAACI,KAAK;QAAMC,QAAQ;QAAYC,SAASN,SAAS;IAAK;IACvD;QAACI,KAAK;QAAWC,QAA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,OAAOxC;wBACPyC,OAAOxC;oBACT;oBACA,OAAOP;gBACT;gBAEF,OAAO;oBAAC2C,MAAM;oBAAStE,KAAK;oBAAgBoE,UAAAA;gBAAQ;YACtD;;;YAOA1E,KAAAA;mBAAAA,SAAAA,QAAOc,CAA4C;gBACjD,OAAOC,UAAUC,MAAM,GAClB,CAAA,AAAC,IAAI,CAACL,OAAO,GAAGX,OAAOc,IAAyC,IAAI,AAAD,IACpE,IAAI,CAACH,OAAO;YAClB;;;WApLmBF;;AAbrB;;;;;;;;;;;;AAYA,GACA,SAAqBA,mBAqLpB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/shapes/Image.ts"],"sourcesContent":["import {select} from \"d3-selection\";\nimport {transition} from \"d3-transition\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {D3Selection} from \"@d3plus/dom\";\nimport type {GroupNode, ImageNode, SceneNode} from \"@d3plus/render\";\n\nimport {accessor, constant} from \"../utils/index.js\";\nimport {installFluent} from \"../fluent.js\";\nimport type {ConfigField} from \"../fluent.js\";\n\n/** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */\nconst imageSchema: ConfigField[] = [\n {key: \"duration\", coerce: \"identity\", default: 600},\n {key: \"height\", coerce: \"accessor\", default: accessor(\"height\")},\n {key: \"id\", coerce: \"identity\", default: accessor(\"id\")},\n {key: \"opacity\", coerce: \"const\", default: constant(1)},\n {key: \"pointerEvents\", coerce: \"const\", default: constant(\"auto\")},\n {key: \"renderMode\", coerce: \"identity\", default: \"full\"},\n {key: \"url\", coerce: \"identity\", default: accessor(\"url\")},\n {key: \"width\", coerce: \"accessor\", default: accessor(\"width\")},\n {key: \"x\", coerce: \"const\", default: accessor(\"x\", 0)},\n {key: \"y\", coerce: \"const\", default: accessor(\"y\", 0)},\n];\n\n/**\n Creates SVG images based on an array of data.\n @example <caption>a sample row of data</caption>\nvar data = {\"url\": \"file.png\", \"width\": \"100\", \"height\": \"50\"};\n@example <caption>passed to the generator</caption>\nnew Image().data([data]).render();\n@example <caption>creates the following</caption>\n<image class=\"d3plus-Image\" opacity=\"1\" href=\"file.png\" width=\"100\" height=\"50\" x=\"0\" y=\"0\"></image>\n@example <caption>this is shorthand for the following</caption>\nimage().data([data])();\n@example <caption>which also allows a post-draw callback function</caption>\nimage().data([data])(function() { alert(\"draw complete!\"); })\n*/\nexport default class Image {\n // installFluent generates the config accessors (width, x, url, …) at\n // runtime; the index signature lets callers reach them through the type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema!: Record<string, any>;\n _select!: D3Selection;\n _data!: DataPoint[];\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n*/\n constructor() {\n installFluent(this, imageSchema);\n }\n\n /**\n Get/set multiple config values at once. Mirrors the `BaseClass.config()`\n contract used by the other shapes (and relied on by the React wrapper):\n each patch key is routed through its matching fluent accessor (or\n `data`/`select`), with unknown keys stored on `schema` verbatim.\n */\n config(): Record<string, unknown>;\n config(_: Record<string, unknown>): this;\n config(_?: Record<string, unknown>): Record<string, unknown> | this {\n if (!arguments.length)\n return {...this.schema, data: this._data, select: this._select};\n const patch = _ as Record<string, unknown>;\n for (const k in patch) {\n if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;\n // `this[k]` resolves the fluent accessor via the index signature.\n if (typeof this[k] === \"function\") this[k](patch[k]);\n else this.schema[k] = patch[k];\n }\n return this;\n }\n\n /**\n Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.\n @param callback Optional callback invoked after rendering completes.\n*/\n render(callback?: () => void): this {\n // Compute mode is a no-op for DOM emission — the caller will read\n // `toScene()` to get a SceneNode tree, no need to mount.\n if (this.schema.renderMode === \"compute\") {\n if (callback) setTimeout(callback, 0);\n return this;\n }\n if (this._select === void 0)\n this.select(\n select(\"body\")\n .append(\"svg\")\n .style(\"width\", `${window.innerWidth}px`)\n .style(\"height\", `${window.innerHeight}px`)\n .style(\"display\", \"block\")\n .node(),\n );\n\n const images = this._select\n .selectAll<SVGImageElement, DataPoint>(\".d3plus-Image\")\n .data(this._data, this.schema.id);\n\n const enter = images\n .enter()\n .append(\"image\")\n .attr(\"class\", \"d3plus-Image\")\n .attr(\"opacity\", 0)\n .attr(\"width\", 0)\n .attr(\"height\", 0)\n .attr(\n \"x\",\n (d: DataPoint, i: number) =>\n (this.schema.x(d, i) as number) + (this.schema.width(d, i) as number) / 2,\n )\n .attr(\n \"y\",\n (d: DataPoint, i: number) =>\n (this.schema.y(d, i) as number) + (this.schema.height(d, i) as number) / 2,\n );\n\n const t = transition().duration(this.schema.duration),\n that = this,\n update = enter.merge(images);\n\n update\n .attr(\"xlink:href\", this.schema.url)\n .style(\"pointer-events\", this.schema.pointerEvents)\n .transition(t)\n .attr(\"opacity\", this.schema.opacity)\n .attr(\"width\", (d: DataPoint, i: number) => this.schema.width(d, i))\n .attr(\"height\", (d: DataPoint, i: number) => this.schema.height(d, i))\n .attr(\"x\", (d: DataPoint, i: number) => this.schema.x(d, i))\n .attr(\"y\", (d: DataPoint, i: number) => this.schema.y(d, i))\n .each(function (this: Element, d: DataPoint, i: number) {\n const image = select(this),\n link = that.schema.url(d, i) as string;\n const fullAddress =\n link.indexOf(\"http://\") === 0 || link.indexOf(\"https://\") === 0;\n if (!fullAddress || link.indexOf(window.location.hostname) === 0) {\n const img = new (\n window as unknown as Record<string, unknown> & {\n Image: new () => HTMLImageElement;\n }\n ).Image();\n img.src = link;\n img.crossOrigin = \"Anonymous\";\n img.onload = function () {\n const canvas = document.createElement(\"canvas\");\n canvas.width = img.width;\n canvas.height = img.height;\n const context = canvas.getContext(\"2d\")!;\n context.drawImage(img, 0, 0);\n image.attr(\"xlink:href\", canvas.toDataURL(\"image/png\"));\n };\n }\n });\n\n images\n .exit<DataPoint>()\n .transition(t)\n .attr(\"width\", (d: DataPoint, i: number) => this.schema.width(d, i))\n .attr(\"height\", (d: DataPoint, i: number) => this.schema.height(d, i))\n .attr(\"x\", (d: DataPoint, i: number) => this.schema.x(d, i))\n .attr(\"y\", (d: DataPoint, i: number) => this.schema.y(d, i))\n .attr(\"opacity\", 0)\n .remove();\n\n if (callback) setTimeout(callback, this.schema.duration + 100);\n\n return this;\n }\n\n /**\n The data array used to create image shapes. An <image> tag will be drawn for each object in the array.\n*/\n data(): DataPoint[];\n data(_: DataPoint[]): this;\n data(_?: DataPoint[]): DataPoint[] | this {\n return arguments.length ? ((this._data = _!), this) : this._data;\n }\n\n /**\n Compute-mode scene emission. Mirrors Shape.toScene's shape — a\n keyed GroupNode wrapping per-datum ImageNodes. Used by chart\n compositors (e.g. plotPaint) that need Image to participate in the\n scene graph rather than emit d3-selection DOM.\n */\n toScene(): GroupNode {\n const children: SceneNode[] = (this._data || []).map(\n (d: DataPoint, i: number) => {\n const node: ImageNode = {\n type: \"image\",\n key: `${this.schema.id(d, i)}`,\n x: this.schema.x(d, i) as number,\n y: this.schema.y(d, i) as number,\n width: this.schema.width(d, i) as number,\n height: this.schema.height(d, i) as number,\n href: this.schema.url(d, i) as string,\n paint: {opacity: this.schema.opacity(d, i) as number},\n datum: d,\n index: i,\n };\n return node;\n },\n );\n return {type: \"group\", key: \"d3plus-Image\", children};\n }\n\n /**\n The SVG container element as a d3 selector or DOM element.\n*/\n select(): D3Selection;\n select(_: string | HTMLElement | SVGElement | null): this;\n select(_?: string | HTMLElement | SVGElement | null): D3Selection | this {\n return arguments.length\n ? ((this._select = select(_ as string) as unknown as D3Selection), this)\n : this._select;\n }\n}\n"],"names":["select","transition","accessor","constant","installFluent","imageSchema","key","coerce","default","Image","schema","_select","_data","config","_","arguments","length","data","patch","k","Object","prototype","hasOwnProperty","call","render","callback","renderMode","setTimeout","append","style","window","innerWidth","innerHeight","node","images","selectAll","id","enter","attr","d","i","x","width","y","height","t","duration","that","update","merge","url","pointerEvents","opacity","each","image","link","fullAddress","indexOf","location","hostname","img","src","crossOrigin","onload","canvas","document","createElement","context","getContext","drawImage","toDataURL","exit","remove","toScene","children","map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