@unovis/ts 1.7.0-Phoenix.0 → 1.7.0-stellar.2

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.
Files changed (54) hide show
  1. package/components/area/config.d.ts +2 -0
  2. package/components/area/config.js +1 -1
  3. package/components/area/config.js.map +1 -1
  4. package/components/area/index.js +6 -3
  5. package/components/area/index.js.map +1 -1
  6. package/components/crosshair/config.d.ts +1 -1
  7. package/components/crosshair/config.js.map +1 -1
  8. package/components/crosshair/index.d.ts +1 -1
  9. package/components/crosshair/index.js.map +1 -1
  10. package/components/sankey/config.d.ts +0 -8
  11. package/components/sankey/config.js +1 -1
  12. package/components/sankey/config.js.map +1 -1
  13. package/components/sankey/index.d.ts +0 -29
  14. package/components/sankey/index.js +0 -70
  15. package/components/sankey/index.js.map +1 -1
  16. package/components/sankey/modules/link.js +3 -16
  17. package/components/sankey/modules/link.js.map +1 -1
  18. package/components/sankey/types.d.ts +0 -2
  19. package/components/sankey/types.js.map +1 -1
  20. package/components/tooltip/index.js +2 -2
  21. package/components/tooltip/index.js.map +1 -1
  22. package/components/topojson-map/config.d.ts +57 -1
  23. package/components/topojson-map/config.js +6 -2
  24. package/components/topojson-map/config.js.map +1 -1
  25. package/components/topojson-map/index.d.ts +25 -0
  26. package/components/topojson-map/index.js +708 -32
  27. package/components/topojson-map/index.js.map +1 -1
  28. package/components/topojson-map/modules/donut.d.ts +3 -0
  29. package/components/topojson-map/modules/donut.js +25 -0
  30. package/components/topojson-map/modules/donut.js.map +1 -0
  31. package/components/topojson-map/style.d.ts +6 -0
  32. package/components/topojson-map/style.js +45 -1
  33. package/components/topojson-map/style.js.map +1 -1
  34. package/components/topojson-map/types.d.ts +82 -0
  35. package/components/topojson-map/types.js +8 -1
  36. package/components/topojson-map/types.js.map +1 -1
  37. package/components/topojson-map/utils.d.ts +17 -0
  38. package/components/topojson-map/utils.js +177 -3
  39. package/components/topojson-map/utils.js.map +1 -1
  40. package/components.d.ts +2 -0
  41. package/components.js +1 -0
  42. package/components.js.map +1 -1
  43. package/containers/single-container/config.d.ts +3 -0
  44. package/containers/single-container/config.js.map +1 -1
  45. package/containers/single-container/index.js +2 -1
  46. package/containers/single-container/index.js.map +1 -1
  47. package/containers/xy-container/config.d.ts +3 -0
  48. package/containers/xy-container/config.js.map +1 -1
  49. package/containers/xy-container/index.d.ts +1 -0
  50. package/containers/xy-container/index.js +13 -9
  51. package/containers/xy-container/index.js.map +1 -1
  52. package/index.js +1 -1
  53. package/package.json +1 -1
  54. package/types.js +1 -1
@@ -21,5 +21,7 @@ export interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<D
21
21
  * practically invisible, but you want to show that the data behind them exists and they're not just empty segments.
22
22
  * Default: `undefined` */
23
23
  minHeight?: number;
24
+ /** Whether to stack min height areas or not. Default: `undefined` */
25
+ stackMinHeight?: boolean;
24
26
  }
25
27
  export declare const AreaDefaultConfig: AreaConfigInterface<unknown>;
@@ -1,7 +1,7 @@
1
1
  import { XYComponentDefaultConfig } from '../../core/xy-component/config.js';
2
2
  import { CurveType } from '../../types/curve.js';
3
3
 
4
- const AreaDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { color: undefined, curveType: CurveType.MonotoneX, baseline: () => 0, opacity: 1, cursor: null, minHeight1Px: false, minHeight: undefined });
4
+ const AreaDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { color: undefined, curveType: CurveType.MonotoneX, baseline: () => 0, opacity: 1, cursor: null, minHeight1Px: false, minHeight: undefined, stackMinHeight: false });
5
5
 
6
6
  export { AreaDefaultConfig };
