@d3plus/core 4.0.0 → 4.1.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/shapes/buildLabelData.ts"],"sourcesContent":["/**\n `buildLabelData(opts)` — pure label-layout function extracted from\n `Shape._buildLabelData()`.\n\n Given the inputs that a Shape would otherwise hold as `this._label`/\n `this._labelBounds`/`this._x`/`this._y`/`this._aes`/`this._rotate`/\n `this._id`/`this._data`, produces the array of label-record DataPoints\n that a TextBox can render. No Shape instance required.\n\n Emit functions that would otherwise instantiate\n `new Rect().renderMode(\"compute\").render()` only to read back the label\n compute via `_labelClass` can call this directly + emit their own text\n nodes — no Shape class needed for labels-only data flows. The Shape\n classes themselves reach it through `this._buildLabelData()`.\n*/\n\nimport type {DataPoint} from \"@d3plus/data\";\n\ntype Accessor<T = unknown> = (d: DataPoint, i: number) => T;\ntype AesFn = (d: DataPoint, i: number) => unknown;\ntype BoundsFn = (\n d: DataPoint,\n i: number,\n aesValue: unknown,\n) => Record<string, unknown> | Record<string, unknown>[] | false | null | undefined;\n\nexport interface BuildLabelDataOpts {\n /** Source data array. */\n data: DataPoint[];\n /** Optional filter applied to `data` before iterating. */\n dataFilter?: (data: DataPoint[]) => DataPoint[];\n /** Returns the label text (or array of texts) for a datum. False/undefined skips. */\n label: Accessor;\n /** Returns the label bounds (or array of bounds per label) for a datum. Required for labels to surface. */\n labelBounds?: BoundsFn;\n /** Returns the x position for a datum. */\n x: Accessor<number>;\n /** Returns the y position for a datum. */\n y: Accessor<number>;\n /** Returns the aesthetic record for a datum (passed to `labelBounds`). */\n aes: AesFn;\n /** Returns the rotation angle (degrees) for a datum. */\n rotate: Accessor<number>;\n /** Returns the unique id for a datum. */\n id: Accessor<string | number>;\n /**\n Resolves the source row stored as each label record's `.data`. Defaults to\n the iterated datum itself. Charts whose `data` array is a layout/hierarchy\n node (e.g. Pack's d3-hierarchy nodes) pass `d => d.data` so the label\n resolves to the same source row its shape node carries — without it, the\n shape and its label unwrap to different objects and hover treats them\n separately (the shape highlights/raises while the label dims behind it).\n */\n datum?: (d: DataPoint, i: number) => DataPoint;\n}\n\nexport function buildLabelData(opts: BuildLabelDataOpts): DataPoint[] {\n const {data, dataFilter, label, labelBounds, x, y, aes, rotate, id, datum: datumFn} = opts;\n const out: DataPoint[] = [];\n const src = dataFilter ? dataFilter(data) : data;\n\n src.forEach((datum: DataPoint, i: number) => {\n let d: DataPoint = datum;\n if (datum.nested && datum.key && datum.values) {\n d = (datum.values as unknown as DataPoint[])[0];\n i = data.indexOf(d);\n }\n\n let labels: unknown = label(d, i);\n\n if (\n labelBounds &&\n labels !== false &&\n labels !== undefined &&\n labels !== null\n ) {\n const bounds = labelBounds(d, i, aes(datum, i)) as Record<string, unknown>;\n if (!bounds) return;\n\n if ((labels as unknown[]).constructor !== Array) labels = [labels];\n\n const xPos: number = d.__d3plusShape__\n ? d.translate\n ? (d.translate as unknown as number[])[0]\n : (x(d.data as DataPoint, d.i as number) as number)\n : (x(d, i) as number);\n const yPos: number = d.__d3plusShape__\n ? d.translate\n ? (d.translate as unknown as number[])[1]\n : (y(d.data as DataPoint, d.i as number) as number)\n : (y(d, i) as number);\n\n if (d.__d3plusShape__) {\n d = d.data as DataPoint;\n i = d.i as number;\n }\n\n for (let l = 0; l < (labels as unknown[]).length; l++) {\n const b = (\n bounds.constructor === Array\n ? (bounds as unknown as Record<string, unknown>[])[l]\n : Object.assign({}, bounds)\n ) as Record<string, number>;\n const rot = rotate(d, i) as number;\n const labelConfig = d.labelConfig as DataPoint | undefined;\n let r: number =\n labelConfig && labelConfig.rotate\n ? (labelConfig.rotate as number)\n : bounds.angle !== undefined\n ? (bounds.angle as number)\n : 0;\n r += rot;\n const rotateAnchor =\n rot !== 0\n ? [b.x * -1 || 0, b.y * -1 || 0]\n : [b.width / 2, b.height / 2];\n\n out.push({\n __d3plus__: true,\n data: datumFn ? datumFn(d, i) : d,\n height: b.height,\n l,\n id: `${id(d, i)}_${l}`,\n r,\n rotateAnchor,\n text: (labels as unknown[])[l],\n width: b.width,\n x: xPos + b.x,\n y: yPos + b.y,\n } as unknown as DataPoint);\n }\n }\n });\n return out;\n}\n"],"names":["buildLabelData","opts","data","dataFilter","label","labelBounds","x","y","aes","rotate","id","datum","datumFn","out","src","forEach","i","d","nested","key","values","indexOf","labels","undefined","bounds","Array","xPos","__d3plusShape__","translate","yPos","l","length","b","Object","assign","rot","labelConfig","r","angle","rotateAnchor","width","height","push","__d3plus__","text"],"mappings":"AAAA;;;;;;;;;;;;;;AAcA,GA0CA,OAAO,SAASA,eAAeC,IAAwB;IACrD,IAAOC,OAA+ED,KAA/EC,MAAMC,aAAyEF,KAAzEE,YAAYC,QAA6DH,KAA7DG,OAAOC,cAAsDJ,KAAtDI,aAAaC,IAAyCL,KAAzCK,GAAGC,IAAsCN,KAAtCM,GAAGC,MAAmCP,KAAnCO,KAAKC,SAA8BR,KAA9BQ,QAAQC,KAAsBT,KAAtBS,IAAIC,AAAOC,UAAWX,KAAlBU;IACpE,IAAME,MAAmB,EAAE;IAC3B,IAAMC,MAAMX,aAAaA,WAAWD,QAAQA;IAE5CY,IAAIC,OAAO,CAAC,SAACJ,OAAkBK;QAC7B,IAAIC,IAAeN;QACnB,IAAIA,MAAMO,MAAM,IAAIP,MAAMQ,GAAG,IAAIR,MAAMS,MAAM,EAAE;YAC7CH,IAAI,AAACN,MAAMS,MAAM,AAA2B,CAAC,EAAE;YAC/CJ,IAAId,KAAKmB,OAAO,CAACJ;QACnB;QAEA,IAAIK,SAAkBlB,MAAMa,GAAGD;QAE/B,IACEX,eACAiB,WAAW,SACXA,WAAWC,aACXD,WAAW,MACX;YACA,IAAME,SAASnB,YAAYY,GAAGD,GAAGR,IAAIG,OAAOK;YAC5C,IAAI,CAACQ,QAAQ;YAEb,IAAI,AAACF,OAAqB,WAAW,KAAKG,OAAOH,SAAS;gBAACA;aAAO;YAElE,IAAMI,OAAeT,EAAEU,eAAe,GAClCV,EAAEW,SAAS,GACT,AAACX,EAAEW,SAAS,AAAwB,CAAC,EAAE,GACtCtB,EAAEW,EAAEf,IAAI,EAAee,EAAED,CAAC,IAC5BV,EAAEW,GAAGD;YACV,IAAMa,OAAeZ,EAAEU,eAAe,GAClCV,EAAEW,SAAS,GACT,AAACX,EAAEW,SAAS,AAAwB,CAAC,EAAE,GACtCrB,EAAEU,EAAEf,IAAI,EAAee,EAAED,CAAC,IAC5BT,EAAEU,GAAGD;YAEV,IAAIC,EAAEU,eAAe,EAAE;gBACrBV,IAAIA,EAAEf,IAAI;gBACVc,IAAIC,EAAED,CAAC;YACT;YAEA,IAAK,IAAIc,IAAI,GAAGA,IAAI,AAACR,OAAqBS,MAAM,EAAED,IAAK;gBACrD,IAAME,IACJR,OAAO,WAAW,KAAKC,QACnB,AAACD,MAA+C,CAACM,EAAE,GACnDG,OAAOC,MAAM,CAAC,CAAC,GAAGV;gBAExB,IAAMW,MAAM1B,OAAOQ,GAAGD;gBACtB,IAAMoB,cAAcnB,EAAEmB,WAAW;gBACjC,IAAIC,IACFD,eAAeA,YAAY3B,MAAM,GAC5B2B,YAAY3B,MAAM,GACnBe,OAAOc,KAAK,KAAKf,YACdC,OAAOc,KAAK,GACb;gBACRD,KAAKF;gBACL,IAAMI,eACJJ,QAAQ,IACJ;oBAACH,EAAE1B,CAAC,GAAG,CAAC,KAAK;oBAAG0B,EAAEzB,CAAC,GAAG,CAAC,KAAK;iBAAE,GAC9B;oBAACyB,EAAEQ,KAAK,GAAG;oBAAGR,EAAES,MAAM,GAAG;iBAAE;gBAEjC5B,IAAI6B,IAAI,CAAC;oBACPC,YAAY;oBACZzC,MAAMU,UAAUA,QAAQK,GAAGD,KAAKC;oBAChCwB,QAAQT,EAAES,MAAM;oBAChBX,GAAAA;oBACApB,IAAI,AAAC,GAAcoB,OAAZpB,GAAGO,GAAGD,IAAG,KAAK,OAAFc;oBACnBO,GAAAA;oBACAE,cAAAA;oBACAK,MAAM,AAACtB,MAAoB,CAACQ,EAAE;oBAC9BU,OAAOR,EAAEQ,KAAK;oBACdlC,GAAGoB,OAAOM,EAAE1B,CAAC;oBACbC,GAAGsB,OAAOG,EAAEzB,CAAC;gBACf;YACF;QACF;IACF;IACA,OAAOM;AACT"}
1
+ {"version":3,"sources":["../../../src/shapes/buildLabelData.ts"],"sourcesContent":["/**\n `buildLabelData(opts)` — pure label-layout function extracted from\n `Shape._buildLabelData()`.\n\n Given the inputs that a Shape would otherwise hold as `this._label`/\n `this._labelBounds`/`this._x`/`this._y`/`this._aes`/`this._rotate`/\n `this._id`/`this._data`, produces the array of label-record DataPoints\n that a TextBox can render. No Shape instance required.\n\n Emit functions that would otherwise instantiate\n `new Rect().renderMode(\"compute\").render()` only to read back the label\n compute via `_labelClass` can call this directly + emit their own text\n nodes — no Shape class needed for labels-only data flows. The Shape\n classes themselves reach it through `this._buildLabelData()`.\n*/\n\nimport type {DataPoint} from \"@d3plus/data\";\n\ntype Accessor<T = unknown> = (d: DataPoint, i: number) => T;\ntype AesFn = (d: DataPoint, i: number) => unknown;\ntype BoundsFn = (\n d: DataPoint,\n i: number,\n aesValue: unknown,\n) => Record<string, unknown> | Record<string, unknown>[] | false | null | undefined;\n\nexport interface BuildLabelDataOpts {\n /** Source data array. */\n data: DataPoint[];\n /** Optional filter applied to `data` before iterating. */\n dataFilter?: (data: DataPoint[]) => DataPoint[];\n /** Returns the label text (or array of texts) for a datum. False/undefined skips. */\n label: Accessor;\n /** Returns the label bounds (or array of bounds per label) for a datum. Required for labels to surface. */\n labelBounds?: BoundsFn;\n /** Returns the x position for a datum. */\n x: Accessor<number>;\n /** Returns the y position for a datum. */\n y: Accessor<number>;\n /** Returns the aesthetic record for a datum (passed to `labelBounds`). */\n aes: AesFn;\n /** Returns the rotation angle (degrees) for a datum. */\n rotate: Accessor<number>;\n /** Returns the unique id for a datum. */\n id: Accessor<string | number>;\n /**\n Resolves the source row stored as each label record's `.data`. Defaults to\n the iterated datum itself. Charts whose `data` array is a layout/hierarchy\n node (e.g. Pack's d3-hierarchy nodes) pass `d => d.data` so the label\n resolves to the same source row its shape node carries — without it, the\n shape and its label unwrap to different objects and hover treats them\n separately (the shape highlights/raises while the label dims behind it).\n */\n datum?: (d: DataPoint, i: number) => DataPoint;\n}\n\nexport function buildLabelData(opts: BuildLabelDataOpts): DataPoint[] {\n const {data, dataFilter, label, labelBounds, x, y, aes, rotate, id, datum: datumFn} = opts;\n const out: DataPoint[] = [];\n const src = dataFilter ? dataFilter(data) : data;\n\n src.forEach((datum: DataPoint, i: number) => {\n let d: DataPoint = datum;\n if (datum.nested && datum.key && datum.values) {\n d = (datum.values as unknown as DataPoint[])[0];\n i = data.indexOf(d);\n }\n\n let labels: unknown = label(d, i);\n\n if (\n labelBounds &&\n labels !== false &&\n labels !== undefined &&\n labels !== null\n ) {\n const bounds = labelBounds(d, i, aes(datum, i)) as Record<string, unknown>;\n if (!bounds) return;\n\n if ((labels as unknown[]).constructor !== Array) labels = [labels];\n\n const xPos: number = d.__d3plusShape__\n ? d.translate\n ? (d.translate as unknown as number[])[0]\n : (x(d.data as DataPoint, d.i as number) as number)\n : (x(d, i) as number);\n const yPos: number = d.__d3plusShape__\n ? d.translate\n ? (d.translate as unknown as number[])[1]\n : (y(d.data as DataPoint, d.i as number) as number)\n : (y(d, i) as number);\n\n if (d.__d3plusShape__) {\n d = d.data as DataPoint;\n i = d.i as number;\n }\n\n for (let l = 0; l < (labels as unknown[]).length; l++) {\n const b = (\n bounds.constructor === Array\n ? (bounds as unknown as Record<string, unknown>[])[l]\n : Object.assign({}, bounds)\n ) as Record<string, number>;\n const rot = rotate(d, i) as number;\n const labelConfig = d.labelConfig as DataPoint | undefined;\n let r: number =\n labelConfig && labelConfig.rotate\n ? (labelConfig.rotate as number)\n : bounds.angle !== undefined\n ? (bounds.angle as number)\n : 0;\n r += rot;\n const rotateAnchor =\n rot !== 0\n ? [b.x * -1 || 0, b.y * -1 || 0]\n : [b.width / 2, b.height / 2];\n\n out.push({\n __d3plus__: true,\n data: datumFn ? datumFn(d, i) : d,\n height: b.height,\n l,\n id: `${id(d, i)}_${l}`,\n r,\n rotateAnchor,\n // Wrapping shape rides on the bounds so it stays paired with them:\n // a shape whose `labelBounds` returns `shape: \"circle\"` wraps to the\n // circle, while a chart that supplies its own rectangular bounds\n // (no `shape`) wraps normally. Stamped under a namespaced key so it\n // can't collide with a `shape` field a caller's own data might carry.\n ...(b.shape ? {__d3plusWrapShape__: b.shape} : {}),\n text: (labels as unknown[])[l],\n width: b.width,\n x: xPos + b.x,\n y: yPos + b.y,\n } as unknown as DataPoint);\n }\n }\n });\n return out;\n}\n"],"names":["buildLabelData","opts","data","dataFilter","label","labelBounds","x","y","aes","rotate","id","datum","datumFn","out","src","forEach","i","d","nested","key","values","indexOf","labels","undefined","bounds","Array","xPos","__d3plusShape__","translate","yPos","l","length","b","Object","assign","rot","labelConfig","r","angle","rotateAnchor","width","height","push","__d3plus__","shape","__d3plusWrapShape__","text"],"mappings":"AAAA;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,OAAO,SAASA,eAAeC,IAAwB;IACrD,IAAOC,OAA+ED,KAA/EC,MAAMC,aAAyEF,KAAzEE,YAAYC,QAA6DH,KAA7DG,OAAOC,cAAsDJ,KAAtDI,aAAaC,IAAyCL,KAAzCK,GAAGC,IAAsCN,KAAtCM,GAAGC,MAAmCP,KAAnCO,KAAKC,SAA8BR,KAA9BQ,QAAQC,KAAsBT,KAAtBS,IAAIC,AAAOC,UAAWX,KAAlBU;IACpE,IAAME,MAAmB,EAAE;IAC3B,IAAMC,MAAMX,aAAaA,WAAWD,QAAQA;IAE5CY,IAAIC,OAAO,CAAC,SAACJ,OAAkBK;QAC7B,IAAIC,IAAeN;QACnB,IAAIA,MAAMO,MAAM,IAAIP,MAAMQ,GAAG,IAAIR,MAAMS,MAAM,EAAE;YAC7CH,IAAI,AAACN,MAAMS,MAAM,AAA2B,CAAC,EAAE;YAC/CJ,IAAId,KAAKmB,OAAO,CAACJ;QACnB;QAEA,IAAIK,SAAkBlB,MAAMa,GAAGD;QAE/B,IACEX,eACAiB,WAAW,SACXA,WAAWC,aACXD,WAAW,MACX;YACA,IAAME,SAASnB,YAAYY,GAAGD,GAAGR,IAAIG,OAAOK;YAC5C,IAAI,CAACQ,QAAQ;YAEb,IAAI,AAACF,OAAqB,WAAW,KAAKG,OAAOH,SAAS;gBAACA;aAAO;YAElE,IAAMI,OAAeT,EAAEU,eAAe,GAClCV,EAAEW,SAAS,GACT,AAACX,EAAEW,SAAS,AAAwB,CAAC,EAAE,GACtCtB,EAAEW,EAAEf,IAAI,EAAee,EAAED,CAAC,IAC5BV,EAAEW,GAAGD;YACV,IAAMa,OAAeZ,EAAEU,eAAe,GAClCV,EAAEW,SAAS,GACT,AAACX,EAAEW,SAAS,AAAwB,CAAC,EAAE,GACtCrB,EAAEU,EAAEf,IAAI,EAAee,EAAED,CAAC,IAC5BT,EAAEU,GAAGD;YAEV,IAAIC,EAAEU,eAAe,EAAE;gBACrBV,IAAIA,EAAEf,IAAI;gBACVc,IAAIC,EAAED,CAAC;YACT;YAEA,IAAK,IAAIc,IAAI,GAAGA,IAAI,AAACR,OAAqBS,MAAM,EAAED,IAAK;gBACrD,IAAME,IACJR,OAAO,WAAW,KAAKC,QACnB,AAACD,MAA+C,CAACM,EAAE,GACnDG,OAAOC,MAAM,CAAC,CAAC,GAAGV;gBAExB,IAAMW,MAAM1B,OAAOQ,GAAGD;gBACtB,IAAMoB,cAAcnB,EAAEmB,WAAW;gBACjC,IAAIC,IACFD,eAAeA,YAAY3B,MAAM,GAC5B2B,YAAY3B,MAAM,GACnBe,OAAOc,KAAK,KAAKf,YACdC,OAAOc,KAAK,GACb;gBACRD,KAAKF;gBACL,IAAMI,eACJJ,QAAQ,IACJ;oBAACH,EAAE1B,CAAC,GAAG,CAAC,KAAK;oBAAG0B,EAAEzB,CAAC,GAAG,CAAC,KAAK;iBAAE,GAC9B;oBAACyB,EAAEQ,KAAK,GAAG;oBAAGR,EAAES,MAAM,GAAG;iBAAE;gBAEjC5B,IAAI6B,IAAI,CAAC;oBACPC,YAAY;oBACZzC,MAAMU,UAAUA,QAAQK,GAAGD,KAAKC;oBAChCwB,QAAQT,EAAES,MAAM;oBAChBX,GAAAA;oBACApB,IAAI,AAAC,GAAcoB,OAAZpB,GAAGO,GAAGD,IAAG,KAAK,OAAFc;oBACnBO,GAAAA;oBACAE,cAAAA;mBAMIP,EAAEY,KAAK,GAAG;oBAACC,qBAAqBb,EAAEY,KAAK;gBAAA,IAAI,CAAC;oBAChDE,MAAM,AAACxB,MAAoB,CAACQ,EAAE;oBAC9BU,OAAOR,EAAEQ,KAAK;oBACdlC,GAAGoB,OAAOM,EAAE1B,CAAC;oBACbC,GAAGsB,OAAOG,EAAEzB,CAAC;;YAEjB;QACF;IACF;IACA,OAAOM;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/D3plusConfig.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\n\nimport type {AccessorFn} from \"./AccessorFn.js\";\n\ntype Position = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DataPointAccessor<T> = string | ((d: DataPoint) => T);\n\n/** A config value that is either a constant or a `(datum, index)` accessor. */\ntype Accessor<T> = T | ((d: DataPoint, i?: number) => T);\n\ntype AxisScale =\n | \"auto\"\n | \"band\"\n | \"diverging\"\n | \"divergingLog\"\n | \"divergingPow\"\n | \"divergingSqrt\"\n | \"divergingSymlog\"\n | \"identity\"\n | \"implicit\"\n | \"jenks\"\n | \"linear\"\n | \"log\"\n | \"ordinal\"\n | \"point\"\n | \"pow\"\n | \"quantile\"\n | \"quantize\"\n | \"radial\"\n | \"sequential\"\n | \"sequentialLog\"\n | \"sequentialPow\"\n | \"sequentialQuantile\"\n | \"sequentialSqrt\"\n | \"sequentialSymlog\"\n | \"sqrt\"\n | \"symlog\"\n | \"threshold\"\n | \"time\"\n | \"utc\";\n\nexport interface AxisConfig {\n barConfig?: Record<string, string | number>;\n /** Grid values of the axis. */\n grid?: unknown[];\n gridConfig?: Record<string, string | number>;\n /** Grid size of the axis. */\n gridSize?: number;\n label?: string;\n /** Visible tick labels of the axis. */\n labels?: unknown[];\n labelOffset?: false | number;\n /** Maximum size allowed for the space that contains the axis tick labels and title. */\n maxSize?: number;\n /** Minimum size alloted for the space that contains the axis tick labels and title. */\n minSize?: number;\n /**\n Scale range (in pixels) of the axis. The given array must have 2 values,\n but one may be `undefined` to allow the default behavior for that value.\n */\n range?: (number | undefined)[];\n /** Scale of the axis. */\n scale?: AxisScale;\n /** Tick formatter. */\n tickFormat?: (d: number | string) => string | number;\n /** Tick values of the axis. */\n ticks?: unknown[];\n tickSize?: number;\n /**\n Defines a custom locale object to be used in time scales. Must include\n `dateTime`, `date`, `time`, `periods`, `days`, `shortDays`, `months`, and\n `shortMonths` (see\n [d3-time-format](https://github.com/d3/d3-time-format/blob/master/README.md#timeFormatLocale)).\n */\n timeLocale?: Record<string, unknown>;\n /** Title of the axis. */\n title?: string;\n}\n\nexport interface TooltipConfig {\n /** The inner HTML content of the arrow element, empty by default. */\n arrow?: ((d: DataPoint) => string) | string;\n /** The background color accessor for each tooltip. */\n background?: ((d: DataPoint) => string) | string;\n /** The border accessor for each tooltip. */\n border?: ((d: DataPoint) => string) | string;\n /** The border-radius accessor for each tooltip. */\n borderRadius?: ((d: DataPoint) => string) | string;\n /** The footer content accessor for each tooltip. */\n footer?: ((d: DataPoint) => string) | string;\n /** The max-width accessor for each tooltip. */\n maxWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The min-width accessor for each tooltip. */\n minWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The pixel offset between the tooltip and its anchor point. */\n offset?: ((d: DataPoint) => number) | number;\n /** The inner padding of each tooltip. */\n padding?: ((d: DataPoint) => string | number) | string | number;\n title?: ((d: DataPoint) => string) | string;\n body?: ((d: DataPoint) => string) | string;\n thead?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n tbody?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n}\n\nexport interface TextBoxConfig {\n /** The text content for each box. */\n text?: Accessor<string>;\n /** The font color as an accessor function or static string. Inferred from the DOM selection by default. */\n fontColor?: Accessor<string>;\n /** The font size in pixels. Inferred from the DOM selection by default. */\n fontSize?: Accessor<number>;\n /**\n The font-family to use: a font name, a comma-separated list of fallbacks,\n an array of fallbacks, or an accessor returning a string or array. The\n first available font on the client is used.\n */\n fontFamily?: Accessor<string | string[]>;\n /** The font weight. Inferred from the DOM selection by default. */\n fontWeight?: Accessor<string | number>;\n /** The minimum font size in pixels, used when dynamically resizing fonts. */\n fontMin?: number;\n /** The maximum font size in pixels, used when dynamically resizing fonts. */\n fontMax?: number;\n /** Toggles font resizing — a static boolean, or an accessor returning a boolean. */\n fontResize?: Accessor<boolean>;\n /** The font opacity as an accessor function or static number between 0 and 1. */\n fontOpacity?: Accessor<number>;\n /** The font stroke color for the rendered text. */\n fontStroke?: Accessor<string>;\n /** The font stroke width for the rendered text. */\n fontStrokeWidth?: Accessor<number>;\n /** The line height, which is 1.2 times the font size by default. */\n lineHeight?: Accessor<number>;\n /** Restricts the maximum number of lines to wrap onto; null (unlimited) by default. */\n maxLines?: Accessor<number | null>;\n /** Whether text is allowed to overflow its bounding box. */\n overflow?: Accessor<boolean>;\n /**\n Handles truncated lines, returning the new line value. Passed the line's\n text and number; by default appends an ellipsis to every line except a\n first word that cannot fit (which returns \"\").\n */\n ellipsis?: (text: string, line: number) => string;\n /** The padding as a CSS shorthand string or number. Defaults to 0. */\n padding?: Accessor<string | number>;\n /** The anchor point around which to rotate the text box. */\n rotateAnchor?: Accessor<[number, number]>;\n /** The word split function: given a string, returns it split into an array of words. */\n split?: (text: string) => string[];\n /** The width for each text box. */\n width?: Accessor<number>;\n /** The height for each text box. */\n height?: Accessor<number>;\n /** The x position (left edge) for each text box. */\n x?: Accessor<number>;\n /** The y position (top edge) for each text box. */\n y?: Accessor<number>;\n}\n\nexport interface TimelineConfig {\n /** Brush event filter. */\n brushFilter?: () => boolean;\n /**\n The minimum number of ticks that can be highlighted when using \"ticks\"\n `buttonBehavior`. Helpful for x/y plots where selecting fewer than 2 time\n periods is undesirable.\n */\n brushMin?: number;\n /** Toggles the horizontal alignment of the button timeline. */\n buttonAlign?: \"start\" | \"middle\" | \"end\";\n /** Toggles the style of the timeline. */\n buttonBehavior?: \"auto\" | \"buttons\" | \"ticks\";\n /** Button height. */\n buttonHeight?: number;\n /** Button padding. */\n buttonPadding?: number;\n /** Handle style. */\n handleConfig?: Record<string, unknown>;\n /** Handle size. */\n handleSize?: number;\n /**\n Determines the visibility of the play button to the left of the timeline,\n which cycles through the available periods at a rate set by `playButtonInterval`.\n */\n playButton?: boolean;\n /**\n The interval, in milliseconds, between periods when cycling via the play\n button. Used only when the chart's `duration` is 0 (no transition);\n otherwise playback steps once per `duration` so each step animates in full.\n */\n playButtonInterval?: number;\n /** The current selection. Defaults to the most recent period in the timeline. */\n selection?: (Date | number)[] | Date | number | false;\n /** Toggles the snapping value. */\n snapping?: boolean;\n}\n\nexport interface LegendConfig {\n /** The active method for all shapes. */\n active?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The hover method for all shapes. */\n hover?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The shape type used for each legend entry. */\n shape?: Accessor<string>;\n}\n\nexport interface ColorScaleConfig {\n /**\n For a linear scale, the `[min, max]` values used by the color scale; values\n outside this range map to the nearest color.\n */\n domain?: number[];\n /**\n Formats the label for each bucket in a bucket-type scale (\"jenks\",\n \"quantile\", …). Passed the bucket's start value, its index, the full\n bucket array, and every data value used to build the buckets.\n */\n bucketFormat?: (\n start: number,\n i: number,\n buckets: number[],\n values: number[],\n ) => string;\n /** Given a bucket's minimum and maximum values, returns the full label. */\n bucketJoiner?: (min: string, max: string) => string;\n}\n\nexport interface D3plusConfig {\n /** Data array or URL string to load data from. */\n data?: DataPoint[] | string;\n /** Locale code used for text and number formatting. */\n locale?: string;\n\n /** The active callback function for highlighting shapes. */\n active?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Custom aggregation functions keyed by data property. */\n aggs?: {[k: string]: (d: DataPoint[]) => unknown};\n /** Hides the SVG from assistive technology when true (`aria-hidden`). */\n ariaHidden?: boolean;\n /** Padding between bars in pixels. */\n barPadding?: number;\n /** The baseline for the x/y plot. */\n baseline?: number;\n /** Whether to cache the processed data between renders. */\n cache?: boolean;\n /** Treat a discrete color field as ordered: color it with a single-hue light→dark ramp instead of nominal categorical hues. */\n colorOrdinal?: boolean;\n /** Color scale key or custom color function. */\n colorScale?: string | ((d: number) => string);\n /** Configuration for the color scale component. */\n colorScaleConfig?: {\n axisConfig?: AxisConfig;\n centered?: boolean;\n colors?: string[];\n colorMin?: string;\n colorMid?: string;\n colorMax?: string;\n scale?: AxisScale;\n };\n /** Position of the color scale, or false to hide it. */\n colorScalePosition?: false | Position;\n /** Column key for matrix-style layouts. */\n column?: string;\n /**\n The confidence interval as `[lower, upper]` bounds — each given as an\n accessor function or a static data key (e.g. `[\"lci\", \"hci\"]`), or `false`\n to disable.\n */\n confidence?:\n | [\n string | ((d: DataPoint, i: number) => number),\n string | ((d: DataPoint, i: number) => number),\n ]\n | false;\n /** Maximum number of data points to render before downsampling. */\n dataCutoff?: number;\n /** Active depth level for nested groupings. */\n depth?: number;\n /** Sets orientation of main category axis. */\n discrete?: \"x\" | \"y\";\n /** Default duration of transitions, in milliseconds. */\n duration?: number;\n /** Predicate filtering which data points are included, or false to disable. */\n filter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Allows removing specific geographies from topojson file to improve zoom. */\n fitFilter?:\n | number\n | string\n | ((d: Record<string, unknown>) => boolean);\n /** Grouping key(s) or accessor function(s). */\n groupBy?:\n | string\n | string[]\n | ((d: DataPoint) => string | number)\n | ((d: DataPoint) => string | number)[];\n /** Padding between groups of bars in pixels. */\n groupPadding?: number;\n /** Overall height of the visualization in pixels. */\n height?: number;\n /** The hover callback function for highlighting shapes on mouseover. */\n hover?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Persistently emphasizes matching marks (keep color) and grays the rest. */\n highlight?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Label accessor for shapes. */\n label?: string | string[] | false | AccessorFn;\n /** Whether to show the legend. */\n legend?: boolean;\n /** Configuration for the legend component. */\n legendConfig?: {\n label?: DataPointAccessor<string>;\n shapeConfig?: Record<string, string | number>;\n };\n /** Position of the legend. */\n legendPosition?: Position;\n /** Custom sort comparator for legend items. */\n legendSort?: (a: DataPoint, b: DataPoint) => number;\n /** Tooltip configuration for legend items. */\n legendTooltip?: TooltipConfig;\n /** Whether to show labels on line charts. */\n lineLabels?: boolean;\n /** Whether to show the loading message. */\n loadingMessage?: boolean;\n /** Custom HTML content for the loading indicator. */\n loadingHTML?: string;\n /** Metric key for the visualization. */\n metric?: string;\n /** Ocean color for geomaps (any CSS value including 'transparent'). */\n ocean?: string;\n /** Event listeners keyed by event name. */\n on?: Record<string, (event: Event) => void>;\n /** Coordinate accessor for point-based geomaps. */\n point?: (d: DataPoint) => number[];\n /** Point size accessor for geomaps. */\n pointSize?: string | ((d: DataPoint) => number);\n /** Minimum point size for geomaps. */\n pointSizeMin?: number;\n /** Maximum point size for geomaps. */\n pointSizeMax?: number;\n /** Map projection name or function. */\n projection?: string | ((x: number, y: number) => [number, number]);\n /** Outer padding between the visualization edge and map shapes. */\n projectionPadding?: number | string;\n /** Rotation offset for the map projection center. */\n projectionRotate?: [number, number];\n /** Row key for matrix-style layouts. */\n row?: string;\n /** Scrollable container selector for tooltip positioning. */\n scrollContainer?: string | Window;\n /** Configuration for shape rendering. */\n shapeConfig?: {\n duration?: number;\n [key: string]: unknown;\n };\n /**\n A [sort comparator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\n that receives each shape class (e.g. \"Circle\", \"Line\") as its arguments.\n Shapes are drawn in groups by type, so this defines the layering order for\n all shapes of a given type.\n */\n shapeSort?: (a: string, b: string) => number;\n /** Size accessor key. */\n size?: string;\n /** Whether to stack series. */\n stacked?: boolean;\n /** Custom order for stacked series. */\n stackOrder?: string[];\n /** Value accessor for treemaps and aggregation. */\n sum?: DataPointAccessor<number>;\n /** Accessible description applied to the root SVG (`<desc>`). */\n svgDesc?: string;\n /** Accessible title applied to the root SVG (`<title>`). */\n svgTitle?: string;\n /** Threshold value for grouping small slices. */\n threshold?: number;\n /** Label for the threshold group. */\n thresholdName?: string;\n /** URL to XYZ map tiles. */\n tileUrl?: string;\n /** Whether to show map tiles. */\n tiles?: boolean;\n /** Time key for temporal data. */\n time?: string;\n /** Predicate filtering which time slices are shown, or false to disable. */\n timeFilter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Whether to show the timeline component. */\n timeline?: boolean;\n /** Chart title or title accessor function. */\n title?: string | ((data: DataPoint[]) => string);\n /** CSS style configuration for the title. */\n titleConfig?: Record<string, string | number>;\n /** Whether to show tooltips. */\n tooltip?: boolean;\n /** Configuration for the tooltip component. */\n tooltipConfig?: TooltipConfig;\n /** Path or object for the topojson data. */\n topojson?: string | object;\n /** CSS color to fill the map shapes. */\n topojsonFill?: string;\n /** Accessor function for topojson feature IDs. */\n topojsonId?: (obj: Record<string, unknown>) => string;\n /** Value accessor for the visualization. */\n value?: DataPointAccessor<number>;\n /** Overall width of the visualization in pixels. */\n width?: number;\n /** Key, index, or accessor function for x-axis values. */\n x?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the x-axis. */\n xConfig?: AxisConfig;\n /** The x domain as an array. If either value is undefined, it is calculated from the data. */\n xDomain?: (number | Date)[];\n /** The x2 domain as an array. If either value is undefined, it is calculated from the data. */\n x2Domain?: (number | Date)[];\n /** Custom sort function for x-axis values. */\n xSort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete x2 axes. */\n x2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Key, index, or accessor function for y-axis values. */\n y?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the y-axis. */\n yConfig?: AxisConfig;\n /** The y domain as an array. If either value is undefined, it is calculated from the data. */\n yDomain?: (number | Date)[];\n /** The y2 domain as an array. If either value is undefined, it is calculated from the data. */\n y2Domain?: (number | Date)[];\n /** Custom sort function for y-axis values. */\n ySort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete y2 axes. */\n y2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Set to false to disable zooming on Geomap and Network. */\n zoom?: boolean;\n /** Multiplier applied to programmatic zoom steps. */\n zoomFactor?: number;\n /** Maximum zoom scale factor. */\n zoomMax?: number;\n /** Whether panning (drag) is enabled while zoomed. */\n zoomPan?: boolean;\n /** Whether scroll-wheel zooming is enabled. */\n zoomScroll?: boolean;\n\n /** Allows additional custom properties. */\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AAkPA,WAsNC"}
1
+ {"version":3,"sources":["../../../src/utils/D3plusConfig.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\n\nimport type VizBase from \"../charts/viz/VizBase.js\";\nimport type {AccessorFn} from \"./AccessorFn.js\";\n\ntype Position = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DataPointAccessor<T> = string | ((d: DataPoint) => T);\n\n/** A config value that is either a constant or a `(datum, index)` accessor. */\ntype Accessor<T> = T | ((d: DataPoint, i?: number) => T);\n\ntype AxisScale =\n | \"auto\"\n | \"band\"\n | \"diverging\"\n | \"divergingLog\"\n | \"divergingPow\"\n | \"divergingSqrt\"\n | \"divergingSymlog\"\n | \"identity\"\n | \"implicit\"\n | \"jenks\"\n | \"linear\"\n | \"log\"\n | \"ordinal\"\n | \"point\"\n | \"pow\"\n | \"quantile\"\n | \"quantize\"\n | \"radial\"\n | \"sequential\"\n | \"sequentialLog\"\n | \"sequentialPow\"\n | \"sequentialQuantile\"\n | \"sequentialSqrt\"\n | \"sequentialSymlog\"\n | \"sqrt\"\n | \"symlog\"\n | \"threshold\"\n | \"time\"\n | \"utc\";\n\nexport interface AxisConfig {\n barConfig?: Record<string, string | number>;\n /** Grid values of the axis. */\n grid?: unknown[];\n gridConfig?: Record<string, string | number>;\n /** Grid size of the axis. */\n gridSize?: number;\n label?: string;\n /** Visible tick labels of the axis. */\n labels?: unknown[];\n labelOffset?: false | number;\n /** Maximum size allowed for the space that contains the axis tick labels and title. */\n maxSize?: number;\n /** Minimum size alloted for the space that contains the axis tick labels and title. */\n minSize?: number;\n /**\n Scale range (in pixels) of the axis. The given array must have 2 values,\n but one may be `undefined` to allow the default behavior for that value.\n */\n range?: (number | undefined)[];\n /** Scale of the axis. */\n scale?: AxisScale;\n /** Tick formatter. */\n tickFormat?: (d: number | string) => string | number;\n /** Tick values of the axis. */\n ticks?: unknown[];\n tickSize?: number;\n /**\n Defines a custom locale object to be used in time scales. Must include\n `dateTime`, `date`, `time`, `periods`, `days`, `shortDays`, `months`, and\n `shortMonths` (see\n [d3-time-format](https://github.com/d3/d3-time-format/blob/master/README.md#timeFormatLocale)).\n */\n timeLocale?: Record<string, unknown>;\n /** Title of the axis. */\n title?: string;\n}\n\nexport interface TooltipConfig {\n /** The inner HTML content of the arrow element, empty by default. */\n arrow?: ((d: DataPoint) => string) | string;\n /** The background color accessor for each tooltip. */\n background?: ((d: DataPoint) => string) | string;\n /** The border accessor for each tooltip. */\n border?: ((d: DataPoint) => string) | string;\n /** The border-radius accessor for each tooltip. */\n borderRadius?: ((d: DataPoint) => string) | string;\n /** The footer content accessor for each tooltip. */\n footer?: ((d: DataPoint) => string) | string;\n /** The max-width accessor for each tooltip. */\n maxWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The min-width accessor for each tooltip. */\n minWidth?: ((d: DataPoint) => string | number) | string | number;\n /** The pixel offset between the tooltip and its anchor point. */\n offset?: ((d: DataPoint) => number) | number;\n /** The inner padding of each tooltip. */\n padding?: ((d: DataPoint) => string | number) | string | number;\n title?: ((d: DataPoint) => string) | string;\n body?: ((d: DataPoint) => string) | string;\n thead?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n tbody?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n}\n\nexport interface TextBoxConfig {\n /** The text content for each box. */\n text?: Accessor<string>;\n /** The font color as an accessor function or static string. Inferred from the DOM selection by default. */\n fontColor?: Accessor<string>;\n /** The font size in pixels. Inferred from the DOM selection by default. */\n fontSize?: Accessor<number>;\n /**\n The font-family to use: a font name, a comma-separated list of fallbacks,\n an array of fallbacks, or an accessor returning a string or array. The\n first available font on the client is used.\n */\n fontFamily?: Accessor<string | string[]>;\n /** The font weight. Inferred from the DOM selection by default. */\n fontWeight?: Accessor<string | number>;\n /** The minimum font size in pixels, used when dynamically resizing fonts. */\n fontMin?: number;\n /** The maximum font size in pixels, used when dynamically resizing fonts. */\n fontMax?: number;\n /** Toggles font resizing — a static boolean, or an accessor returning a boolean. */\n fontResize?: Accessor<boolean>;\n /** The font opacity as an accessor function or static number between 0 and 1. */\n fontOpacity?: Accessor<number>;\n /** The font stroke color for the rendered text. */\n fontStroke?: Accessor<string>;\n /** The font stroke width for the rendered text. */\n fontStrokeWidth?: Accessor<number>;\n /** The line height, which is 1.2 times the font size by default. */\n lineHeight?: Accessor<number>;\n /** Restricts the maximum number of lines to wrap onto; null (unlimited) by default. */\n maxLines?: Accessor<number | null>;\n /** Whether text is allowed to overflow its bounding box. */\n overflow?: Accessor<boolean>;\n /**\n Handles truncated lines, returning the new line value. Passed the line's\n text and number; by default appends an ellipsis to every line except a\n first word that cannot fit (which returns \"\").\n */\n ellipsis?: (text: string, line: number) => string;\n /** The padding as a CSS shorthand string or number. Defaults to 0. */\n padding?: Accessor<string | number>;\n /** The anchor point around which to rotate the text box. */\n rotateAnchor?: Accessor<[number, number]>;\n /** The word split function: given a string, returns it split into an array of words. */\n split?: (text: string) => string[];\n /** The width for each text box. */\n width?: Accessor<number>;\n /** The height for each text box. */\n height?: Accessor<number>;\n /** The x position (left edge) for each text box. */\n x?: Accessor<number>;\n /** The y position (top edge) for each text box. */\n y?: Accessor<number>;\n}\n\nexport interface TimelineConfig {\n /** Brush event filter. */\n brushFilter?: () => boolean;\n /**\n The minimum number of ticks that can be highlighted when using \"ticks\"\n `buttonBehavior`. Helpful for x/y plots where selecting fewer than 2 time\n periods is undesirable.\n */\n brushMin?: number;\n /** Toggles the horizontal alignment of the button timeline. */\n buttonAlign?: \"start\" | \"middle\" | \"end\";\n /** Toggles the style of the timeline. */\n buttonBehavior?: \"auto\" | \"buttons\" | \"ticks\";\n /** Button height. */\n buttonHeight?: number;\n /** Button padding. */\n buttonPadding?: number;\n /** Handle style. */\n handleConfig?: Record<string, unknown>;\n /** Handle size. */\n handleSize?: number;\n /**\n Determines the visibility of the play button to the left of the timeline,\n which cycles through the available periods at a rate set by `playButtonInterval`.\n */\n playButton?: boolean;\n /**\n The interval, in milliseconds, between periods when cycling via the play\n button. Used only when the chart's `duration` is 0 (no transition);\n otherwise playback steps once per `duration` so each step animates in full.\n */\n playButtonInterval?: number;\n /** The current selection. Defaults to the most recent period in the timeline. */\n selection?: (Date | number)[] | Date | number | false;\n /** Toggles the snapping value. */\n snapping?: boolean;\n}\n\nexport interface LegendConfig {\n /** The active method for all shapes. */\n active?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The hover method for all shapes. */\n hover?: ((d: DataPoint, i?: number) => boolean) | false;\n /** The shape type used for each legend entry. */\n shape?: Accessor<string>;\n}\n\nexport interface ColorScaleConfig {\n /**\n For a linear scale, the `[min, max]` values used by the color scale; values\n outside this range map to the nearest color.\n */\n domain?: number[];\n /**\n Formats the label for each bucket in a bucket-type scale (\"jenks\",\n \"quantile\", …). Passed the bucket's start value, its index, the full\n bucket array, and every data value used to build the buckets.\n */\n bucketFormat?: (\n start: number,\n i: number,\n buckets: number[],\n values: number[],\n ) => string;\n /** Given a bucket's minimum and maximum values, returns the full label. */\n bucketJoiner?: (min: string, max: string) => string;\n}\n\nexport interface D3plusConfig {\n /** Data array or URL string to load data from. */\n data?: DataPoint[] | string;\n /** Locale code used for text and number formatting. */\n locale?: string;\n\n /** The active callback function for highlighting shapes. */\n active?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Custom aggregation functions keyed by data property. */\n aggs?: {[k: string]: (d: DataPoint[]) => unknown};\n /** Hides the SVG from assistive technology when true (`aria-hidden`). */\n ariaHidden?: boolean;\n /** Padding between bars in pixels. */\n barPadding?: number;\n /** The baseline for the x/y plot. */\n baseline?: number;\n /** Whether to cache the processed data between renders. */\n cache?: boolean;\n /** Treat a discrete color field as ordered: color it with a single-hue light→dark ramp instead of nominal categorical hues. */\n colorOrdinal?: boolean;\n /** Color scale key or custom color function. */\n colorScale?: string | ((d: number) => string);\n /** Configuration for the color scale component. */\n colorScaleConfig?: {\n axisConfig?: AxisConfig;\n centered?: boolean;\n colors?: string[];\n colorMin?: string;\n colorMid?: string;\n colorMax?: string;\n scale?: AxisScale;\n };\n /** Whether the color scale uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n colorScalePadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the color scale, `false` to hide it, or an accessor returning either. */\n colorScalePosition?: false | Position | (() => false | Position);\n /** Column key for matrix-style layouts. */\n column?: string;\n /**\n The confidence interval as `[lower, upper]` bounds — each given as an\n accessor function or a static data key (e.g. `[\"lci\", \"hci\"]`), or `false`\n to disable.\n */\n confidence?:\n | [\n string | ((d: DataPoint, i: number) => number),\n string | ((d: DataPoint, i: number) => number),\n ]\n | false;\n /** Maximum number of data points to render before downsampling. */\n dataCutoff?: number;\n /** Active depth level for nested groupings. */\n depth?: number;\n /** Sets orientation of main category axis. */\n discrete?: \"x\" | \"y\";\n /** Default duration of transitions, in milliseconds. */\n duration?: number;\n /** Predicate filtering which data points are included, or false to disable. */\n filter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Allows removing specific geographies from topojson file to improve zoom. */\n fitFilter?:\n | number\n | string\n | ((d: Record<string, unknown>) => boolean);\n /** Grouping key(s) or accessor function(s). */\n groupBy?:\n | string\n | string[]\n | ((d: DataPoint) => string | number)\n | ((d: DataPoint) => string | number)[];\n /** Padding between groups of bars in pixels. */\n groupPadding?: number;\n /** Overall height of the visualization in pixels. */\n height?: number;\n /** Color for legend shapes whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenColor?: string | ((d: DataPoint, i: number) => string);\n /** Opacity for legend labels whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */\n hiddenOpacity?: number | ((d: DataPoint, i: number) => number);\n /** The hover callback function for highlighting shapes on mouseover. */\n hover?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Persistently emphasizes matching marks (keep color) and grays the rest. */\n highlight?: ((d: DataPoint, i: number) => boolean) | false | null;\n /** Label accessor for shapes. */\n label?: string | string[] | false | AccessorFn;\n /**\n Controls legend visibility. Pass `false` to hide it, `true` to always\n show it, or a `(config, data) => boolean` accessor to decide dynamically\n — the chart defaults use an accessor to auto-hide the legend when it\n would be redundant.\n */\n legend?: boolean | ((config: D3plusConfig, arr: DataPoint[]) => boolean);\n /** Configuration for the legend component. */\n legendConfig?: {\n label?: DataPointAccessor<string>;\n shapeConfig?: Record<string, string | number>;\n };\n /** Inverts legend click behavior (click hides / shift-click solos, or the reverse), or an accessor receiving the viz. */\n legendFilterInvert?: boolean | ((viz: VizBase) => boolean);\n /** Whether the legend uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n legendPadding?: boolean | ((viz: VizBase) => boolean);\n /** Position of the legend, or an accessor returning it. */\n legendPosition?: Position | (() => Position);\n /** Custom sort comparator for legend items. */\n legendSort?: (a: DataPoint, b: DataPoint) => number;\n /** Tooltip configuration for legend items. */\n legendTooltip?: TooltipConfig;\n /** Whether to show labels on line charts. */\n lineLabels?: boolean;\n /** Whether to show the loading message. */\n loadingMessage?: boolean;\n /** Custom HTML content for the loading indicator, or a function receiving the viz instance. */\n loadingHTML?: string | ((viz: VizBase) => string);\n /** Metric key for the visualization. */\n metric?: string;\n /** Custom HTML content shown when no data is supplied, or a function receiving the viz instance. */\n noDataHTML?: string | ((viz: VizBase) => string);\n /** Ocean color for geomaps (any CSS value including 'transparent'). */\n ocean?: string;\n /** Event listeners keyed by event name. */\n on?: Record<string, (event: Event) => void>;\n /** Coordinate accessor for point-based geomaps. */\n point?: (d: DataPoint) => number[];\n /** Point size accessor for geomaps. */\n pointSize?: string | ((d: DataPoint) => number);\n /** Minimum point size for geomaps. */\n pointSizeMin?: number;\n /** Maximum point size for geomaps. */\n pointSizeMax?: number;\n /** Map projection name or function. */\n projection?: string | ((x: number, y: number) => [number, number]);\n /** Outer padding between the visualization edge and map shapes. */\n projectionPadding?: number | string;\n /** Rotation offset for the map projection center. */\n projectionRotate?: [number, number];\n /** Row key for matrix-style layouts. */\n row?: string;\n /** Scrollable container selector for tooltip positioning. */\n scrollContainer?: string | Window;\n /** Configuration for shape rendering. */\n shapeConfig?: {\n duration?: number;\n [key: string]: unknown;\n };\n /**\n A [sort comparator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\n that receives each shape class (e.g. \"Circle\", \"Line\") as its arguments.\n Shapes are drawn in groups by type, so this defines the layering order for\n all shapes of a given type.\n */\n shapeSort?: (a: string, b: string) => number;\n /** Size accessor key. */\n size?: string;\n /** Whether to stack series. */\n stacked?: boolean;\n /** Custom order for stacked series. */\n stackOrder?: string[];\n /** Subtitle text, or an accessor returning it. */\n subtitle?: string | ((data: DataPoint[]) => string);\n /** Whether the subtitle uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n subtitlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for treemaps and aggregation. */\n sum?: DataPointAccessor<number>;\n /** Accessible description applied to the root SVG (`<desc>`). */\n svgDesc?: string;\n /** Accessible title applied to the root SVG (`<title>`). */\n svgTitle?: string;\n /** Threshold value for grouping small slices. */\n threshold?: number;\n /** Label for the threshold group, or a `(datum, index)` accessor. */\n thresholdName?: string | ((d: DataPoint, i: number) => string);\n /** URL to XYZ map tiles. */\n tileUrl?: string;\n /** Whether to show map tiles. */\n tiles?: boolean;\n /** Time key for temporal data. */\n time?: string;\n /** Predicate filtering which time slices are shown, or false to disable. */\n timeFilter?: ((d: DataPoint, i: number) => boolean) | false;\n /** Whether to show the timeline component. */\n timeline?: boolean;\n /** Whether the timeline uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n timelinePadding?: boolean | ((viz: VizBase) => boolean);\n /** Chart title or title accessor function. */\n title?: string | ((data: DataPoint[]) => string);\n /** CSS style configuration for the title. */\n titleConfig?: Record<string, string | number>;\n /** Whether the title uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n titlePadding?: boolean | ((viz: VizBase) => boolean);\n /** Whether to show tooltips, or a `(datum, index)` accessor deciding per mark. */\n tooltip?: boolean | ((d: DataPoint, i: number) => boolean);\n /** Configuration for the tooltip component. */\n tooltipConfig?: TooltipConfig;\n /** Path or object for the topojson data. */\n topojson?: string | object;\n /** CSS color to fill the map shapes. */\n topojsonFill?: string;\n /** Accessor function for topojson feature IDs. */\n topojsonId?: (obj: Record<string, unknown>) => string;\n /** Whether the total uses the visualization's internal padding when positioning, or an accessor receiving the viz. */\n totalPadding?: boolean | ((viz: VizBase) => boolean);\n /** Value accessor for the visualization. */\n value?: DataPointAccessor<number>;\n /** Overall width of the visualization in pixels. */\n width?: number;\n /** Key, index, or accessor function for x-axis values. */\n x?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the x-axis. */\n xConfig?: AxisConfig;\n /** The x domain as an array. If either value is undefined, it is calculated from the data. */\n xDomain?: (number | Date)[];\n /** The x2 domain as an array. If either value is undefined, it is calculated from the data. */\n x2Domain?: (number | Date)[];\n /** Custom sort function for x-axis values. */\n xSort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete x2 axes. */\n x2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Key, index, or accessor function for y-axis values. */\n y?: string | number | ((d: DataPoint, i: number) => unknown);\n /** Configuration for the y-axis. */\n yConfig?: AxisConfig;\n /** The y domain as an array. If either value is undefined, it is calculated from the data. */\n yDomain?: (number | Date)[];\n /** The y2 domain as an array. If either value is undefined, it is calculated from the data. */\n y2Domain?: (number | Date)[];\n /** Custom sort function for y-axis values. */\n ySort?: (a: DataPoint, b: DataPoint) => number;\n /** Defines a custom sorting comparator function for discrete y2 axes. */\n y2Sort?: (a: DataPoint, b: DataPoint) => number;\n /** Set to false to disable zooming on Geomap and Network. */\n zoom?: boolean;\n /** Multiplier applied to programmatic zoom steps. */\n zoomFactor?: number;\n /** Maximum zoom scale factor. */\n zoomMax?: number;\n /** Whether panning (drag) is enabled while zoomed. */\n zoomPan?: boolean;\n /** Whether scroll-wheel zooming is enabled. */\n zoomScroll?: boolean;\n\n /** Allows additional custom properties. */\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AAmPA,WAiPC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3plus/core",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "browser": "./umd/d3plus-core.full.js",
19
19
  "engines": {
20
- "node": ">=20"
20
+ "node": ">=22"
21
21
  },
22
22
  "sideEffects": false,
23
23
  "files": [
@@ -62,14 +62,14 @@
62
62
  "open-color": "^1.9.1",
63
63
  "textures": "^1.2.3",
64
64
  "topojson-client": "^3.1.0",
65
- "@d3plus/dom": "4.0.0",
66
- "@d3plus/locales": "4.0.0",
67
- "@d3plus/render": "4.0.0",
68
- "@d3plus/data": "4.0.0",
69
- "@d3plus/text": "4.0.0",
70
- "@d3plus/math": "4.0.0",
71
- "@d3plus/color": "4.0.0",
72
- "@d3plus/format": "4.0.0"
65
+ "@d3plus/data": "4.1.0",
66
+ "@d3plus/dom": "4.1.0",
67
+ "@d3plus/format": "4.1.0",
68
+ "@d3plus/color": "4.1.0",
69
+ "@d3plus/text": "4.1.0",
70
+ "@d3plus/locales": "4.1.0",
71
+ "@d3plus/render": "4.1.0",
72
+ "@d3plus/math": "4.1.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "playwright": "1.59.1"
@@ -63,7 +63,7 @@ export default class VizBase extends VizBaseConfig {
63
63
  /**
64
64
  Tells the subtitle 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 subtitle appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
65
65
  */
66
- subtitlePadding(_?: boolean | (() => boolean)): this | boolean | (() => boolean);
66
+ subtitlePadding(_?: boolean | ((viz: VizBase) => boolean)): this | boolean | ((viz: VizBase) => boolean);
67
67
  /**
68
68
  The threshold value for bucketing small data points together.
69
69
  */
@@ -92,7 +92,7 @@ export default class VizBase extends VizBaseConfig {
92
92
  /**
93
93
  Tells the timeline 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 timeline appears centered underneath the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
94
94
  */
95
- timelinePadding(_?: boolean | (() => boolean)): this | boolean | (() => boolean);
95
+ timelinePadding(_?: boolean | ((viz: VizBase) => boolean)): this | boolean | ((viz: VizBase) => boolean);
96
96
  /**
97
97
  Accessor function or string for the visualization's title.
98
98
  */
@@ -104,7 +104,7 @@ export default class VizBase extends VizBaseConfig {
104
104
  /**
105
105
  Tells the title 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 title appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
106
106
  */
107
- titlePadding(_?: boolean | (() => boolean)): this | boolean | (() => boolean);
107
+ titlePadding(_?: boolean | ((viz: VizBase) => boolean)): this | boolean | ((viz: VizBase) => boolean);
108
108
  /**
109
109
  Whether to display tooltips on hover.
110
110
  */
@@ -128,7 +128,7 @@ export default class VizBase extends VizBaseConfig {
128
128
  /**
129
129
  Tells the total 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 total appears centered above the x-axis. By default, this padding is only applied on screens larger than 600 pixels wide.
130
130
  */
131
- totalPadding(_?: boolean | (() => boolean)): this | boolean | (() => boolean);
131
+ totalPadding(_?: boolean | ((viz: VizBase) => boolean)): this | boolean | ((viz: VizBase) => boolean);
132
132
  /**
133
133
  The pixel stroke-width of the zoom brush area.
134
134
  */
@@ -1,5 +1,6 @@
1
1
  import type { DataPoint } from "@d3plus/data";
2
2
  import { BaseClass } from "../../utils/index.js";
3
+ import type VizBase from "./VizBase.js";
3
4
  /**
4
5
  First half of the fluent config accessors shared by every Viz chart
5
6
  (`active` through `legendTooltip`). Split from `VizBase` purely so each
@@ -44,7 +45,7 @@ export default class VizBaseConfig extends BaseClass {
44
45
  /**
45
46
  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.
46
47
  */
47
- colorScalePadding(_?: boolean | (() => boolean)): this | boolean | (() => boolean);
48
+ colorScalePadding(_?: boolean | ((viz: VizBase) => boolean)): this | boolean | ((viz: VizBase) => boolean);
48
49
  /**
49
50
  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.
50
51
  */
@@ -140,11 +141,11 @@ export default class VizBaseConfig extends BaseClass {
140
141
  /**
141
142
  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.
142
143
  */
143
- legendFilterInvert(_?: boolean | (() => boolean)): this | boolean | (() => boolean);
144
+ legendFilterInvert(_?: boolean | ((viz: VizBase) => boolean)): this | boolean | ((viz: VizBase) => boolean);
144
145
  /**
145
146
  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.
146
147
  */
147
- legendPadding(_?: boolean | (() => boolean)): this | boolean | (() => boolean);
148
+ legendPadding(_?: boolean | ((viz: VizBase) => boolean)): this | boolean | ((viz: VizBase) => boolean);
148
149
  /**
149
150
  Defines which side of the visualization to anchor the legend. Expected values are `"top"`, `"bottom"`, `"left"`, and `"right"`.
150
151
  */
@@ -1,4 +1,5 @@
1
1
  import type { DataPoint } from "@d3plus/data";
2
+ import type VizBase from "../charts/viz/VizBase.js";
2
3
  import type { AccessorFn } from "./AccessorFn.js";
3
4
  type Position = "top" | "right" | "bottom" | "left";
4
5
  type DataPointAccessor<T> = string | ((d: DataPoint) => T);
@@ -217,8 +218,10 @@ export interface D3plusConfig {
217
218
  colorMax?: string;
218
219
  scale?: AxisScale;
219
220
  };
220
- /** Position of the color scale, or false to hide it. */
221
- colorScalePosition?: false | Position;
221
+ /** Whether the color scale uses the visualization's internal padding when positioning, or an accessor receiving the viz. */
222
+ colorScalePadding?: boolean | ((viz: VizBase) => boolean);
223
+ /** Position of the color scale, `false` to hide it, or an accessor returning either. */
224
+ colorScalePosition?: false | Position | (() => false | Position);
222
225
  /** Column key for matrix-style layouts. */
223
226
  column?: string;
224
227
  /**
@@ -248,21 +251,34 @@ export interface D3plusConfig {
248
251
  groupPadding?: number;
249
252
  /** Overall height of the visualization in pixels. */
250
253
  height?: number;
254
+ /** Color for legend shapes whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */
255
+ hiddenColor?: string | ((d: DataPoint, i: number) => string);
256
+ /** Opacity for legend labels whose grouping is hidden (via legend click), or a `(datum, index)` accessor. */
257
+ hiddenOpacity?: number | ((d: DataPoint, i: number) => number);
251
258
  /** The hover callback function for highlighting shapes on mouseover. */
252
259
  hover?: ((d: DataPoint, i: number) => boolean) | false | null;
253
260
  /** Persistently emphasizes matching marks (keep color) and grays the rest. */
254
261
  highlight?: ((d: DataPoint, i: number) => boolean) | false | null;
255
262
  /** Label accessor for shapes. */
256
263
  label?: string | string[] | false | AccessorFn;
257
- /** Whether to show the legend. */
258
- legend?: boolean;
264
+ /**
265
+ Controls legend visibility. Pass `false` to hide it, `true` to always
266
+ show it, or a `(config, data) => boolean` accessor to decide dynamically
267
+ — the chart defaults use an accessor to auto-hide the legend when it
268
+ would be redundant.
269
+ */
270
+ legend?: boolean | ((config: D3plusConfig, arr: DataPoint[]) => boolean);
259
271
  /** Configuration for the legend component. */
260
272
  legendConfig?: {
261
273
  label?: DataPointAccessor<string>;
262
274
  shapeConfig?: Record<string, string | number>;
263
275
  };
264
- /** Position of the legend. */
265
- legendPosition?: Position;
276
+ /** Inverts legend click behavior (click hides / shift-click solos, or the reverse), or an accessor receiving the viz. */
277
+ legendFilterInvert?: boolean | ((viz: VizBase) => boolean);
278
+ /** Whether the legend uses the visualization's internal padding when positioning, or an accessor receiving the viz. */
279
+ legendPadding?: boolean | ((viz: VizBase) => boolean);
280
+ /** Position of the legend, or an accessor returning it. */
281
+ legendPosition?: Position | (() => Position);
266
282
  /** Custom sort comparator for legend items. */
267
283
  legendSort?: (a: DataPoint, b: DataPoint) => number;
268
284
  /** Tooltip configuration for legend items. */
@@ -271,10 +287,12 @@ export interface D3plusConfig {
271
287
  lineLabels?: boolean;
272
288
  /** Whether to show the loading message. */
273
289
  loadingMessage?: boolean;
274
- /** Custom HTML content for the loading indicator. */
275
- loadingHTML?: string;
290
+ /** Custom HTML content for the loading indicator, or a function receiving the viz instance. */
291
+ loadingHTML?: string | ((viz: VizBase) => string);
276
292
  /** Metric key for the visualization. */
277
293
  metric?: string;
294
+ /** Custom HTML content shown when no data is supplied, or a function receiving the viz instance. */
295
+ noDataHTML?: string | ((viz: VizBase) => string);
278
296
  /** Ocean color for geomaps (any CSS value including 'transparent'). */
279
297
  ocean?: string;
280
298
  /** Event listeners keyed by event name. */
@@ -315,6 +333,10 @@ export interface D3plusConfig {
315
333
  stacked?: boolean;
316
334
  /** Custom order for stacked series. */
317
335
  stackOrder?: string[];
336
+ /** Subtitle text, or an accessor returning it. */
337
+ subtitle?: string | ((data: DataPoint[]) => string);
338
+ /** Whether the subtitle uses the visualization's internal padding when positioning, or an accessor receiving the viz. */
339
+ subtitlePadding?: boolean | ((viz: VizBase) => boolean);
318
340
  /** Value accessor for treemaps and aggregation. */
319
341
  sum?: DataPointAccessor<number>;
320
342
  /** Accessible description applied to the root SVG (`<desc>`). */
@@ -323,8 +345,8 @@ export interface D3plusConfig {
323
345
  svgTitle?: string;
324
346
  /** Threshold value for grouping small slices. */
325
347
  threshold?: number;
326
- /** Label for the threshold group. */
327
- thresholdName?: string;
348
+ /** Label for the threshold group, or a `(datum, index)` accessor. */
349
+ thresholdName?: string | ((d: DataPoint, i: number) => string);
328
350
  /** URL to XYZ map tiles. */
329
351
  tileUrl?: string;
330
352
  /** Whether to show map tiles. */
@@ -335,12 +357,16 @@ export interface D3plusConfig {
335
357
  timeFilter?: ((d: DataPoint, i: number) => boolean) | false;
336
358
  /** Whether to show the timeline component. */
337
359
  timeline?: boolean;
360
+ /** Whether the timeline uses the visualization's internal padding when positioning, or an accessor receiving the viz. */
361
+ timelinePadding?: boolean | ((viz: VizBase) => boolean);
338
362
  /** Chart title or title accessor function. */
339
363
  title?: string | ((data: DataPoint[]) => string);
340
364
  /** CSS style configuration for the title. */
341
365
  titleConfig?: Record<string, string | number>;
342
- /** Whether to show tooltips. */
343
- tooltip?: boolean;
366
+ /** Whether the title uses the visualization's internal padding when positioning, or an accessor receiving the viz. */
367
+ titlePadding?: boolean | ((viz: VizBase) => boolean);
368
+ /** Whether to show tooltips, or a `(datum, index)` accessor deciding per mark. */
369
+ tooltip?: boolean | ((d: DataPoint, i: number) => boolean);
344
370
  /** Configuration for the tooltip component. */
345
371
  tooltipConfig?: TooltipConfig;
346
372
  /** Path or object for the topojson data. */
@@ -349,6 +375,8 @@ export interface D3plusConfig {
349
375
  topojsonFill?: string;
350
376
  /** Accessor function for topojson feature IDs. */
351
377
  topojsonId?: (obj: Record<string, unknown>) => string;
378
+ /** Whether the total uses the visualization's internal padding when positioning, or an accessor receiving the viz. */
379
+ totalPadding?: boolean | ((viz: VizBase) => boolean);
352
380
  /** Value accessor for the visualization. */
353
381
  value?: DataPointAccessor<number>;
354
382
  /** Overall width of the visualization in pixels. */