@unovis/ts 1.6.5 → 1.6.6-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/axis/config.d.ts +10 -7
- package/components/axis/config.js +1 -1
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.d.ts +1 -0
- package/components/axis/index.js +44 -53
- package/components/axis/index.js.map +1 -1
- package/components/axis/style.d.ts +2 -38
- package/components/axis/style.js +28 -24
- package/components/axis/style.js.map +1 -1
- package/components/brush/config.d.ts +3 -0
- package/components/brush/config.js +1 -1
- package/components/brush/config.js.map +1 -1
- package/components/brush/index.d.ts +1 -0
- package/components/brush/index.js +7 -3
- package/components/brush/index.js.map +1 -1
- package/components/crosshair/config.d.ts +2 -0
- package/components/crosshair/config.js +1 -1
- package/components/crosshair/config.js.map +1 -1
- package/components/crosshair/index.d.ts +2 -0
- package/components/crosshair/index.js +8 -1
- package/components/crosshair/index.js.map +1 -1
- package/components/sankey/config.d.ts +2 -0
- package/components/sankey/config.js +1 -1
- package/components/sankey/config.js.map +1 -1
- package/components/sankey/index.d.ts +2 -2
- package/components/sankey/index.js +12 -5
- package/components/sankey/index.js.map +1 -1
- package/components/sankey/types.d.ts +4 -0
- package/components/sankey/types.js +7 -2
- package/components/sankey/types.js.map +1 -1
- package/components/scatter/index.js +2 -0
- package/components/scatter/index.js.map +1 -1
- package/components/timeline/config.d.ts +5 -1
- package/components/timeline/config.js +2 -2
- package/components/timeline/config.js.map +1 -1
- package/components/timeline/index.d.ts +2 -2
- package/components/timeline/index.js +64 -31
- package/components/timeline/index.js.map +1 -1
- package/components/timeline/style.d.ts +6 -1
- package/components/timeline/style.js +40 -46
- package/components/timeline/style.js.map +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/types/style.d.ts +1 -0
- package/types.js +1 -1
- package/utils/text.js +6 -2
- package/utils/text.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/scatter/index.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { max, min } from 'd3-array'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, getExtent, getNumber, getString, isArray, flatten, getValue } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\n\n// Types\nimport { Spacing } from 'types/spacing'\nimport { SymbolType } from 'types/symbol'\nimport { NumericAccessor } from 'types/accessor'\nimport { Position } from 'types/position'\nimport { ContinuousScale } from 'types/scale'\n\n// Local Types\nimport { ScatterPointGroupNode, ScatterPoint } from './types'\n\n// Config\nimport { ScatterDefaultConfig, ScatterConfigInterface } from './config'\n\n// Modules\nimport { createPoints, updatePoints, removePoints } from './modules/point'\nimport { collideLabels, getEstimatedLabelBBox } from './modules/utils'\n\n// Styles\nimport * as s from './style'\n\n\nexport class Scatter<Datum> extends XYComponentCore<Datum, ScatterConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = ScatterDefaultConfig as ScatterConfigInterface<Datum>\n public config: ScatterConfigInterface<Datum> = this._defaultConfig\n\n events = {\n [Scatter.selectors.point]: {\n mouseenter: this._onPointMouseOver.bind(this),\n mouseleave: this._onPointMouseOut.bind(this),\n },\n }\n\n private _pointData: ScatterPoint<Datum>[][] = []\n private _points: Selection<SVGGElement, ScatterPoint<Datum>, SVGGElement, ScatterPoint<Datum>[]>\n private _sizeScale: ContinuousScale\n private _collideLabelsAnimFrameId: ReturnType<typeof requestAnimationFrame>\n\n constructor (config?: ScatterConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n setConfig (config: ScatterConfigInterface<Datum>): void {\n super.setConfig(config)\n this._updateSizeScale()\n }\n\n setData (data: Datum[]): void {\n super.setData(data)\n this._updateSizeScale()\n }\n\n get bleed (): Spacing {\n this._pointData = this._getOnScreenData()\n const pointDataFlat: ScatterPoint<Datum>[] = flatten(this._pointData)\n\n const yRangeStart = min(this.yScale.range())\n const yRangeEnd = max(this.yScale.range())\n const xRangeStart = this.xScale.range()[0]\n const xRangeEnd = this.xScale.range()[1]\n\n const fontSizePx = getCSSVariableValueInPixels('var(--vis-scatter-point-label-text-font-size)', this.element)\n\n const extent = pointDataFlat.reduce((ext, d) => {\n const x = this.xScale(d._point.xValue)\n const y = this.yScale(d._point.yValue)\n const r = d._point.sizePx / 2\n\n ext.minX = Math.min(ext.minX, x - r)\n ext.maxX = Math.max(ext.maxX, x + r)\n ext.minY = Math.min(ext.minY, y - r)\n ext.maxY = Math.max(ext.maxY, y + r)\n\n if (d._point.label) {\n const labelBBox = getEstimatedLabelBBox(d, d._point.labelPosition, this.xScale, this.yScale, fontSizePx)\n ext.minX = Math.min(ext.minX, labelBBox.x)\n ext.maxX = Math.max(ext.maxX, labelBBox.x + labelBBox.width)\n ext.minY = Math.min(ext.minY, labelBBox.y)\n ext.maxY = Math.max(ext.maxY, labelBBox.y + labelBBox.height)\n }\n return ext\n }, {\n minX: Number.POSITIVE_INFINITY,\n maxX: Number.NEGATIVE_INFINITY,\n minY: Number.POSITIVE_INFINITY,\n maxY: Number.NEGATIVE_INFINITY,\n })\n\n const coeff = 1.2 // Multiplier to take into account subsequent scale range changes and shape irregularities\n const top = extent.minY < yRangeStart ? coeff * (yRangeStart - extent.minY) : 0\n const bottom = extent.maxY > yRangeEnd ? coeff * (extent.maxY - yRangeEnd) : 0\n const left = extent.minX < xRangeStart ? coeff * (xRangeStart - extent.minX) : 0\n const right = extent.maxX > xRangeEnd ? coeff * (extent.maxX - xRangeEnd) : 0\n\n return { top, bottom, left, right }\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n // Groups\n const pointGroups = this.g\n .selectAll<SVGGElement, ScatterPoint<Datum>[]>(`.${s.pointGroup}`)\n .data(this._pointData)\n\n const pointGroupsEnter = pointGroups\n .enter()\n .append('g')\n .attr('class', s.pointGroup)\n\n const pointGroupsMerged = pointGroupsEnter.merge(pointGroups)\n smartTransition(pointGroupsMerged, duration)\n .style('opacity', 1)\n\n const pointGroupExit = pointGroups.exit().attr('class', s.pointGroupExit)\n smartTransition(pointGroupExit, duration).style('opacity', 0).remove()\n\n // Points\n const points = pointGroupsMerged\n .selectAll<SVGGElement, ScatterPoint<Datum>>(`.${s.point}`)\n .data(\n d => d,\n d => `${getString(d, config.id, d._point.pointIndex) ?? d._point.pointIndex}`\n )\n\n const pointsEnter = points.enter().append('g')\n .attr('class', s.point)\n createPoints(pointsEnter, this.xScale, this.yScale)\n\n this._points = pointsEnter.merge(points)\n updatePoints(this._points, config, this.xScale, this.yScale, duration)\n\n removePoints(points.exit<ScatterPoint<Datum>>(), this.xScale, this.yScale, duration)\n\n // Take care of overlapping labels\n if (this._hasLabels()) {\n this._resolveLabelOverlap()\n }\n }\n\n private _hasLabels (): boolean {\n // If label config is not defined, no labels will be shown\n if (!this.config.label) return false\n\n // Check if any point in the flattened data has a label\n const pointDataFlat: ScatterPoint<Datum>[] = flatten(this._pointData)\n return pointDataFlat.some(d => d._point.label)\n }\n\n private _resolveLabelOverlap (): void {\n if (!this.config.labelHideOverlapping) {\n const label = this._points.selectAll<SVGTextElement, ScatterPoint<Datum>>('text')\n label.attr('opacity', null)\n return\n }\n\n cancelAnimationFrame(this._collideLabelsAnimFrameId)\n this._collideLabelsAnimFrameId = requestAnimationFrame(() => {\n collideLabels(this._points, this.config, this.xScale, this.yScale)\n })\n }\n\n private _updateSizeScale (): void {\n const { config, datamodel } = this\n\n this._sizeScale = config.sizeScale.copy()\n this._sizeScale.domain(getExtent(datamodel.data, config.size))\n this._sizeScale.range(config.sizeRange ?? [0, 0])\n }\n\n private _getOnScreenData (): ScatterPoint<Datum>[][] {\n const { config, datamodel: { data } } = this\n\n const xDomain = this.xScale.domain().map((d: number | Date) => +d) // Convert Date to number\n const yDomain = this.yScale.domain().map((d: number | Date) => +d) // Convert Date to number\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const maxSizeValue = max<number>(flatten(yAccessors.map((y, j) => data?.map(d => getNumber(d, config.size, j)))))\n const maxSizePx = config.sizeRange ? this._sizeScale(maxSizeValue) : maxSizeValue\n\n const maxSizeXDomain = (this.xScale.invert(maxSizePx) as number) - (this.xScale.invert(0) as number)\n const maxSizeYDomain = Math.abs((this.yScale.invert(maxSizePx) as number) - (this.yScale.invert(0) as number))\n\n return yAccessors.map((y, j) => {\n return data?.reduce<ScatterPoint<Datum>[]>((acc, d, i) => {\n const xValue = getNumber(d, config.x, i)\n const yValue = getNumber(d, y, j)\n const pointSize = getNumber(d, config.size, i)\n const pointSizeScaled = config.sizeRange ? this._sizeScale(pointSize) : pointSize\n const pointSizeXDomain = (this.xScale.invert(pointSizeScaled) as number) - (this.xScale.invert(0) as number)\n const pointSizeYDomain = Math.abs((this.yScale.invert(pointSizeScaled) as number) - (this.yScale.invert(0) as number))\n\n if (\n ((xValue - pointSizeXDomain / 2) >= (xDomain[0] - maxSizeXDomain / 2)) &&\n ((xValue + pointSizeXDomain / 2) <= (xDomain[1] + maxSizeXDomain / 2)) &&\n ((yValue - pointSizeYDomain / 2) >= (yDomain[0] - maxSizeYDomain / 2)) &&\n ((yValue + pointSizeYDomain / 2) <= (yDomain[1] + maxSizeYDomain / 2))\n ) {\n acc.push({\n ...d,\n _point: {\n xValue: xValue,\n yValue: yValue,\n sizePx: pointSizeScaled,\n color: getColor(d, config.color, j),\n strokeColor: getColor(d, config.strokeColor, j, true),\n strokeWidthPx: getNumber(d, config.strokeWidth, j),\n shape: getString(d, config.shape, j) as SymbolType,\n label: getString(d, config.label, j),\n labelColor: getColor(d, config.labelColor, j, true),\n labelPosition: getValue(d, config.labelPosition, i) as Position,\n cursor: getString(d, config.cursor, j),\n groupIndex: j,\n pointIndex: i,\n },\n })\n }\n\n return acc\n }, []) ?? []\n })\n }\n\n private _onPointMouseOver (d: ScatterPoint<Datum>, event: MouseEvent): void {\n const point = select(event.target as SVGGElement)\n const pointNode = point.node() as ScatterPointGroupNode | null\n if (pointNode) pointNode._forceShowLabel = true\n\n point.raise()\n this._resolveLabelOverlap()\n }\n\n private _onPointMouseOut (d: ScatterPoint<Datum>, event: MouseEvent): void {\n const pointNode = select(event.target as SVGGElement).node() as ScatterPointGroupNode | null\n if (pointNode) delete pointNode._forceShowLabel\n\n this._resolveLabelOverlap()\n }\n}\n"],"names":["s.pointGroup","pointGroupExit","s.pointGroupExit","s.point","s"],"mappings":";;;;;;;;;;;;;AAiCM,MAAO,OAAe,SAAQ,eAAqD,CAAA;AAiBvF,IAAA,WAAA,CAAa,MAAsC,EAAA;AACjD,QAAA,KAAK,EAAE,CAAA;QAhBC,IAAc,CAAA,cAAA,GAAG,oBAAqD,CAAA;AACzE,QAAA,IAAA,CAAA,MAAM,GAAkC,IAAI,CAAC,cAAc,CAAA;AAElE,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,GAAG;gBACzB,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC7C,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7C,aAAA;SACF,CAAA;QAEO,IAAU,CAAA,UAAA,GAA4B,EAAE,CAAA;AAO9C,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACnC;AAED,IAAA,SAAS,CAAE,MAAqC,EAAA;AAC9C,QAAA,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QACvB,IAAI,CAAC,gBAAgB,EAAE,CAAA;KACxB;AAED,IAAA,OAAO,CAAE,IAAa,EAAA;AACpB,QAAA,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACnB,IAAI,CAAC,gBAAgB,EAAE,CAAA;KACxB;AAED,IAAA,IAAI,KAAK,GAAA;AACP,QAAA,IA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A,CAAA,GAAA,EAAA,GAAI,EAAE,CAAA;AACd,SAAC,CAAC,CAAA;KACH;IAEO,iBAAiB,CAAE,CAAsB,EAAE,KAAiB,EAAA;QAClE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAqB,CAAC,CAAA;AACjD,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAkC,CAAA;AAC9D,QAAA,IAAI,SAAS;AAAE,YAAA,SAAS,CAAC,eAAe,GAAG,IAAI,CAAA;QAE/C,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,IAAI,CAAC,oBAAoB,EAAE,CAAA;KAC5B;IAEO,gBAAgB,CAAE,CAAsB,EAAE,KAAiB,EAAA;QACjE,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,MAAqB,CAAC,CAAC,IAAI,EAAkC,CAAA;AAC5F,QAAA,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC,eAAe,CAAA;QAE/C,IAAI,CAAC,oBAAoB,EAAE,CAAA;KAC5B;;AAzNM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/scatter/index.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\nimport { max, min } from 'd3-array'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, getExtent, getNumber, getString, isArray, flatten, getValue } from 'utils/data'\nimport { getColor } from 'utils/color'\nimport { smartTransition } from 'utils/d3'\nimport { getCSSVariableValueInPixels } from 'utils/misc'\n\n// Types\nimport { Spacing } from 'types/spacing'\nimport { SymbolType } from 'types/symbol'\nimport { NumericAccessor } from 'types/accessor'\nimport { Position } from 'types/position'\nimport { ContinuousScale } from 'types/scale'\n\n// Local Types\nimport { ScatterPointGroupNode, ScatterPoint } from './types'\n\n// Config\nimport { ScatterDefaultConfig, ScatterConfigInterface } from './config'\n\n// Modules\nimport { createPoints, updatePoints, removePoints } from './modules/point'\nimport { collideLabels, getEstimatedLabelBBox } from './modules/utils'\n\n// Styles\nimport * as s from './style'\n\n\nexport class Scatter<Datum> extends XYComponentCore<Datum, ScatterConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = ScatterDefaultConfig as ScatterConfigInterface<Datum>\n public config: ScatterConfigInterface<Datum> = this._defaultConfig\n\n events = {\n [Scatter.selectors.point]: {\n mouseenter: this._onPointMouseOver.bind(this),\n mouseleave: this._onPointMouseOut.bind(this),\n },\n }\n\n private _pointData: ScatterPoint<Datum>[][] = []\n private _points: Selection<SVGGElement, ScatterPoint<Datum>, SVGGElement, ScatterPoint<Datum>[]>\n private _sizeScale: ContinuousScale\n private _collideLabelsAnimFrameId: ReturnType<typeof requestAnimationFrame>\n\n constructor (config?: ScatterConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n setConfig (config: ScatterConfigInterface<Datum>): void {\n super.setConfig(config)\n this._updateSizeScale()\n }\n\n setData (data: Datum[]): void {\n super.setData(data)\n this._updateSizeScale()\n }\n\n get bleed (): Spacing {\n this._pointData = this._getOnScreenData()\n const pointDataFlat: ScatterPoint<Datum>[] = flatten(this._pointData)\n\n const yRangeStart = min(this.yScale.range())\n const yRangeEnd = max(this.yScale.range())\n const xRangeStart = this.xScale.range()[0]\n const xRangeEnd = this.xScale.range()[1]\n\n const fontSizePx = getCSSVariableValueInPixels('var(--vis-scatter-point-label-text-font-size)', this.element)\n\n const extent = pointDataFlat.reduce((ext, d) => {\n const x = this.xScale(d._point.xValue)\n const y = this.yScale(d._point.yValue)\n const r = d._point.sizePx / 2\n\n ext.minX = Math.min(ext.minX, x - r)\n ext.maxX = Math.max(ext.maxX, x + r)\n ext.minY = Math.min(ext.minY, y - r)\n ext.maxY = Math.max(ext.maxY, y + r)\n\n if (d._point.label) {\n const labelBBox = getEstimatedLabelBBox(d, d._point.labelPosition, this.xScale, this.yScale, fontSizePx)\n ext.minX = Math.min(ext.minX, labelBBox.x)\n ext.maxX = Math.max(ext.maxX, labelBBox.x + labelBBox.width)\n ext.minY = Math.min(ext.minY, labelBBox.y)\n ext.maxY = Math.max(ext.maxY, labelBBox.y + labelBBox.height)\n }\n return ext\n }, {\n minX: Number.POSITIVE_INFINITY,\n maxX: Number.NEGATIVE_INFINITY,\n minY: Number.POSITIVE_INFINITY,\n maxY: Number.NEGATIVE_INFINITY,\n })\n\n const coeff = 1.2 // Multiplier to take into account subsequent scale range changes and shape irregularities\n const top = extent.minY < yRangeStart ? coeff * (yRangeStart - extent.minY) : 0\n const bottom = extent.maxY > yRangeEnd ? coeff * (extent.maxY - yRangeEnd) : 0\n const left = extent.minX < xRangeStart ? coeff * (xRangeStart - extent.minX) : 0\n const right = extent.maxX > xRangeEnd ? coeff * (extent.maxX - xRangeEnd) : 0\n\n return { top, bottom, left, right }\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n // Groups\n const pointGroups = this.g\n .selectAll<SVGGElement, ScatterPoint<Datum>[]>(`.${s.pointGroup}`)\n .data(this._pointData)\n\n const pointGroupsEnter = pointGroups\n .enter()\n .append('g')\n .attr('class', s.pointGroup)\n\n const pointGroupsMerged = pointGroupsEnter.merge(pointGroups)\n smartTransition(pointGroupsMerged, duration)\n .style('opacity', 1)\n\n const pointGroupExit = pointGroups.exit().attr('class', s.pointGroupExit)\n smartTransition(pointGroupExit, duration).style('opacity', 0).remove()\n\n // Points\n const points = pointGroupsMerged\n .selectAll<SVGGElement, ScatterPoint<Datum>>(`.${s.point}`)\n .data(\n d => d,\n d => `${getString(d, config.id, d._point.pointIndex) ?? d._point.pointIndex}`\n )\n\n const pointsEnter = points.enter().append('g')\n .attr('class', s.point)\n createPoints(pointsEnter, this.xScale, this.yScale)\n\n this._points = pointsEnter.merge(points)\n updatePoints(this._points, config, this.xScale, this.yScale, duration)\n\n removePoints(points.exit<ScatterPoint<Datum>>(), this.xScale, this.yScale, duration)\n\n // Take care of overlapping labels\n if (this._hasLabels()) {\n this._resolveLabelOverlap()\n }\n }\n\n private _hasLabels (): boolean {\n // If label config is not defined, no labels will be shown\n if (!this.config.label) return false\n\n // Check if any point in the flattened data has a label\n const pointDataFlat: ScatterPoint<Datum>[] = flatten(this._pointData)\n return pointDataFlat.some(d => d._point.label)\n }\n\n private _resolveLabelOverlap (): void {\n if (!this.config.labelHideOverlapping) {\n const label = this._points.selectAll<SVGTextElement, ScatterPoint<Datum>>('text')\n label.attr('opacity', null)\n return\n }\n\n cancelAnimationFrame(this._collideLabelsAnimFrameId)\n this._collideLabelsAnimFrameId = requestAnimationFrame(() => {\n collideLabels(this._points, this.config, this.xScale, this.yScale)\n })\n }\n\n private _updateSizeScale (): void {\n const { config, datamodel } = this\n\n this._sizeScale = config.sizeScale.copy()\n this._sizeScale.domain(getExtent(datamodel.data, config.size))\n this._sizeScale.range(config.sizeRange ?? [0, 0])\n }\n\n private _getOnScreenData (): ScatterPoint<Datum>[][] {\n const { config, datamodel: { data } } = this\n\n const xDomain = this.xScale.domain().map((d: number | Date) => +d) // Convert Date to number\n const yDomain = this.yScale.domain().map((d: number | Date) => +d) // Convert Date to number\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const maxSizeValue = max<number>(flatten(yAccessors.map((y, j) => data?.map(d => getNumber(d, config.size, j)))))\n const maxSizePx = config.sizeRange ? this._sizeScale(maxSizeValue) : maxSizeValue\n\n const maxSizeXDomain = (this.xScale.invert(maxSizePx) as number) - (this.xScale.invert(0) as number)\n const maxSizeYDomain = Math.abs((this.yScale.invert(maxSizePx) as number) - (this.yScale.invert(0) as number))\n\n return yAccessors.map((y, j) => {\n return data?.reduce<ScatterPoint<Datum>[]>((acc, d, i) => {\n const xValue = getNumber(d, config.x, i)\n const yValue = getNumber(d, y, j)\n if (xValue == null || yValue == null) return acc\n\n const pointSize = getNumber(d, config.size, i)\n const pointSizeScaled = config.sizeRange ? this._sizeScale(pointSize) : pointSize\n const pointSizeXDomain = (this.xScale.invert(pointSizeScaled) as number) - (this.xScale.invert(0) as number)\n const pointSizeYDomain = Math.abs((this.yScale.invert(pointSizeScaled) as number) - (this.yScale.invert(0) as number))\n\n if (\n ((xValue - pointSizeXDomain / 2) >= (xDomain[0] - maxSizeXDomain / 2)) &&\n ((xValue + pointSizeXDomain / 2) <= (xDomain[1] + maxSizeXDomain / 2)) &&\n ((yValue - pointSizeYDomain / 2) >= (yDomain[0] - maxSizeYDomain / 2)) &&\n ((yValue + pointSizeYDomain / 2) <= (yDomain[1] + maxSizeYDomain / 2))\n ) {\n acc.push({\n ...d,\n _point: {\n xValue: xValue,\n yValue: yValue,\n sizePx: pointSizeScaled,\n color: getColor(d, config.color, j),\n strokeColor: getColor(d, config.strokeColor, j, true),\n strokeWidthPx: getNumber(d, config.strokeWidth, j),\n shape: getString(d, config.shape, j) as SymbolType,\n label: getString(d, config.label, j),\n labelColor: getColor(d, config.labelColor, j, true),\n labelPosition: getValue(d, config.labelPosition, i) as Position,\n cursor: getString(d, config.cursor, j),\n groupIndex: j,\n pointIndex: i,\n },\n })\n }\n\n return acc\n }, []) ?? []\n })\n }\n\n private _onPointMouseOver (d: ScatterPoint<Datum>, event: MouseEvent): void {\n const point = select(event.target as SVGGElement)\n const pointNode = point.node() as ScatterPointGroupNode | null\n if (pointNode) pointNode._forceShowLabel = true\n\n point.raise()\n this._resolveLabelOverlap()\n }\n\n private _onPointMouseOut (d: ScatterPoint<Datum>, event: MouseEvent): void {\n const pointNode = select(event.target as SVGGElement).node() as ScatterPointGroupNode | null\n if (pointNode) delete pointNode._forceShowLabel\n\n this._resolveLabelOverlap()\n }\n}\n"],"names":["s.pointGroup","pointGroupExit","s.pointGroupExit","s.point","s"],"mappings":";;;;;;;;;;;;;AAiCM,MAAO,OAAe,SAAQ,eAAqD,CAAA;AAiBvF,IAAA,WAAA,CAAa,MAAsC,EAAA;AACjD,QAAA,KAAK,EAAE,CAAA;QAhBC,IAAc,CAAA,cAAA,GAAG,oBAAqD,CAAA;AACzE,Q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KAC5B;IAEO,gBAAgB,CAAE,CAAsB,EAAE,KAAiB,EAAA;QACjE,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,MAAqB,CAAC,CAAC,IAAI,EAAkC,CAAA;AAC5F,QAAA,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC,eAAe,CAAA;QAE/C,IAAI,CAAC,oBAAoB,EAAE,CAAA;KAC5B;;AA3NM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { XYComponentConfigInterface } from "../../core/xy-component/config";
|
|
2
2
|
import { WithOptional } from "../../types/misc";
|
|
3
3
|
import { ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from "../../types/accessor";
|
|
4
|
-
import { TextAlign } from "../../types/text";
|
|
4
|
+
import { TextAlign, TrimMode } from "../../types/text";
|
|
5
5
|
import { Arrangement } from "../../types/position";
|
|
6
6
|
import type { TimelineArrow, TimelineLineRenderState, TimelineRowIcon, TimelineRowLabel } from './types';
|
|
7
7
|
export interface TimelineConfigInterface<Datum> extends WithOptional<XYComponentConfigInterface<Datum>, 'y'> {
|
|
@@ -74,6 +74,10 @@ export interface TimelineConfigInterface<Datum> extends WithOptional<XYComponent
|
|
|
74
74
|
rowMaxLabelWidth?: number;
|
|
75
75
|
/** Text alignment for labels: `TextAlign.Left`, `TextAlign.Center` or `TextAlign.Right`. Default: `TextAlign.Right` */
|
|
76
76
|
rowLabelTextAlign?: TextAlign | `${TextAlign}`;
|
|
77
|
+
/** Row label trim mode when width is limited: `TrimMode.Start`, `TrimMode.Middle` or `TrimMode.End`. Default: `TrimMode.Middle` */
|
|
78
|
+
rowLabelTrimMode?: TrimMode | `${TrimMode}`;
|
|
79
|
+
/** Row label margin in pixels. Can be a single number or a `[left, right]` tuple. Default: `[0, 5]` */
|
|
80
|
+
rowLabelMargin?: number | [number, number];
|
|
77
81
|
arrows?: TimelineArrow[];
|
|
78
82
|
/** Control the animation by specify the initial position for new lines as [x, y]. Default: `undefined` */
|
|
79
83
|
animationLineEnterPosition?: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XYComponentDefaultConfig } from '../../core/xy-component/config.js';
|
|
2
|
-
import { TextAlign } from '../../types/text.js';
|
|
2
|
+
import { TextAlign, TrimMode } from '../../types/text.js';
|
|
3
3
|
import { Arrangement } from '../../types/position.js';
|
|
4
4
|
|
|
5
5
|
const TimelineDefaultConfig = Object.assign(Object.assign({}, XYComponentDefaultConfig), { id: undefined,
|
|
@@ -8,7 +8,7 @@ const TimelineDefaultConfig = Object.assign(Object.assign({}, XYComponentDefault
|
|
|
8
8
|
// Rows
|
|
9
9
|
rowHeight: 22, alternatingRowColors: true,
|
|
10
10
|
// Row Labels
|
|
11
|
-
showLabels: false, labelWidth: undefined, maxLabelWidth: 120, showRowLabels: undefined, rowLabelFormatter: undefined, rowIcon: undefined, rowLabelStyle: undefined, rowLabelWidth: undefined, rowMaxLabelWidth: undefined, rowLabelTextAlign: TextAlign.Right,
|
|
11
|
+
showLabels: false, labelWidth: undefined, maxLabelWidth: 120, showRowLabels: undefined, rowLabelFormatter: undefined, rowIcon: undefined, rowLabelStyle: undefined, rowLabelWidth: undefined, rowMaxLabelWidth: undefined, rowLabelTextAlign: TextAlign.Right, rowLabelTrimMode: TrimMode.Middle, rowLabelMargin: [0, 5],
|
|
12
12
|
// Arrows
|
|
13
13
|
arrows: undefined,
|
|
14
14
|
// Animation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/timeline/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { WithOptional } from 'types/misc'\nimport { ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\nimport { TextAlign } from 'types/text'\nimport { Arrangement } from 'types/position'\n\n// Local Types\nimport type { TimelineArrow, TimelineLineRenderState, TimelineRowIcon, TimelineRowLabel } from './types'\n\nexport interface TimelineConfigInterface<Datum> extends WithOptional<XYComponentConfigInterface<Datum>, 'y'> {\n // Items (Lines)\n /** @deprecated This property has been renamed to `key` */\n type?: StringAccessor<Datum>;\n /** @deprecated This property has been renamed to `lineDuration` */\n length?: NumericAccessor<Datum>;\n /** @deprecated This property has been renamed to `lineCursor` */\n cursor?: StringAccessor<Datum>;\n /** Timeline item row accessor function. Records with the `lineRow` will be plotted in one row. Default: `undefined` */\n lineRow?: StringAccessor<Datum>;\n /** Timeline item duration accessor function. Default: `undefined`. Falls back to the deprecated `length` property */\n lineDuration?: NumericAccessor<Datum>;\n /** Timeline item color accessor function. Default: `d => d.color` */\n color?: ColorAccessor<Datum>;\n /** Width of the timeline items. Default: `8` */\n lineWidth?: NumericAccessor<Datum>;\n /** Display rounded ends for timeline items. Default: `true` */\n lineCap?: boolean;\n /** Provide a href to an SVG defined in container's `svgDefs` to display an icon at the start of the line. Default: undefined */\n lineStartIcon?: StringAccessor<Datum>;\n /** Line start icon color accessor function. Default: `undefined` */\n lineStartIconColor?: StringAccessor<Datum>;\n /** Line start icon size accessor function. Default: `undefined` */\n lineStartIconSize?: NumericAccessor<Datum>;\n /** Line start icon arrangement configuration. Controls how the icon is positioned relative to the line.\n * Accepts values from the Arrangement enum: `Arrangement.Start`, `Arrangement.Middle`, `Arrangement.End` or a string equivalent.\n * Default: `Arrangement.Inside` */\n lineStartIconArrangement?: GenericAccessor<Arrangement | `${Arrangement}`, Datum>;\n /** Provide a href to an SVG defined in container's `svgDefs` to display an icon at the end of the line. Default: undefined */\n lineEndIcon?: StringAccessor<Datum>;\n /** Line end icon color accessor function. Default: `undefined` */\n lineEndIconColor?: StringAccessor<Datum>;\n /** Line end icon size accessor function. Default: `undefined` */\n lineEndIconSize?: NumericAccessor<Datum>;\n /** Line end icon arrangement configuration. Controls how the icon is positioned relative to the line.\n * Accepts values from the Arrangement enum: `Arrangement.Start`, `Arrangement.Middle`, `Arrangement.End` or a string equivalent.\n * Default: `Arrangement.Inside` */\n lineEndIconArrangement?: GenericAccessor<Arrangement | `${Arrangement}`, Datum>;\n /** Configurable Timeline item cursor when hovering over. Default: `undefined` */\n lineCursor?: StringAccessor<Datum>;\n /** Sets the minimum line length to 1 pixel for better visibility of small values.\n * When `lineCap` is set to `true`, the segment will be rendered as a circle.\n * Default: `false` */\n showEmptySegments?: boolean;\n /** Center small segments when `showEmptySegments` and `lineCap` are set to `true`.\n * Default: `true` */\n showEmptySegmentsCorrectPosition?: boolean;\n\n /** Timeline row height. Default: `22` */\n rowHeight?: number;\n /** Alternating row colors. Default: `true` */\n alternatingRowColors?: boolean;\n\n // Row Labels\n /** @deprecated This property has been renamed to `showRowLabels */\n showLabels?: boolean;\n /** @deprecated This property has been renamed to `rowLabelWidth */\n labelWidth?: number;\n /** @deprecated This property has been renamed to `rowMaxLabelWidth */\n maxLabelWidth?: number;\n\n /** Show row labels when set to `true`. Default: `false`. Falls back to deprecated `showLabels` */\n showRowLabels?: boolean;\n /** Row label style as an object with the `{ [property-name]: value }` format. Default: `undefined` */\n rowLabelStyle?: GenericAccessor<Record<string, string>, TimelineRowLabel<Datum>>;\n /** Row label formatter function. Default: `undefined` */\n rowLabelFormatter?: (key: string, items: Datum[], i: number) => string;\n /** Provide an icon href to be displayed before the row label. Default: `undefined` */\n rowIcon?: (key: string, items: Datum[], i: number) => TimelineRowIcon | undefined;\n /** Fixed label width in pixels. Labels longer than the specified value will be trimmed. Default: `undefined`. Falls back to deprecated `labelWidth`. */\n rowLabelWidth?: number;\n /** Maximum label width in pixels. Labels longer than the specified value will be trimmed. Default: `undefined`. Falls back to deprecated `maxLabelWidth`. */\n rowMaxLabelWidth?: number;\n /** Text alignment for labels: `TextAlign.Left`, `TextAlign.Center` or `TextAlign.Right`. Default: `TextAlign.Right` */\n rowLabelTextAlign?: TextAlign | `${TextAlign}`;\n\n // Arrows\n arrows?: TimelineArrow[];\n\n // Animation\n /** Control the animation by specify the initial position for new lines as [x, y]. Default: `undefined` */\n animationLineEnterPosition?:\n [number | undefined | null, number | undefined | null] |\n ((d: Datum & TimelineLineRenderState, i: number, data: (Datum & TimelineLineRenderState)[]) => [number | undefined, number | undefined]) |\n undefined;\n /** Control the animation by specify the destination position for exiting lines as [x, y]. Default: `undefined` */\n animationLineExitPosition?: [number | undefined | null, number | undefined | null] |\n ((d: Datum & TimelineLineRenderState, i: number, data: (Datum & TimelineLineRenderState)[]) => [number | undefined, number | undefined]) |\n undefined;\n\n // Callbacks\n /** Scrolling callback function: `(scrollTop: number) => void`. Default: `undefined` */\n onScroll?: (scrollTop: number) => void;\n}\n\nexport const TimelineDefaultConfig: TimelineConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n id: undefined,\n\n // Items (Lines)\n cursor: undefined, // Deprecated (see above)\n type: (d: unknown): string => (d as { type: string }).type, // Deprecated (see above)\n length: (d: unknown): number => (d as { length: number }).length, // Deprecated (see above)\n color: (d: unknown): string => (d as { color: string }).color,\n lineRow: undefined,\n lineDuration: undefined,\n lineWidth: 8,\n lineCap: false,\n lineCursor: undefined,\n showEmptySegments: false,\n showEmptySegmentsCorrectPosition: true,\n lineStartIcon: undefined,\n lineStartIconColor: undefined,\n lineStartIconSize: undefined,\n lineStartIconArrangement: Arrangement.Inside,\n lineEndIcon: undefined,\n lineEndIconColor: undefined,\n lineEndIconSize: undefined,\n lineEndIconArrangement: Arrangement.Inside,\n\n // Rows\n rowHeight: 22,\n alternatingRowColors: true,\n\n // Row Labels\n showLabels: false, // Deprecated (see above)\n labelWidth: undefined, // Deprecated (see above)\n maxLabelWidth: 120, // Deprecated (see above)\n\n showRowLabels: undefined,\n rowLabelFormatter: undefined,\n rowIcon: undefined,\n rowLabelStyle: undefined,\n rowLabelWidth: undefined,\n rowMaxLabelWidth: undefined,\n rowLabelTextAlign: TextAlign.Right,\n\n // Arrows\n arrows: undefined,\n\n // Animation\n animationLineEnterPosition: undefined,\n\n // Callbacks\n onScroll: undefined,\n}\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/timeline/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { WithOptional } from 'types/misc'\nimport { ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\nimport { TextAlign, TrimMode } from 'types/text'\nimport { Arrangement } from 'types/position'\n\n// Local Types\nimport type { TimelineArrow, TimelineLineRenderState, TimelineRowIcon, TimelineRowLabel } from './types'\n\nexport interface TimelineConfigInterface<Datum> extends WithOptional<XYComponentConfigInterface<Datum>, 'y'> {\n // Items (Lines)\n /** @deprecated This property has been renamed to `key` */\n type?: StringAccessor<Datum>;\n /** @deprecated This property has been renamed to `lineDuration` */\n length?: NumericAccessor<Datum>;\n /** @deprecated This property has been renamed to `lineCursor` */\n cursor?: StringAccessor<Datum>;\n /** Timeline item row accessor function. Records with the `lineRow` will be plotted in one row. Default: `undefined` */\n lineRow?: StringAccessor<Datum>;\n /** Timeline item duration accessor function. Default: `undefined`. Falls back to the deprecated `length` property */\n lineDuration?: NumericAccessor<Datum>;\n /** Timeline item color accessor function. Default: `d => d.color` */\n color?: ColorAccessor<Datum>;\n /** Width of the timeline items. Default: `8` */\n lineWidth?: NumericAccessor<Datum>;\n /** Display rounded ends for timeline items. Default: `true` */\n lineCap?: boolean;\n /** Provide a href to an SVG defined in container's `svgDefs` to display an icon at the start of the line. Default: undefined */\n lineStartIcon?: StringAccessor<Datum>;\n /** Line start icon color accessor function. Default: `undefined` */\n lineStartIconColor?: StringAccessor<Datum>;\n /** Line start icon size accessor function. Default: `undefined` */\n lineStartIconSize?: NumericAccessor<Datum>;\n /** Line start icon arrangement configuration. Controls how the icon is positioned relative to the line.\n * Accepts values from the Arrangement enum: `Arrangement.Start`, `Arrangement.Middle`, `Arrangement.End` or a string equivalent.\n * Default: `Arrangement.Inside` */\n lineStartIconArrangement?: GenericAccessor<Arrangement | `${Arrangement}`, Datum>;\n /** Provide a href to an SVG defined in container's `svgDefs` to display an icon at the end of the line. Default: undefined */\n lineEndIcon?: StringAccessor<Datum>;\n /** Line end icon color accessor function. Default: `undefined` */\n lineEndIconColor?: StringAccessor<Datum>;\n /** Line end icon size accessor function. Default: `undefined` */\n lineEndIconSize?: NumericAccessor<Datum>;\n /** Line end icon arrangement configuration. Controls how the icon is positioned relative to the line.\n * Accepts values from the Arrangement enum: `Arrangement.Start`, `Arrangement.Middle`, `Arrangement.End` or a string equivalent.\n * Default: `Arrangement.Inside` */\n lineEndIconArrangement?: GenericAccessor<Arrangement | `${Arrangement}`, Datum>;\n /** Configurable Timeline item cursor when hovering over. Default: `undefined` */\n lineCursor?: StringAccessor<Datum>;\n /** Sets the minimum line length to 1 pixel for better visibility of small values.\n * When `lineCap` is set to `true`, the segment will be rendered as a circle.\n * Default: `false` */\n showEmptySegments?: boolean;\n /** Center small segments when `showEmptySegments` and `lineCap` are set to `true`.\n * Default: `true` */\n showEmptySegmentsCorrectPosition?: boolean;\n\n /** Timeline row height. Default: `22` */\n rowHeight?: number;\n /** Alternating row colors. Default: `true` */\n alternatingRowColors?: boolean;\n\n // Row Labels\n /** @deprecated This property has been renamed to `showRowLabels */\n showLabels?: boolean;\n /** @deprecated This property has been renamed to `rowLabelWidth */\n labelWidth?: number;\n /** @deprecated This property has been renamed to `rowMaxLabelWidth */\n maxLabelWidth?: number;\n\n /** Show row labels when set to `true`. Default: `false`. Falls back to deprecated `showLabels` */\n showRowLabels?: boolean;\n /** Row label style as an object with the `{ [property-name]: value }` format. Default: `undefined` */\n rowLabelStyle?: GenericAccessor<Record<string, string>, TimelineRowLabel<Datum>>;\n /** Row label formatter function. Default: `undefined` */\n rowLabelFormatter?: (key: string, items: Datum[], i: number) => string;\n /** Provide an icon href to be displayed before the row label. Default: `undefined` */\n rowIcon?: (key: string, items: Datum[], i: number) => TimelineRowIcon | undefined;\n /** Fixed label width in pixels. Labels longer than the specified value will be trimmed. Default: `undefined`. Falls back to deprecated `labelWidth`. */\n rowLabelWidth?: number;\n /** Maximum label width in pixels. Labels longer than the specified value will be trimmed. Default: `undefined`. Falls back to deprecated `maxLabelWidth`. */\n rowMaxLabelWidth?: number;\n /** Text alignment for labels: `TextAlign.Left`, `TextAlign.Center` or `TextAlign.Right`. Default: `TextAlign.Right` */\n rowLabelTextAlign?: TextAlign | `${TextAlign}`;\n /** Row label trim mode when width is limited: `TrimMode.Start`, `TrimMode.Middle` or `TrimMode.End`. Default: `TrimMode.Middle` */\n rowLabelTrimMode?: TrimMode | `${TrimMode}`;\n /** Row label margin in pixels. Can be a single number or a `[left, right]` tuple. Default: `[0, 5]` */\n rowLabelMargin?: number | [number, number];\n\n // Arrows\n arrows?: TimelineArrow[];\n\n // Animation\n /** Control the animation by specify the initial position for new lines as [x, y]. Default: `undefined` */\n animationLineEnterPosition?:\n [number | undefined | null, number | undefined | null] |\n ((d: Datum & TimelineLineRenderState, i: number, data: (Datum & TimelineLineRenderState)[]) => [number | undefined, number | undefined]) |\n undefined;\n /** Control the animation by specify the destination position for exiting lines as [x, y]. Default: `undefined` */\n animationLineExitPosition?: [number | undefined | null, number | undefined | null] |\n ((d: Datum & TimelineLineRenderState, i: number, data: (Datum & TimelineLineRenderState)[]) => [number | undefined, number | undefined]) |\n undefined;\n\n // Callbacks\n /** Scrolling callback function: `(scrollTop: number) => void`. Default: `undefined` */\n onScroll?: (scrollTop: number) => void;\n}\n\nexport const TimelineDefaultConfig: TimelineConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n id: undefined,\n\n // Items (Lines)\n cursor: undefined, // Deprecated (see above)\n type: (d: unknown): string => (d as { type: string }).type, // Deprecated (see above)\n length: (d: unknown): number => (d as { length: number }).length, // Deprecated (see above)\n color: (d: unknown): string => (d as { color: string }).color,\n lineRow: undefined,\n lineDuration: undefined,\n lineWidth: 8,\n lineCap: false,\n lineCursor: undefined,\n showEmptySegments: false,\n showEmptySegmentsCorrectPosition: true,\n lineStartIcon: undefined,\n lineStartIconColor: undefined,\n lineStartIconSize: undefined,\n lineStartIconArrangement: Arrangement.Inside,\n lineEndIcon: undefined,\n lineEndIconColor: undefined,\n lineEndIconSize: undefined,\n lineEndIconArrangement: Arrangement.Inside,\n\n // Rows\n rowHeight: 22,\n alternatingRowColors: true,\n\n // Row Labels\n showLabels: false, // Deprecated (see above)\n labelWidth: undefined, // Deprecated (see above)\n maxLabelWidth: 120, // Deprecated (see above)\n\n showRowLabels: undefined,\n rowLabelFormatter: undefined,\n rowIcon: undefined,\n rowLabelStyle: undefined,\n rowLabelWidth: undefined,\n rowMaxLabelWidth: undefined,\n rowLabelTextAlign: TextAlign.Right,\n rowLabelTrimMode: TrimMode.Middle,\n rowLabelMargin: [0, 5],\n\n // Arrows\n arrows: undefined,\n\n // Animation\n animationLineEnterPosition: undefined,\n\n // Callbacks\n onScroll: undefined,\n}\n"],"names":[],"mappings":";;;;MA8Ga,qBAAqB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC7B,wBAAwB,CAC3B,EAAA,EAAA,EAAE,EAAE,SAAS;;IAGb,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,CAAC,CAAU,KAAc,CAAsB,CAAC,IAAI,EAC1D,MAAM,EAAE,CAAC,CAAU,KAAc,CAAwB,CAAC,MAAM,EAChE,KAAK,EAAE,CAAC,CAAU,KAAc,CAAuB,CAAC,KAAK,EAC7D,OAAO,EAAE,SAAS,EAClB,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,KAAK,EACd,UAAU,EAAE,SAAS,EACrB,iBAAiB,EAAE,KAAK,EACxB,gCAAgC,EAAE,IAAI,EACtC,aAAa,EAAE,SAAS,EACxB,kBAAkB,EAAE,SAAS,EAC7B,iBAAiB,EAAE,SAAS,EAC5B,wBAAwB,EAAE,WAAW,CAAC,MAAM,EAC5C,WAAW,EAAE,SAAS,EACtB,gBAAgB,EAAE,SAAS,EAC3B,eAAe,EAAE,SAAS,EAC1B,sBAAsB,EAAE,WAAW,CAAC,MAAM;;AAG1C,IAAA,SAAS,EAAE,EAAE,EACb,oBAAoB,EAAE,IAAI;;IAG1B,UAAU,EAAE,KAAK,EACjB,UAAU,EAAE,SAAS,EACrB,aAAa,EAAE,GAAG,EAElB,aAAa,EAAE,SAAS,EACxB,iBAAiB,EAAE,SAAS,EAC5B,OAAO,EAAE,SAAS,EAClB,aAAa,EAAE,SAAS,EACxB,aAAa,EAAE,SAAS,EACxB,gBAAgB,EAAE,SAAS,EAC3B,iBAAiB,EAAE,SAAS,CAAC,KAAK,EAClC,gBAAgB,EAAE,QAAQ,CAAC,MAAM,EACjC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;;AAGtB,IAAA,MAAM,EAAE,SAAS;;AAGjB,IAAA,0BAA0B,EAAE,SAAS;;IAGrC,QAAQ,EAAE,SAAS,EAAA;;;;"}
|
|
@@ -25,9 +25,8 @@ export declare class Timeline<Datum> extends XYComponentCore<Datum, TimelineConf
|
|
|
25
25
|
private _scrollBarMargin;
|
|
26
26
|
private _maxScroll;
|
|
27
27
|
private _scrollbarHeight;
|
|
28
|
-
private _labelMargin;
|
|
29
28
|
private _labelWidth;
|
|
30
|
-
private
|
|
29
|
+
private _lineIconBleed;
|
|
31
30
|
private _lineBleed;
|
|
32
31
|
/** We define a dedicated clipping path for this component because it needs to behave
|
|
33
32
|
* differently than the regular XYContainer's clipPath */
|
|
@@ -38,6 +37,7 @@ export declare class Timeline<Datum> extends XYComponentCore<Datum, TimelineConf
|
|
|
38
37
|
setData(data: Datum[]): void;
|
|
39
38
|
get bleed(): Spacing;
|
|
40
39
|
_render(customDuration?: number): void;
|
|
40
|
+
private _getRowLabelMargin;
|
|
41
41
|
private _getLineLength;
|
|
42
42
|
private _getLineWidth;
|
|
43
43
|
private _getLineDuration;
|
|
@@ -12,7 +12,7 @@ import { guid } from '../../utils/misc.js';
|
|
|
12
12
|
import '../../types.js';
|
|
13
13
|
import { TimelineDefaultConfig } from './config.js';
|
|
14
14
|
import * as style from './style.js';
|
|
15
|
-
import { background, rows, arrows, lines, labels, rowIcons, scrollbar, scrollbarBackground, scrollbarHandle, label, rowIcon, row, rowOdd, lineGroup, line, lineStartIcon, lineEndIcon, arrow } from './style.js';
|
|
15
|
+
import { background, rows, arrows, lines, labels, rowIcons, scrollbar, scrollbarBackground, scrollbarHandle, label, rowIcon, labelBackground, row, rowOdd, lineGroup, line, lineStartIcon, lineEndIcon, arrow } from './style.js';
|
|
16
16
|
import { TIMELINE_DEFAULT_ARROW_HEAD_LENGTH, TIMELINE_DEFAULT_ARROW_HEAD_WIDTH, TIMELINE_DEFAULT_ARROW_MARGIN } from './constants.js';
|
|
17
17
|
import { getIconBleed } from './utils.js';
|
|
18
18
|
import { TextAlign } from '../../types/text.js';
|
|
@@ -30,6 +30,9 @@ class Timeline extends XYComponentCore {
|
|
|
30
30
|
[Timeline.selectors.label]: {
|
|
31
31
|
wheel: this._onMouseWheel.bind(this),
|
|
32
32
|
},
|
|
33
|
+
[Timeline.selectors.labelBackground]: {
|
|
34
|
+
wheel: this._onMouseWheel.bind(this),
|
|
35
|
+
},
|
|
33
36
|
[Timeline.selectors.rows]: {
|
|
34
37
|
wheel: this._onMouseWheel.bind(this),
|
|
35
38
|
},
|
|
@@ -42,9 +45,8 @@ class Timeline extends XYComponentCore {
|
|
|
42
45
|
this._scrollBarMargin = 5;
|
|
43
46
|
this._maxScroll = 0;
|
|
44
47
|
this._scrollbarHeight = 0;
|
|
45
|
-
this._labelMargin = 5;
|
|
46
48
|
this._labelWidth = 0; // Will be overridden in `get bleed ()`
|
|
47
|
-
this.
|
|
49
|
+
this._lineIconBleed = [0, 0];
|
|
48
50
|
this._lineBleed = [0, 0];
|
|
49
51
|
/** We define a dedicated clipping path for this component because it needs to behave
|
|
50
52
|
* differently than the regular XYContainer's clipPath */
|
|
@@ -84,26 +86,31 @@ class Timeline extends XYComponentCore {
|
|
|
84
86
|
super.setData(data);
|
|
85
87
|
}
|
|
86
88
|
get bleed() {
|
|
87
|
-
var _a, _b, _c
|
|
89
|
+
var _a, _b, _c;
|
|
88
90
|
const { config, datamodel: { data } } = this;
|
|
89
91
|
const rowLabels = this._getRowLabels(data);
|
|
90
92
|
const rowHeight = config.rowHeight || (this._height / (rowLabels.length || 1));
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
+
const hasRowIcons = rowLabels.some(l => l.iconHref);
|
|
94
|
+
const maxRowIconSize = max(rowLabels.map(l => l.iconSize || 0));
|
|
93
95
|
// We calculate the longest label width to set the bleed values accordingly
|
|
94
96
|
if ((_a = config.showRowLabels) !== null && _a !== void 0 ? _a : config.showLabels) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
const [marginLeft, marginRight] = this._getRowLabelMargin();
|
|
98
|
+
if ((_b = config.rowLabelWidth) !== null && _b !== void 0 ? _b : config.labelWidth) {
|
|
99
|
+
// We add a little of extra space to take into account the fact that `trimSVGText` is not always precise
|
|
100
|
+
const tolerance = 1.1;
|
|
101
|
+
this._labelWidth = tolerance * ((_c = config.rowLabelWidth) !== null && _c !== void 0 ? _c : config.labelWidth) + marginLeft + marginRight;
|
|
102
|
+
}
|
|
97
103
|
else {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
104
|
+
const labels = rowLabels.map(l => {
|
|
105
|
+
var _a;
|
|
106
|
+
return this._labelsGroup.append('text')
|
|
107
|
+
.attr('class', label)
|
|
108
|
+
.text(l.formattedLabel || '')
|
|
109
|
+
.call(trimSVGText, (_a = config.rowMaxLabelWidth) !== null && _a !== void 0 ? _a : config.maxLabelWidth, config.rowLabelTrimMode);
|
|
110
|
+
});
|
|
111
|
+
const labelWidth = max(labels.map(l => l.node().getBBox().width)) || 0;
|
|
112
|
+
labels.forEach(l => l.remove());
|
|
113
|
+
this._labelWidth = labelWidth ? labelWidth + marginLeft + marginRight : 0;
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
// There can be multiple start / end items with the same timestamp, so we need to find the shortest one
|
|
@@ -136,23 +143,23 @@ class Timeline extends XYComponentCore {
|
|
|
136
143
|
}
|
|
137
144
|
this._lineBleed = lineBleed;
|
|
138
145
|
// Icon bleed
|
|
139
|
-
const
|
|
146
|
+
const lineIconBleed = [0, 0];
|
|
140
147
|
if (config.lineStartIcon) {
|
|
141
|
-
|
|
148
|
+
lineIconBleed[0] = max(data, (d, i) => getIconBleed(d, i, config.lineStartIcon, config.lineStartIconSize, config.lineStartIconArrangement, rowHeight)) || 0;
|
|
142
149
|
}
|
|
143
150
|
if (config.lineEndIcon) {
|
|
144
|
-
|
|
151
|
+
lineIconBleed[1] = max(data, (d, i) => getIconBleed(d, i, config.lineEndIcon, config.lineEndIconSize, config.lineEndIconArrangement, rowHeight)) || 0;
|
|
145
152
|
}
|
|
146
|
-
this.
|
|
153
|
+
this._lineIconBleed = lineIconBleed;
|
|
147
154
|
return {
|
|
148
155
|
top: 0,
|
|
149
156
|
bottom: 0,
|
|
150
|
-
left: this._labelWidth +
|
|
151
|
-
right: this._scrollBarWidth + this._scrollBarMargin +
|
|
157
|
+
left: this._labelWidth + lineIconBleed[0] + (hasRowIcons ? maxRowIconSize : 0) + lineBleed[0],
|
|
158
|
+
right: this._scrollBarWidth + this._scrollBarMargin + lineIconBleed[1] + lineBleed[1],
|
|
152
159
|
};
|
|
153
160
|
}
|
|
154
161
|
_render(customDuration) {
|
|
155
|
-
var _a;
|
|
162
|
+
var _a, _b, _c;
|
|
156
163
|
super._render(customDuration);
|
|
157
164
|
const { config, datamodel: { data } } = this;
|
|
158
165
|
const duration = isNumber(customDuration) ? customDuration : config.duration;
|
|
@@ -181,6 +188,7 @@ class Timeline extends XYComponentCore {
|
|
|
181
188
|
.attr('width', l => l.iconSize)
|
|
182
189
|
.attr('height', l => l.iconSize)
|
|
183
190
|
.attr('y', l => yStart + (yOrdinalScale(l.label) + 0.5) * rowHeight - l.iconSize / 2)
|
|
191
|
+
.style('color', l => l.iconColor)
|
|
184
192
|
.style('opacity', 0);
|
|
185
193
|
smartTransition(rowIconsEnter.merge(rowIcons), duration)
|
|
186
194
|
.attr('href', l => l.iconHref)
|
|
@@ -196,11 +204,28 @@ class Timeline extends XYComponentCore {
|
|
|
196
204
|
// Labels
|
|
197
205
|
const labels = this._labelsGroup.selectAll(`.${label}`)
|
|
198
206
|
.data(((_a = config.showRowLabels) !== null && _a !== void 0 ? _a : config.showLabels) ? rowLabels : [], l => l === null || l === void 0 ? void 0 : l.label);
|
|
207
|
+
const [labelMarginLeft, labelMarginRight] = this._getRowLabelMargin();
|
|
199
208
|
const labelOffset = config.rowLabelTextAlign === TextAlign.Center ? this._labelWidth / 2
|
|
200
|
-
: config.rowLabelTextAlign === TextAlign.Left ? this._labelWidth
|
|
201
|
-
:
|
|
202
|
-
const xStart = xRange[0] - this.
|
|
209
|
+
: config.rowLabelTextAlign === TextAlign.Left ? this._labelWidth - labelMarginLeft
|
|
210
|
+
: labelMarginRight;
|
|
211
|
+
const xStart = xRange[0] - this._lineBleed[0] - this._lineIconBleed[0];
|
|
203
212
|
const labelXStart = xStart - labelOffset;
|
|
213
|
+
// Invisible background rects covering the full label column width for pointer events
|
|
214
|
+
const labelBackgrounds = this._labelsGroup
|
|
215
|
+
.selectAll(`.${labelBackground}`)
|
|
216
|
+
.data(((_b = config.showRowLabels) !== null && _b !== void 0 ? _b : config.showLabels) ? rowLabels : [], l => l === null || l === void 0 ? void 0 : l.label);
|
|
217
|
+
const labelBackgroundsEnter = labelBackgrounds.enter().append('rect')
|
|
218
|
+
.attr('class', labelBackground)
|
|
219
|
+
.attr('x', xStart - this._labelWidth)
|
|
220
|
+
.attr('y', l => yStart + yOrdinalScale(l.label) * rowHeight)
|
|
221
|
+
.attr('width', this._labelWidth)
|
|
222
|
+
.attr('height', rowHeight);
|
|
223
|
+
labelBackgroundsEnter.merge(labelBackgrounds)
|
|
224
|
+
.attr('x', xStart - this._labelWidth)
|
|
225
|
+
.attr('y', l => yStart + yOrdinalScale(l.label) * rowHeight)
|
|
226
|
+
.attr('width', this._labelWidth)
|
|
227
|
+
.attr('height', rowHeight);
|
|
228
|
+
labelBackgrounds.exit().remove();
|
|
204
229
|
const labelsEnter = labels.enter().append('text')
|
|
205
230
|
.attr('class', label)
|
|
206
231
|
.attr('x', labelXStart)
|
|
@@ -211,7 +236,8 @@ class Timeline extends XYComponentCore {
|
|
|
211
236
|
.each((label, i, els) => {
|
|
212
237
|
var _a, _b;
|
|
213
238
|
const labelSelection = select(els[i]);
|
|
214
|
-
|
|
239
|
+
const maxLabelWidth = ((_a = config.rowLabelWidth) !== null && _a !== void 0 ? _a : config.labelWidth) || ((_b = config.rowMaxLabelWidth) !== null && _b !== void 0 ? _b : config.maxLabelWidth);
|
|
240
|
+
trimSVGText(labelSelection, maxLabelWidth, config.rowLabelTrimMode);
|
|
215
241
|
// Apply custom label style if it has been provided
|
|
216
242
|
const customStyle = getValue(label, config.rowLabelStyle);
|
|
217
243
|
if (!isPlainObject(customStyle))
|
|
@@ -229,7 +255,7 @@ class Timeline extends XYComponentCore {
|
|
|
229
255
|
.style('opacity', 0)
|
|
230
256
|
.remove();
|
|
231
257
|
// Row background rects
|
|
232
|
-
const timelineWidth = xRange[1] - xRange[0] + this.
|
|
258
|
+
const timelineWidth = xRange[1] - xRange[0] + this._lineIconBleed[0] + this._lineIconBleed[1] + this._lineBleed[0] + this._lineBleed[1];
|
|
233
259
|
const numRows = Math.max(Math.floor(yHeight / rowHeight), numRowLabels);
|
|
234
260
|
const recordTypes = Array(numRows).fill(null).map((_, i) => rowLabels[i]);
|
|
235
261
|
const rects = this._rowsGroup.selectAll(`.${row}`)
|
|
@@ -360,12 +386,19 @@ class Timeline extends XYComponentCore {
|
|
|
360
386
|
.attr('ry', this._scrollBarWidth / 2);
|
|
361
387
|
this._updateScrollPosition(0);
|
|
362
388
|
// Clip path
|
|
389
|
+
// Arrowheads can get cut off when they are too close to the edges, so we extend the clip path to account for them.
|
|
390
|
+
// TODO: In rare scenarios this can have unwanted side effects, so we might need to create a dedicated clip path for arrows.
|
|
391
|
+
const maxArrowHeadWidth = (_c = max(arrowsData !== null && arrowsData !== void 0 ? arrowsData : [], a => { var _a; return (_a = a.arrowHeadWidth) !== null && _a !== void 0 ? _a : TIMELINE_DEFAULT_ARROW_HEAD_WIDTH; })) !== null && _c !== void 0 ? _c : 0;
|
|
363
392
|
const clipPathRect = this._clipPath.select('rect');
|
|
364
393
|
smartTransition(clipPathRect, clipPathRect.attr('width') ? duration : 0)
|
|
365
|
-
.attr('x', xStart)
|
|
366
|
-
.attr('width', timelineWidth)
|
|
394
|
+
.attr('x', xStart - maxArrowHeadWidth / 2)
|
|
395
|
+
.attr('width', timelineWidth + maxArrowHeadWidth)
|
|
367
396
|
.attr('height', this._height);
|
|
368
397
|
}
|
|
398
|
+
_getRowLabelMargin() {
|
|
399
|
+
const m = this.config.rowLabelMargin;
|
|
400
|
+
return Array.isArray(m) ? m : [m, m];
|
|
401
|
+
}
|
|
369
402
|
_getLineLength(d, i) {
|
|
370
403
|
var _a, _b;
|
|
371
404
|
const { config, xScale } = this;
|