7
7
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/area/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { ColorAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Area color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n color?: ColorAccessor<Datum[]>;\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType | string;\n /** Baseline value or accessor function. Default: `undefined` */\n baseline?: NumericAccessor<Datum>;\n /** Opacity value or accessor function. Default: `1` */\n opacity?: NumericAccessor<Datum[]>;\n /** Optional area cursor. String or accessor function. Default: `null` */\n cursor?: StringAccessor<Datum[]>;\n /** If an area is smaller than 1px, extend it to have 1px height. Default: `false`\n * @deprecated Use minHeight instead\n */\n minHeight1Px?: boolean;\n /** Minimum height of the area, use carefully.\n * This setting is useful when some of the area values are zeros or very small so visually they become\n * practically invisible, but you want to show that the data behind them exists and they're not just empty segments.\n * Default: `undefined` */\n minHeight?: number;\n}\n\nexport const AreaDefaultConfig: AreaConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n color: undefined,\n curveType: CurveType.MonotoneX,\n baseline: (): number => 0,\n opacity: 1,\n cursor: null,\n minHeight1Px: false,\n minHeight: undefined,\n}\n"],"names":[],"mappings":";;;AA4Ba,MAAA,iBAAiB,GACzB,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,wBAAwB,KAC3B,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,QAAQ,EAAE,MAAc,CAAC,EACzB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,IAAI,EACZ,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,SAAS;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/area/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { ColorAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Area color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n color?: ColorAccessor<Datum[]>;\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType | string;\n /** Baseline value or accessor function. Default: `undefined` */\n baseline?: NumericAccessor<Datum>;\n /** Opacity value or accessor function. Default: `1` */\n opacity?: NumericAccessor<Datum[]>;\n /** Optional area cursor. String or accessor function. Default: `null` */\n cursor?: StringAccessor<Datum[]>;\n /** If an area is smaller than 1px, extend it to have 1px height. Default: `false`\n * @deprecated Use minHeight instead\n */\n minHeight1Px?: boolean;\n /** Minimum height of the area, use carefully.\n * This setting is useful when some of the area values are zeros or very small so visually they become\n * practically invisible, but you want to show that the data behind them exists and they're not just empty segments.\n * Default: `undefined` */\n minHeight?: number;\n /** Whether to stack min height areas or not. Default: `undefined` */\n stackMinHeight?: boolean;\n}\n\nexport const AreaDefaultConfig: AreaConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n color: undefined,\n curveType: CurveType.MonotoneX,\n baseline: (): number => 0,\n opacity: 1,\n cursor: null,\n minHeight1Px: false,\n minHeight: undefined,\n stackMinHeight: false,\n}\n"],"names":[],"mappings":";;;AA8Ba,MAAA,iBAAiB,mCACzB,wBAAwB,CAAA,EAAA,EAC3B,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,QAAQ,EAAE,MAAc,CAAC,EACzB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,IAAI,EACZ,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,KAAK;;;;"}
@@ -47,8 +47,8 @@ class Area extends XYComponentCore {
47
47
  const y0 = this.yScale(d[0]);
48
48
  const y1 = this.yScale(d[1]);
49
49
  const isNegativeArea = y1 > y0;
50
- // Get cumulative adjustment and apply in the correct direction
51
- const cumulative = minHeightCumulativeArray[j] || 0;
50
+ // Only apply cumulative adjustment if `config.stackMinHeight` is true
51
+ const cumulative = config.stackMinHeight ? (minHeightCumulativeArray[j] || 0) : 0;
52
52
  const adjustedY0 = isNegativeArea ? y0 + cumulative : y0 - cumulative;
53
53
  const adjustedY1 = isNegativeArea ? y1 + cumulative : y1 - cumulative;
54
54
  // Calculate height adjustment if needed
@@ -56,7 +56,10 @@ class Area extends XYComponentCore {
56
56
  if ((config.minHeight || config.minHeight1Px) &&
57
57
  Math.abs(adjustedY1 - adjustedY0) < ((_a = config.minHeight) !== null && _a !== void 0 ? _a : 1)) {
58
58
  heightAdjustment = ((_b = config.minHeight) !== null && _b !== void 0 ? _b : 1) - Math.abs(adjustedY1 - adjustedY0);
59
- minHeightCumulativeArray[j] = cumulative + heightAdjustment;
59
+ // Only update cumulative array if we're stacking min heights
60
+ if (config.stackMinHeight) {
61
+ minHeightCumulativeArray[j] = cumulative + heightAdjustment;
62
+ }
60
63
  }
61
64
  return {
62
65
  x,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/area/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { area, Area as AreaInterface } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, isArray, isNumber, getStackedExtent, getStackedData, filterDataByRange } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Curve, CurveType } from 'types/curve'\nimport { NumericAccessor } from 'types/accessor'\n\n// Local Types\nimport { AreaDatum } from './types'\n\n// Config\nimport { AreaDefaultConfig, AreaConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Area<Datum> extends XYComponentCore<Datum, AreaConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = AreaDefaultConfig as AreaConfigInterface<Datum>\n public config: AreaConfigInterface<Datum> = this._defaultConfig\n public stacked = true\n private _areaGen: AreaInterface<AreaDatum>\n private _prevNegative: boolean[] | undefined // To help guessing the stack direction when an accessor was set to null or 0\n\n events = {\n [Area.selectors.area]: {},\n }\n\n constructor (config?: AreaConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n // Determine if the provided chart should be stacked\n this.stacked = Array.isArray(this.config.y)\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const curveGen = Curve[config.curveType as CurveType]\n this._areaGen = area<AreaDatum>()\n .x(d => d.x)\n .y0(d => d.y0)\n .y1(d => d.y1)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n .curve(curveGen)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const areaDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n\n const stacked = getStackedData(data, config.baseline, yAccessors, this._prevNegative)\n this._prevNegative = stacked.map(s => !!s.isMostlyNegative)\n const minHeightCumulativeArray: number[] = []\n const stackedData: AreaDatum[][] = stacked.map(\n arr => arr.map(\n (d, j) => {\n const x = areaDataX[j]\n const y0 = this.yScale(d[0])\n const y1 = this.yScale(d[1])\n const isNegativeArea = y1 > y0\n\n // Get cumulative adjustment and apply in the correct direction\n const cumulative = minHeightCumulativeArray[j] || 0\n const adjustedY0 = isNegativeArea ? y0 + cumulative : y0 - cumulative\n const adjustedY1 = isNegativeArea ? y1 + cumulative : y1 - cumulative\n\n // Calculate height adjustment if needed\n let heightAdjustment = 0\n if ((config.minHeight || config.minHeight1Px) &&\n Math.abs(adjustedY1 - adjustedY0) < (config.minHeight ?? 1)) {\n heightAdjustment = (config.minHeight ?? 1) - Math.abs(adjustedY1 - adjustedY0)\n minHeightCumulativeArray[j] = cumulative + heightAdjustment\n }\n\n return {\n x,\n y0: adjustedY0,\n y1: isNegativeArea ? adjustedY1 + heightAdjustment : adjustedY1 - heightAdjustment,\n }\n }\n )\n )\n\n // We reverse the data in order to have the first areas to be displayed on top\n // for better visibility when they're close to zero\n const areaMaxIdx = stackedData.length - 1\n const stackedDataReversed = stackedData.reverse()\n const areas = this.g\n .selectAll<SVGPathElement, AreaDatum>(`.${s.area}`)\n .data(stackedDataReversed)\n\n const areasEnter = areas.enter().append('path')\n .attr('class', s.area)\n .attr('d', d => this._areaGen(d) || this._emptyPath())\n .style('opacity', 0)\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n\n const areasMerged = smartTransition(areasEnter.merge(areas), duration)\n .style('opacity', (d, i) => {\n const isDefined = d.some(p => (p.y0 - p.y1) !== 0)\n return isDefined ? getNumber(data, config.opacity, areaMaxIdx - i) : 0\n })\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n .style('cursor', (d, i) => getString(data, config.cursor, areaMaxIdx - i))\n\n if (duration) {\n const transition = areasMerged as Transition<SVGPathElement, AreaDatum[], SVGGElement, AreaDatum[]>\n transition.attrTween('d', (d, i, el) => {\n const previous = select(el[i]).attr('d')\n const next = this._areaGen(d) || this._emptyPath()\n return interpolatePath(previous, next)\n })\n } else {\n areasMerged.attr('d', d => this._areaGen(d) || this._emptyPath())\n }\n\n smartTransition(areas.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const xDomain = this.xScale.domain() as [number, number]\n const data = scaleByVisibleData ? filterDataByRange(datamodel.data, xDomain, config.x, true) : datamodel.data\n return getStackedExtent(data, config.baseline, ...yAccessors)\n }\n\n _emptyPath (): string {\n const xRange = this.xScale.range()\n const yDomain = this.yScale.domain() as number[]\n\n const y0 = this.yScale((yDomain[0] + yDomain[1]) / 2)\n const y1 = y0\n\n return this._areaGen([\n { y0, y1, x: xRange[0] },\n { y0, y1, x: xRange[1] },\n ])\n }\n}\n"],"names":["s.area","s"],"mappings":";;;;;;;;;;;;AA0BM,MAAO,IAAY,SAAQ,eAAkD,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,IAAI,CAAC,QAAQ,CAAC;YACnB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;YACxB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;AACzB,SAAA,CAAC,CAAA;KACH;;AA/HM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/area/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { area, Area as AreaInterface } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, isArray, isNumber, getStackedExtent, getStackedData, filterDataByRange } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Curve, CurveType } from 'types/curve'\nimport { NumericAccessor } from 'types/accessor'\n\n// Local Types\nimport { AreaDatum } from './types'\n\n// Config\nimport { AreaDefaultConfig, AreaConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Area<Datum> extends XYComponentCore<Datum, AreaConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = AreaDefaultConfig as AreaConfigInterface<Datum>\n public config: AreaConfigInterface<Datum> = this._defaultConfig\n public stacked = true\n private _areaGen: AreaInterface<AreaDatum>\n private _prevNegative: boolean[] | undefined // To help guessing the stack direction when an accessor was set to null or 0\n\n events = {\n [Area.selectors.area]: {},\n }\n\n constructor (config?: AreaConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n // Determine if the provided chart should be stacked\n this.stacked = Array.isArray(this.config.y)\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const curveGen = Curve[config.curveType as CurveType]\n this._areaGen = area<AreaDatum>()\n .x(d => d.x)\n .y0(d => d.y0)\n .y1(d => d.y1)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n .curve(curveGen)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const areaDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n\n const stacked = getStackedData(data, config.baseline, yAccessors, this._prevNegative)\n this._prevNegative = stacked.map(s => !!s.isMostlyNegative)\n const minHeightCumulativeArray: number[] = []\n const stackedData: AreaDatum[][] = stacked.map(\n arr => arr.map(\n (d, j) => {\n const x = areaDataX[j]\n const y0 = this.yScale(d[0])\n const y1 = this.yScale(d[1])\n const isNegativeArea = y1 > y0\n\n // Only apply cumulative adjustment if `config.stackMinHeight` is true\n const cumulative = config.stackMinHeight ? (minHeightCumulativeArray[j] || 0) : 0\n const adjustedY0 = isNegativeArea ? y0 + cumulative : y0 - cumulative\n const adjustedY1 = isNegativeArea ? y1 + cumulative : y1 - cumulative\n\n // Calculate height adjustment if needed\n let heightAdjustment = 0\n if ((config.minHeight || config.minHeight1Px) &&\n Math.abs(adjustedY1 - adjustedY0) < (config.minHeight ?? 1)) {\n heightAdjustment = (config.minHeight ?? 1) - Math.abs(adjustedY1 - adjustedY0)\n\n // Only update cumulative array if we're stacking min heights\n if (config.stackMinHeight) {\n minHeightCumulativeArray[j] = cumulative + heightAdjustment\n }\n }\n\n return {\n x,\n y0: adjustedY0,\n y1: isNegativeArea ? adjustedY1 + heightAdjustment : adjustedY1 - heightAdjustment,\n }\n }\n )\n )\n\n // We reverse the data in order to have the first areas to be displayed on top\n // for better visibility when they're close to zero\n const areaMaxIdx = stackedData.length - 1\n const stackedDataReversed = stackedData.reverse()\n const areas = this.g\n .selectAll<SVGPathElement, AreaDatum>(`.${s.area}`)\n .data(stackedDataReversed)\n\n const areasEnter = areas.enter().append('path')\n .attr('class', s.area)\n .attr('d', d => this._areaGen(d) || this._emptyPath())\n .style('opacity', 0)\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n\n const areasMerged = smartTransition(areasEnter.merge(areas), duration)\n .style('opacity', (d, i) => {\n const isDefined = d.some(p => (p.y0 - p.y1) !== 0)\n return isDefined ? getNumber(data, config.opacity, areaMaxIdx - i) : 0\n })\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n .style('cursor', (d, i) => getString(data, config.cursor, areaMaxIdx - i))\n\n if (duration) {\n const transition = areasMerged as Transition<SVGPathElement, AreaDatum[], SVGGElement, AreaDatum[]>\n transition.attrTween('d', (d, i, el) => {\n const previous = select(el[i]).attr('d')\n const next = this._areaGen(d) || this._emptyPath()\n return interpolatePath(previous, next)\n })\n } else {\n areasMerged.attr('d', d => this._areaGen(d) || this._emptyPath())\n }\n\n smartTransition(areas.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const xDomain = this.xScale.domain() as [number, number]\n const data = scaleByVisibleData ? filterDataByRange(datamodel.data, xDomain, config.x, true) : datamodel.data\n return getStackedExtent(data, config.baseline, ...yAccessors)\n }\n\n _emptyPath (): string {\n const xRange = this.xScale.range()\n const yDomain = this.yScale.domain() as number[]\n\n const y0 = this.yScale((yDomain[0] + yDomain[1]) / 2)\n const y1 = y0\n\n return this._areaGen([\n { y0, y1, x: xRange[0] },\n { y0, y1, x: xRange[1] },\n ])\n }\n}\n"],"names":["s.area","s"],"mappings":";;;;;;;;;;;;AA0BM,MAAO,IAAY,SAAQ,eAAkD,CAAA;AAYjF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QAXC,IAAc,CAAA,cAAA,GAAG,iBAA+C,CAAA;AACnE,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;QACxD,IAAO,CAAA,OAAA,GAAG,IAAI,CAAA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AAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;AACzB,SAAA,CAAC,CAAA;KACH;;AAnIM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -24,7 +24,7 @@ export interface CrosshairConfigInterface<Datum> extends WithOptional<XYComponen
24
24
  /** Tooltip template accessor. The function is supposed to return either a valid HTML string or an HTMLElement.
25
25
  * When `snapToData` is `false`, `datum` will be `undefined` but `data` and `leftNearestDatumIndex` will be provided.
26
26
  * Default: `d => ''` */
27
- template?: (datum: Datum, x: number | Date, data?: Datum[], leftNearestDatumIndex?: number) => string | HTMLElement;
27
+ template?: (datum: Datum, x: number | Date, data: Datum[], leftNearestDatumIndex?: number) => string | HTMLElement;
28
28
  /** Hide Crosshair when the corresponding datum element is far from mouse pointer. Default: `true` */
29
29
  hideWhenFarFromPointer?: boolean;
30
30
  /** Distance in pixels to check in the hideWhenFarFromPointer condition. Default: `100` */
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/crosshair/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\nimport { Tooltip } from 'components/tooltip'\n\n// Types\nimport { NumericAccessor, ColorAccessor } from 'types/accessor'\nimport { ContinuousScale } from 'types/scale'\nimport { WithOptional } from 'types/misc'\nimport { CrosshairCircle } from './types'\n\n// We extend partial XY config interface because x and y properties are optional for Crosshair\nexport interface CrosshairConfigInterface<Datum> extends WithOptional<XYComponentConfigInterface<Datum>, 'x' | 'y'> {\n /** Optional accessor function for getting the values along the X axis. Default: `undefined` */\n x?: NumericAccessor<Datum>;\n /** Optional single of multiple accessor functions for getting the values along the Y axis. Default: `undefined` */\n y?: NumericAccessor<Datum> | NumericAccessor<Datum>[];\n /** Optional color array or color accessor function for crosshair circles. Default: `d => d.color` */\n color?: ColorAccessor<Datum>;\n /** Optional stroke color accessor function for crosshair circles. Default: `undefined` */\n strokeColor?: ColorAccessor<Datum>;\n /** Optional stroke width for crosshair circles. Default: `undefined` */\n strokeWidth?: NumericAccessor<Datum>;\n /** Separate array of accessors for stacked components (eg StackedBar, Area). Default: `undefined` */\n yStacked?: NumericAccessor<Datum>[];\n /** Baseline accessor function for stacked values, useful with stacked areas. Default: `null` */\n baseline?: NumericAccessor<Datum>;\n /** An instance of the Tooltip component to be used with Crosshair. Default: `undefined` */\n tooltip?: Tooltip | undefined;\n // TODO: Change `datum` type to `Datum | undefined`. This may break the build for many people, so we might want to do it in version 2.0\n /** Tooltip template accessor. The function is supposed to return either a valid HTML string or an HTMLElement.\n * When `snapToData` is `false`, `datum` will be `undefined` but `data` and `leftNearestDatumIndex` will be provided.\n * Default: `d => ''` */\n template?: (datum: Datum, x: number | Date, data?: Datum[], leftNearestDatumIndex?: number) => string | HTMLElement;\n /** Hide Crosshair when the corresponding datum element is far from mouse pointer. Default: `true` */\n hideWhenFarFromPointer?: boolean;\n /** Distance in pixels to check in the hideWhenFarFromPointer condition. Default: `100` */\n hideWhenFarFromPointerDistance?: number;\n /** Snap to the nearest data point.\n * If disabled, the tooltip template will receive only the horizontal position of the crosshair and you'll be responsible\n * for getting the underlying data records and crosshair circles (see the `getCircles` configuration option).\n * Default: `true`\n */\n snapToData?: boolean;\n /** Custom function for setting up the crosshair circles, usually needed when `snapToData` is set to `false`.\n * The function receives the horizontal position of the crosshair (in the data space, not in pixels), the data array,\n * the `yScale` instance to help you calculate the correct vertical position of the circles, and the nearest datum index.\n * It has to return an array of the `CrosshairCircle` objects: `{ y: number; color: string; opacity?: number }[]`.\n * Default: `undefined`\n */\n getCircles?: (x: number | Date, data: Datum[], yScale: ContinuousScale, leftNearestDatumIndex?: number) => CrosshairCircle[];\n /** Callback function that is called when the crosshair is moved:\n * - `x` is the horizontal position of the crosshair in the data space;\n * - `datum` is the nearest datum to the crosshair;\n * - `datumIndex` is the index of the nearest datum.\n * - `event` is the event that triggered the crosshair move (mouse or wheel).\n *\n * When the mouse goes out of the container and on wheel events, all the arguments are `undefined` except for `event`.\n * Default: `undefined` */\n onCrosshairMove?: (x?: number | Date, datum?: Datum, datumIndex?: number, event?: MouseEvent | WheelEvent) => void;\n /** Force the crosshair to show at a specific position. Default: `undefined` */\n forceShowAt?: number | Date;\n /** Skip range checks for crosshair visibility. When true, crosshair will show regardless of position within chart bounds. Default: `false`\n * This is useful for testing, especially when you only triggers mousemove event but does not have real mouse event.\n */\n skipRangeCheck?: boolean;\n}\n\nexport const CrosshairDefaultConfig: CrosshairConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n yStacked: undefined,\n baseline: null,\n duration: 100,\n tooltip: undefined,\n template: <Datum>(d: Datum, x: number | Date, data?: Datum[], leftNearestDatumIndex?: number): string => '',\n hideWhenFarFromPointer: true,\n hideWhenFarFromPointerDistance: 100,\n snapToData: true,\n getCircles: undefined,\n color: undefined,\n strokeColor: undefined,\n strokeWidth: undefined,\n onCrosshairMove: undefined,\n forceShowAt: undefined,\n skipRangeCheck: false,\n}\n\n"],"names":[],"mappings":";;AAkEa,MAAA,sBAAsB,GAC9B,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,wBAAwB,KAC3B,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,CAAQ,CAAQ,EAAE,CAAgB,EAAE,IAAc,EAAE,qBAA8B,KAAa,EAAE,EAC3G,sBAAsB,EAAE,IAAI,EAC5B,8BAA8B,EAAE,GAAG,EACnC,UAAU,EAAE,IAAI,EAChB,UAAU,EAAE,SAAS,EACrB,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,SAAS,EACtB,WAAW,EAAE,SAAS,EACtB,eAAe,EAAE,SAAS,EAC1B,WAAW,EAAE,SAAS,EACtB,cAAc,EAAE,KAAK;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/crosshair/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\nimport { Tooltip } from 'components/tooltip'\n\n// Types\nimport { NumericAccessor, ColorAccessor } from 'types/accessor'\nimport { ContinuousScale } from 'types/scale'\nimport { WithOptional } from 'types/misc'\nimport { CrosshairCircle } from './types'\n\n// We extend partial XY config interface because x and y properties are optional for Crosshair\nexport interface CrosshairConfigInterface<Datum> extends WithOptional<XYComponentConfigInterface<Datum>, 'x' | 'y'> {\n /** Optional accessor function for getting the values along the X axis. Default: `undefined` */\n x?: NumericAccessor<Datum>;\n /** Optional single of multiple accessor functions for getting the values along the Y axis. Default: `undefined` */\n y?: NumericAccessor<Datum> | NumericAccessor<Datum>[];\n /** Optional color array or color accessor function for crosshair circles. Default: `d => d.color` */\n color?: ColorAccessor<Datum>;\n /** Optional stroke color accessor function for crosshair circles. Default: `undefined` */\n strokeColor?: ColorAccessor<Datum>;\n /** Optional stroke width for crosshair circles. Default: `undefined` */\n strokeWidth?: NumericAccessor<Datum>;\n /** Separate array of accessors for stacked components (eg StackedBar, Area). Default: `undefined` */\n yStacked?: NumericAccessor<Datum>[];\n /** Baseline accessor function for stacked values, useful with stacked areas. Default: `null` */\n baseline?: NumericAccessor<Datum>;\n /** An instance of the Tooltip component to be used with Crosshair. Default: `undefined` */\n tooltip?: Tooltip | undefined;\n // TODO: Change `datum` type to `Datum | undefined`. This may break the build for many people, so we might want to do it in version 2.0\n /** Tooltip template accessor. The function is supposed to return either a valid HTML string or an HTMLElement.\n * When `snapToData` is `false`, `datum` will be `undefined` but `data` and `leftNearestDatumIndex` will be provided.\n * Default: `d => ''` */\n template?: (datum: Datum, x: number | Date, data: Datum[], leftNearestDatumIndex?: number) => string | HTMLElement;\n /** Hide Crosshair when the corresponding datum element is far from mouse pointer. Default: `true` */\n hideWhenFarFromPointer?: boolean;\n /** Distance in pixels to check in the hideWhenFarFromPointer condition. Default: `100` */\n hideWhenFarFromPointerDistance?: number;\n /** Snap to the nearest data point.\n * If disabled, the tooltip template will receive only the horizontal position of the crosshair and you'll be responsible\n * for getting the underlying data records and crosshair circles (see the `getCircles` configuration option).\n * Default: `true`\n */\n snapToData?: boolean;\n /** Custom function for setting up the crosshair circles, usually needed when `snapToData` is set to `false`.\n * The function receives the horizontal position of the crosshair (in the data space, not in pixels), the data array,\n * the `yScale` instance to help you calculate the correct vertical position of the circles, and the nearest datum index.\n * It has to return an array of the `CrosshairCircle` objects: `{ y: number; color: string; opacity?: number }[]`.\n * Default: `undefined`\n */\n getCircles?: (x: number | Date, data: Datum[], yScale: ContinuousScale, leftNearestDatumIndex?: number) => CrosshairCircle[];\n /** Callback function that is called when the crosshair is moved:\n * - `x` is the horizontal position of the crosshair in the data space;\n * - `datum` is the nearest datum to the crosshair;\n * - `datumIndex` is the index of the nearest datum.\n * - `event` is the event that triggered the crosshair move (mouse or wheel).\n *\n * When the mouse goes out of the container and on wheel events, all the arguments are `undefined` except for `event`.\n * Default: `undefined` */\n onCrosshairMove?: (x?: number | Date, datum?: Datum, datumIndex?: number, event?: MouseEvent | WheelEvent) => void;\n /** Force the crosshair to show at a specific position. Default: `undefined` */\n forceShowAt?: number | Date;\n /** Skip range checks for crosshair visibility. When true, crosshair will show regardless of position within chart bounds. Default: `false`\n * This is useful for testing, especially when you only triggers mousemove event but does not have real mouse event.\n */\n skipRangeCheck?: boolean;\n}\n\nexport const CrosshairDefaultConfig: CrosshairConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n yStacked: undefined,\n baseline: null,\n duration: 100,\n tooltip: undefined,\n template: <Datum>(d: Datum, x: number | Date, data: Datum[], leftNearestDatumIndex?: number): string => '',\n hideWhenFarFromPointer: true,\n hideWhenFarFromPointerDistance: 100,\n snapToData: true,\n getCircles: undefined,\n color: undefined,\n strokeColor: undefined,\n strokeWidth: undefined,\n onCrosshairMove: undefined,\n forceShowAt: undefined,\n skipRangeCheck: false,\n}\n\n"],"names":[],"mappings":";;AAkEa,MAAA,sBAAsB,GAC9B,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,wBAAwB,KAC3B,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,CAAQ,CAAQ,EAAE,CAAgB,EAAE,IAAa,EAAE,qBAA8B,KAAa,EAAE,EAC1G,sBAAsB,EAAE,IAAI,EAC5B,8BAA8B,EAAE,GAAG,EACnC,UAAU,EAAE,IAAI,EAChB,UAAU,EAAE,SAAS,EACrB,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,SAAS,EACtB,WAAW,EAAE,SAAS,EACtB,eAAe,EAAE,SAAS,EAC1B,WAAW,EAAE,SAAS,EACtB,cAAc,EAAE,KAAK;;;;"}
@@ -30,7 +30,7 @@ export declare class Crosshair<Datum> extends XYComponentCore<Datum, CrosshairCo
30
30
  _onMouseMove(event: MouseEvent): void;
31
31
  _onMouseOut(event?: MouseEvent): void;
32
32
  _onWheel(event: WheelEvent): void;
33
- _showTooltip(datum: Datum, xValue: number, pos: [number, number], nearestDatumIndex: number | undefined): void;
33
+ _showTooltip(datum: Datum | undefined, xValue: number, pos: [number, number], nearestDatumIndex: number | undefined): void;
34
34
  _hideTooltip(): void;
35
35
  getYDataExtent(): number[];
36
36
  private getCircleData;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/crosshair/index.ts"],"sourcesContent":["import { Selection, pointer } from 'd3-selection'\nimport { easeLinear } from 'd3-ease'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\nimport { Tooltip } from 'components/tooltip'\n\n// Utils\nimport { isNumber, isArray, getNumber, clamp, getStackedValues, getNearest, isFunction } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Position } from 'types/position'\nimport { FindNearestDirection } from 'types/data'\n\n// Local Types\nimport { CrosshairAccessors, CrosshairCircle } from './types'\n\n// Config\nimport { CrosshairDefaultConfig, CrosshairConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\n\nexport class Crosshair<Datum> extends XYComponentCore<Datum, CrosshairConfigInterface<Datum>> {\n static selectors = s\n clippable = true // Don't apply clipping path to this component. See XYContainer\n protected _defaultConfig = CrosshairDefaultConfig as CrosshairConfigInterface<Datum>\n public config: CrosshairConfigInterface<Datum> = this._defaultConfig\n container: Selection<SVGSVGElement, any, SVGSVGElement, any>\n line: Selection<SVGLineElement, any, SVGElement, any>\n private _xPx: number | undefined = undefined\n private _yPx: number | undefined = undefined\n private _mouseEvent: MouseEvent | undefined = undefined\n private _animFrameId: number = null\n\n /** Tooltip component to be used by Crosshair if not provided by the config.\n * This property is supposed to be set externally by a container component like XYContainer. */\n public tooltip: Tooltip\n\n /** Accessors passed externally (e.g. from XYContainer) */\n private _accessors: CrosshairAccessors<Datum> = {\n x: undefined,\n y: undefined,\n yStacked: undefined,\n baseline: undefined,\n }\n\n public set accessors (accessors: CrosshairAccessors<Datum>) { this._accessors = accessors }\n public get accessors (): CrosshairAccessors<Datum> {\n const { config } = this\n\n const hasConfig = !!(config.x || config.y || config.yStacked)\n const x = hasConfig ? config.x : this._accessors.x\n const yAcc = hasConfig ? config.y : this._accessors.y\n const y = yAcc ? (isArray(yAcc) ? yAcc : [yAcc]) : undefined\n const yStacked = hasConfig ? config.yStacked : this._accessors.yStacked\n const baseline = config.baseline ?? this._accessors.baseline\n\n return { x, y, yStacked, baseline }\n }\n\n private _isContainerInViewport (): boolean {\n if (!this.container?.node()) return false\n\n const containerRect = this.container.node().getBoundingClientRect()\n const viewportWidth = window.innerWidth || document.documentElement.clientWidth\n const viewportHeight = window.innerHeight || document.documentElement.clientHeight\n\n // Calculate the visible area of the container\n const visibleWidth = Math.max(0, Math.min(containerRect.right, viewportWidth) - Math.max(containerRect.left, 0))\n const visibleHeight = Math.max(0, Math.min(containerRect.bottom, viewportHeight) - Math.max(containerRect.top, 0))\n const containerArea = containerRect.width * containerRect.height\n const visibleArea = visibleWidth * visibleHeight\n\n // Container must be at least 35% visible\n return containerArea > 0 && (visibleArea / containerArea) >= 0.35\n }\n\n constructor (config?: CrosshairConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n this.g.style('opacity', 0)\n this.line = this.g.append('line')\n .attr('class', s.line)\n }\n\n setContainer (containerSvg: Selection<SVGSVGElement, unknown, SVGSVGElement, unknown>): void {\n if (this.container === containerSvg) return\n\n this.container = containerSvg\n this.container.on('mousemove.crosshair', this._onMouseMove.bind(this))\n this.container.on('mouseout.crosshair', this._onMouseOut.bind(this))\n this.container.on('wheel.crosshair', this._onWheel.bind(this))\n }\n\n _render (customDuration?: number): void {\n const { config, datamodel } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const isForceShowAtDefined = config.forceShowAt !== undefined\n const xPx = isForceShowAtDefined ? this.xScale(config.forceShowAt) : this._xPx\n\n const xValue = this.xScale.invert(xPx) as number\n\n const leftNearestDatumIndex = (datamodel.data?.length && this.accessors.x)\n ? datamodel.data.indexOf(\n getNearest(datamodel.data, xValue, this.accessors.x, FindNearestDirection.Left)\n ) : undefined\n\n // If `snapToData` is `true`, we need to find the nearest datum to the crosshair\n // It can be from a mouse interaction or from a `forceShowAt` setting\n let nearestDatum: Datum | undefined\n let nearestDatumIndex: number | undefined\n if (config.snapToData) {\n if (!this.accessors.y && !this.accessors.yStacked && datamodel.data?.length) {\n console.warn('Unovis | Crosshair: Y accessors have not been configured. Please check if they\\'re present in the configuration object')\n }\n\n // Emit a warning if there's no data to snap to.\n // To keep the console clean, only emit the warning when there's mouse interaction.\n if (!datamodel.data?.length && this._mouseEvent) {\n console.warn('Unovis | Crosshair: No data to snap to. Make sure the data has been passed to the container or to the crosshair itself')\n }\n\n nearestDatum = getNearest(datamodel.data, xValue, this.accessors.x)\n nearestDatumIndex = datamodel.data.indexOf(nearestDatum)\n }\n\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n const xClamped = config.snapToData && nearestDatum\n ? clamp(Math.round(this.xScale(getNumber(nearestDatum, this.accessors.x, nearestDatumIndex))), 0, this._width)\n : clamp(xPx, xRange[0], xRange[1])\n\n const isCrosshairWithinXRange = (xPx >= xRange[0]) && (xPx <= xRange[1])\n const isCrosshairWithinYRange = (this._yPx >= Math.min(yRange[0], yRange[1])) && (this._yPx <= Math.max(yRange[0], yRange[1]))\n let shouldShow = config.skipRangeCheck ? !!this._xPx : (this._xPx ? isCrosshairWithinXRange && isCrosshairWithinYRange : isCrosshairWithinXRange)\n\n // If the crosshair is far from the mouse pointer (usually when `snapToData` is `true` and data resolution is low), hide it\n if (config.hideWhenFarFromPointer && ((Math.abs(xClamped - (+xPx)) >= config.hideWhenFarFromPointerDistance))) {\n shouldShow = false\n }\n\n const tooltip = config.tooltip ?? this.tooltip\n if (shouldShow && tooltip && this._isContainerInViewport()) {\n const container = tooltip.getContainer() || this.container.node()\n const isContainerBody = tooltip.isContainerBody()\n\n if (isForceShowAtDefined) {\n // Convert SVG coordinates to screen coordinates\n const containerRect = this.container.node().getBoundingClientRect()\n\n // Use the actual left margin from the container\n const screenX = (isContainerBody ? xPx + containerRect.left : xPx) + this._containerMargin.left\n const screenY = this._height / 2 + (isContainerBody ? containerRect.top : 0)\n const pos = [screenX, screenY] as [number, number]\n this._showTooltip(nearestDatum, xValue, pos, leftNearestDatumIndex)\n } else if (this._mouseEvent) {\n const pos = (isContainerBody ? [this._mouseEvent.clientX, this._mouseEvent.clientY] : pointer(this._mouseEvent, container)) as [number, number]\n this._showTooltip(nearestDatum, xValue, pos, leftNearestDatumIndex)\n }\n } else this._hideTooltip()\n\n // Trigger `onCrosshairMove` if the render was triggered by a mouse move event\n if (this._mouseEvent) {\n config.onCrosshairMove?.(shouldShow ? this.xScale.invert(this._xPx) as number : undefined, nearestDatum, nearestDatumIndex, this._mouseEvent)\n this._mouseEvent = undefined\n }\n\n smartTransition(this.g, duration)\n .style('opacity', shouldShow ? 1 : 0)\n\n // When `config.forceShowAt` becomes `undefined`, the crosshair \"jumps\" to the edge of the chart.\n // This looks off, so we stop further rendering when the `xPx` value is not finite.\n if (!isFinite(xPx)) return\n\n this.line\n .attr('y1', 0)\n .attr('y2', this._height)\n\n smartTransition(this.line, duration, easeLinear)\n .attr('x1', xClamped)\n .attr('x2', xClamped)\n\n const circleData = isFunction(config.getCircles)\n ? config.getCircles(xValue, datamodel.data, this.yScale, leftNearestDatumIndex)\n : this.getCircleData(nearestDatum, nearestDatumIndex)\n\n const circles = this.g\n .selectAll<SVGCircleElement, CrosshairCircle>('circle')\n .data(circleData, (d, i) => d.id ?? i)\n\n const circlesEnter = circles.enter()\n .append('circle')\n .attr('class', s.circle)\n .attr('r', 0)\n .attr('cx', xClamped)\n .attr('cy', d => d.y)\n .style('fill', d => d.color)\n .style('stroke', d => d.strokeColor)\n .style('stroke-width', d => d.strokeWidth)\n\n smartTransition(circlesEnter.merge(circles), duration, easeLinear)\n .attr('cx', xClamped)\n .attr('cy', d => d.y)\n .attr('r', 4)\n .style('opacity', d => d.opacity)\n .style('fill', d => d.color)\n .style('stroke', d => d.strokeColor)\n .style('stroke-width', d => d.strokeWidth)\n\n circles.exit().remove()\n }\n\n hide (sourceEvent?: MouseEvent | WheelEvent): void {\n window.cancelAnimationFrame(this._animFrameId)\n this._animFrameId = window.requestAnimationFrame(() => {\n this._xPx = undefined\n this._yPx = undefined\n this._mouseEvent = undefined\n // We call `onCrosshairMove` with all the arguments set to `undefined` because we want\n // the users to be able to hide the crosshair easily when using `forceShowAt`\n this.config.onCrosshairMove?.(undefined, undefined, undefined, sourceEvent)\n this._render()\n })\n }\n\n _onMouseMove (event: MouseEvent): void {\n const { datamodel, element } = this\n if (!this.accessors.x && datamodel.data?.length) {\n console.warn('Unovis | Crosshair: X accessor function has not been configured. Please check if it\\'s present in the configuration object')\n }\n const [x, y] = pointer(event, element)\n this._xPx = x\n this._yPx = y\n this._mouseEvent = event\n\n window.cancelAnimationFrame(this._animFrameId)\n this._animFrameId = window.requestAnimationFrame(() => {\n // We'll call `config.onCrosshairMove` in `_render` with the found `nearestDatum` and `nearestDatumIndex`,\n // which can come from the mouse interaction or from the `forceShowAt` setting\n this._render()\n })\n }\n\n _onMouseOut (event?: MouseEvent): void {\n // Only hide if the mouse actually left the SVG, not just moved to a child\n if (!event || !this.container?.node().contains((event as MouseEvent).relatedTarget as Node)) {\n this.hide(event)\n }\n }\n\n _onWheel (event: WheelEvent): void {\n this.hide(event)\n }\n\n _showTooltip (datum: Datum, xValue: number, pos: [number, number], nearestDatumIndex: number | undefined): void {\n const { config, datamodel } = this\n const tooltip = config.tooltip ?? this.tooltip\n if (!tooltip || !pos) return\n\n const [x, y] = pos\n const content = config.template(datum, xValue, datamodel.data, nearestDatumIndex)\n // Force set `followCursor` to `true` because we don't want Crosshair's tooltip to be hoverable\n tooltip.config.followCursor = true\n\n // Set tooltip placement based on Crosshair's position (left / right)\n if (!tooltip.config.horizontalPlacement || tooltip.config.horizontalPlacement === Position.Auto) {\n const xRelative = tooltip.isContainerBody() ? x - this.container.node().getBoundingClientRect().left : x\n tooltip.overrideHorizontalPlacement(xRelative > this._containerWidth / 2 ? Position.Left : Position.Right)\n }\n\n if (content) tooltip.show(content, { x, y })\n }\n\n _hideTooltip (): void {\n const { config } = this\n const tooltip = config.tooltip ?? this.tooltip\n tooltip?.hide()\n }\n\n // We don't want Crosshair to be be taken in to account in domain calculations\n getYDataExtent (): number[] {\n return [undefined, undefined]\n }\n\n private getCircleData (datum: Datum, datumIndex: number): CrosshairCircle[] {\n const { config } = this\n\n if (config.snapToData && datum) {\n const yAccessors = this.accessors.y ?? []\n const yStackedAccessors = this.accessors.yStacked ?? []\n const baselineValue = getNumber(datum, this.accessors.baseline, datumIndex) || 0\n const stackedValues: CrosshairCircle[] = getStackedValues(datum, datumIndex, ...yStackedAccessors)\n .map((value, index) => ({\n y: this.yScale(value + baselineValue),\n opacity: isNumber(getNumber(datum, yStackedAccessors[index], index)) ? 1 : 0,\n color: getColor(datum, config.color, index),\n strokeColor: config.strokeColor ? getColor(datum, config.strokeColor, index) : undefined,\n strokeWidth: config.strokeWidth ? getNumber(datum, config.strokeWidth, index) : undefined,\n }))\n\n const regularValues: CrosshairCircle[] = yAccessors\n .map((a, index) => {\n const value = getNumber(datum, a, datumIndex)\n return {\n y: this.yScale(value),\n opacity: isNumber(value) ? 1 : 0,\n color: getColor(datum, config.color, stackedValues.length + index),\n strokeColor: config.strokeColor ? getColor(datum, config.strokeColor, index) : undefined,\n strokeWidth: config.strokeWidth ? getNumber(datum, config.strokeWidth, index) : undefined,\n }\n })\n\n return stackedValues.concat(regularValues)\n }\n\n return []\n }\n}\n"],"names":["s.line","s.circle","s"],"mappings":";;;;;;;;;;;;AA0BM,MAAO,SAAiB,SAAQ,eAAuD,CAAA;AAuD3F,IAAA,WAAA,CAAa,MAAwC,EAAA;AACnD,QAAA,KAAK,EAAE,CAAA;AAtDT,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,CAAA;QACN,IAAc,CAAA,cAAA,GAAG,sBAAyD,CAAA;AAC7E,QAAA,IAAA,CAAA,MAAM,GAAoC,IAAI,CAAC,cAAc,CAAA;QAG5D,IAAI,CAAA,IAAA,GAAuB,SAAS,CAAA;QACpC,IAAI,CAAA,IAAA,GAAuB,SAAS,CAAA;QACpC,IAAW,CAAA,WAAA,GAA2B,SAAS,CAAA;QAC/C,IAAY,CAAA,YAAA,GAAW,IAAI,CAAA;;AAO3B,QAAA,IAAA,CAAA,UAAU,GAA8B;AAC9C,YAAA,CAAC,EAAE,SAAS;AACZ,YAAA,CAAC,EAAE,SAAS;AACZ,YAAA,QAAQ,EAAE,SAAS;AACnB,YAAA,QAAQ,EAAE,SAAS;SACpB,CAAA;AAmCC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAElC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,MA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J,YAAA,OAAO,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;AAC3C,SAAA;AAED,QAAA,OAAO,EAAE,CAAA;KACV;;AAtSM,SAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/crosshair/index.ts"],"sourcesContent":["import { Selection, pointer } from 'd3-selection'\nimport { easeLinear } from 'd3-ease'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\nimport { Tooltip } from 'components/tooltip'\n\n// Utils\nimport { isNumber, isArray, getNumber, clamp, getStackedValues, getNearest, isFunction } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Position } from 'types/position'\nimport { FindNearestDirection } from 'types/data'\n\n// Local Types\nimport { CrosshairAccessors, CrosshairCircle } from './types'\n\n// Config\nimport { CrosshairDefaultConfig, CrosshairConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\n\nexport class Crosshair<Datum> extends XYComponentCore<Datum, CrosshairConfigInterface<Datum>> {\n static selectors = s\n clippable = true // Don't apply clipping path to this component. See XYContainer\n protected _defaultConfig = CrosshairDefaultConfig as CrosshairConfigInterface<Datum>\n public config: CrosshairConfigInterface<Datum> = this._defaultConfig\n container: Selection<SVGSVGElement, any, SVGSVGElement, any>\n line: Selection<SVGLineElement, any, SVGElement, any>\n private _xPx: number | undefined = undefined\n private _yPx: number | undefined = undefined\n private _mouseEvent: MouseEvent | undefined = undefined\n private _animFrameId: number = null\n\n /** Tooltip component to be used by Crosshair if not provided by the config.\n * This property is supposed to be set externally by a container component like XYContainer. */\n public tooltip: Tooltip\n\n /** Accessors passed externally (e.g. from XYContainer) */\n private _accessors: CrosshairAccessors<Datum> = {\n x: undefined,\n y: undefined,\n yStacked: undefined,\n baseline: undefined,\n }\n\n public set accessors (accessors: CrosshairAccessors<Datum>) { this._accessors = accessors }\n public get accessors (): CrosshairAccessors<Datum> {\n const { config } = this\n\n const hasConfig = !!(config.x || config.y || config.yStacked)\n const x = hasConfig ? config.x : this._accessors.x\n const yAcc = hasConfig ? config.y : this._accessors.y\n const y = yAcc ? (isArray(yAcc) ? yAcc : [yAcc]) : undefined\n const yStacked = hasConfig ? config.yStacked : this._accessors.yStacked\n const baseline = config.baseline ?? this._accessors.baseline\n\n return { x, y, yStacked, baseline }\n }\n\n private _isContainerInViewport (): boolean {\n if (!this.container?.node()) return false\n\n const containerRect = this.container.node().getBoundingClientRect()\n const viewportWidth = window.innerWidth || document.documentElement.clientWidth\n const viewportHeight = window.innerHeight || document.documentElement.clientHeight\n\n // Calculate the visible area of the container\n const visibleWidth = Math.max(0, Math.min(containerRect.right, viewportWidth) - Math.max(containerRect.left, 0))\n const visibleHeight = Math.max(0, Math.min(containerRect.bottom, viewportHeight) - Math.max(containerRect.top, 0))\n const containerArea = containerRect.width * containerRect.height\n const visibleArea = visibleWidth * visibleHeight\n\n // Container must be at least 35% visible\n return containerArea > 0 && (visibleArea / containerArea) >= 0.35\n }\n\n constructor (config?: CrosshairConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n this.g.style('opacity', 0)\n this.line = this.g.append('line')\n .attr('class', s.line)\n }\n\n setContainer (containerSvg: Selection<SVGSVGElement, unknown, SVGSVGElement, unknown>): void {\n if (this.container === containerSvg) return\n\n this.container = containerSvg\n this.container.on('mousemove.crosshair', this._onMouseMove.bind(this))\n this.container.on('mouseout.crosshair', this._onMouseOut.bind(this))\n this.container.on('wheel.crosshair', this._onWheel.bind(this))\n }\n\n _render (customDuration?: number): void {\n const { config, datamodel } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const isForceShowAtDefined = config.forceShowAt !== undefined\n const xPx = isForceShowAtDefined ? this.xScale(config.forceShowAt) : this._xPx\n\n const xValue = this.xScale.invert(xPx) as number\n\n const leftNearestDatumIndex = (datamodel.data?.length && this.accessors.x)\n ? datamodel.data.indexOf(\n getNearest(datamodel.data, xValue, this.accessors.x, FindNearestDirection.Left)\n ) : undefined\n\n // If `snapToData` is `true`, we need to find the nearest datum to the crosshair\n // It can be from a mouse interaction or from a `forceShowAt` setting\n let nearestDatum: Datum | undefined\n let nearestDatumIndex: number | undefined\n if (config.snapToData) {\n if (!this.accessors.y && !this.accessors.yStacked && datamodel.data?.length) {\n console.warn('Unovis | Crosshair: Y accessors have not been configured. Please check if they\\'re present in the configuration object')\n }\n\n // Emit a warning if there's no data to snap to.\n // To keep the console clean, only emit the warning when there's mouse interaction.\n if (!datamodel.data?.length && this._mouseEvent) {\n console.warn('Unovis | Crosshair: No data to snap to. Make sure the data has been passed to the container or to the crosshair itself')\n }\n\n nearestDatum = getNearest(datamodel.data, xValue, this.accessors.x)\n nearestDatumIndex = datamodel.data.indexOf(nearestDatum)\n }\n\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n const xClamped = config.snapToData && nearestDatum\n ? clamp(Math.round(this.xScale(getNumber(nearestDatum, this.accessors.x, nearestDatumIndex))), 0, this._width)\n : clamp(xPx, xRange[0], xRange[1])\n\n const isCrosshairWithinXRange = (xPx >= xRange[0]) && (xPx <= xRange[1])\n const isCrosshairWithinYRange = (this._yPx >= Math.min(yRange[0], yRange[1])) && (this._yPx <= Math.max(yRange[0], yRange[1]))\n let shouldShow = config.skipRangeCheck ? !!this._xPx : (this._xPx ? isCrosshairWithinXRange && isCrosshairWithinYRange : isCrosshairWithinXRange)\n\n // If the crosshair is far from the mouse pointer (usually when `snapToData` is `true` and data resolution is low), hide it\n if (config.hideWhenFarFromPointer && ((Math.abs(xClamped - (+xPx)) >= config.hideWhenFarFromPointerDistance))) {\n shouldShow = false\n }\n\n const tooltip = config.tooltip ?? this.tooltip\n if (shouldShow && tooltip && this._isContainerInViewport()) {\n const container = tooltip.getContainer() || this.container.node()\n const isContainerBody = tooltip.isContainerBody()\n\n if (isForceShowAtDefined) {\n // Convert SVG coordinates to screen coordinates\n const containerRect = this.container.node().getBoundingClientRect()\n\n // Use the actual left margin from the container\n const screenX = (isContainerBody ? xPx + containerRect.left : xPx) + this._containerMargin.left\n const screenY = this._height / 2 + (isContainerBody ? containerRect.top : 0)\n const pos = [screenX, screenY] as [number, number]\n this._showTooltip(nearestDatum, xValue, pos, leftNearestDatumIndex)\n } else if (this._mouseEvent) {\n const pos = (isContainerBody ? [this._mouseEvent.clientX, this._mouseEvent.clientY] : pointer(this._mouseEvent, container)) as [number, number]\n this._showTooltip(nearestDatum, xValue, pos, leftNearestDatumIndex)\n }\n } else this._hideTooltip()\n\n // Trigger `onCrosshairMove` if the render was triggered by a mouse move event\n if (this._mouseEvent) {\n config.onCrosshairMove?.(shouldShow ? this.xScale.invert(this._xPx) as number : undefined, nearestDatum, nearestDatumIndex, this._mouseEvent)\n this._mouseEvent = undefined\n }\n\n smartTransition(this.g, duration)\n .style('opacity', shouldShow ? 1 : 0)\n\n // When `config.forceShowAt` becomes `undefined`, the crosshair \"jumps\" to the edge of the chart.\n // This looks off, so we stop further rendering when the `xPx` value is not finite.\n if (!isFinite(xPx)) return\n\n this.line\n .attr('y1', 0)\n .attr('y2', this._height)\n\n smartTransition(this.line, duration, easeLinear)\n .attr('x1', xClamped)\n .attr('x2', xClamped)\n\n const circleData = isFunction(config.getCircles)\n ? config.getCircles(xValue, datamodel.data, this.yScale, leftNearestDatumIndex)\n : this.getCircleData(nearestDatum, nearestDatumIndex)\n\n const circles = this.g\n .selectAll<SVGCircleElement, CrosshairCircle>('circle')\n .data(circleData, (d, i) => d.id ?? i)\n\n const circlesEnter = circles.enter()\n .append('circle')\n .attr('class', s.circle)\n .attr('r', 0)\n .attr('cx', xClamped)\n .attr('cy', d => d.y)\n .style('fill', d => d.color)\n .style('stroke', d => d.strokeColor)\n .style('stroke-width', d => d.strokeWidth)\n\n smartTransition(circlesEnter.merge(circles), duration, easeLinear)\n .attr('cx', xClamped)\n .attr('cy', d => d.y)\n .attr('r', 4)\n .style('opacity', d => d.opacity)\n .style('fill', d => d.color)\n .style('stroke', d => d.strokeColor)\n .style('stroke-width', d => d.strokeWidth)\n\n circles.exit().remove()\n }\n\n hide (sourceEvent?: MouseEvent | WheelEvent): void {\n window.cancelAnimationFrame(this._animFrameId)\n this._animFrameId = window.requestAnimationFrame(() => {\n this._xPx = undefined\n this._yPx = undefined\n this._mouseEvent = undefined\n // We call `onCrosshairMove` with all the arguments set to `undefined` because we want\n // the users to be able to hide the crosshair easily when using `forceShowAt`\n this.config.onCrosshairMove?.(undefined, undefined, undefined, sourceEvent)\n this._render()\n })\n }\n\n _onMouseMove (event: MouseEvent): void {\n const { datamodel, element } = this\n if (!this.accessors.x && datamodel.data?.length) {\n console.warn('Unovis | Crosshair: X accessor function has not been configured. Please check if it\\'s present in the configuration object')\n }\n const [x, y] = pointer(event, element)\n this._xPx = x\n this._yPx = y\n this._mouseEvent = event\n\n window.cancelAnimationFrame(this._animFrameId)\n this._animFrameId = window.requestAnimationFrame(() => {\n // We'll call `config.onCrosshairMove` in `_render` with the found `nearestDatum` and `nearestDatumIndex`,\n // which can come from the mouse interaction or from the `forceShowAt` setting\n this._render()\n })\n }\n\n _onMouseOut (event?: MouseEvent): void {\n // Only hide if the mouse actually left the SVG, not just moved to a child\n if (!event || !this.container?.node().contains((event as MouseEvent).relatedTarget as Node)) {\n this.hide(event)\n }\n }\n\n _onWheel (event: WheelEvent): void {\n this.hide(event)\n }\n\n _showTooltip (datum: Datum | undefined, xValue: number, pos: [number, number], nearestDatumIndex: number | undefined): void {\n const { config, datamodel } = this\n const tooltip = config.tooltip ?? this.tooltip\n if (!tooltip || !pos) return\n\n const [x, y] = pos\n const content = config.template(datum, xValue, datamodel.data, nearestDatumIndex)\n // Force set `followCursor` to `true` because we don't want Crosshair's tooltip to be hoverable\n tooltip.config.followCursor = true\n\n // Set tooltip placement based on Crosshair's position (left / right)\n if (!tooltip.config.horizontalPlacement || tooltip.config.horizontalPlacement === Position.Auto) {\n const xRelative = tooltip.isContainerBody() ? x - this.container.node().getBoundingClientRect().left : x\n tooltip.overrideHorizontalPlacement(xRelative > this._containerWidth / 2 ? Position.Left : Position.Right)\n }\n\n if (content) tooltip.show(content, { x, y })\n }\n\n _hideTooltip (): void {\n const { config } = this\n const tooltip = config.tooltip ?? this.tooltip\n tooltip?.hide()\n }\n\n // We don't want Crosshair to be be taken in to account in domain calculations\n getYDataExtent (): number[] {\n return [undefined, undefined]\n }\n\n private getCircleData (datum: Datum, datumIndex: number): CrosshairCircle[] {\n const { config } = this\n\n if (config.snapToData && datum) {\n const yAccessors = this.accessors.y ?? []\n const yStackedAccessors = this.accessors.yStacked ?? []\n const baselineValue = getNumber(datum, this.accessors.baseline, datumIndex) || 0\n const stackedValues: CrosshairCircle[] = getStackedValues(datum, datumIndex, ...yStackedAccessors)\n .map((value, index) => ({\n y: this.yScale(value + baselineValue),\n opacity: isNumber(getNumber(datum, yStackedAccessors[index], index)) ? 1 : 0,\n color: getColor(datum, config.color, index),\n strokeColor: config.strokeColor ? getColor(datum, config.strokeColor, index) : undefined,\n strokeWidth: config.strokeWidth ? getNumber(datum, config.strokeWidth, index) : undefined,\n }))\n\n const regularValues: CrosshairCircle[] = yAccessors\n .map((a, index) => {\n const value = getNumber(datum, a, datumIndex)\n return {\n y: this.yScale(value),\n opacity: isNumber(value) ? 1 : 0,\n color: getColor(datum, config.color, stackedValues.length + index),\n strokeColor: config.strokeColor ? getColor(datum, config.strokeColor, index) : undefined,\n strokeWidth: config.strokeWidth ? getNumber(datum, config.strokeWidth, index) : undefined,\n }\n })\n\n return stackedValues.concat(regularValues)\n }\n\n return []\n }\n}\n"],"names":["s.line","s.circle","s"],"mappings":";;;;;;;;;;;;AA0BM,MAAO,SAAiB,SAAQ,eAAuD,CAAA;AAuD3F,IAAA,WAAA,CAAa,MAAwC,EAAA;AACnD,QAAA,KAAK,EAAE,CAAA;AAtDT,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,CAAA;QACN,IAAc,CAAA,cAAA,GAAG,sBAAyD,CAAA;AAC7E,QAAA,IAAA,CAAA,MAAM,GAAoC,IAAI,CAAC,cAA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EAAE,CAAC,EAAE,UAAU,CAAC,CAAA;gBAC7C,OAAO;AACL,oBAAA,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;AACrB,oBAAA,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;AAChC,oBAAA,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,KAAK,CAAC;oBAClE,WAAW,EAAE,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,SAAS;oBACxF,WAAW,EAAE,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,SAAS;iBAC1F,CAAA;AACH,aAAC,CAAC,CAAA;AAEJ,YAAA,OAAO,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;AAC3C,SAAA;AAED,QAAA,OAAO,EAAE,CAAA;KACV;;AAtSM,SAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -20,14 +20,6 @@ export interface SankeyConfigInterface<N extends SankeyInputNode, L extends Sank
20
20
  highlightDelay?: number;
21
21
  /** Sankey algorithm iterations. Default: `32` */
22
22
  iterations?: number;
23
- /** Enable node collapse functionality. When enabled, clicking on nodes will toggle their collapse state. Default: `false` */
24
- enableNodeCollapse?: boolean;
25
- /** Node collapse animation duration, ms. Default: `300` */
26
- collapseAnimationDuration?: number;
27
- /** Field name in the node data that indicates if a node should be pre-collapsed.
28
- * For example, if set to "disabled", nodes with `disabled: true` will start collapsed.
29
- * Default: `undefined` */
30
- disabledField?: string;
31
23
  /** Sankey node sorting function. Default: `undefined`.
32
24
  * Node sorting is applied to nodes in one layer (column). Layer by layer.
33
25
  * Options: `undefined` - the order is determined by the layout;
@@ -5,7 +5,7 @@ import { Position } from '../../types/position.js';
5
5
  import { SankeyExitTransitionType, SankeyEnterTransitionType, SankeyNodeAlign, SankeySubLabelPlacement } from './types.js';
6
6
 
7
7
  // Config
8
- const SankeyDefaultConfig = (Object.assign(Object.assign({}, ComponentDefaultConfig), { heightNormalizationCoeff: 1 / 16, exitTransitionType: SankeyExitTransitionType.Default, enterTransitionType: SankeyEnterTransitionType.Default, id: (d, i) => { var _a; return (_a = d._id) !== null && _a !== void 0 ? _a : `${i}`; }, highlightSubtreeOnHover: false, highlightDuration: 300, highlightDelay: 1000, iterations: 32, enableNodeCollapse: false, collapseAnimationDuration: 300, disabledField: undefined, nodeSort: undefined, nodeWidth: 25, nodeAlign: SankeyNodeAlign.Justify, nodeHorizontalSpacing: 150, nodeMinHeight: 20, nodeMaxHeight: 100, nodePadding: 2, nodeColor: (d) => d.color, nodeFixedValue: (d) => d.fixedValue, showSingleNode: true, nodeCursor: undefined, nodeIcon: undefined, nodeIconColor: undefined, label: (d) => d.label, labelPosition: Position.Auto, labelVerticalAlign: VerticalAlign.Middle, labelBackground: false, labelTextSeparator: [' ', '-'], labelFit: FitMode.Trim, labelTrimMode: TrimMode.Middle, labelForceWordBreak: true, labelFontSize: undefined, labelCursor: undefined, labelColor: undefined, labelMaxWidth: 70, labelExpandTrimmedOnHover: true, labelVisibility: undefined, subLabel: undefined, subLabelFontSize: undefined, subLabelColor: undefined, subLabelPlacement: SankeySubLabelPlacement.Below, subLabelToLabelInlineWidthRatio: 0.4, linkValue: (d) => d.value, linkColor: (d) => d.color, linkCursor: undefined,
8
+ const SankeyDefaultConfig = (Object.assign(Object.assign({}, ComponentDefaultConfig), { heightNormalizationCoeff: 1 / 16, exitTransitionType: SankeyExitTransitionType.Default, enterTransitionType: SankeyEnterTransitionType.Default, id: (d, i) => { var _a; return (_a = d._id) !== null && _a !== void 0 ? _a : `${i}`; }, highlightSubtreeOnHover: false, highlightDuration: 300, highlightDelay: 1000, iterations: 32, nodeSort: undefined, nodeWidth: 25, nodeAlign: SankeyNodeAlign.Justify, nodeHorizontalSpacing: 150, nodeMinHeight: 20, nodeMaxHeight: 100, nodePadding: 2, nodeColor: (d) => d.color, nodeFixedValue: (d) => d.fixedValue, showSingleNode: true, nodeCursor: undefined, nodeIcon: undefined, nodeIconColor: undefined, label: (d) => d.label, labelPosition: Position.Auto, labelVerticalAlign: VerticalAlign.Middle, labelBackground: false, labelTextSeparator: [' ', '-'], labelFit: FitMode.Trim, labelTrimMode: TrimMode.Middle, labelForceWordBreak: true, labelFontSize: undefined, labelCursor: undefined, labelColor: undefined, labelMaxWidth: 70, labelExpandTrimmedOnHover: true, labelVisibility: undefined, subLabel: undefined, subLabelFontSize: undefined, subLabelColor: undefined, subLabelPlacement: SankeySubLabelPlacement.Below, subLabelToLabelInlineWidthRatio: 0.4, linkValue: (d) => d.value, linkColor: (d) => d.color, linkCursor: undefined,
9
9
  // https://stackoverflow.com/a/21648197/2040291
10
10
  init: function () {
11
11
  this.linkSort =
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/sankey/config.ts"],"sourcesContent":["// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Utils\nimport { getNumber } from 'utils/data'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { TrimMode, VerticalAlign, FitMode } from 'types/text'\nimport { Position } from 'types/position'\nimport {\n SankeyInputLink,\n SankeyInputNode,\n SankeyNodeAlign,\n SankeySubLabelPlacement,\n SankeyExitTransitionType,\n SankeyEnterTransitionType,\n SankeyLink,\n SankeyNode,\n} from './types'\n\nexport interface SankeyConfigInterface<N extends SankeyInputNode, L extends SankeyInputLink> extends ComponentConfigInterface {\n // General\n /** Node / Link id accessor function. Used for mapping of data updates to corresponding SVG objects. Default: `(d, i) => d.id ?? i.toString()` */\n id?: (d: SankeyInputNode | SankeyInputLink, i: number, ...any: unknown[]) => string;\n /** Coefficient to scale the height of the diagram when the amount of links is low: `C * links.length`, clamped to `[height / 2, height]`. Default: `1/16` */\n heightNormalizationCoeff?: number;\n /** Type of animation on removing nodes. Default: `ExitTransitionType.Default` */\n exitTransitionType?: SankeyExitTransitionType;\n /** Type of animation on creating nodes. Default: `EnterTransitionType.Default` */\n enterTransitionType?: SankeyEnterTransitionType;\n /** Highlight the corresponding subtree on node / link hover. Default: `false` */\n highlightSubtreeOnHover?: boolean;\n /** Highlight animation duration, ms. Default: `400` */\n highlightDuration?: number;\n /** Highlight delay, ms. Default: `1000` */\n highlightDelay?: number;\n /** Sankey algorithm iterations. Default: `32` */\n iterations?: number;\n\n // Collapse/Expand\n /** Enable node collapse functionality. When enabled, clicking on nodes will toggle their collapse state. Default: `false` */\n enableNodeCollapse?: boolean;\n /** Node collapse animation duration, ms. Default: `300` */\n collapseAnimationDuration?: number;\n /** Field name in the node data that indicates if a node should be pre-collapsed.\n * For example, if set to \"disabled\", nodes with `disabled: true` will start collapsed.\n * Default: `undefined` */\n disabledField?: string;\n\n // Sorting\n /** Sankey node sorting function. Default: `undefined`.\n * Node sorting is applied to nodes in one layer (column). Layer by layer.\n * Options: `undefined` - the order is determined by the layout;\n * `null` - the order is fixed by the input;\n * sort function - the order is determined by the function.\n */\n nodeSort?: ((node1: SankeyNode<N, L>, node2: SankeyNode<N, L>) => number) | null | undefined;\n /** Sankey link sorting function. Default: `(link2, link1) => link1.value - link2.value`.\n * Link sorting is applied to the source (exiting) links within one node.\n * Options: `undefined` - the order is determined by the layout;\n * `null` - the order is fixed by the input;\n * sort function - the order is determined by the function.\n */\n linkSort?: ((link1: SankeyLink<N, L>, link2: SankeyLink<N, L>) => number) | null | undefined;\n\n // Nodes\n /** Sankey node width in pixels */\n nodeWidth?: number;\n /** Sankey node alignment method */\n nodeAlign?: SankeyNodeAlign;\n /** Horizontal space between the nodes. Extended Sizing property only. Default: `150` */\n nodeHorizontalSpacing?: number;\n /** Minimum node height. Extended Sizing property only. Default: `20` */\n nodeMinHeight?: number;\n /** Maximum node height. Extended Sizing property only. Default: `100` */\n nodeMaxHeight?: number;\n /** Sankey vertical separation between nodes in pixels. Default: `2` */\n nodePadding?: number;\n /** Display the graph when data has just one element */\n showSingleNode?: boolean;\n /** Node cursor on hover. Default: `undefined` */\n nodeCursor?: StringAccessor<SankeyNode<N, L>>;\n /** Node icon accessor function or value. Default: `undefined` */\n nodeIcon?: StringAccessor<SankeyNode<N, L>>;\n /** Node color accessor function or value. Default: `undefined` */\n nodeColor?: ColorAccessor<SankeyNode<N, L>>;\n /** Node `fixedValue` accessor function or constant. It defines the node value that will be used to calculate\n * the height of the nodes by d3-sankey (by default the height will be based on aggregated `linkValue`).\n * Default: `n => n.fixedValue`\n */\n nodeFixedValue?: NumericAccessor<N>;\n /** Icon color accessor function or value. Default: `undefined` */\n nodeIconColor?: ColorAccessor<SankeyNode<N, L>>;\n\n // Links\n /** Link color accessor function or value. Default: `l => l.color` */\n linkColor?: StringAccessor<SankeyLink<N, L>>;\n /** Link flow accessor function or value. Default: `l => l.value` */\n linkValue?: NumericAccessor<L>;\n /** Link cursor on hover. Default: `undefined` */\n linkCursor?: StringAccessor<SankeyLink<N, L>>;\n\n // Labels\n /** Node label accessor function or value. Default: `n => n.label` */\n label?: StringAccessor<SankeyNode<N, L>>;\n /** Node sub-label accessor function or value. Default: `undefined` */\n subLabel?: StringAccessor<SankeyNode<N, L>>;\n /** Label position relative to the Node. Default: `Position.AUTO` */\n labelPosition?: GenericAccessor<Position.Auto | Position.Left | Position.Right | string, SankeyNode<N, L>>;\n /** Label vertical alignment */\n labelVerticalAlign?: VerticalAlign | string;\n /** Label background */\n labelBackground?: boolean;\n /** Label fit mode (wrap or trim). Default: `FitMode.TRIM` **/\n labelFit?: FitMode;\n /** Maximum label with in pixels. Default: `70` */\n labelMaxWidth?: number;\n /** Expand trimmed label on hover. Default: `true` */\n labelExpandTrimmedOnHover?: boolean;\n /** Label trimming mode. Default: `TrimMode.Middle` */\n labelTrimMode?: TrimMode;\n /** Label font size in pixels. If not provided, the value of CSS variable `--vis-sankey-node-label-font-size` will be used. Default: `undefined` */\n labelFontSize?: number;\n /** Label text separators for wrapping. Default: `[' ', '-']` */\n labelTextSeparator?: string[];\n /** Force break words to fit long labels. Default: `true` */\n labelForceWordBreak?: boolean;\n /** Label color. Default: `undefined` */\n labelColor?: ColorAccessor<SankeyNode<N, L>>;\n /** Label cursor on hover. Default: `undefined` */\n labelCursor?: StringAccessor<SankeyNode<N, L>>;\n /** Custom function to set the label visibility. Default: `undefined` */\n labelVisibility?: ((d: SankeyNode<N, L>, bbox: { x: number; y: number; width: number; height: number }, hovered: boolean) => boolean) | undefined;\n /** Sub-label font size in pixels. If not provided, the value of CSS variable `--vis-sankey-node-sublabel-font-size` will be used. Default: `undefined` */\n subLabelFontSize?: number;\n /** Sub-label color. Default: `undefined` */\n subLabelColor?: ColorAccessor<SankeyNode<N, L>>;\n /** Sub-label position. Default: `SankeySubLabelPlacement.Below` */\n subLabelPlacement?: SankeySubLabelPlacement | string;\n /**\n * Sub-label to label width ratio when `subLabelPlacement` is set to `SankeySubLabelPlacement.Inline`\n * Default: `0.4`, which means that 40% of `labelMaxWidth` will be given to sub-label, and 60% to the main label.\n */\n subLabelToLabelInlineWidthRatio?: number;\n}\n\nexport const SankeyDefaultConfig: SankeyConfigInterface<SankeyInputNode, SankeyInputLink> = ({\n ...ComponentDefaultConfig,\n heightNormalizationCoeff: 1 / 16,\n exitTransitionType: SankeyExitTransitionType.Default,\n enterTransitionType: SankeyEnterTransitionType.Default,\n id: (d: SankeyInputNode, i: number) => (d as { _id: string })._id ?? `${i}`,\n highlightSubtreeOnHover: false,\n highlightDuration: 300,\n highlightDelay: 1000,\n iterations: 32,\n enableNodeCollapse: false,\n collapseAnimationDuration: 300,\n disabledField: undefined,\n nodeSort: undefined,\n nodeWidth: 25,\n nodeAlign: SankeyNodeAlign.Justify,\n nodeHorizontalSpacing: 150,\n nodeMinHeight: 20,\n nodeMaxHeight: 100,\n nodePadding: 2,\n nodeColor: (d: SankeyInputNode) => (d as { color: string }).color,\n nodeFixedValue: (d: SankeyInputNode) => (d as { fixedValue: number }).fixedValue,\n showSingleNode: true,\n nodeCursor: undefined,\n nodeIcon: undefined,\n nodeIconColor: undefined,\n label: (d: SankeyInputNode) => (d as { label: string }).label,\n labelPosition: Position.Auto,\n labelVerticalAlign: VerticalAlign.Middle,\n labelBackground: false,\n labelTextSeparator: [' ', '-'],\n labelFit: FitMode.Trim,\n labelTrimMode: TrimMode.Middle,\n labelForceWordBreak: true,\n labelFontSize: undefined,\n labelCursor: undefined,\n labelColor: undefined,\n labelMaxWidth: 70,\n labelExpandTrimmedOnHover: true,\n labelVisibility: undefined,\n subLabel: undefined,\n subLabelFontSize: undefined,\n subLabelColor: undefined,\n subLabelPlacement: SankeySubLabelPlacement.Below,\n subLabelToLabelInlineWidthRatio: 0.4,\n linkValue: (d: SankeyInputNode) => (d as { value: number }).value,\n linkColor: (d: SankeyInputNode) => (d as { color: string }).color,\n linkCursor: undefined,\n\n // https://stackoverflow.com/a/21648197/2040291\n init: function () {\n (this as SankeyConfigInterface<SankeyInputNode, SankeyInputLink>).linkSort =\n (link2, link1) => getNumber(link1, this.linkValue) - getNumber(link2, this.linkValue)\n delete this.init\n return this\n },\n}).init()\n\n"],"names":[],"mappings":";;;;;;AAAA;AAmJO,MAAM,mBAAmB,GAA4D,CACvF,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,sBAAsB,CACzB,EAAA,EAAA,wBAAwB,EAAE,CAAC,GAAG,EAAE,EAChC,kBAAkB,EAAE,wBAAwB,CAAC,OAAO,EACpD,mBAAmB,EAAE,yBAAyB,CAAC,OAAO,EACtD,EAAE,EAAE,CAAC,CAAkB,EAAE,CAAS,KAAK,EAAA,IAAA,EAAA,CAAA,CAAA,OAAA,CAAC,EAAA,GAAA,CAAqB,CAAC,GAAG,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAG,CAAC,CAAA,CAAE,CAAA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CAAC,KAAK,EACjE,SAAS,EAAE,CAAC,CAAkB,KAAM,CAAuB,CAAC,KAAK,EACjE,UAAU,EAAE,SAAS;;AAGrB,IAAA,IAAI,EAAE,YAAA;AACH,QAAA,IAAgE,CAAC,QAAQ;YACxE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QACvF,OAAO,IAAI,CAAC,IAAI,CAAA;AAChB,QAAA,OAAO,IAAI,CAAA;AACb,KAAC,EACD,CAAA,EAAC,IAAI;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/sankey/config.ts"],"sourcesContent":["// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Utils\nimport { getNumber } from 'utils/data'\n\n// Types\nimport { ColorAccessor, GenericAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\nimport { TrimMode, VerticalAlign, FitMode } from 'types/text'\nimport { Position } from 'types/position'\nimport {\n SankeyInputLink,\n SankeyInputNode,\n SankeyNodeAlign,\n SankeySubLabelPlacement,\n SankeyExitTransitionType,\n SankeyEnterTransitionType,\n SankeyLink,\n SankeyNode,\n} from './types'\n\nexport interface SankeyConfigInterface<N extends SankeyInputNode, L extends SankeyInputLink> extends ComponentConfigInterface {\n // General\n /** Node / Link id accessor function. Used for mapping of data updates to corresponding SVG objects. Default: `(d, i) => d.id ?? i.toString()` */\n id?: (d: SankeyInputNode | SankeyInputLink, i: number, ...any: unknown[]) => string;\n /** Coefficient to scale the height of the diagram when the amount of links is low: `C * links.length`, clamped to `[height / 2, height]`. Default: `1/16` */\n heightNormalizationCoeff?: number;\n /** Type of animation on removing nodes. Default: `ExitTransitionType.Default` */\n exitTransitionType?: SankeyExitTransitionType;\n /** Type of animation on creating nodes. Default: `EnterTransitionType.Default` */\n enterTransitionType?: SankeyEnterTransitionType;\n /** Highlight the corresponding subtree on node / link hover. Default: `false` */\n highlightSubtreeOnHover?: boolean;\n /** Highlight animation duration, ms. Default: `400` */\n highlightDuration?: number;\n /** Highlight delay, ms. Default: `1000` */\n highlightDelay?: number;\n /** Sankey algorithm iterations. Default: `32` */\n iterations?: number;\n\n // Sorting\n /** Sankey node sorting function. Default: `undefined`.\n * Node sorting is applied to nodes in one layer (column). Layer by layer.\n * Options: `undefined` - the order is determined by the layout;\n * `null` - the order is fixed by the input;\n * sort function - the order is determined by the function.\n */\n nodeSort?: ((node1: SankeyNode<N, L>, node2: SankeyNode<N, L>) => number) | null | undefined;\n /** Sankey link sorting function. Default: `(link2, link1) => link1.value - link2.value`.\n * Link sorting is applied to the source (exiting) links within one node.\n * Options: `undefined` - the order is determined by the layout;\n * `null` - the order is fixed by the input;\n * sort function - the order is determined by the function.\n */\n linkSort?: ((link1: SankeyLink<N, L>, link2: SankeyLink<N, L>) => number) | null | undefined;\n\n // Nodes\n /** Sankey node width in pixels */\n nodeWidth?: number;\n /** Sankey node alignment method */\n nodeAlign?: SankeyNodeAlign;\n /** Horizontal space between the nodes. Extended Sizing property only. Default: `150` */\n nodeHorizontalSpacing?: number;\n /** Minimum node height. Extended Sizing property only. Default: `20` */\n nodeMinHeight?: number;\n /** Maximum node height. Extended Sizing property only. Default: `100` */\n nodeMaxHeight?: number;\n /** Sankey vertical separation between nodes in pixels. Default: `2` */\n nodePadding?: number;\n /** Display the graph when data has just one element */\n showSingleNode?: boolean;\n /** Node cursor on hover. Default: `undefined` */\n nodeCursor?: StringAccessor<SankeyNode<N, L>>;\n /** Node icon accessor function or value. Default: `undefined` */\n nodeIcon?: StringAccessor<SankeyNode<N, L>>;\n /** Node color accessor function or value. Default: `undefined` */\n nodeColor?: ColorAccessor<SankeyNode<N, L>>;\n /** Node `fixedValue` accessor function or constant. It defines the node value that will be used to calculate\n * the height of the nodes by d3-sankey (by default the height will be based on aggregated `linkValue`).\n * Default: `n => n.fixedValue`\n */\n nodeFixedValue?: NumericAccessor<N>;\n /** Icon color accessor function or value. Default: `undefined` */\n nodeIconColor?: ColorAccessor<SankeyNode<N, L>>;\n\n // Links\n /** Link color accessor function or value. Default: `l => l.color` */\n linkColor?: StringAccessor<SankeyLink<N, L>>;\n /** Link flow accessor function or value. Default: `l => l.value` */\n linkValue?: NumericAccessor<L>;\n /** Link cursor on hover. Default: `undefined` */\n linkCursor?: StringAccessor<SankeyLink<N, L>>;\n\n // Labels\n /** Node label accessor function or value. Default: `n => n.label` */\n label?: StringAccessor<SankeyNode<N, L>>;\n /** Node sub-label accessor function or value. Default: `undefined` */\n subLabel?: StringAccessor<SankeyNode<N, L>>;\n /** Label position relative to the Node. Default: `Position.AUTO` */\n labelPosition?: GenericAccessor<Position.Auto | Position.Left | Position.Right | string, SankeyNode<N, L>>;\n /** Label vertical alignment */\n labelVerticalAlign?: VerticalAlign | string;\n /** Label background */\n labelBackground?: boolean;\n /** Label fit mode (wrap or trim). Default: `FitMode.TRIM` **/\n labelFit?: FitMode;\n /** Maximum label with in pixels. Default: `70` */\n labelMaxWidth?: number;\n /** Expand trimmed label on hover. Default: `true` */\n labelExpandTrimmedOnHover?: boolean;\n /** Label trimming mode. Default: `TrimMode.Middle` */\n labelTrimMode?: TrimMode;\n /** Label font size in pixels. If not provided, the value of CSS variable `--vis-sankey-node-label-font-size` will be used. Default: `undefined` */\n labelFontSize?: number;\n /** Label text separators for wrapping. Default: `[' ', '-']` */\n labelTextSeparator?: string[];\n /** Force break words to fit long labels. Default: `true` */\n labelForceWordBreak?: boolean;\n /** Label color. Default: `undefined` */\n labelColor?: ColorAccessor<SankeyNode<N, L>>;\n /** Label cursor on hover. Default: `undefined` */\n labelCursor?: StringAccessor<SankeyNode<N, L>>;\n /** Custom function to set the label visibility. Default: `undefined` */\n labelVisibility?: ((d: SankeyNode<N, L>, bbox: { x: number; y: number; width: number; height: number }, hovered: boolean) => boolean) | undefined;\n /** Sub-label font size in pixels. If not provided, the value of CSS variable `--vis-sankey-node-sublabel-font-size` will be used. Default: `undefined` */\n subLabelFontSize?: number;\n /** Sub-label color. Default: `undefined` */\n subLabelColor?: ColorAccessor<SankeyNode<N, L>>;\n /** Sub-label position. Default: `SankeySubLabelPlacement.Below` */\n subLabelPlacement?: SankeySubLabelPlacement | string;\n /**\n * Sub-label to label width ratio when `subLabelPlacement` is set to `SankeySubLabelPlacement.Inline`\n * Default: `0.4`, which means that 40% of `labelMaxWidth` will be given to sub-label, and 60% to the main label.\n */\n subLabelToLabelInlineWidthRatio?: number;\n}\n\nexport const SankeyDefaultConfig: SankeyConfigInterface<SankeyInputNode, SankeyInputLink> = ({\n ...ComponentDefaultConfig,\n heightNormalizationCoeff: 1 / 16,\n exitTransitionType: SankeyExitTransitionType.Default,\n enterTransitionType: SankeyEnterTransitionType.Default,\n id: (d: SankeyInputNode, i: number) => (d as { _id: string })._id ?? `${i}`,\n highlightSubtreeOnHover: false,\n highlightDuration: 300,\n highlightDelay: 1000,\n iterations: 32,\n nodeSort: undefined,\n nodeWidth: 25,\n nodeAlign: SankeyNodeAlign.Justify,\n nodeHorizontalSpacing: 150,\n nodeMinHeight: 20,\n nodeMaxHeight: 100,\n nodePadding: 2,\n nodeColor: (d: SankeyInputNode) => (d as { color: string }).color,\n nodeFixedValue: (d: SankeyInputNode) => (d as { fixedValue: number }).fixedValue,\n showSingleNode: true,\n nodeCursor: undefined,\n nodeIcon: undefined,\n nodeIconColor: undefined,\n label: (d: SankeyInputNode) => (d as { label: string }).label,\n labelPosition: Position.Auto,\n labelVerticalAlign: VerticalAlign.Middle,\n labelBackground: false,\n labelTextSeparator: [' ', '-'],\n labelFit: FitMode.Trim,\n labelTrimMode: TrimMode.Middle,\n labelForceWordBreak: true,\n labelFontSize: undefined,\n labelCursor: undefined,\n labelColor: undefined,\n labelMaxWidth: 70,\n labelExpandTrimmedOnHover: true,\n labelVisibility: undefined,\n subLabel: undefined,\n subLabelFontSize: undefined,\n subLabelColor: undefined,\n subLabelPlacement: SankeySubLabelPlacement.Below,\n subLabelToLabelInlineWidthRatio: 0.4,\n linkValue: (d: SankeyInputNode) => (d as { value: number }).value,\n linkColor: (d: SankeyInputNode) => (d as { color: string }).color,\n linkCursor: undefined,\n\n // https://stackoverflow.com/a/21648197/2040291\n init: function () {\n (this as SankeyConfigInterface<SankeyInputNode, SankeyInputLink>).linkSort =\n (link2, link1) => getNumber(link1, this.linkValue) - getNumber(link2, this.linkValue)\n delete this.init\n return this\n },\n}).init()\n\n"],"names":[],"mappings":";;;;;;AAAA;AAyIa,MAAA,mBAAmB,GAA4D,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACvF,sBAAsB,CAAA,EAAA,EACzB,wBAAwB,EAAE,CAAC,GAAG,EAAE,EAChC,kBAAkB,EAAE,wBAAwB,CAAC,OAAO,EACpD,mBAAmB,EAAE,yBAAyB,CAAC,OAAO,EACtD,EAAE,EAAE,CAAC,CAAkB,EAAE,CAAS,KAAK,EAAA,IAAA,EAAA,CAAA,CAAA,OAAA,CAAC,EAAA,GAAA,CAAqB,CAAC,GAAG,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAG,CAAC,CAAA,CAAE,CAAA,EAAA,EAC3E,uBAAuB,EAAE,KAAK,EAC9B,iBAAiB,EAAE,GAAG,EACtB,cAAc,EAAE,IAAI,EACpB,UAAU,EAAE,EAAE,EACd,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,EAAE,EACb,SAAS,EAAE,eAAe,CAAC,OAAO,EAClC,qBAAqB,EAAE,GAAG,EAC1B,aAAa,EAAE,EAAE,EACjB,aAAa,EAAE,GAAG,EAClB,WAAW,EAAE,CAAC,EACd,SAAS,EAAE,CAAC,CAAkB,KAAM,CAAuB,CAAC,KAAK,EACjE,cAAc,EAAE,CAAC,CAAkB,KAAM,CAA4B,CAAC,UAAU,EAChF,cAAc,EAAE,IAAI,EACpB,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,EACnB,aAAa,EAAE,SAAS,EACxB,KAAK,EAAE,CAAC,CAAkB,KAAM,CAAuB,CAAC,KAAK,EAC7D,aAAa,EAAE,QAAQ,CAAC,IAAI,EAC5B,kBAAkB,EAAE,aAAa,CAAC,MAAM,EACxC,eAAe,EAAE,KAAK,EACtB,kBAAkB,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAC9B,QAAQ,EAAE,OAAO,CAAC,IAAI,EACtB,aAAa,EAAE,QAAQ,CAAC,MAAM,EAC9B,mBAAmB,EAAE,IAAI,EACzB,aAAa,EAAE,SAAS,EACxB,WAAW,EAAE,SAAS,EACtB,UAAU,EAAE,SAAS,EACrB,aAAa,EAAE,EAAE,EACjB,yBAAyB,EAAE,IAAI,EAC/B,eAAe,EAAE,SAAS,EAC1B,QAAQ,EAAE,SAAS,EACnB,gBAAgB,EAAE,SAAS,EAC3B,aAAa,EAAE,SAAS,EACxB,iBAAiB,EAAE,uBAAuB,CAAC,KAAK,EAChD,+BAA+B,EAAE,GAAG,EACpC,SAAS,EAAE,CAAC,CAAkB,KAAM,CAAuB,CAAC,KAAK,EACjE,SAAS,EAAE,CAAC,CAAkB,KAAM,CAAuB,CAAC,KAAK,EACjE,UAAU,EAAE,SAAS;;AAGrB,IAAA,IAAI,EAAE,YAAA;AACH,QAAA,IAAgE,CAAC,QAAQ;YACxE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QACvF,OAAO,IAAI,CAAC,IAAI,CAAA;AAChB,QAAA,OAAO,IAAI,CAAA;AACb,KAAC,EACD,CAAA,EAAC,IAAI;;;;"}
@@ -26,15 +26,9 @@ export declare class Sankey<N extends SankeyInputNode, L extends SankeyInputLink
26
26
  [x: string]: {
27
27
  mouseenter: (d: SankeyNode<N, L>, event: MouseEvent) => void;
28
28
  mouseleave: (d: SankeyNode<N, L>, event: MouseEvent) => void;
29
- click?: undefined;
30
- } | {
31
- mouseenter: (d: SankeyNode<N, L>) => void;
32
- mouseleave: (d: SankeyNode<N, L>) => void;
33
- click: (d: SankeyNode<N, L>, event: MouseEvent) => void;
34
29
  } | {
35
30
  mouseenter: (d: SankeyLink<N, L>, event: MouseEvent) => void;
36
31
  mouseleave: (d: SankeyLink<N, L>, event: MouseEvent) => void;
37
- click?: undefined;
38
32
  };
39
33
  };
