@unovis/ts 1.4.0-beta.4 → 1.4.0-version.12
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/area/config.d.ts +1 -1
- package/components/area/config.js.map +1 -1
- package/components/area/index.js.map +1 -1
- package/components/bullet-legend/config.d.ts +2 -4
- package/components/bullet-legend/config.js +2 -1
- package/components/bullet-legend/config.js.map +1 -1
- package/components/bullet-legend/index.js +17 -15
- package/components/bullet-legend/index.js.map +1 -1
- package/components/bullet-legend/modules/shape.d.ts +2 -1
- package/components/bullet-legend/modules/shape.js +48 -39
- package/components/bullet-legend/modules/shape.js.map +1 -1
- package/components/bullet-legend/style.js +5 -2
- package/components/bullet-legend/style.js.map +1 -1
- package/components/bullet-legend/types.d.ts +5 -14
- package/components/bullet-legend/types.js +6 -4
- package/components/bullet-legend/types.js.map +1 -1
- package/components/chord-diagram/index.d.ts +3 -3
- package/components/chord-diagram/index.js +15 -24
- package/components/chord-diagram/index.js.map +1 -1
- package/components/chord-diagram/modules/label.js +18 -15
- package/components/chord-diagram/modules/label.js.map +1 -1
- package/components/chord-diagram/modules/layout.js +5 -9
- package/components/chord-diagram/modules/layout.js.map +1 -1
- package/components/chord-diagram/style.js +1 -1
- package/components/chord-diagram/style.js.map +1 -1
- package/components/graph/config.d.ts +22 -15
- package/components/graph/config.js +4 -2
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +7 -2
- package/components/graph/index.js +114 -110
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/layout.js +30 -19
- package/components/graph/modules/layout.js.map +1 -1
- package/components/graph/modules/link/helper.d.ts +4 -6
- package/components/graph/modules/link/helper.js +15 -25
- package/components/graph/modules/link/helper.js.map +1 -1
- package/components/graph/modules/link/index.d.ts +3 -3
- package/components/graph/modules/link/index.js +111 -89
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/link/style.d.ts +5 -5
- package/components/graph/modules/link/style.js +26 -22
- package/components/graph/modules/link/style.js.map +1 -1
- package/components/graph/modules/node/helper.d.ts +1 -0
- package/components/graph/modules/node/helper.js +4 -1
- package/components/graph/modules/node/helper.js.map +1 -1
- package/components/graph/modules/node/index.js +28 -11
- package/components/graph/modules/node/index.js.map +1 -1
- package/components/graph/modules/node/style.d.ts +1 -1
- package/components/graph/modules/node/style.js +13 -6
- package/components/graph/modules/node/style.js.map +1 -1
- package/components/graph/modules/shape.d.ts +0 -2
- package/components/graph/modules/shape.js +7 -9
- package/components/graph/modules/shape.js.map +1 -1
- package/components/graph/types.d.ts +63 -5
- package/components/graph/types.js +1 -0
- package/components/graph/types.js.map +1 -1
- package/components/nested-donut/config.d.ts +0 -1
- package/components/nested-donut/config.js +1 -1
- package/components/nested-donut/config.js.map +1 -1
- package/components/nested-donut/index.js +10 -16
- package/components/nested-donut/index.js.map +1 -1
- package/components/stacked-bar/index.js.map +1 -1
- package/components/tooltip/config.d.ts +1 -1
- package/components/tooltip/config.js.map +1 -1
- package/components/tooltip/index.js +3 -1
- package/components/tooltip/index.js.map +1 -1
- package/components/vis-controls/index.d.ts +3 -0
- package/components/vis-controls/index.js +6 -1
- package/components/vis-controls/index.js.map +1 -1
- package/components.d.ts +0 -2
- package/components.js +0 -1
- package/components.js.map +1 -1
- package/containers/single-container/config.d.ts +0 -3
- package/containers/single-container/config.js.map +1 -1
- package/containers/single-container/index.js +1 -10
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/config.d.ts +0 -3
- package/containers/xy-container/config.js +1 -1
- package/containers/xy-container/config.js.map +1 -1
- package/containers/xy-container/index.js +5 -17
- package/containers/xy-container/index.js.map +1 -1
- package/core/component/index.d.ts +3 -3
- package/core/component/index.js +1 -1
- package/core/component/index.js.map +1 -1
- package/index.js +0 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types/misc.d.ts +0 -1
- package/types/scale.d.ts +2 -3
- package/types/scale.js +1 -2
- package/types/scale.js.map +1 -1
- package/types.d.ts +0 -1
- package/types.js +0 -1
- package/types.js.map +1 -1
- package/utils/misc.d.ts +1 -2
- package/utils/misc.js +1 -13
- package/utils/misc.js.map +1 -1
- package/utils/svg.d.ts +3 -0
- package/utils/svg.js +61 -0
- package/utils/svg.js.map +1 -0
- package/utils/text.js.map +1 -1
- package/components/annotations/config.d.ts +0 -19
- package/components/annotations/config.js +0 -6
- package/components/annotations/config.js.map +0 -1
- package/components/annotations/index.d.ts +0 -24
- package/components/annotations/index.js +0 -117
- package/components/annotations/index.js.map +0 -1
- package/components/annotations/style.d.ts +0 -13
- package/components/annotations/style.js +0 -43
- package/components/annotations/style.js.map +0 -1
- package/components/annotations/types.d.ts +0 -43
- package/components/annotations/types.js +0 -8
- package/components/annotations/types.js.map +0 -1
|
@@ -5,7 +5,7 @@ export interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<D
|
|
|
5
5
|
/** Area color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */
|
|
6
6
|
color?: ColorAccessor<Datum[]>;
|
|
7
7
|
/** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */
|
|
8
|
-
curveType?: CurveType
|
|
8
|
+
curveType?: CurveType;
|
|
9
9
|
/** Baseline value or accessor function. Default: `undefined` */
|
|
10
10
|
baseline?: NumericAccessor<Datum>;
|
|
11
11
|
/** Opacity value or accessor function. Default: `1` */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/area/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { ColorAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Area color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n color?: ColorAccessor<Datum[]>;\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/area/config.ts"],"sourcesContent":["import { XYComponentConfigInterface, XYComponentDefaultConfig } from 'core/xy-component/config'\n\n// Types\nimport { CurveType } from 'types/curve'\nimport { ColorAccessor, NumericAccessor, StringAccessor } from 'types/accessor'\n\nexport interface AreaConfigInterface<Datum> extends XYComponentConfigInterface<Datum> {\n /** Area color accessor function. The whole data array will be passed as the first argument. Default: `undefined` */\n color?: ColorAccessor<Datum[]>;\n /** Curve type from the CurveType enum. Default: `CurveType.MonotoneX` */\n curveType?: CurveType;\n /** Baseline value or accessor function. Default: `undefined` */\n baseline?: NumericAccessor<Datum>;\n /** Opacity value or accessor function. Default: `1` */\n opacity?: NumericAccessor<Datum[]>;\n /** Optional area cursor. String or accessor function. Default: `null` */\n cursor?: StringAccessor<Datum[]>;\n /** If an area is smaller than 1px, extend it to have 1px height.\n * This setting is useful when some of the area values are zeros or very small so visually they become\n * practically invisible, but you want to show that the data behind them exists and they're not just empty segments.\n * Default: `false` */\n minHeight1Px?: boolean;\n}\n\nexport const AreaDefaultConfig: AreaConfigInterface<unknown> = {\n ...XYComponentDefaultConfig,\n color: undefined,\n curveType: CurveType.MonotoneX,\n baseline: (): number => 0,\n opacity: 1,\n cursor: null,\n minHeight1Px: false,\n}\n"],"names":[],"mappings":";;;AAwBO,MAAM,iBAAiB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACzB,wBAAwB,CAC3B,EAAA,EAAA,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,QAAQ,EAAE,MAAc,CAAC,EACzB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,IAAI,EACZ,YAAY,EAAE,KAAK;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/area/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { area, Area as AreaInterface } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, isArray, isNumber, getStackedExtent, getStackedData, filterDataByRange } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Curve
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/area/index.ts"],"sourcesContent":["import { select } from 'd3-selection'\nimport { Transition } from 'd3-transition'\nimport { area, Area as AreaInterface } from 'd3-shape'\nimport { interpolatePath } from 'd3-interpolate-path'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getNumber, getString, isArray, isNumber, getStackedExtent, getStackedData, filterDataByRange } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Curve } from 'types/curve'\nimport { NumericAccessor } from 'types/accessor'\n\n// Local Types\nimport { AreaDatum } from './types'\n\n// Config\nimport { AreaDefaultConfig, AreaConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Area<Datum> extends XYComponentCore<Datum, AreaConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = AreaDefaultConfig as AreaConfigInterface<Datum>\n public config: AreaConfigInterface<Datum> = this._defaultConfig\n public stacked = true\n private _areaGen: AreaInterface<AreaDatum>\n private _prevNegative: boolean[] | undefined // To help guessing the stack direction when an accessor was set to null or 0\n\n events = {\n [Area.selectors.area]: {},\n }\n\n constructor (config?: AreaConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n _render (customDuration?: number): void {\n super._render(customDuration)\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const curveGen = Curve[config.curveType]\n this._areaGen = area<AreaDatum>()\n .x(d => d.x)\n .y0(d => d.y0)\n .y1(d => {\n const isSmallerThanPixel = Math.abs(d.y1 - d.y0) < 1\n return d.y1 - ((isSmallerThanPixel && config.minHeight1Px) ? 1 : 0)\n })\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n .curve(curveGen)\n\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n const areaDataX = data.map((d, i) => this.xScale(getNumber(d, config.x, i)))\n\n const stacked = getStackedData(data, config.baseline, yAccessors, this._prevNegative)\n this._prevNegative = stacked.map(s => !!s.negative)\n const stackedData: AreaDatum[][] = stacked.map(\n arr => arr.map(\n (d, j) => ({\n y0: this.yScale(d[0]),\n y1: this.yScale(d[1]),\n x: areaDataX[j],\n })\n )\n )\n\n // We reverse the data in order to have the first areas to be displayed on top\n // for better visibility when they're close to zero\n const areaMaxIdx = stackedData.length - 1\n const stackedDataReversed = stackedData.reverse()\n const areas = this.g\n .selectAll<SVGPathElement, AreaDatum>(`.${s.area}`)\n .data(stackedDataReversed)\n\n const areasEnter = areas.enter().append('path')\n .attr('class', s.area)\n .attr('d', d => this._areaGen(d) || this._emptyPath())\n .style('opacity', 0)\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n\n const areasMerged = smartTransition(areasEnter.merge(areas), duration)\n .style('opacity', (d, i) => {\n const isDefined = d.some(p => (p.y0 - p.y1) !== 0)\n return isDefined ? getNumber(data, config.opacity, areaMaxIdx - i) : 0\n })\n .style('fill', (d, i) => getColor(data, config.color, areaMaxIdx - i))\n .style('cursor', (d, i) => getString(data, config.cursor, areaMaxIdx - i))\n\n if (duration) {\n const transition = areasMerged as Transition<SVGPathElement, AreaDatum[], SVGGElement, AreaDatum[]>\n transition.attrTween('d', (d, i, el) => {\n const previous = select(el[i]).attr('d')\n const next = this._areaGen(d) || this._emptyPath()\n return interpolatePath(previous, next)\n })\n } else {\n areasMerged.attr('d', d => this._areaGen(d) || this._emptyPath())\n }\n\n smartTransition(areas.exit(), duration)\n .style('opacity', 0)\n .remove()\n }\n\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n\n const data = scaleByVisibleData ? filterDataByRange(datamodel.data, this.xScale.domain() as [number, number], config.x) : datamodel.data\n return getStackedExtent(data, config.baseline, ...yAccessors)\n }\n\n _emptyPath (): string {\n const xRange = this.xScale.range()\n const yDomain = this.yScale.domain() as number[]\n\n const y0 = this.yScale((yDomain[0] + yDomain[1]) / 2)\n const y1 = y0\n\n return this._areaGen([\n { y0, y1, x: xRange[0] },\n { y0, y1, x: xRange[1] },\n ])\n }\n}\n"],"names":["s.area","s"],"mappings":";;;;;;;;;;;;AA0BM,MAAO,IAAY,SAAQ,eAAkD,CAAA;AAYjF,IAAA,WAAA,CAAa,MAAmC,EAAA;AAC9C,QAAA,KAAK,EAAE,CAAA;QAXC,IAAc,CAAA,cAAA,GAAG,iBAA+C,CAAA;AACnE,QAAA,IAAA,CAAA,MAAM,GAA+B,IAAI,CAAC,cAAc,CAAA;QACxD,IAAO,CAAA,OAAA,GAAG,IAAI,CAAA;AAIrB,QAAA,IAAA,CAAA,MAAM,GAAG;AACP,YAAA,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE;SAC1B,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KACnC;AAED,IAAA,OAAO,CAAE,cAAuB,EAAA;AAC9B,QAAA,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;QAC7B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAAA;AAC5C,QAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAA;QAE5E,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AACxC,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAa;aAC9B,CAAC,CAAC,CAAC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GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAA6B,CAAA;AAE1F,QAAA,MAAM,IAAI,GAAG,kBAAkB,GAAG,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAsB,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAA;QACxI,OAAO,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,UAAU,CAAC,CAAA;KAC9D;IAED,UAAU,GAAA;QACR,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAc,CAAA;QAEhD,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;QACrD,MAAM,EAAE,GAAG,EAAE,CAAA;QAEb,OAAO,IAAI,CAAC,QAAQ,CAAC;YACnB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;YACxB,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;AACzB,SAAA,CAAC,CAAA;KACH;;AAzGM,IAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GenericAccessor } from "../../types/accessor";
|
|
2
1
|
import { BulletLegendItemInterface, BulletShape } from './types';
|
|
3
2
|
export interface BulletLegendConfigInterface {
|
|
4
3
|
/** Legend items. Array of `BulletLegendItemInterface`:
|
|
@@ -6,7 +5,6 @@ export interface BulletLegendConfigInterface {
|
|
|
6
5
|
* {
|
|
7
6
|
* name: string | number;
|
|
8
7
|
* color?: string;
|
|
9
|
-
* shape?: BulletShape;
|
|
10
8
|
* inactive?: boolean;
|
|
11
9
|
* hidden?: boolean;
|
|
12
10
|
* pointer?: boolean;
|
|
@@ -24,7 +22,7 @@ export interface BulletLegendConfigInterface {
|
|
|
24
22
|
labelMaxWidth?: string | null;
|
|
25
23
|
/** Bullet shape size, mapped to the width and height CSS properties. Default: `null` */
|
|
26
24
|
bulletSize?: string | null;
|
|
27
|
-
/** Bullet shape
|
|
28
|
-
bulletShape?:
|
|
25
|
+
/** Bullet shape: `BulletShape.Circle`, `BulletShape.Line` or `BulletShape.Square`. Default: `BulletShape.Circle` */
|
|
26
|
+
bulletShape?: BulletShape;
|
|
29
27
|
}
|
|
30
28
|
export declare const BulletLegendDefaultConfig: BulletLegendConfigInterface;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BulletShape } from './types.js';
|
|
2
2
|
|
|
3
|
+
// Local Types
|
|
3
4
|
const BulletLegendDefaultConfig = {
|
|
4
5
|
items: [],
|
|
5
6
|
labelClassName: '',
|
|
@@ -7,7 +8,7 @@ const BulletLegendDefaultConfig = {
|
|
|
7
8
|
labelFontSize: null,
|
|
8
9
|
labelMaxWidth: null,
|
|
9
10
|
bulletSize: null,
|
|
10
|
-
bulletShape:
|
|
11
|
+
bulletShape: BulletShape.Circle,
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export { BulletLegendDefaultConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/bullet-legend/config.ts"],"sourcesContent":["// Local Types\nimport {
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/bullet-legend/config.ts"],"sourcesContent":["// Local Types\nimport { BulletLegendItemInterface, BulletShape } from './types'\n\nexport interface BulletLegendConfigInterface {\n /** Legend items. Array of `BulletLegendItemInterface`:\n * ```\n * {\n * name: string | number;\n * color?: string;\n * inactive?: boolean;\n * hidden?: boolean;\n * pointer?: boolean;\n * }\n * ```\n * Default: `[]` */\n items: BulletLegendItemInterface[];\n /** Apply a specific class to the labels. Default: `''` */\n labelClassName?: string;\n /** Callback function for the legend item click. Default: `undefined` */\n onLegendItemClick?: ((d: BulletLegendItemInterface, i: number) => void);\n /** Label text (<span> element) font-size CSS. Default: `null` */\n labelFontSize?: string | null;\n /** Label text (<span> element) max-width CSS property. Default: `null` */\n labelMaxWidth?: string | null;\n /** Bullet shape size, mapped to the width and height CSS properties. Default: `null` */\n bulletSize?: string | null;\n /** Bullet shape: `BulletShape.Circle`, `BulletShape.Line` or `BulletShape.Square`. Default: `BulletShape.Circle` */\n bulletShape?: BulletShape;\n}\n\nexport const BulletLegendDefaultConfig: BulletLegendConfigInterface = {\n items: [],\n labelClassName: '',\n onLegendItemClick: undefined,\n labelFontSize: null,\n labelMaxWidth: null,\n bulletSize: null,\n bulletShape: BulletShape.Circle,\n}\n"],"names":[],"mappings":";;AAAA;AA8Ba,MAAA,yBAAyB,GAAgC;AACpE,IAAA,KAAK,EAAE,EAAE;AACT,IAAA,cAAc,EAAE,EAAE;AAClB,IAAA,iBAAiB,EAAE,SAAS;AAC5B,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,WAAW,CAAC,MAAM;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
2
|
import { merge } from '../../utils/data.js';
|
|
3
3
|
import { BulletLegendDefaultConfig } from './config.js';
|
|
4
|
-
import { updateBullets } from './modules/shape.js';
|
|
4
|
+
import { createBullets, updateBullets } from './modules/shape.js';
|
|
5
5
|
import * as style from './style.js';
|
|
6
|
-
import { root, item,
|
|
6
|
+
import { root, item, bullet, label, clickable } from './style.js';
|
|
7
7
|
|
|
8
8
|
class BulletLegend {
|
|
9
9
|
constructor(element, config) {
|
|
@@ -26,26 +26,28 @@ class BulletLegend {
|
|
|
26
26
|
}
|
|
27
27
|
render() {
|
|
28
28
|
const { config } = this;
|
|
29
|
-
const legendItems = this.div.selectAll(`.${item}`)
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const legendItems = this.div.selectAll(`.${item}`)
|
|
30
|
+
.data(config.items);
|
|
31
|
+
const legendItemsEnter = legendItems.enter()
|
|
32
|
+
.append('div')
|
|
33
|
+
.attr('class', item)
|
|
32
34
|
.on('click', this._onItemClick.bind(this));
|
|
33
|
-
|
|
34
|
-
legendItemsMerged
|
|
35
|
-
.classed(clickable, d => !!config.onLegendItemClick && this._isItemClickable(d))
|
|
36
|
-
.style('display', (d) => d.hidden ? 'none' : null);
|
|
37
|
-
// Bullet
|
|
38
|
-
legendItemsEnter.append('svg')
|
|
35
|
+
legendItemsEnter.append('span')
|
|
39
36
|
.attr('class', bullet)
|
|
40
|
-
.
|
|
41
|
-
legendItemsMerged.select(`.${bullet}`)
|
|
42
|
-
.call(updateBullets, this.config, this._colorAccessor);
|
|
43
|
-
// Labels
|
|
37
|
+
.call(createBullets, config);
|
|
44
38
|
legendItemsEnter.append('span')
|
|
45
39
|
.attr('class', label)
|
|
46
40
|
.classed(config.labelClassName, true)
|
|
47
41
|
.style('max-width', config.labelMaxWidth)
|
|
48
42
|
.style('font-size', config.labelFontSize);
|
|
43
|
+
const legendItemsMerged = legendItemsEnter.merge(legendItems);
|
|
44
|
+
legendItemsMerged
|
|
45
|
+
.classed(clickable, d => !!config.onLegendItemClick && this._isItemClickable(d))
|
|
46
|
+
.style('display', (d) => d.hidden ? 'none' : null);
|
|
47
|
+
legendItemsMerged.select(`.${bullet}`)
|
|
48
|
+
.style('min-width', config.bulletSize)
|
|
49
|
+
.style('height', config.bulletSize)
|
|
50
|
+
.call(updateBullets, this.config, this._colorAccessor);
|
|
49
51
|
legendItemsMerged.select(`.${label}`)
|
|
50
52
|
.text((d) => d.name);
|
|
51
53
|
legendItems.exit().remove();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/bullet-legend/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Utils\nimport { merge } from 'utils/data'\n\n// Config\nimport { BulletLegendDefaultConfig, BulletLegendConfigInterface } from './config'\n\n// Local Types\nimport { BulletLegendItemInterface } from './types'\n\n// Modules\nimport { updateBullets } from './modules/shape'\n\n// Styles\nimport * as s from './style'\n\nexport class BulletLegend {\n static selectors = s\n protected _defaultConfig = BulletLegendDefaultConfig as BulletLegendConfigInterface\n public config: BulletLegendConfigInterface = this._defaultConfig\n\n div: Selection<HTMLDivElement, unknown, null, undefined>\n element: HTMLElement\n prevConfig: BulletLegendConfigInterface\n protected _container: HTMLElement\n\n private _colorAccessor = (d: BulletLegendItemInterface): string => d.color\n\n constructor (element: HTMLElement, config?: BulletLegendConfigInterface) {\n this._container = element\n\n // Create SVG element for visualizations\n this.div = select(this._container)\n .append('div')\n .attr('class', s.root)\n\n this.element = this.div.node()\n\n if (config) this.update(config)\n }\n\n update (config: BulletLegendConfigInterface): void {\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n this.render()\n }\n\n render (): void {\n const { config } = this\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/bullet-legend/index.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Utils\nimport { merge } from 'utils/data'\n\n// Config\nimport { BulletLegendDefaultConfig, BulletLegendConfigInterface } from './config'\n\n// Local Types\nimport { BulletLegendItemInterface } from './types'\n\n// Modules\nimport { createBullets, updateBullets } from './modules/shape'\n\n// Styles\nimport * as s from './style'\n\nexport class BulletLegend {\n static selectors = s\n protected _defaultConfig = BulletLegendDefaultConfig as BulletLegendConfigInterface\n public config: BulletLegendConfigInterface = this._defaultConfig\n\n div: Selection<HTMLDivElement, unknown, null, undefined>\n element: HTMLElement\n prevConfig: BulletLegendConfigInterface\n protected _container: HTMLElement\n\n private _colorAccessor = (d: BulletLegendItemInterface): string => d.color\n\n constructor (element: HTMLElement, config?: BulletLegendConfigInterface) {\n this._container = element\n\n // Create SVG element for visualizations\n this.div = select(this._container)\n .append('div')\n .attr('class', s.root)\n\n this.element = this.div.node()\n\n if (config) this.update(config)\n }\n\n update (config: BulletLegendConfigInterface): void {\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n this.render()\n }\n\n render (): void {\n const { config } = this\n const legendItems = this.div.selectAll<HTMLDivElement, unknown>(`.${s.item}`)\n .data(config.items)\n\n const legendItemsEnter = legendItems.enter()\n .append('div')\n .attr('class', s.item)\n .on('click', this._onItemClick.bind(this))\n\n legendItemsEnter.append('span')\n .attr('class', s.bullet)\n .call(createBullets, config)\n\n legendItemsEnter.append('span')\n .attr('class', s.label)\n .classed(config.labelClassName, true)\n .style('max-width', config.labelMaxWidth)\n .style('font-size', config.labelFontSize)\n\n const legendItemsMerged = legendItemsEnter.merge(legendItems)\n legendItemsMerged\n .classed(s.clickable, d => !!config.onLegendItemClick && this._isItemClickable(d))\n .style('display', (d: BulletLegendItemInterface) => d.hidden ? 'none' : null)\n\n legendItemsMerged.select<HTMLSpanElement>(`.${s.bullet}`)\n .style('min-width', config.bulletSize)\n .style('height', config.bulletSize)\n .call(updateBullets, this.config, this._colorAccessor)\n\n legendItemsMerged.select(`.${s.label}`)\n .text((d: BulletLegendItemInterface) => d.name)\n\n legendItems.exit().remove()\n }\n\n _isItemClickable (item: BulletLegendItemInterface): boolean {\n return item.pointer === undefined ? true : item.pointer\n }\n\n _onItemClick (event: MouseEvent, d: BulletLegendItemInterface): void {\n const { config: { onLegendItemClick } } = this\n\n const legendItems = this.div.selectAll(`.${s.item}`).nodes() as HTMLElement[]\n const index = legendItems.indexOf(event.currentTarget as HTMLElement)\n if (onLegendItemClick) onLegendItemClick(d, index)\n }\n\n public destroy (): void {\n this.div.remove()\n }\n}\n"],"names":["s.root","s.item","s.bullet","s.label","s.clickable","s"],"mappings":";;;;;;;MAiBa,YAAY,CAAA;IAYvB,WAAa,CAAA,OAAoB,EAAE,MAAoC,EAAA;QAV7D,IAAc,CAAA,cAAA,GAAG,yBAAwD,CAAA;AA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;AAC/C,QAAA,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAA;KACxD;IAED,YAAY,CAAE,KAAiB,EAAE,CAA4B,EAAA;QAC3D,MAAM,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,EAAE,GAAG,IAAI,CAAA;AAE9C,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAI,CAAA,EAAAF,IAAM,CAAA,CAAE,CAAC,CAAC,KAAK,EAAmB,CAAA;QAC7E,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,aAA4B,CAAC,CAAA;AACrE,QAAA,IAAI,iBAAiB;AAAE,YAAA,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;KACnD;IAEM,OAAO,GAAA;AACZ,QAAA,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;KAClB;;AAhFM,YAAS,CAAA,SAAA,GAAGI,KAAC;;;;"}
|
|
@@ -2,4 +2,5 @@ import { Selection } from 'd3-selection';
|
|
|
2
2
|
import { ColorAccessor } from "../../../types/accessor";
|
|
3
3
|
import { BulletLegendConfigInterface } from '../config';
|
|
4
4
|
import { BulletLegendItemInterface } from '../types';
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function createBullets(container: Selection<HTMLSpanElement, BulletLegendItemInterface, HTMLDivElement, unknown>, config: BulletLegendConfigInterface): void;
|
|
6
|
+
export declare function updateBullets(container: Selection<HTMLSpanElement, BulletLegendItemInterface, HTMLDivElement, unknown>, config: BulletLegendConfigInterface, colorAccessor: ColorAccessor<BulletLegendItemInterface>): void;
|
|
@@ -1,50 +1,59 @@
|
|
|
1
|
-
import { select } from 'd3-selection';
|
|
2
|
-
import { symbol } from 'd3-shape';
|
|
3
|
-
import { Symbol } from '../../../types/symbol.js';
|
|
4
1
|
import { getColor } from '../../../utils/color.js';
|
|
5
|
-
import {
|
|
2
|
+
import { circlePath } from '../../../utils/path.js';
|
|
6
3
|
import { PATTERN_SIZE_PX } from '../../../styles/patterns.js';
|
|
7
4
|
import { BulletShape } from '../types.js';
|
|
8
5
|
|
|
6
|
+
// Utils
|
|
9
7
|
// Size with respect to the viewBox. We use this to compute path data which is independent of the
|
|
10
8
|
// the configured size.
|
|
11
9
|
const BULLET_SIZE = PATTERN_SIZE_PX * 3;
|
|
10
|
+
function getHeight(shape) {
|
|
11
|
+
switch (shape) {
|
|
12
|
+
case BulletShape.Line:
|
|
13
|
+
return BULLET_SIZE / 2.5;
|
|
14
|
+
default:
|
|
15
|
+
return BULLET_SIZE;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function getPath(shape, width, height) {
|
|
19
|
+
switch (shape) {
|
|
20
|
+
case BulletShape.Line:
|
|
21
|
+
return `M0,${height / 2} L${width / 2},${height / 2} L${width},${height / 2}`;
|
|
22
|
+
case BulletShape.Square:
|
|
23
|
+
return `M0,0 L${width},0 L${width},${height} L0,${height}Z`;
|
|
24
|
+
case BulletShape.Circle:
|
|
25
|
+
return circlePath(height / 2, height / 2, height / 2 - 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function createBullets(container, config) {
|
|
29
|
+
container.append('svg')
|
|
30
|
+
.attr('width', '100%')
|
|
31
|
+
.attr('height', '100%')
|
|
32
|
+
.append('path')
|
|
33
|
+
.attr('d', getPath(config.bulletShape, BULLET_SIZE, getHeight(config.bulletShape)));
|
|
34
|
+
}
|
|
12
35
|
function updateBullets(container, config, colorAccessor) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else {
|
|
34
|
-
const symbolGen = symbol().type(Symbol[shape]);
|
|
35
|
-
selection.attr('d', symbolGen)
|
|
36
|
-
.attr('transform', `translate(${width / 2},${height / 2})`)
|
|
37
|
-
.style('stroke-width', '1px')
|
|
38
|
-
.style('opacity', null)
|
|
39
|
-
.style('fill', color)
|
|
40
|
-
.style('fill-opacity', d.inactive ? 0.4 : 1);
|
|
41
|
-
const box = selection.node().getBBox();
|
|
42
|
-
const scaledSize = Math.min(width / box.width, height / box.height);
|
|
43
|
-
const scale = Math.floor(scaledSize * 2) / 2;
|
|
44
|
-
selection.transition().duration(0).attr('d', symbolGen.size(scale * scale * 64));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
36
|
+
const width = BULLET_SIZE;
|
|
37
|
+
const height = getHeight(config.bulletShape);
|
|
38
|
+
const getOpacity = (d) => d.inactive ? 0.4 : 1;
|
|
39
|
+
const selection = container.select('svg')
|
|
40
|
+
.attr('viewBox', `0 0 ${width} ${height}`)
|
|
41
|
+
.select('path')
|
|
42
|
+
.attr('d', getPath(config.bulletShape, width, height))
|
|
43
|
+
.attr('stroke', (d, i) => getColor(d, colorAccessor, i))
|
|
44
|
+
.style('stroke-width', '1px')
|
|
45
|
+
.style('fill', (d, i) => getColor(d, colorAccessor, i))
|
|
46
|
+
.style('fill-opacity', getOpacity);
|
|
47
|
+
if (config.bulletShape === BulletShape.Line) {
|
|
48
|
+
selection
|
|
49
|
+
.style('stroke-width', `${height / 5}px`)
|
|
50
|
+
.style('opacity', getOpacity)
|
|
51
|
+
.style('fill', null)
|
|
52
|
+
.style('fill-opacity', null)
|
|
53
|
+
.style('marker-start', 'none')
|
|
54
|
+
.style('marker-end', 'none');
|
|
55
|
+
}
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
export { updateBullets };
|
|
58
|
+
export { createBullets, updateBullets };
|
|
50
59
|
//# sourceMappingURL=shape.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","sources":["../../../../src/components/bullet-legend/modules/shape.ts"],"sourcesContent":["import { Selection
|
|
1
|
+
{"version":3,"file":"shape.js","sources":["../../../../src/components/bullet-legend/modules/shape.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\n\n// Types\nimport { ColorAccessor } from 'types/accessor'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { circlePath } from 'utils/path'\n\n// Constants\nimport { PATTERN_SIZE_PX } from 'styles/patterns'\n\n// Local types\nimport { BulletLegendConfigInterface } from '../config'\nimport { BulletShape, BulletLegendItemInterface } from '../types'\n\n// Size with respect to the viewBox. We use this to compute path data which is independent of the\n// the configured size.\nconst BULLET_SIZE = PATTERN_SIZE_PX * 3\n\nfunction getHeight (shape: BulletShape): number {\n switch (shape) {\n case BulletShape.Line:\n return BULLET_SIZE / 2.5\n default:\n return BULLET_SIZE\n }\n}\n\nfunction getPath (shape: BulletShape, width: number, height: number): string {\n switch (shape) {\n case BulletShape.Line:\n return `M0,${height / 2} L${width / 2},${height / 2} L${width},${height / 2}`\n case BulletShape.Square:\n return `M0,0 L${width},0 L${width},${height} L0,${height}Z`\n case BulletShape.Circle:\n return circlePath(height / 2, height / 2, height / 2 - 1)\n }\n}\n\nexport function createBullets (\n container: Selection<HTMLSpanElement, BulletLegendItemInterface, HTMLDivElement, unknown>,\n config: BulletLegendConfigInterface\n): void {\n container.append('svg')\n .attr('width', '100%')\n .attr('height', '100%')\n .append('path')\n .attr('d', getPath(config.bulletShape, BULLET_SIZE, getHeight(config.bulletShape)))\n}\n\nexport function updateBullets (\n container: Selection<HTMLSpanElement, BulletLegendItemInterface, HTMLDivElement, unknown>,\n config: BulletLegendConfigInterface,\n colorAccessor: ColorAccessor<BulletLegendItemInterface>\n): void {\n const width = BULLET_SIZE\n const height = getHeight(config.bulletShape)\n\n const getOpacity = (d: BulletLegendItemInterface): number => d.inactive ? 0.4 : 1\n\n const selection = container.select('svg')\n .attr('viewBox', `0 0 ${width} ${height}`)\n .select('path')\n .attr('d', getPath(config.bulletShape, width, height))\n .attr('stroke', (d, i) => getColor(d, colorAccessor, i))\n .style('stroke-width', '1px')\n .style('fill', (d, i) => getColor(d, colorAccessor, i))\n .style('fill-opacity', getOpacity)\n\n if (config.bulletShape === BulletShape.Line) {\n selection\n .style('stroke-width', `${height / 5}px`)\n .style('opacity', getOpacity)\n .style('fill', null)\n .style('fill-opacity', null)\n .style('marker-start', 'none')\n .style('marker-end', 'none')\n }\n}\n"],"names":[],"mappings":";;;;;AAKA;AAWA;AACA;AACA,MAAM,WAAW,GAAG,eAAe,GAAG,CAAC,CAAA;AAEvC,SAAS,SAAS,CAAE,KAAkB,EAAA;AACpC,IAAA,QAAQ,KAAK;QACX,KAAK,WAAW,CAAC,IAAI;YACnB,OAAO,WAAW,GAAG,GAAG,CAAA;AAC1B,QAAA;AACE,YAAA,OAAO,WAAW,CAAA;AACrB,KAAA;AACH,CAAC;AAED,SAAS,OAAO,CAAE,KAAkB,EAAE,KAAa,EAAE,MAAc,EAAA;AACjE,IAAA,QAAQ,KAAK;QACX,KAAK,WAAW,CAAC,IAAI;AACnB,YAAA,OAAO,MAAM,MAAM,GAAG,CAAC,CAAK,EAAA,EAAA,KAAK,GAAG,CAAC,CAAA,CAAA,EAAI,MAAM,GAAG,CAAC,KAAK,KAAK,CAAA,CAAA,EAAI,MAAM,GAAG,CAAC,EAAE,CAAA;QAC/E,KAAK,WAAW,CAAC,MAAM;YACrB,OAAO,CAAA,MAAA,EAAS,KAAK,CAAO,IAAA,EAAA,KAAK,IAAI,MAAM,CAAA,IAAA,EAAO,MAAM,CAAA,CAAA,CAAG,CAAA;QAC7D,KAAK,WAAW,CAAC,MAAM;AACrB,YAAA,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5D,KAAA;AACH,CAAC;AAEe,SAAA,aAAa,CAC3B,SAAyF,EACzF,MAAmC,EAAA;AAEnC,IAAA,SAAS,CAAC,MAAM,C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AK,WAAW,CAAC,IAAI,EAAE;QAC3C,SAAS;aACN,KAAK,CAAC,cAAc,EAAE,CAAA,EAAG,MAAM,GAAG,CAAC,IAAI,CAAC;AACxC,aAAA,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC;AAC5B,aAAA,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC;AACnB,aAAA,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC;AAC3B,aAAA,KAAK,CAAC,cAAc,EAAE,MAAM,CAAC;AAC7B,aAAA,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;AAC/B,KAAA;AACH;;;;"}
|
|
@@ -56,9 +56,12 @@ const label = css `
|
|
|
56
56
|
const bullet = css `
|
|
57
57
|
label: legendItemBullet;
|
|
58
58
|
margin-right: var(--vis-legend-bullet-label-spacing);
|
|
59
|
-
|
|
59
|
+
min-width: var(--vis-legend-bullet-size);
|
|
60
60
|
height: var(--vis-legend-bullet-size);
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
> svg {
|
|
63
|
+
display: block;
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
66
|
`;
|
|
64
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../src/components/bullet-legend/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const root = css`\n label: bullet-legend-component;\n`\n\nexport const variables = injectGlobal`\n :root {\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-legend-font-family: */\n\n --vis-legend-label-color: #6c778c;\n --vis-legend-label-max-width: 300px;\n --vis-legend-label-font-size: 12px;\n --vis-legend-bullet-size: 9px;\n --vis-legend-bullet-inactive-color: #eee;\n --vis-legend-item-spacing: 20px;\n --vis-legend-bullet-label-spacing: 8px;\n\n --vis-dark-legend-label-color: #eee;\n --vis-dark-legend-bullet-inactive-color: #6c778c;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-legend-label-color: var(--vis-dark-legend-label-color);\n --vis-legend-bullet-inactive-color: var(--vis-dark-legend-bullet-inactive-color);\n }\n\n body.theme-patterns {\n --vis-legend-bullet-size: 14px;\n }\n`\n\nexport const item = css`\n label: legendItem;\n display: inline-flex;\n align-items: center;\n font-family: var(--vis-legend-font-family, var(--vis-font-family));\n margin-right: var(--vis-legend-item-spacing);\n white-space: nowrap;\n cursor: default;\n user-select: none;\n`\n\nexport const clickable = css`\n cursor: pointer;\n`\n\nexport const label = css`\n label: legendItemLabel;\n font-size: var(--vis-legend-label-font-size);\n display: inline-block;\n vertical-align: middle;\n color: var(--vis-legend-label-color);\n max-width: var(--vis-legend-label-max-width);\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n`\n\nexport const bullet = css`\n label: legendItemBullet;\n margin-right: var(--vis-legend-bullet-label-spacing);\n
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/bullet-legend/style.ts"],"sourcesContent":["import { css, injectGlobal } from '@emotion/css'\n\nexport const root = css`\n label: bullet-legend-component;\n`\n\nexport const variables = injectGlobal`\n :root {\n // Undefined by default to allow proper fallback to var(--vis-font-family)\n /* --vis-legend-font-family: */\n\n --vis-legend-label-color: #6c778c;\n --vis-legend-label-max-width: 300px;\n --vis-legend-label-font-size: 12px;\n --vis-legend-bullet-size: 9px;\n --vis-legend-bullet-inactive-color: #eee;\n --vis-legend-item-spacing: 20px;\n --vis-legend-bullet-label-spacing: 8px;\n\n --vis-dark-legend-label-color: #eee;\n --vis-dark-legend-bullet-inactive-color: #6c778c;\n }\n\n body.theme-dark ${`.${root}`} {\n --vis-legend-label-color: var(--vis-dark-legend-label-color);\n --vis-legend-bullet-inactive-color: var(--vis-dark-legend-bullet-inactive-color);\n }\n\n body.theme-patterns {\n --vis-legend-bullet-size: 14px;\n }\n`\n\nexport const item = css`\n label: legendItem;\n display: inline-flex;\n align-items: center;\n font-family: var(--vis-legend-font-family, var(--vis-font-family));\n margin-right: var(--vis-legend-item-spacing);\n white-space: nowrap;\n cursor: default;\n user-select: none;\n`\n\nexport const clickable = css`\n cursor: pointer;\n`\n\nexport const label = css`\n label: legendItemLabel;\n font-size: var(--vis-legend-label-font-size);\n display: inline-block;\n vertical-align: middle;\n color: var(--vis-legend-label-color);\n max-width: var(--vis-legend-label-max-width);\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n`\n\nexport const bullet = css`\n label: legendItemBullet;\n margin-right: var(--vis-legend-bullet-label-spacing);\n min-width: var(--vis-legend-bullet-size);\n height: var(--vis-legend-bullet-size);\n\n > svg {\n display: block;\n }\n}\n`\n"],"names":[],"mappings":";;AAEO,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,SAAS,GAAG,YAAY,CAAA,CAAA;;;;;;;;;;;;;;;;;AAiBjB,kBAAA,EAAA,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA,CAAA;;;;;;;;EAQ7B;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;;;;;EAStB;AAEM,MAAM,SAAS,GAAG,GAAG,CAAA,CAAA;;EAE3B;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;EAUvB;AAEM,MAAM,MAAM,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;"}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { SymbolType } from "../../types/symbol";
|
|
2
1
|
export interface BulletLegendItemInterface {
|
|
3
2
|
name: string | number;
|
|
4
3
|
color?: string;
|
|
5
|
-
className?: string;
|
|
6
|
-
shape?: BulletShape;
|
|
7
4
|
inactive?: boolean;
|
|
8
5
|
hidden?: boolean;
|
|
9
6
|
pointer?: boolean;
|
|
10
7
|
}
|
|
11
|
-
export declare
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly Square: SymbolType.Square;
|
|
17
|
-
readonly Star: SymbolType.Star;
|
|
18
|
-
readonly Triangle: SymbolType.Triangle;
|
|
19
|
-
readonly Wye: SymbolType.Wye;
|
|
20
|
-
};
|
|
21
|
-
export declare type BulletShape = typeof BulletShape[keyof typeof BulletShape];
|
|
8
|
+
export declare enum BulletShape {
|
|
9
|
+
Circle = "circle",
|
|
10
|
+
Line = "line",
|
|
11
|
+
Square = "square"
|
|
12
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var BulletShape;
|
|
2
|
+
(function (BulletShape) {
|
|
3
|
+
BulletShape["Circle"] = "circle";
|
|
4
|
+
BulletShape["Line"] = "line";
|
|
5
|
+
BulletShape["Square"] = "square";
|
|
6
|
+
})(BulletShape || (BulletShape = {}));
|
|
5
7
|
|
|
6
8
|
export { BulletShape };
|
|
7
9
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/components/bullet-legend/types.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/components/bullet-legend/types.ts"],"sourcesContent":["export interface BulletLegendItemInterface {\n name: string | number;\n color?: string;\n inactive?: boolean;\n hidden?: boolean;\n pointer?: boolean;\n}\n\nexport enum BulletShape {\n Circle = 'circle',\n Line = 'line',\n Square = 'square',\n}\n"],"names":[],"mappings":"IAQY,YAIX;AAJD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW,GAItB,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -17,6 +17,9 @@ export declare class ChordDiagram<N extends ChordInputNode, L extends ChordInput
|
|
|
17
17
|
labelGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>;
|
|
18
18
|
arcGen: import("d3-shape").Arc<any, ChordNode<N>>;
|
|
19
19
|
radiusScale: ScalePower<number, number>;
|
|
20
|
+
private _nodes;
|
|
21
|
+
private _links;
|
|
22
|
+
private _rootNode;
|
|
20
23
|
events: {
|
|
21
24
|
[x: string]: {
|
|
22
25
|
mouseover: (d: ChordNode<N>) => void;
|
|
@@ -26,9 +29,6 @@ export declare class ChordDiagram<N extends ChordInputNode, L extends ChordInput
|
|
|
26
29
|
mouseout: () => void;
|
|
27
30
|
};
|
|
28
31
|
};
|
|
29
|
-
private _nodes;
|
|
30
|
-
private _links;
|
|
31
|
-
private _rootNode;
|
|
32
32
|
private get _forceHighlight();
|
|
33
33
|
constructor(config?: ChordDiagramConfigInterface<N, L>);
|
|
34
34
|
get bleed(): Spacing;
|
|
@@ -6,7 +6,6 @@ import { ComponentCore } from '../../core/component/index.js';
|
|
|
6
6
|
import { GraphDataModel } from '../../data-models/graph.js';
|
|
7
7
|
import { getValue, getString, getNumber, isNumber } from '../../utils/data.js';
|
|
8
8
|
import { estimateStringPixelLength } from '../../utils/text.js';
|
|
9
|
-
import { getCSSVariableValueInPixels } from '../../utils/misc.js';
|
|
10
9
|
import { ChordLabelAlignment } from './types.js';
|
|
11
10
|
import { ChordDiagramDefaultConfig } from './config.js';
|
|
12
11
|
import { createNode, updateNode, removeNode } from './modules/node.js';
|
|
@@ -24,6 +23,8 @@ class ChordDiagram extends ComponentCore {
|
|
|
24
23
|
this.datamodel = new GraphDataModel();
|
|
25
24
|
this.arcGen = arc();
|
|
26
25
|
this.radiusScale = scalePow();
|
|
26
|
+
this._nodes = [];
|
|
27
|
+
this._links = [];
|
|
27
28
|
this.events = {
|
|
28
29
|
[ChordDiagram.selectors.node]: {
|
|
29
30
|
mouseover: this._onNodeMouseOver.bind(this),
|
|
@@ -38,8 +39,6 @@ class ChordDiagram extends ComponentCore {
|
|
|
38
39
|
mouseout: this._onNodeMouseOut.bind(this),
|
|
39
40
|
},
|
|
40
41
|
};
|
|
41
|
-
this._nodes = [];
|
|
42
|
-
this._links = [];
|
|
43
42
|
if (config)
|
|
44
43
|
this.setConfig(config);
|
|
45
44
|
this.background = this.g.append('rect').attr('class', background);
|
|
@@ -53,7 +52,7 @@ class ChordDiagram extends ComponentCore {
|
|
|
53
52
|
}
|
|
54
53
|
get bleed() {
|
|
55
54
|
const { config } = this;
|
|
56
|
-
const padding = LABEL_PADDING * 2;
|
|
55
|
+
const padding = 4 + LABEL_PADDING * 2;
|
|
57
56
|
let top = 0;
|
|
58
57
|
let bottom = 0;
|
|
59
58
|
let right = 0;
|
|
@@ -62,9 +61,7 @@ class ChordDiagram extends ComponentCore {
|
|
|
62
61
|
var _a;
|
|
63
62
|
const nodeLabelAlignment = getValue(n.data, config.nodeLabelAlignment);
|
|
64
63
|
if (n.height === 0 && nodeLabelAlignment === ChordLabelAlignment.Perpendicular) {
|
|
65
|
-
const
|
|
66
|
-
const fontSize = getCSSVariableValueInPixels('var(--vis-chord-diagram-label-text-font-size)', this.element);
|
|
67
|
-
const labelWidth = estimateStringPixelLength(label, fontSize);
|
|
64
|
+
const labelWidth = estimateStringPixelLength((_a = getString(n.data, config.nodeLabel)) !== null && _a !== void 0 ? _a : '', 16);
|
|
68
65
|
const [x, y] = this.arcGen.centroid(n);
|
|
69
66
|
if (x < 0)
|
|
70
67
|
left = Math.max(left, labelWidth);
|
|
@@ -118,22 +115,18 @@ class ChordDiagram extends ComponentCore {
|
|
|
118
115
|
this._links = getRibbons(partitionData, links, padAngle);
|
|
119
116
|
}
|
|
120
117
|
_render(customDuration) {
|
|
121
|
-
var _a;
|
|
122
118
|
super._render(customDuration);
|
|
123
119
|
const { config, bleed } = this;
|
|
124
120
|
this._layoutData();
|
|
125
121
|
const duration = isNumber(customDuration) ? customDuration : config.duration;
|
|
126
122
|
const size = Math.min(this._width, this._height);
|
|
127
123
|
const radius = size / 2 - max([bleed.top, bleed.bottom, bleed.left, bleed.right]);
|
|
128
|
-
|
|
129
|
-
const maxSpace = config.nodeWidth * numLevels;
|
|
130
|
-
const nodeWidth = radius > maxSpace ? config.nodeWidth : Math.max(radius / numLevels, 0);
|
|
131
|
-
this.radiusScale.range([0, Math.max(radius, 0)]);
|
|
124
|
+
this.radiusScale.range([0, radius - config.nodeWidth]);
|
|
132
125
|
this.arcGen
|
|
133
126
|
.startAngle(d => d.x0 + config.padAngle / 2 - (d.value ? 0 : Math.PI / 360))
|
|
134
127
|
.endAngle(d => d.x1 - config.padAngle / 2 + (d.value ? 0 : Math.PI / 360))
|
|
135
128
|
.cornerRadius(d => getNumber(d.data, config.cornerRadius))
|
|
136
|
-
.innerRadius(d =>
|
|
129
|
+
.innerRadius(d => this.radiusScale(d.y1) - getNumber(d, config.nodeWidth))
|
|
137
130
|
.outerRadius(d => this.radiusScale(d.y1));
|
|
138
131
|
this.g.classed(transparent, this._forceHighlight);
|
|
139
132
|
this.background
|
|
@@ -147,35 +140,33 @@ class ChordDiagram extends ComponentCore {
|
|
|
147
140
|
// Links
|
|
148
141
|
const linksSelection = this.linkGroup
|
|
149
142
|
.selectAll(`.${link}`)
|
|
150
|
-
.data(this._links, d => String(d.data._id))
|
|
151
|
-
const linksEnter = linksSelection.enter().append('path')
|
|
152
|
-
.attr('class', link)
|
|
153
|
-
.call(createLink, this.radiusScale);
|
|
154
|
-
const linksMerged = linksSelection
|
|
155
|
-
.merge(linksEnter)
|
|
143
|
+
.data(this._links, d => String(d.data._id))
|
|
156
144
|
.classed(highlightedLink, l => {
|
|
157
145
|
var _a, _b;
|
|
158
146
|
const linkId = (_a = l.data.id) !== null && _a !== void 0 ? _a : l.data._indexGlobal;
|
|
159
147
|
return (_b = config.highlightedLinkIds) === null || _b === void 0 ? void 0 : _b.includes(linkId);
|
|
160
148
|
});
|
|
149
|
+
const linksEnter = linksSelection.enter().append('path')
|
|
150
|
+
.attr('class', link)
|
|
151
|
+
.call(createLink, this.radiusScale);
|
|
152
|
+
const linksMerged = linksSelection.merge(linksEnter);
|
|
161
153
|
linksMerged.call(updateLink, config, this.radiusScale, duration);
|
|
162
154
|
linksSelection.exit()
|
|
163
155
|
.call(removeLink, duration);
|
|
164
156
|
// Nodes
|
|
165
157
|
const nodesSelection = this.nodeGroup
|
|
166
158
|
.selectAll(`.${node}`)
|
|
167
|
-
.data(this._nodes, d => String(d.uid))
|
|
159
|
+
.data(this._nodes, d => String(d.uid))
|
|
160
|
+
.classed(highlightedNode, d => config.highlightedNodeId === d.data._id);
|
|
168
161
|
const nodesEnter = nodesSelection.enter().append('path')
|
|
169
162
|
.attr('class', node)
|
|
170
163
|
.call(createNode, config);
|
|
171
|
-
const nodesMerged = nodesSelection
|
|
172
|
-
.merge(nodesEnter)
|
|
173
|
-
.classed(highlightedNode, d => config.highlightedNodeId === d.data._id);
|
|
164
|
+
const nodesMerged = nodesSelection.merge(nodesEnter);
|
|
174
165
|
nodesMerged.call(updateNode, config, this.arcGen, duration, this.bleed);
|
|
175
166
|
nodesSelection.exit()
|
|
176
167
|
.call(removeNode, duration);
|
|
177
168
|
// Labels
|
|
178
|
-
const labelWidth = size - radius;
|
|
169
|
+
const labelWidth = size - radius - config.nodeWidth;
|
|
179
170
|
const labels = this.labelGroup
|
|
180
171
|
.selectAll(`.${label}`)
|
|
181
172
|
.data(this._nodes, d => String(d.uid));
|