@unovis/ts 1.1.2-beta.4 → 1.1.2-beta.5

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.
@@ -244,10 +244,10 @@ class Axis extends XYComponentCore {
244
244
  // We always use this.axisRenderHelperGroup to calculate the size of the axis because
245
245
  // this.axisGroup will give us incorrect values due to animation
246
246
  const { width: axisWidth, height: axisHeight } = (_a = this._axisRawBBox) !== null && _a !== void 0 ? _a : selection.node().getBBox();
247
- const offsetX = type === AxisType.X ? this._width / 2 : Math.pow((-1), (+(axisPosition === Position.Left))) * axisWidth;
248
- const offsetY = type === AxisType.X ? Math.pow((-1), (+(axisPosition === Position.Top))) * axisHeight : this._height / 2;
249
- const marginX = type === AxisType.X ? 0 : Math.pow((-1), (+(axisPosition === Position.Left))) * labelMargin;
250
- const marginY = type === AxisType.X ? Math.pow((-1), (+(axisPosition === Position.Top))) * labelMargin : 0;
247
+ const offsetX = type === AxisType.X ? this._width / 2 : (-1) ** (+(axisPosition === Position.Left)) * axisWidth;
248
+ const offsetY = type === AxisType.X ? (-1) ** (+(axisPosition === Position.Top)) * axisHeight : this._height / 2;
249
+ const marginX = type === AxisType.X ? 0 : (-1) ** (+(axisPosition === Position.Left)) * labelMargin;
250
+ const marginY = type === AxisType.X ? (-1) ** (+(axisPosition === Position.Top)) * labelMargin : 0;
251
251
  const rotation = type === AxisType.Y ? -90 : 0;
252
252
  // Append new label
253
253
  selection
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/axis/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\nimport { interrupt } from 'd3-transition'\nimport { Axis as D3Axis, axisBottom, axisLeft, axisRight, axisTop } from 'd3-axis'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Types\nimport { Position } from 'types/position'\nimport { ContinuousScale } from 'types/scale'\nimport { Spacing } from 'types/spacing'\nimport { FitMode, TextAlign, UnovisText, UnovisTextOptions, VerticalAlign } from 'types/text'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\nimport { renderTextToSvgTextElement, trimSVGText } from 'utils/text'\nimport { isEqual } from 'utils/data'\n\n// Local Types\nimport { AxisType } from './types'\n\n// Config\nimport { AxisConfig, AxisConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Axis<Datum> extends XYComponentCore<Datum, AxisConfig<Datum>, AxisConfigInterface<Datum>> {\n static selectors = s\n config: AxisConfig<Datum> = new AxisConfig<Datum>()\n axisGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n gridGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n\n private _axisRawBBox: DOMRect\n private _axisSizeBBox: SVGRect\n private _requiredMargin: Spacing\n private _defaultNumTicks = 3\n private _minMaxTicksOnlyEnforceWidth = 250\n\n events = {}\n\n constructor (config?: AxisConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n\n this.axisGroup = this.g.append('g')\n this.gridGroup = this.g.append('g')\n .attr('class', s.grid)\n }\n\n /** Renders axis to an invisible grouped to calculate automatic chart margins */\n preRender (): void {\n const { config } = this\n const axisRenderHelperGroup = this.g.append('g').attr('opacity', 0)\n\n this._renderAxis(axisRenderHelperGroup, 0)\n\n // Store axis raw BBox (without the label) for further label positioning (see _renderAxisLabel)\n this._axisRawBBox = axisRenderHelperGroup.node().getBBox()\n\n // Align tick text\n if (config.tickTextAlign) this._alignTickLabels()\n\n // Render label and store total axis size and required margins\n this._renderAxisLabel(axisRenderHelperGroup)\n this._axisSizeBBox = this._getAxisSize(axisRenderHelperGroup)\n this._requiredMargin = this._getRequiredMargin(this._axisSizeBBox)\n\n axisRenderHelperGroup.remove()\n }\n\n getPosition (): Position {\n const { config: { type, position } } = this\n return (position ?? ((type === AxisType.X) ? Position.Bottom : Position.Left)) as Position\n }\n\n _getAxisSize (selection: Selection<SVGGElement, unknown, SVGGElement, undefined>): SVGRect {\n const bBox = selection.node().getBBox()\n return bBox\n }\n\n _getRequiredMargin (axisSize = this._axisSizeBBox): Spacing {\n const { config: { type, position } } = this\n\n switch (type) {\n case AxisType.X: {\n const tolerancePx = 1\n const xEnd = this._axisSizeBBox.x + this._axisSizeBBox.width\n\n const left = this._axisSizeBBox.x < 0 ? Math.abs(this._axisSizeBBox.x) : 0\n const right = (xEnd - this._width) > tolerancePx ? xEnd - this._width : 0\n\n switch (position) {\n case Position.Top: return { top: axisSize.height, left, right }\n case Position.Bottom: default: return { bottom: axisSize.height, left, right }\n }\n }\n case AxisType.Y: {\n const bleedY = axisSize.height > this._height ? (axisSize.height - this._height) / 2 : 0\n const top = bleedY\n const bottom = bleedY\n\n switch (position) {\n case Position.Right: return { right: axisSize.width, top, bottom }\n case Position.Left: default: return { left: axisSize.width, top, bottom }\n }\n }\n }\n }\n\n getRequiredMargin (): Spacing {\n return this._requiredMargin\n }\n\n /** Calculates axis transform:translate offset based on passed container margins */\n getOffset (containerMargin: Spacing): {left: number; top: number} {\n const { config: { type, position } } = this\n\n switch (type) {\n case AxisType.X:\n switch (position) {\n case Position.Top: return { top: containerMargin.top, left: containerMargin.left }\n case Position.Bottom: default: return { top: containerMargin.top + this._height, left: containerMargin.left }\n }\n case AxisType.Y:\n switch (position) {\n case Position.Right: return { top: containerMargin.top, left: containerMargin.left + this._width }\n case Position.Left: default: return { top: containerMargin.top, left: containerMargin.left }\n }\n }\n }\n\n _render (duration = this.config.duration, selection = this.axisGroup): void {\n const { config } = this\n\n this._renderAxis(selection, duration)\n this._renderAxisLabel(selection)\n\n if (config.gridLine) {\n const gridGen = this._buildGrid().tickFormat(() => '')\n gridGen.tickValues(this._getConfiguredTickValues())\n // Interrupting all active transitions first to prevent them from being stuck.\n // Somehow we see it happening in Angular apps.\n this.gridGroup.selectAll('*').interrupt()\n smartTransition(this.gridGroup, duration).call(gridGen).style('opacity', 1)\n } else {\n smartTransition(this.gridGroup, duration).style('opacity', 0)\n }\n\n if (config.tickTextAlign) this._alignTickLabels()\n }\n\n _buildAxis (): D3Axis<any> {\n const { config: { type, position, tickPadding } } = this\n\n const ticks = this._getNumTicks()\n switch (type) {\n case AxisType.X:\n switch (position) {\n case Position.Top: return axisTop(this.xScale).ticks(ticks).tickPadding(tickPadding)\n case Position.Bottom: default: return axisBottom(this.xScale).ticks(ticks).tickPadding(tickPadding)\n }\n case AxisType.Y:\n switch (position) {\n case Position.Right: return axisRight(this.yScale).ticks(ticks).tickPadding(tickPadding)\n case Position.Left: default: return axisLeft(this.yScale).ticks(ticks).tickPadding(tickPadding)\n }\n }\n }\n\n _buildGrid (): D3Axis<any> {\n const { config: { type, position } } = this\n\n const ticks = this._getNumTicks()\n switch (type) {\n case AxisType.X:\n switch (position) {\n case Position.Top: return axisTop(this.xScale).ticks(ticks * 2).tickSize(-this._height).tickSizeOuter(0)\n case Position.Bottom: default: return axisBottom(this.xScale).ticks(ticks * 2).tickSize(-this._height).tickSizeOuter(0)\n }\n case AxisType.Y:\n switch (position) {\n case Position.Right: return axisRight(this.yScale).ticks(ticks * 2).tickSize(-this._width).tickSizeOuter(0)\n case Position.Left: default: return axisLeft(this.yScale).ticks(ticks * 2).tickSize(-this._width).tickSizeOuter(0)\n }\n }\n }\n\n _renderAxis (selection = this.axisGroup, duration = this.config.duration): void {\n const { config } = this\n\n const axisGen = this._buildAxis()\n const tickValues: (number | Date)[] = this._getConfiguredTickValues() || axisGen.scale<ContinuousScale>().ticks(this._getNumTicks())\n axisGen.tickValues(tickValues)\n\n // Interrupting all active transitions first to prevent them from being stuck.\n // Somehow we see it happening in Angular apps.\n selection.selectAll('*').interrupt()\n smartTransition(selection, duration).call(axisGen)\n\n const ticks = selection.selectAll<SVGGElement, number | Date>('g.tick')\n\n ticks\n .classed(s.tick, true)\n .style('font-size', config.tickTextFontSize)\n\n // Selecting the <text> elements of the ticks to apply formatting. By default, this selection\n // will include exiting elements, so we're filtering them out.\n const tickText = selection.selectAll<SVGTextElement, number | Date>('g.tick > text')\n .filter(tickValue => tickValues.some(t => isEqual(tickValue, t))) // We use isEqual to compare Dates\n\n // We interrupt the transition on tick's <text> to make it 'wrappable'\n tickText.nodes().forEach(node => interrupt(node))\n\n tickText.each((value, i, elements) => {\n const text = config.tickFormat?.(value, i, tickValues) ?? `${value}`\n const textElement = elements[i]\n const textMaxWidth = config.tickTextWidth || (config.type === AxisType.X ? this._containerWidth / (ticks.size() + 1) : this._containerWidth / 5)\n const styleDeclaration = getComputedStyle(textElement)\n const fontSize = Number.parseFloat(styleDeclaration.fontSize)\n const fontFamily = styleDeclaration.fontFamily\n\n if (config.tickTextFitMode === FitMode.Trim) {\n const textElementSelection = select<SVGTextElement, string>(textElement).text(text)\n trimSVGText(textElementSelection, textMaxWidth, config.tickTextTrimType, true, fontSize, 0.58)\n } else {\n const textBlock: UnovisText = { text, fontFamily, fontSize }\n const textOptions: UnovisTextOptions = {\n verticalAlign: config.type === AxisType.X ? VerticalAlign.Top : VerticalAlign.Middle,\n width: textMaxWidth,\n }\n renderTextToSvgTextElement(textElement, textBlock, textOptions)\n }\n })\n\n selection\n .classed(s.axis, true)\n .classed(s.hideTickLine, !config.tickLine)\n .classed(s.hideDomain, !config.domainLine)\n\n if (config.fullSize) {\n const path = this._getFullDomainPath(0)\n smartTransition(selection.select('.domain'), duration).attr('d', path)\n }\n }\n\n _getNumTicks (): number {\n const { config: { type, numTicks } } = this\n\n if (numTicks) return numTicks\n\n if (type === AxisType.X) {\n const xRange = this.xScale.range() as [number, number]\n const width = xRange[1] - xRange[0]\n return Math.floor(width / 175)\n }\n\n if (type === AxisType.Y) {\n const yRange = this.yScale.range() as [number, number]\n const height = Math.abs(yRange[0] - yRange[1])\n return Math.pow(height, 0.85) / 25\n }\n\n return this._defaultNumTicks\n }\n\n _getConfiguredTickValues (): number[] | null {\n const { config: { tickValues, type, minMaxTicksOnly } } = this\n const scale = type === AxisType.X ? this.xScale : this.yScale\n const scaleDomain = scale?.domain()\n\n if (tickValues) {\n return tickValues.filter(v => (v >= scaleDomain[0]) && (v <= scaleDomain[1]))\n }\n\n if (minMaxTicksOnly || (type === AxisType.X && this._width < this._minMaxTicksOnlyEnforceWidth)) {\n return scaleDomain as number[]\n }\n\n return null\n }\n\n _getFullDomainPath (tickSize = 0): string {\n const { config: { type } } = this\n switch (type) {\n case AxisType.X: return `M0.5, ${tickSize} V0.5 H${this._width + 0.5} V${tickSize}`\n case AxisType.Y: return `M${-tickSize}, ${this._height + 0.5} H0.5 V0.5 H${-tickSize}`\n }\n }\n\n _renderAxisLabel (selection = this.axisGroup): void {\n const { type, label, labelMargin, labelFontSize } = this.config\n\n // Remove the old label first to calculate the axis size properly\n selection.selectAll(`.${s.label}`).remove()\n\n // Calculate label position and rotation\n const axisPosition = this.getPosition()\n // We always use this.axisRenderHelperGroup to calculate the size of the axis because\n // this.axisGroup will give us incorrect values due to animation\n const { width: axisWidth, height: axisHeight } = this._axisRawBBox ?? selection.node().getBBox()\n\n const offsetX = type === AxisType.X ? this._width / 2 : (-1) ** (+(axisPosition === Position.Left)) * axisWidth\n const offsetY = type === AxisType.X ? (-1) ** (+(axisPosition === Position.Top)) * axisHeight : this._height / 2\n\n const marginX = type === AxisType.X ? 0 : (-1) ** (+(axisPosition === Position.Left)) * labelMargin\n const marginY = type === AxisType.X ? (-1) ** (+(axisPosition === Position.Top)) * labelMargin : 0\n\n const rotation = type === AxisType.Y ? -90 : 0\n\n // Append new label\n selection\n .append('text')\n .attr('class', s.label)\n .text(label)\n .style('font-size', labelFontSize)\n .attr('dy', `${this._getLabelDY()}em`)\n .attr('transform', `translate(${offsetX + marginX},${offsetY + marginY}) rotate(${rotation})`)\n }\n\n _getLabelDY (): number {\n const { type, position } = this.config\n switch (type) {\n case AxisType.X:\n switch (position) {\n case Position.Top: return 0\n case Position.Bottom: default: return 0.75\n }\n case AxisType.Y:\n switch (position) {\n case Position.Right: return 0.75\n case Position.Left: default: return -0.25\n }\n }\n }\n\n _alignTickLabels (): void {\n const { config: { type, tickTextAlign, position } } = this\n\n const tickText = this.g.selectAll('g.tick > text')\n const textAnchor = this._getTickTextAnchor(tickTextAlign)\n const translateX = type === AxisType.X ? 0 : this._getYTickTextTranslate(tickTextAlign, position)\n\n tickText\n .attr('text-anchor', textAnchor)\n .attr('transform', `translate(${translateX},0)`)\n }\n\n _getTickTextAnchor (textAlign: TextAlign): string {\n switch (textAlign) {\n case TextAlign.Left: return 'start'\n case TextAlign.Right: return 'end'\n case TextAlign.Center: return 'middle'\n default: return null\n }\n }\n\n _getYTickTextTranslate (textAlign: TextAlign, axisPosition: Position = Position.Left): number {\n const defaultTickTextSpacingPx = 9 // Default in D3\n const width = this._axisRawBBox.width - defaultTickTextSpacingPx\n\n switch (textAlign) {\n case TextAlign.Left: return axisPosition === Position.Left ? width * -1 : 0\n case TextAlign.Right: return axisPosition === Position.Left ? 0 : width\n case TextAlign.Center: return axisPosition === Position.Left ? width * (-0.5) : width * 0.5\n default: return 0\n }\n }\n}\n"],"names":["s.grid","s.tick","s.axis","s.hideTickLine","s.hideDomain","label","s.label","s"],"mappings":";;;;;;;;;;;;;;AA2BM,MAAO,IAAY,SAAQ,eAAqE,CAAA;AAcpG,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;AAbT,QAAA,IAAA,CAAA,MAAM,GAAsB,IAAI,UAAU,EAAS,CAAA;QAO3C,IAAgB,CAAA,gBAAA,GAAG,CAAC,CAAA;QACpB,IAA4B,CAAA,4BAAA,GAAG,GAAG,CAAA;QAE1C,IAAM,CAAA,MAAA,GAAG,EAAE,CAAA;AAIT,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAChC,aAAA,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC,CAAA;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AACnC,YAAA,KAAK,SAAS,CAAC,KAAK,EAAE,OAAO,KAAK,CAAA;AAClC,YAAA,KAAK,SAAS,CAAC,MAAM,EAAE,OAAO,QAAQ,CAAA;AACtC,YAAA,SAAS,OAAO,IAAI,CAAA;AACrB,SAAA;KACF;AAED,IAAA,sBAAsB,CAAE,SAAoB,EAAE,YAAyB,GAAA,QAAQ,CAAC,IAAI,EAAA;AAClF,QAAA,MAAM,wBAAwB,GAAG,CAAC,CAAA;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,wBAAwB,CAAA;AAEhE,QAAA,QAAQ,SAAS;YACf,KAAK,SAAS,CAAC,IAAI,EAAE,OAAO,YAAY,KAAK,QAAQ,CAAC,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;AAC3E,YAAA,KAAK,SAAS,CAAC,KAAK,EAAE,OAAO,YAAY,KAAK,QAAQ,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,CAAA;YACvE,KAAK,SAAS,CAAC,MAAM,EAAE,OAAO,YAAY,KAAK,QAAQ,CAAC,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,GAAG,CAAA;AAC3F,YAAA,SAAS,OAAO,CAAC,CAAA;AAClB,SAAA;KACF;;AAnVM,IAAS,CAAA,SAAA,GAAGE,KAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/axis/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\nimport { interrupt } from 'd3-transition'\nimport { Axis as D3Axis, axisBottom, axisLeft, axisRight, axisTop } from 'd3-axis'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Types\nimport { Position } from 'types/position'\nimport { ContinuousScale } from 'types/scale'\nimport { Spacing } from 'types/spacing'\nimport { FitMode, TextAlign, UnovisText, UnovisTextOptions, VerticalAlign } from 'types/text'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\nimport { renderTextToSvgTextElement, trimSVGText } from 'utils/text'\nimport { isEqual } from 'utils/data'\n\n// Local Types\nimport { AxisType } from './types'\n\n// Config\nimport { AxisConfig, AxisConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Axis<Datum> extends XYComponentCore<Datum, AxisConfig<Datum>, AxisConfigInterface<Datum>> {\n static selectors = s\n config: AxisConfig<Datum> = new AxisConfig<Datum>()\n axisGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n gridGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n\n private _axisRawBBox: DOMRect\n private _axisSizeBBox: SVGRect\n private _requiredMargin: Spacing\n private _defaultNumTicks = 3\n private _minMaxTicksOnlyEnforceWidth = 250\n\n events = {}\n\n constructor (config?: AxisConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n\n this.axisGroup = this.g.append('g')\n this.gridGroup = this.g.append('g')\n .attr('class', s.grid)\n }\n\n /** Renders axis to an invisible grouped to calculate automatic chart margins */\n preRender (): void {\n const { config } = this\n const axisRenderHelperGroup = this.g.append('g').attr('opacity', 0)\n\n this._renderAxis(axisRenderHelperGroup, 0)\n\n // Store axis raw BBox (without the label) for further label positioning (see _renderAxisLabel)\n this._axisRawBBox = axisRenderHelperGroup.node().getBBox()\n\n // Align tick text\n if (config.tickTextAlign) this._alignTickLabels()\n\n // Render label and store total axis size and required margins\n this._renderAxisLabel(axisRenderHelperGroup)\n this._axisSizeBBox = this._getAxisSize(axisRenderHelperGroup)\n this._requiredMargin = this._getRequiredMargin(this._axisSizeBBox)\n\n axisRenderHelperGroup.remove()\n }\n\n getPosition (): Position {\n const { config: { type, position } } = this\n return (position ?? ((type === AxisType.X) ? Position.Bottom : Position.Left)) as Position\n }\n\n _getAxisSize (selection: Selection<SVGGElement, unknown, SVGGElement, undefined>): SVGRect {\n const bBox = selection.node().getBBox()\n return bBox\n }\n\n _getRequiredMargin (axisSize = this._axisSizeBBox): Spacing {\n const { config: { type, position } } = this\n\n switch (type) {\n case AxisType.X: {\n const tolerancePx = 1\n const xEnd = this._axisSizeBBox.x + this._axisSizeBBox.width\n\n const left = this._axisSizeBBox.x < 0 ? Math.abs(this._axisSizeBBox.x) : 0\n const right = (xEnd - this._width) > tolerancePx ? xEnd - this._width : 0\n\n switch (position) {\n case Position.Top: return { top: axisSize.height, left, right }\n case Position.Bottom: default: return { bottom: axisSize.height, left, right }\n }\n }\n case AxisType.Y: {\n const bleedY = axisSize.height > this._height ? (axisSize.height - this._height) / 2 : 0\n const top = bleedY\n const bottom = bleedY\n\n switch (position) {\n case Position.Right: return { right: axisSize.width, top, bottom }\n case Position.Left: default: return { left: axisSize.width, top, bottom }\n }\n }\n }\n }\n\n getRequiredMargin (): Spacing {\n return this._requiredMargin\n }\n\n /** Calculates axis transform:translate offset based on passed container margins */\n getOffset (containerMargin: Spacing): {left: number; top: number} {\n const { config: { type, position } } = this\n\n switch (type) {\n case AxisType.X:\n switch (position) {\n case Position.Top: return { top: containerMargin.top, left: containerMargin.left }\n case Position.Bottom: default: return { top: containerMargin.top + this._height, left: containerMargin.left }\n }\n case AxisType.Y:\n switch (position) {\n case Position.Right: return { top: containerMargin.top, left: containerMargin.left + this._width }\n case Position.Left: default: return { top: containerMargin.top, left: containerMargin.left }\n }\n }\n }\n\n _render (duration = this.config.duration, selection = this.axisGroup): void {\n const { config } = this\n\n this._renderAxis(selection, duration)\n this._renderAxisLabel(selection)\n\n if (config.gridLine) {\n const gridGen = this._buildGrid().tickFormat(() => '')\n gridGen.tickValues(this._getConfiguredTickValues())\n // Interrupting all active transitions first to prevent them from being stuck.\n // Somehow we see it happening in Angular apps.\n this.gridGroup.selectAll('*').interrupt()\n smartTransition(this.gridGroup, duration).call(gridGen).style('opacity', 1)\n } else {\n smartTransition(this.gridGroup, duration).style('opacity', 0)\n }\n\n if (config.tickTextAlign) this._alignTickLabels()\n }\n\n _buildAxis (): D3Axis<any> {\n const { config: { type, position, tickPadding } } = this\n\n const ticks = this._getNumTicks()\n switch (type) {\n case AxisType.X:\n switch (position) {\n case Position.Top: return axisTop(this.xScale).ticks(ticks).tickPadding(tickPadding)\n case Position.Bottom: default: return axisBottom(this.xScale).ticks(ticks).tickPadding(tickPadding)\n }\n case AxisType.Y:\n switch (position) {\n case Position.Right: return axisRight(this.yScale).ticks(ticks).tickPadding(tickPadding)\n case Position.Left: default: return axisLeft(this.yScale).ticks(ticks).tickPadding(tickPadding)\n }\n }\n }\n\n _buildGrid (): D3Axis<any> {\n const { config: { type, position } } = this\n\n const ticks = this._getNumTicks()\n switch (type) {\n case AxisType.X:\n switch (position) {\n case Position.Top: return axisTop(this.xScale).ticks(ticks * 2).tickSize(-this._height).tickSizeOuter(0)\n case Position.Bottom: default: return axisBottom(this.xScale).ticks(ticks * 2).tickSize(-this._height).tickSizeOuter(0)\n }\n case AxisType.Y:\n switch (position) {\n case Position.Right: return axisRight(this.yScale).ticks(ticks * 2).tickSize(-this._width).tickSizeOuter(0)\n case Position.Left: default: return axisLeft(this.yScale).ticks(ticks * 2).tickSize(-this._width).tickSizeOuter(0)\n }\n }\n }\n\n _renderAxis (selection = this.axisGroup, duration = this.config.duration): void {\n const { config } = this\n\n const axisGen = this._buildAxis()\n const tickValues: (number | Date)[] = this._getConfiguredTickValues() || axisGen.scale<ContinuousScale>().ticks(this._getNumTicks())\n axisGen.tickValues(tickValues)\n\n // Interrupting all active transitions first to prevent them from being stuck.\n // Somehow we see it happening in Angular apps.\n selection.selectAll('*').interrupt()\n smartTransition(selection, duration).call(axisGen)\n\n const ticks = selection.selectAll<SVGGElement, number | Date>('g.tick')\n\n ticks\n .classed(s.tick, true)\n .style('font-size', config.tickTextFontSize)\n\n // Selecting the <text> elements of the ticks to apply formatting. By default, this selection\n // will include exiting elements, so we're filtering them out.\n const tickText = selection.selectAll<SVGTextElement, number | Date>('g.tick > text')\n .filter(tickValue => tickValues.some(t => isEqual(tickValue, t))) // We use isEqual to compare Dates\n\n // We interrupt the transition on tick's <text> to make it 'wrappable'\n tickText.nodes().forEach(node => interrupt(node))\n\n tickText.each((value, i, elements) => {\n const text = config.tickFormat?.(value, i, tickValues) ?? `${value}`\n const textElement = elements[i]\n const textMaxWidth = config.tickTextWidth || (config.type === AxisType.X ? this._containerWidth / (ticks.size() + 1) : this._containerWidth / 5)\n const styleDeclaration = getComputedStyle(textElement)\n const fontSize = Number.parseFloat(styleDeclaration.fontSize)\n const fontFamily = styleDeclaration.fontFamily\n\n if (config.tickTextFitMode === FitMode.Trim) {\n const textElementSelection = select<SVGTextElement, string>(textElement).text(text)\n trimSVGText(textElementSelection, textMaxWidth, config.tickTextTrimType, true, fontSize, 0.58)\n } else {\n const textBlock: UnovisText = { text, fontFamily, fontSize }\n const textOptions: UnovisTextOptions = {\n verticalAlign: config.type === AxisType.X ? VerticalAlign.Top : VerticalAlign.Middle,\n width: textMaxWidth,\n }\n renderTextToSvgTextElement(textElement, textBlock, textOptions)\n }\n })\n\n selection\n .classed(s.axis, true)\n .classed(s.hideTickLine, !config.tickLine)\n .classed(s.hideDomain, !config.domainLine)\n\n if (config.fullSize) {\n const path = this._getFullDomainPath(0)\n smartTransition(selection.select('.domain'), duration).attr('d', path)\n }\n }\n\n _getNumTicks (): number {\n const { config: { type, numTicks } } = this\n\n if (numTicks) return numTicks\n\n if (type === AxisType.X) {\n const xRange = this.xScale.range() as [number, number]\n const width = xRange[1] - xRange[0]\n return Math.floor(width / 175)\n }\n\n if (type === AxisType.Y) {\n const yRange = this.yScale.range() as [number, number]\n const height = Math.abs(yRange[0] - yRange[1])\n return Math.pow(height, 0.85) / 25\n }\n\n return this._defaultNumTicks\n }\n\n _getConfiguredTickValues (): number[] | null {\n const { config: { tickValues, type, minMaxTicksOnly } } = this\n const scale = type === AxisType.X ? this.xScale : this.yScale\n const scaleDomain = scale?.domain()\n\n if (tickValues) {\n return tickValues.filter(v => (v >= scaleDomain[0]) && (v <= scaleDomain[1]))\n }\n\n if (minMaxTicksOnly || (type === AxisType.X && this._width < this._minMaxTicksOnlyEnforceWidth)) {\n return scaleDomain as number[]\n }\n\n return null\n }\n\n _getFullDomainPath (tickSize = 0): string {\n const { config: { type } } = this\n switch (type) {\n case AxisType.X: return `M0.5, ${tickSize} V0.5 H${this._width + 0.5} V${tickSize}`\n case AxisType.Y: return `M${-tickSize}, ${this._height + 0.5} H0.5 V0.5 H${-tickSize}`\n }\n }\n\n _renderAxisLabel (selection = this.axisGroup): void {\n const { type, label, labelMargin, labelFontSize } = this.config\n\n // Remove the old label first to calculate the axis size properly\n selection.selectAll(`.${s.label}`).remove()\n\n // Calculate label position and rotation\n const axisPosition = this.getPosition()\n // We always use this.axisRenderHelperGroup to calculate the size of the axis because\n // this.axisGroup will give us incorrect values due to animation\n const { width: axisWidth, height: axisHeight } = this._axisRawBBox ?? selection.node().getBBox()\n\n const offsetX = type === AxisType.X ? this._width / 2 : (-1) ** (+(axisPosition === Position.Left)) * axisWidth\n const offsetY = type === AxisType.X ? (-1) ** (+(axisPosition === Position.Top)) * axisHeight : this._height / 2\n\n const marginX = type === AxisType.X ? 0 : (-1) ** (+(axisPosition === Position.Left)) * labelMargin\n const marginY = type === AxisType.X ? (-1) ** (+(axisPosition === Position.Top)) * labelMargin : 0\n\n const rotation = type === AxisType.Y ? -90 : 0\n\n // Append new label\n selection\n .append('text')\n .attr('class', s.label)\n .text(label)\n .style('font-size', labelFontSize)\n .attr('dy', `${this._getLabelDY()}em`)\n .attr('transform', `translate(${offsetX + marginX},${offsetY + marginY}) rotate(${rotation})`)\n }\n\n _getLabelDY (): number {\n const { type, position } = this.config\n switch (type) {\n case AxisType.X:\n switch (position) {\n case Position.Top: return 0\n case Position.Bottom: default: return 0.75\n }\n case AxisType.Y:\n switch (position) {\n case Position.Right: return 0.75\n case Position.Left: default: return -0.25\n }\n }\n }\n\n _alignTickLabels (): void {\n const { config: { type, tickTextAlign, position } } = this\n\n const tickText = this.g.selectAll('g.tick > text')\n const textAnchor = this._getTickTextAnchor(tickTextAlign)\n const translateX = type === AxisType.X ? 0 : this._getYTickTextTranslate(tickTextAlign, position)\n\n tickText\n .attr('text-anchor', textAnchor)\n .attr('transform', `translate(${translateX},0)`)\n }\n\n _getTickTextAnchor (textAlign: TextAlign): string {\n switch (textAlign) {\n case TextAlign.Left: return 'start'\n case TextAlign.Right: return 'end'\n case TextAlign.Center: return 'middle'\n default: return null\n }\n }\n\n _getYTickTextTranslate (textAlign: TextAlign, axisPosition: Position = Position.Left): number {\n const defaultTickTextSpacingPx = 9 // Default in D3\n const width = this._axisRawBBox.width - defaultTickTextSpacingPx\n\n switch (textAlign) {\n case TextAlign.Left: return axisPosition === Position.Left ? width * -1 : 0\n case TextAlign.Right: return axisPosition === Position.Left ? 0 : width\n case TextAlign.Center: return axisPosition === Position.Left ? width * (-0.5) : width * 0.5\n default: return 0\n }\n }\n}\n"],"names":["s.grid","s.tick","s.axis","s.hideTickLine","s.hideDomain","label","s.label","s"],"mappings":";;;;;;;;;;;;;;AA2BM,MAAO,IAAY,SAAQ,eAAqE,CAAA;AAcpG,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;AAbT,QAAA,IAAA,CAAA,MAAM,GAAsB,IAAI,UAAU,EAAS,CAAA;QAO3C,IAAgB,CAAA,gBAAA,GAAG,CAAC,CAAA;QACpB,IAA4B,CAAA,4BAAA,GAAG,GAAG,CAAA;QAE1C,IAAM,CAAA,MAAA,GAAG,EAAE,CAAA;AAIT,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAChC,aAAA,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC,CAAA;KACzB;;IAGD,SAAS,GAAA;AACP,QAAA,MAAM,EAAE,MAA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O,QAAQ,CAAA;AACtC,YAAA,SAAS,OAAO,IAAI,CAAA;AACrB,SAAA;KACF;AAED,IAAA,sBAAsB,CAAE,SAAoB,EAAE,YAAyB,GAAA,QAAQ,CAAC,IAAI,EAAA;AAClF,QAAA,MAAM,wBAAwB,GAAG,CAAC,CAAA;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,wBAAwB,CAAA;AAEhE,QAAA,QAAQ,SAAS;YACf,KAAK,SAAS,CAAC,IAAI,EAAE,OAAO,YAAY,KAAK,QAAQ,CAAC,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;AAC3E,YAAA,KAAK,SAAS,CAAC,KAAK,EAAE,OAAO,YAAY,KAAK,QAAQ,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,CAAA;YACvE,KAAK,SAAS,CAAC,MAAM,EAAE,OAAO,YAAY,KAAK,QAAQ,CAAC,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,GAAG,CAAA;AAC3F,YAAA,SAAS,OAAO,CAAC,CAAA;AAClB,SAAA;KACF;;AAnVM,IAAS,CAAA,SAAA,GAAGE,KAAC;;;;"}
@@ -115,8 +115,8 @@ class Brush extends XYComponentCore {
115
115
  const west = d.type === BrushDirection.West;
116
116
  const inside = config.handlePosition === Arrangement.Inside;
117
117
  return `translate(${west
118
- ? s[0] - Math.pow((-1), Number(inside)) * config.handleWidth / 2
119
- : s[1] + Math.pow((-1), Number(inside)) * config.handleWidth / 2},0)`;
118
+ ? s[0] - (-1) ** Number(inside) * config.handleWidth / 2
119
+ : s[1] + (-1) ** Number(inside) * config.handleWidth / 2},0)`;
120
120
  });
121
121
  }
122
122
  _onBrush(event) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/brush/index.ts"],"sourcesContent":["import { BrushBehavior, brushX, D3BrushEvent } from 'd3-brush'\nimport { Selection } from 'd3-selection'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, clamp } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Arrangement } from 'types/position'\n\n// Config\nimport { BrushConfig, BrushConfigInterface } from './config'\n\n// Local Types\nimport { BrushDirection, BrushHandleType } from './types'\n\n// Styles\nimport * as s from './style'\n\nexport class Brush<Datum> extends XYComponentCore<Datum, BrushConfig<Datum>, BrushConfigInterface<Datum>> {\n static selectors = s\n clippable = false // Don't apply clipping path to this component. See XYContainer\n config: BrushConfig<Datum> = new BrushConfig()\n brush: Selection<SVGGElement, unknown, SVGGElement, unknown>\n unselectedRange: Selection<SVGRectElement, BrushHandleType, SVGGElement, unknown>\n handleLines: Selection<SVGLineElement, BrushHandleType, SVGGElement, unknown>\n brushBehaviour: BrushBehavior<unknown> = brushX()\n events = {\n [Brush.selectors.brush]: {},\n }\n\n private _selection: [number, number] | null = null\n private _firstRender = true\n\n constructor (config?: BrushConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n\n this.brush = this.g\n .append('g')\n .attr('class', s.brush)\n\n const directions: BrushHandleType[] = [{ type: BrushDirection.West }, { type: BrushDirection.East }]\n this.unselectedRange = this.g\n .selectAll(`.${s.unselected}`)\n .data(directions)\n .enter().append('rect')\n .attr('class', s.unselected)\n\n this.handleLines = this.g\n .selectAll(`.${s.handleLine}`)\n .data(directions)\n .enter().append('line')\n .attr('class', s.handleLine)\n }\n\n _render (customDuration?: number): void {\n const { brushBehaviour, config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const xScale = this.xScale\n\n brushBehaviour\n .extent([[0, 0], [this._width, this._height]])\n .on('start', this._onBrushStart.bind(this))\n .on('brush', this._onBrushMove.bind(this))\n .on('end', this._onBrushEnd.bind(this))\n\n this.brush\n .call(brushBehaviour)\n .classed('non-draggable', !config.draggable)\n\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.unselectedRange\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.handleLines\n .attr('y1', yRange[1] + 10)\n .attr('y2', yRange[1] + h - 10)\n\n // We save the X scale range and set it to the available horizontal space to calculate the selection range in pixels correctly\n const xRange = [0, this._width]\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectionMin = clamp(xScale((config.selection || this._selection)?.[0]) ?? 0, xRange[0], xRange[1])\n const selectionMax = clamp(xScale((config.selection || this._selection)?.[1]) ?? 0, xRange[0], xRange[1])\n xScale.range(xScaleRange) // Restore the X scale range\n\n const selectionLength = selectionMax - selectionMin\n const brushRange = (selectionLength ? [selectionMin, selectionMax] : xRange) as [number, number]\n this._positionHandles(brushRange)\n\n smartTransition(this.brush, duration)\n .call(brushBehaviour.move, brushRange) // Sets up the brush and calls brush events\n .on('end interrupt', () => { this._firstRender = false })\n // We track the first render to not trigger user events on component initialization\n if (!duration) this._firstRender = false\n }\n\n _updateSelection (s: [number, number]): void {\n const xRange = [0, this._width]\n this.unselectedRange\n .attr('x', d => d.type === BrushDirection.West ? xRange[0] : s[1])\n .attr('width', d => {\n const length = d.type === BrushDirection.West ? s[0] - xRange[0] : xRange[1] - s[1]\n const lengthClamped = clamp(length, 0, xRange[1] - xRange[0])\n return lengthClamped\n })\n\n this._positionHandles(s)\n\n // D3 sets brush handle height to be too long, so we need to update it\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n }\n\n private _positionHandles (s: [number, number]): void {\n const { config } = this\n\n this.brush.selectAll<SVGRectElement, BrushHandleType>('.handle')\n .attr('width', config.handleWidth)\n .attr('x', d => {\n if (!s) return 0\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n\n if (west) return s[0] + (inside ? 0 : -config.handleWidth)\n else return s[1] + (inside ? -config.handleWidth : 0)\n })\n\n this.handleLines\n .attr('transform', d => {\n if (!s) return null\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n return `translate(${west\n ? s[0] - (-1) ** Number(inside) * config.handleWidth / 2\n : s[1] + (-1) ** Number(inside) * config.handleWidth / 2},0)`\n })\n }\n\n _onBrush (event: D3BrushEvent<Datum>): void {\n const { config } = this\n const xScale = this.xScale\n const xRange = [0, this._width]\n const s = (event?.selection || xRange) as [number, number]\n const userDriven = !!event?.sourceEvent\n // Handle edge cases:\n // (event?.selection === null) happens when user clicks to reset the selection\n // (s?.[0] === s?.[1]) happens when user drags the selection out of range\n if (userDriven && (\n (event?.selection === null) || // happens when user clicks to reset the selection\n (s?.[0] === s?.[1]) || // happens when user drags the selection out of range\n (s?.[0] < xRange[0]) || //\n (s?.[0] > xRange[1]) || // happens when you drag the brush and the domain updates\n (s?.[1] < xRange[0]) || // to a smaller one and brush goes out of range\n (s?.[1] > xRange[1]) //\n )) {\n this.brush.call(this.brushBehaviour.move, xRange) // Will trigger the 'brush end' callback with `range`\n return\n }\n\n // When you reset selection by clicking on a non-selected brush area, D3 triggers the brush event twice.\n // The first call will have equal selection coordinates (e.g. [441, 441]), the second call will have the full range (e.g. [0, 700]).\n // To avoid unnecessary render from the first call we skip it\n if (s[0] !== s[1] && isNumber(s[0]) && isNumber(s[1])) {\n // We save the X scale range and set it to the available horizontal space to invert the selection correctly\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectedDomain = s.map(n => +xScale.invert(n)) as [number, number]\n\n if (userDriven) {\n // Constraint the selection if configured\n const xDomain = xScale.domain() as [number, number]\n const xDomainLength = Math.abs(xDomain[1] - xDomain[0])\n const selectionLength = Math.abs(selectedDomain[1] - selectedDomain[0])\n\n if (config.selectionMinLength >= xDomainLength) {\n console.warn('Unovis | Brush: Configured `selectionMinLength` is bigger than the brush domain')\n }\n\n if ((selectionLength < config.selectionMinLength) && (config.selectionMinLength < xDomainLength)) {\n const selection = config.selection ?? this._selection\n const range = [xScale(selection[0]), xScale(selection[1])] as [number, number]\n this.brush.call(this.brushBehaviour.move, range) // Will trigger the 'brush end' callback with `range`\n // Restore the X scale range\n xScale.range(xScaleRange)\n return\n } else {\n this._selection = selectedDomain\n // Restore the X scale range\n xScale.range(xScaleRange)\n }\n }\n\n this._updateSelection(s)\n if (!this._firstRender) config.onBrush(selectedDomain, event, userDriven)\n }\n }\n\n _onBrushStart (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushStart(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushMove (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushMove(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushEnd (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushEnd(this._selection, event, !!event?.sourceEvent)\n }\n}\n"],"names":["s.brush","s.unselected","s.handleLine","s"],"mappings":";;;;;;;;;;AAsBM,MAAO,KAAa,SAAQ,eAAuE,CAAA;AAevG,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;AAdT,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAA;AACjB,QAAA,IAAA,CAAA,MAAM,GAAuB,IAAI,WAAW,EAAE,CAAA;QAI9C,IAAc,CAAA,cAAA,GAA2B,MAAM,EAAE,CAAA;AACjD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE;SAC5B,CAAA;QAEO,IAAU,CAAA,UAAA,GAA4B,IAAI,CAAA;QAC1C,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA;AAIzB,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAEpC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;aAChB,MAAM,CAAC,GA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AAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KAC1F;AAED,IAAA,YAAY,CAAE,KAA0B,EAAA;AACtC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACzF;AAED,IAAA,WAAW,CAAE,KAA0B,EAAA;AACrC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACxF;;AAhNM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/brush/index.ts"],"sourcesContent":["import { BrushBehavior, brushX, D3BrushEvent } from 'd3-brush'\nimport { Selection } from 'd3-selection'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { isNumber, clamp } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Arrangement } from 'types/position'\n\n// Config\nimport { BrushConfig, BrushConfigInterface } from './config'\n\n// Local Types\nimport { BrushDirection, BrushHandleType } from './types'\n\n// Styles\nimport * as s from './style'\n\nexport class Brush<Datum> extends XYComponentCore<Datum, BrushConfig<Datum>, BrushConfigInterface<Datum>> {\n static selectors = s\n clippable = false // Don't apply clipping path to this component. See XYContainer\n config: BrushConfig<Datum> = new BrushConfig()\n brush: Selection<SVGGElement, unknown, SVGGElement, unknown>\n unselectedRange: Selection<SVGRectElement, BrushHandleType, SVGGElement, unknown>\n handleLines: Selection<SVGLineElement, BrushHandleType, SVGGElement, unknown>\n brushBehaviour: BrushBehavior<unknown> = brushX()\n events = {\n [Brush.selectors.brush]: {},\n }\n\n private _selection: [number, number] | null = null\n private _firstRender = true\n\n constructor (config?: BrushConfigInterface<Datum>) {\n super()\n if (config) this.config.init(config)\n\n this.brush = this.g\n .append('g')\n .attr('class', s.brush)\n\n const directions: BrushHandleType[] = [{ type: BrushDirection.West }, { type: BrushDirection.East }]\n this.unselectedRange = this.g\n .selectAll(`.${s.unselected}`)\n .data(directions)\n .enter().append('rect')\n .attr('class', s.unselected)\n\n this.handleLines = this.g\n .selectAll(`.${s.handleLine}`)\n .data(directions)\n .enter().append('line')\n .attr('class', s.handleLine)\n }\n\n _render (customDuration?: number): void {\n const { brushBehaviour, config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const xScale = this.xScale\n\n brushBehaviour\n .extent([[0, 0], [this._width, this._height]])\n .on('start', this._onBrushStart.bind(this))\n .on('brush', this._onBrushMove.bind(this))\n .on('end', this._onBrushEnd.bind(this))\n\n this.brush\n .call(brushBehaviour)\n .classed('non-draggable', !config.draggable)\n\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.unselectedRange\n .attr('y', yRange[1])\n .attr('height', h)\n\n this.handleLines\n .attr('y1', yRange[1] + 10)\n .attr('y2', yRange[1] + h - 10)\n\n // We save the X scale range and set it to the available horizontal space to calculate the selection range in pixels correctly\n const xRange = [0, this._width]\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectionMin = clamp(xScale((config.selection || this._selection)?.[0]) ?? 0, xRange[0], xRange[1])\n const selectionMax = clamp(xScale((config.selection || this._selection)?.[1]) ?? 0, xRange[0], xRange[1])\n xScale.range(xScaleRange) // Restore the X scale range\n\n const selectionLength = selectionMax - selectionMin\n const brushRange = (selectionLength ? [selectionMin, selectionMax] : xRange) as [number, number]\n this._positionHandles(brushRange)\n\n smartTransition(this.brush, duration)\n .call(brushBehaviour.move, brushRange) // Sets up the brush and calls brush events\n .on('end interrupt', () => { this._firstRender = false })\n // We track the first render to not trigger user events on component initialization\n if (!duration) this._firstRender = false\n }\n\n _updateSelection (s: [number, number]): void {\n const xRange = [0, this._width]\n this.unselectedRange\n .attr('x', d => d.type === BrushDirection.West ? xRange[0] : s[1])\n .attr('width', d => {\n const length = d.type === BrushDirection.West ? s[0] - xRange[0] : xRange[1] - s[1]\n const lengthClamped = clamp(length, 0, xRange[1] - xRange[0])\n return lengthClamped\n })\n\n this._positionHandles(s)\n\n // D3 sets brush handle height to be too long, so we need to update it\n const yRange = [this._height, 0]\n const h = yRange[0] - yRange[1]\n this.g.selectAll('.handle')\n .attr('y', yRange[1])\n .attr('height', h)\n }\n\n private _positionHandles (s: [number, number]): void {\n const { config } = this\n\n this.brush.selectAll<SVGRectElement, BrushHandleType>('.handle')\n .attr('width', config.handleWidth)\n .attr('x', d => {\n if (!s) return 0\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n\n if (west) return s[0] + (inside ? 0 : -config.handleWidth)\n else return s[1] + (inside ? -config.handleWidth : 0)\n })\n\n this.handleLines\n .attr('transform', d => {\n if (!s) return null\n const west = d.type === BrushDirection.West\n const inside = config.handlePosition === Arrangement.Inside\n return `translate(${west\n ? s[0] - (-1) ** Number(inside) * config.handleWidth / 2\n : s[1] + (-1) ** Number(inside) * config.handleWidth / 2},0)`\n })\n }\n\n _onBrush (event: D3BrushEvent<Datum>): void {\n const { config } = this\n const xScale = this.xScale\n const xRange = [0, this._width]\n const s = (event?.selection || xRange) as [number, number]\n const userDriven = !!event?.sourceEvent\n // Handle edge cases:\n // (event?.selection === null) happens when user clicks to reset the selection\n // (s?.[0] === s?.[1]) happens when user drags the selection out of range\n if (userDriven && (\n (event?.selection === null) || // happens when user clicks to reset the selection\n (s?.[0] === s?.[1]) || // happens when user drags the selection out of range\n (s?.[0] < xRange[0]) || //\n (s?.[0] > xRange[1]) || // happens when you drag the brush and the domain updates\n (s?.[1] < xRange[0]) || // to a smaller one and brush goes out of range\n (s?.[1] > xRange[1]) //\n )) {\n this.brush.call(this.brushBehaviour.move, xRange) // Will trigger the 'brush end' callback with `range`\n return\n }\n\n // When you reset selection by clicking on a non-selected brush area, D3 triggers the brush event twice.\n // The first call will have equal selection coordinates (e.g. [441, 441]), the second call will have the full range (e.g. [0, 700]).\n // To avoid unnecessary render from the first call we skip it\n if (s[0] !== s[1] && isNumber(s[0]) && isNumber(s[1])) {\n // We save the X scale range and set it to the available horizontal space to invert the selection correctly\n const xScaleRange = xScale.range()\n xScale.range(xRange)\n const selectedDomain = s.map(n => +xScale.invert(n)) as [number, number]\n\n if (userDriven) {\n // Constraint the selection if configured\n const xDomain = xScale.domain() as [number, number]\n const xDomainLength = Math.abs(xDomain[1] - xDomain[0])\n const selectionLength = Math.abs(selectedDomain[1] - selectedDomain[0])\n\n if (config.selectionMinLength >= xDomainLength) {\n console.warn('Unovis | Brush: Configured `selectionMinLength` is bigger than the brush domain')\n }\n\n if ((selectionLength < config.selectionMinLength) && (config.selectionMinLength < xDomainLength)) {\n const selection = config.selection ?? this._selection\n const range = [xScale(selection[0]), xScale(selection[1])] as [number, number]\n this.brush.call(this.brushBehaviour.move, range) // Will trigger the 'brush end' callback with `range`\n // Restore the X scale range\n xScale.range(xScaleRange)\n return\n } else {\n this._selection = selectedDomain\n // Restore the X scale range\n xScale.range(xScaleRange)\n }\n }\n\n this._updateSelection(s)\n if (!this._firstRender) config.onBrush(selectedDomain, event, userDriven)\n }\n }\n\n _onBrushStart (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushStart(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushMove (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushMove(this._selection, event, !!event?.sourceEvent)\n }\n\n _onBrushEnd (event: D3BrushEvent<Datum>): void {\n const { config } = this\n\n this._onBrush(event)\n if (!this._firstRender) config.onBrushEnd(this._selection, event, !!event?.sourceEvent)\n }\n}\n"],"names":["s.brush","s.unselected","s.handleLine","s"],"mappings":";;;;;;;;;;AAsBM,MAAO,KAAa,SAAQ,eAAuE,CAAA;AAevG,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;AAdT,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAAA;AACjB,QAAA,IAAA,CAAA,MAAM,GAAuB,IAAI,WAAW,EAAE,CAAA;QAI9C,IAAc,CAAA,cAAA,GAA2B,MAAM,EAAE,CAAA;AACjD,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE;SAC5B,CAAA;QAEO,IAAU,CAAA,UAAA,GAA4B,IAAI,CAAA;QAC1C,IAAY,CAAA,YAAA,GAAG,IAAI,CAAA;AAIzB,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAEpC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;aAChB,MAAM,CAAC,GAAG,CAAC;AACX,aAAA,IAAI,CAAC,OAAO,EAAEA,KAAO,CAAC,CAAA;AAEzB,QAAA,MAAM,UAAU,GAAsB,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,CAAA;AACpG,QAAA,IAAI,CAAC,eAAe,GAAG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AM,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACzF;AAED,IAAA,WAAW,CAAE,KAA0B,EAAA;AACrC,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAC,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,WAAW,CAAA,CAAC,CAAA;KACxF;;AAhNM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -1,4 +1,3 @@
1
- import { __awaiter } from 'tslib';
2
1
  import { min, max } from 'd3-array';
3
2
  import { select, pointer } from 'd3-selection';
4
3
  import { zoom, zoomTransform, zoomIdentity } from 'd3-zoom';
@@ -237,39 +236,37 @@ class Graph extends ComponentCore {
237
236
  return;
238
237
  panelToUpdate.call(updatePanels, config, duration);
239
238
  }
240
- _calculateLayout() {
241
- return __awaiter(this, void 0, void 0, function* () {
242
- const { config, datamodel } = this;
243
- const firstRender = this._isFirstRender;
244
- if (this._shouldRecalculateLayout) {
245
- switch (config.layoutType) {
246
- case GraphLayoutType.Parallel:
247
- applyLayoutParallel(datamodel, config, this._width, this._height);
248
- break;
249
- case GraphLayoutType.ParallelHorizontal:
250
- applyLayoutParallel(datamodel, config, this._width, this._height, 'horizontal');
251
- break;
252
- case GraphLayoutType.Dagre:
253
- yield applyLayoutDagre(datamodel, config, this._width);
254
- break;
255
- case GraphLayoutType.Force:
256
- yield applyLayoutForce(datamodel, config, this._width);
257
- break;
258
- case GraphLayoutType.Concentric:
259
- applyLayoutConcentric(datamodel, config, this._width, this._height);
260
- break;
261
- case GraphLayoutType.Elk:
262
- yield applyELKLayout(datamodel, config, this._width);
263
- break;
264
- case GraphLayoutType.Circular:
265
- default:
266
- applyLayoutCircular(datamodel, config, this._width, this._height);
267
- break;
268
- }
269
- this._shouldRecalculateLayout = false;
239
+ async _calculateLayout() {
240
+ const { config, datamodel } = this;
241
+ const firstRender = this._isFirstRender;
242
+ if (this._shouldRecalculateLayout) {
243
+ switch (config.layoutType) {
244
+ case GraphLayoutType.Parallel:
245
+ applyLayoutParallel(datamodel, config, this._width, this._height);
246
+ break;
247
+ case GraphLayoutType.ParallelHorizontal:
248
+ applyLayoutParallel(datamodel, config, this._width, this._height, 'horizontal');
249
+ break;
250
+ case GraphLayoutType.Dagre:
251
+ await applyLayoutDagre(datamodel, config, this._width);
252
+ break;
253
+ case GraphLayoutType.Force:
254
+ await applyLayoutForce(datamodel, config, this._width);
255
+ break;
256
+ case GraphLayoutType.Concentric:
257
+ applyLayoutConcentric(datamodel, config, this._width, this._height);
258
+ break;
259
+ case GraphLayoutType.Elk:
260
+ await applyELKLayout(datamodel, config, this._width);
261
+ break;
262
+ case GraphLayoutType.Circular:
263
+ default:
264
+ applyLayoutCircular(datamodel, config, this._width, this._height);
265
+ break;
270
266
  }
271
- return firstRender;
272
- });
267
+ this._shouldRecalculateLayout = false;
268
+ }
269
+ return firstRender;
273
270
  }
274
271
  _fit(duration = 0) {
275
272
  var _a;