40
34
  constructor(config?: SankeyConfigInterface<N, L>);
@@ -56,34 +50,11 @@ export declare class Sankey<N extends SankeyInputNode, L extends SankeyInputLink
56
50
  highlightSubtree(node: SankeyNode<N, L>): void;
57
51
  recursiveSetSubtreeState(node: SankeyNode<N, L>, linksKey: 'sourceLinks' | 'targetLinks', nodeKey: 'source' | 'target', key: string, value: unknown): void;
58
52
  disableHighlight(): void;
59
- /**
60
- * Collapses a node by hiding only the links directly connected to it.
61
- * All other nodes (including children and descendants) remain visible in their original positions.
62
- * Only the immediate incoming and outgoing links of the collapsed node are hidden.
63
- */
64
- collapseNode(node: SankeyNode<N, L>): void;
65
- /**
66
- * Expands a previously collapsed node by showing its directly connected links.
67
- */
68
- expandNode(node: SankeyNode<N, L>): void;
69
- /**
70
- * Toggles the collapse state of a node.
71
- *
72
- * @param node The node to toggle
73
- */
74
- toggleNodeCollapse(node: SankeyNode<N, L>): void;
75
53
  private _hasLinks;
76
- /**
77
- * Applies initial collapse state to nodes based on the disabledField configuration.
78
- * If disabledField is set (e.g., "disabled"), nodes with that field set to true
79
- * will be pre-collapsed when the component loads.
80
- */
81
- private _applyInitialCollapseState;
82
54
  private _onNodeMouseOver;
83
55
  private _onNodeMouseOut;
84
56
  private _onNodeRectMouseOver;
85
57
  private _onNodeRectMouseOut;
86
58
  private _onLinkMouseOver;
87
59
  private _onLinkMouseOut;
88
- private _onNodeClick;
89
60
  }
@@ -38,7 +38,6 @@ class Sankey extends ComponentCore {
38
38
  [Sankey.selectors.node]: {
39
39
  mouseenter: this._onNodeRectMouseOver.bind(this),
40
40
  mouseleave: this._onNodeRectMouseOut.bind(this),
41
- click: this._onNodeClick.bind(this),
42
41
  },
43
42
  [Sankey.selectors.link]: {
44
43
  mouseenter: this._onLinkMouseOver.bind(this),
@@ -81,16 +80,12 @@ class Sankey extends ComponentCore {
81
80
  }
82
81
  setData(data) {
83
82
  super.setData(data);
84
- // Pre-collapse nodes based on disabledField
85
- this._applyInitialCollapseState();
86
83
  // Pre-calculate component size for Sizing.EXTEND
87
84
  if ((this.sizing !== Sizing.Fit) || !this._hasLinks())
88
85
  this._preCalculateComponentSize();
89
86
  }
90
87
  setConfig(config) {
91
88
  super.setConfig(config);
92
- // Apply initial collapse state if disabledField is set
93
- this._applyInitialCollapseState();
94
89
  // Pre-calculate component size for Sizing.EXTEND
95
90
  if ((this.sizing !== Sizing.Fit) || !this._hasLinks())
96
91
  this._preCalculateComponentSize();
@@ -279,69 +274,10 @@ class Sankey extends ComponentCore {
279
274
  this._render(config.highlightDuration);
280
275
  }
281
276
  }
282
- /**
283
- * Collapses a node by hiding only the links directly connected to it.
284
- * All other nodes (including children and descendants) remain visible in their original positions.
285
- * Only the immediate incoming and outgoing links of the collapsed node are hidden.
286
- */
287
- collapseNode(node) {
288
- const { config } = this;
289
- // Clear any active highlights before collapsing
290
- this.disableHighlight();
291
- node._state = node._state || {};
292
- node._state.collapsed = true;
293
- this._render(config.collapseAnimationDuration);
294
- }
295
- /**
296
- * Expands a previously collapsed node by showing its directly connected links.
297
- */
298
- expandNode(node) {
299
- const { config } = this;
300
- // Clear any active highlights before expanding
301
- this.disableHighlight();
302
- node._state = node._state || {};
303
- node._state.collapsed = false;
304
- this._render(config.collapseAnimationDuration);
305
- }
306
- /**
307
- * Toggles the collapse state of a node.
308
- *
309
- * @param node The node to toggle
310
- */
311
- toggleNodeCollapse(node) {
312
- var _a;
313
- if ((_a = node._state) === null || _a === void 0 ? void 0 : _a.collapsed) {
314
- this.expandNode(node);
315
- }
316
- else {
317
- this.collapseNode(node);
318
- }
319
- }
320
277
  _hasLinks() {
321
278
  const { datamodel } = this;
322
279
  return datamodel.links.length > 0;
323
280
  }
324
- /**
325
- * Applies initial collapse state to nodes based on the disabledField configuration.
326
- * If disabledField is set (e.g., "disabled"), nodes with that field set to true
327
- * will be pre-collapsed when the component loads.
328
- */
329
- _applyInitialCollapseState() {
330
- const { config, datamodel } = this;
331
- if (!config.disabledField)
332
- return;
333
- // Check each node for the disabled field and set initial collapse state
334
- for (const node of datamodel.nodes) {
335
- const inputData = node;
336
- const isDisabled = inputData && typeof inputData === 'object' &&
337
- config.disabledField in inputData &&
338
- inputData[config.disabledField] === true;
339
- if (isDisabled) {
340
- node._state = node._state || {};
341
- node._state.collapsed = true;
342
- }
343
- }
344
- }
345
281
  _onNodeMouseOver(d, event) {
346
282
  onNodeMouseOver(d, select(event.currentTarget), this.config, this._width);
347
283
  }
@@ -364,12 +300,6 @@ class Sankey extends ComponentCore {
364
300
  _onLinkMouseOut(d, event) {
365
301
  this.disableHighlight();
366
302
  }
367
- _onNodeClick(d, event) {
368
- const { config } = this;
369
- if (config.enableNodeCollapse) {
370
- this.toggleNodeCollapse(d);
371
- }
372
- }
373
303
  }
374
304
  Sankey.selectors = style;
375
305