@unovis/ts 1.6.0-pre.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/area/index.js +2 -1
- package/components/area/index.js.map +1 -1
- package/components/axis/config.d.ts +4 -0
- package/components/axis/config.js +2 -2
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.d.ts +0 -1
- package/components/axis/index.js +51 -19
- package/components/axis/index.js.map +1 -1
- package/components/axis/style.d.ts +40 -1
- package/components/axis/style.js +34 -35
- package/components/axis/style.js.map +1 -1
- package/components/brush/config.d.ts +1 -1
- package/components/brush/config.js.map +1 -1
- package/components/bullet-legend/config.d.ts +2 -0
- package/components/bullet-legend/config.js +1 -0
- package/components/bullet-legend/config.js.map +1 -1
- package/components/bullet-legend/index.js +10 -2
- package/components/bullet-legend/index.js.map +1 -1
- package/components/bullet-legend/modules/shape.d.ts +1 -0
- package/components/bullet-legend/modules/shape.js +61 -41
- package/components/bullet-legend/modules/shape.js.map +1 -1
- package/components/bullet-legend/types.d.ts +1 -1
- package/components/bullet-legend/types.js.map +1 -1
- package/components/crosshair/config.d.ts +20 -7
- package/components/crosshair/config.js +1 -1
- package/components/crosshair/config.js.map +1 -1
- package/components/crosshair/index.d.ts +8 -7
- package/components/crosshair/index.js +144 -72
- package/components/crosshair/index.js.map +1 -1
- package/components/graph/config.d.ts +8 -0
- package/components/graph/config.js +1 -1
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +1 -0
- package/components/graph/index.js +14 -9
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/layout.js +33 -31
- package/components/graph/modules/layout.js.map +1 -1
- package/components/graph/modules/link/index.js +1 -1
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/types.d.ts +2 -1
- package/components/graph/types.js.map +1 -1
- package/components/nested-donut/config.d.ts +1 -1
- package/components/nested-donut/config.js.map +1 -1
- package/components/plotband/config.d.ts +59 -0
- package/components/plotband/config.js +9 -0
- package/components/plotband/config.js.map +1 -0
- package/components/plotband/constants.d.ts +5 -0
- package/components/plotband/constants.js +413 -0
- package/components/plotband/constants.js.map +1 -0
- package/components/plotband/index.d.ts +15 -0
- package/components/plotband/index.js +92 -0
- package/components/plotband/index.js.map +1 -0
- package/components/plotband/style.d.ts +4 -0
- package/components/plotband/style.js +38 -0
- package/components/plotband/style.js.map +1 -0
- package/components/plotband/types.d.ts +51 -0
- package/components/plotband/types.js +27 -0
- package/components/plotband/types.js.map +1 -0
- package/components/plotline/config.d.ts +91 -0
- package/components/plotline/config.js +9 -0
- package/components/plotline/config.js.map +1 -0
- package/components/plotline/constants.d.ts +6 -0
- package/components/plotline/constants.js +58 -0
- package/components/plotline/constants.js.map +1 -0
- package/components/plotline/index.d.ts +14 -0
- package/components/plotline/index.js +102 -0
- package/components/plotline/index.js.map +1 -0
- package/components/plotline/style.d.ts +4 -0
- package/components/plotline/style.js +42 -0
- package/components/plotline/style.js.map +1 -0
- package/components/plotline/types.d.ts +53 -0
- package/components/plotline/types.js +33 -0
- package/components/plotline/types.js.map +1 -0
- package/components/rolling-pin-legend/config.d.ts +19 -0
- package/components/rolling-pin-legend/config.js +11 -0
- package/components/rolling-pin-legend/config.js.map +1 -0
- package/components/rolling-pin-legend/index.d.ts +16 -0
- package/components/rolling-pin-legend/index.js +69 -0
- package/components/rolling-pin-legend/index.js.map +1 -0
- package/components/rolling-pin-legend/style.d.ts +22 -0
- package/components/rolling-pin-legend/style.js +39 -0
- package/components/rolling-pin-legend/style.js.map +1 -0
- package/components/rolling-pin-legend/types.d.ts +1 -0
- package/components/rolling-pin-legend/types.js +2 -0
- package/components/rolling-pin-legend/types.js.map +1 -0
- package/components/scatter/index.d.ts +1 -0
- package/components/scatter/index.js +11 -1
- package/components/scatter/index.js.map +1 -1
- package/components/timeline/config.d.ts +65 -14
- package/components/timeline/config.js +15 -1
- package/components/timeline/config.js.map +1 -1
- package/components/timeline/constants.d.ts +3 -0
- package/components/timeline/constants.js +6 -0
- package/components/timeline/constants.js.map +1 -0
- package/components/timeline/index.d.ts +21 -10
- package/components/timeline/index.js +380 -95
- package/components/timeline/index.js.map +1 -1
- package/components/timeline/style.d.ts +7 -0
- package/components/timeline/style.js +40 -1
- package/components/timeline/style.js.map +1 -1
- package/components/timeline/types.d.ts +62 -0
- package/components/timeline/types.js +2 -0
- package/components/timeline/types.js.map +1 -0
- package/components/timeline/utils.d.ts +2 -0
- package/components/timeline/utils.js +16 -0
- package/components/timeline/utils.js.map +1 -0
- package/components/tooltip/index.js +4 -3
- package/components/tooltip/index.js.map +1 -1
- package/components/treemap/config.d.ts +52 -0
- package/components/treemap/config.js +6 -0
- package/components/treemap/config.js.map +1 -0
- package/components/treemap/index.d.ts +18 -0
- package/components/treemap/index.js +274 -0
- package/components/treemap/index.js.map +1 -0
- package/components/treemap/style.d.ts +25 -0
- package/components/treemap/style.js +69 -0
- package/components/treemap/style.js.map +1 -0
- package/components/treemap/types.d.ts +11 -0
- package/components/treemap/types.js +2 -0
- package/components/treemap/types.js.map +1 -0
- package/components/xy-labels/index.js +1 -1
- package/components/xy-labels/index.js.map +1 -1
- package/components.d.ts +10 -2
- package/components.js +4 -0
- package/components.js.map +1 -1
- package/containers/single-container/index.js +3 -1
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/config.d.ts +2 -0
- package/containers/xy-container/config.js +1 -1
- package/containers/xy-container/config.js.map +1 -1
- package/containers/xy-container/index.js +17 -7
- package/containers/xy-container/index.js.map +1 -1
- package/core/component/index.d.ts +4 -0
- package/core/component/index.js +6 -0
- package/core/component/index.js.map +1 -1
- package/core/xy-component/index.d.ts +1 -0
- package/core/xy-component/index.js +3 -1
- package/core/xy-component/index.js.map +1 -1
- package/data-models/graph.js +7 -1
- package/data-models/graph.js.map +1 -1
- package/index.js +10 -3
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/styles/index.js +1 -0
- package/styles/index.js.map +1 -1
- package/types/data.d.ts +5 -0
- package/types/data.js +7 -0
- package/types/data.js.map +1 -1
- package/types/position.d.ts +2 -1
- package/types/position.js +1 -0
- package/types/position.js.map +1 -1
- package/types/text.d.ts +1 -1
- package/types/text.js.map +1 -1
- package/types.d.ts +5 -0
- package/types.js +6 -1
- package/types.js.map +1 -1
- package/utils/color.d.ts +7 -0
- package/utils/color.js +14 -2
- package/utils/color.js.map +1 -1
- package/utils/data.d.ts +4 -4
- package/utils/data.js +41 -10
- package/utils/data.js.map +1 -1
- package/utils/index.js +3 -3
- package/utils/path.d.ts +8 -0
- package/utils/path.js +109 -1
- package/utils/path.js.map +1 -1
- package/utils/text.d.ts +3 -2
- package/utils/text.js +22 -10
- package/utils/text.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/core/xy-component/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { filterDataByRange, getExtent, isArray } from 'utils/data'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { ContinuousScale, Scale, ScaleDimension } from 'types/scale'\n\n// Config\nimport { XYComponentDefaultConfig, XYComponentConfigInterface } from './config'\n\nexport class XYComponentCore<\n Datum,\n ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>,\n> extends ComponentCore<Datum[], ConfigInterface> {\n public element: SVGGraphicsElement\n public g: Selection<SVGGElement, unknown, null, undefined>\n public config: ConfigInterface\n public prevConfig: ConfigInterface\n public datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n /** Clippable components can be affected by a clipping path (set up in the container) */\n public clippable = true\n\n /** Identifies whether the component displayed stacked data (eg StackedBar, Area) */\n public stacked = false\n\n protected _defaultConfig: ConfigInterface = XYComponentDefaultConfig as ConfigInterface\n\n private _xScale: ContinuousScale = Scale.scaleLinear()\n private _yScale: ContinuousScale = Scale.scaleLinear()\n\n get xScale (): ContinuousScale {\n return this.config.xScale || this._xScale\n }\n\n get yScale (): ContinuousScale {\n return this.config.yScale || this._yScale\n }\n\n setConfig (config: ConfigInterface): void {\n // We don't allow changing scales after the component has been initialized\n if (this.config?.xScale) config.xScale = this.config.xScale\n if (this.config?.yScale) config.yScale = this.config.yScale\n\n super.setConfig(config)\n }\n\n setScaleDomain (dimension: ScaleDimension, domain: number[]): void {\n if (dimension === ScaleDimension.X) this._xScale?.domain(domain)\n if (dimension === ScaleDimension.Y) this._yScale?.domain(domain)\n }\n\n setScaleRange (dimension: ScaleDimension, range: number[]): void {\n if (dimension === ScaleDimension.X) this._xScale?.range(range)\n if (dimension === ScaleDimension.Y) this._yScale?.range(range)\n }\n\n setScale (dimension: ScaleDimension, scale: ContinuousScale): void {\n if (scale && (dimension === ScaleDimension.X)) this._xScale = scale\n if (scale && (dimension === ScaleDimension.Y)) this._yScale = scale\n }\n\n getDataExtent (dimension: ScaleDimension, scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n\n switch (dimension) {\n case ScaleDimension.X: return this.getXDataExtent()\n case ScaleDimension.Y: return this.getYDataExtent(scaleByVisibleData)\n default: return getExtent(datamodel.data, config[dimension])\n }\n }\n\n getXDataExtent (): number[] {\n const { config, datamodel } = this\n return getExtent(datamodel.data, config.x)\n }\n\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n\n const
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/xy-component/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { filterDataByRange, getExtent, isArray } from 'utils/data'\n\n// Types\nimport { NumericAccessor } from 'types/accessor'\nimport { ContinuousScale, Scale, ScaleDimension } from 'types/scale'\n\n// Config\nimport { XYComponentDefaultConfig, XYComponentConfigInterface } from './config'\n\nexport class XYComponentCore<\n Datum,\n ConfigInterface extends Partial<XYComponentConfigInterface<Datum>> = Partial<XYComponentConfigInterface<Datum>>,\n> extends ComponentCore<Datum[], ConfigInterface> {\n public element: SVGGraphicsElement\n public g: Selection<SVGGElement, unknown, null, undefined>\n public config: ConfigInterface\n public prevConfig: ConfigInterface\n public datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n /** Clippable components can be affected by a clipping path (set up in the container) */\n public clippable = true\n\n /** Identifies whether the component displayed stacked data (eg StackedBar, Area) */\n public stacked = false\n\n protected _defaultConfig: ConfigInterface = XYComponentDefaultConfig as ConfigInterface\n\n private _xScale: ContinuousScale = Scale.scaleLinear()\n private _yScale: ContinuousScale = Scale.scaleLinear()\n\n get xScale (): ContinuousScale {\n return this.config.xScale || this._xScale\n }\n\n get yScale (): ContinuousScale {\n return this.config.yScale || this._yScale\n }\n\n setConfig (config: ConfigInterface): void {\n // We don't allow changing scales after the component has been initialized\n if (this.config?.xScale) config.xScale = this.config.xScale\n if (this.config?.yScale) config.yScale = this.config.yScale\n\n super.setConfig(config)\n }\n\n setScaleDomain (dimension: ScaleDimension, domain: number[]): void {\n if (dimension === ScaleDimension.X) this._xScale?.domain(domain)\n if (dimension === ScaleDimension.Y) this._yScale?.domain(domain)\n }\n\n setScaleRange (dimension: ScaleDimension, range: number[]): void {\n if (dimension === ScaleDimension.X) this._xScale?.range(range)\n if (dimension === ScaleDimension.Y) this._yScale?.range(range)\n }\n\n setScale (dimension: ScaleDimension, scale: ContinuousScale): void {\n if (scale && (dimension === ScaleDimension.X)) this._xScale = scale\n if (scale && (dimension === ScaleDimension.Y)) this._yScale = scale\n }\n\n getDataExtent (dimension: ScaleDimension, scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n\n switch (dimension) {\n case ScaleDimension.X: return this.getXDataExtent()\n case ScaleDimension.Y: return this.getYDataExtent(scaleByVisibleData)\n default: return getExtent(datamodel.data, config[dimension])\n }\n }\n\n getXDataExtent (): number[] {\n const { config, datamodel } = this\n return getExtent(datamodel.data, config.x)\n }\n\n /** Some components override this method to provide custom data extent calculation */\n getYDataExtent (scaleByVisibleData: boolean): number[] {\n const { config, datamodel } = this\n\n const xDomain = this.xScale.domain() as [number, number]\n const data = scaleByVisibleData ? filterDataByRange(datamodel.data, xDomain, config.x, true) : datamodel.data\n const yAccessors = (isArray(config.y) ? config.y : [config.y]) as NumericAccessor<Datum>[]\n return getExtent(data, ...yAccessors)\n }\n}\n"],"names":[],"mappings":";;;;;;AAEA;AAcM,MAAO,eAGX,SAAQ,aAAuC,CAAA;AAHjD,IAAA,WAAA,GAAA;;AAQS,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;;QAGzD,IAAS,CAAA,SAAA,GAAG,IAAI,CAAA;;QAGhB,IAAO,CAAA,OAAA,GAAG,KAAK,CAAA;QAEZ,IAAc,CAAA,cAAA,GAAoB,wBAA2C,CAAA;AAE/E,QAAA,IAAA,CAAA,OAAO,GAAoB,KAAK,CAAC,WAAW,EAAE,CAAA;AAC9C,QAAA,IAAA,CAAA,OAAO,GAAoB,KAAK,CAAC,WAAW,EAAE,CAAA;KAyDvD;AAvDC,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAA;KAC1C;AAED,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAA;KAC1C;AAED,IAAA,SAAS,CAAE,MAAuB,EAAA;;;AAEhC,QAAA,IAAI,CAAA,EAAA,GAAA,IAAI,CAAC,MAAM,0CAAE,MAAM;YAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA;AAC3D,QAAA,IAAI,CAAA,EAAA,GAAA,IAAI,CAAC,MAAM,0CAAE,MAAM;YAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA;AAE3D,QAAA,KAAK,CAAC,SAAS,CAAC,MAAM,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QAAA,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;AAElC,QAAA,QAAQ,SAAS;YACf,KAAK,cAAc,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,cAAc,EAAE,CAAA;AACnD,YAAA,KAAK,cAAc,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAA;AACrE,YAAA,SAAS,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7D,SAAA;KACF;IAED,cAAc,GAAA;AACZ,QAAA,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAClC,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;KAC3C;;AAGD,IAAA,cAAc,CAAE,kBAA2B,EAAA;AACzC,QAAA,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAElC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAsB,CAAA;QACxD,MAAM,IAAI,GAAG,kBAAkB,GAAG,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC,IAAI,CAAA;QAC7G,MAAM,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAA6B,CAAA;AAC1F,QAAA,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAA;KACtC;AACF;;;;"}
|
package/data-models/graph.js
CHANGED
|
@@ -72,7 +72,13 @@ class GraphDataModel extends CoreDataModel {
|
|
|
72
72
|
this._nonConnectedNodes = nodes.filter(d => !d._isConnected);
|
|
73
73
|
this._connectedNodes = without(nodes, ...this._nonConnectedNodes);
|
|
74
74
|
this._nodes = nodes;
|
|
75
|
-
this._links = links.filter(l =>
|
|
75
|
+
this._links = links.filter(l => {
|
|
76
|
+
if (l.source === l.target) {
|
|
77
|
+
console.warn(`Unovis | Graph Data Model: Skipping link ${l._id} because it has the same source and target`);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return l.source && l.target;
|
|
81
|
+
});
|
|
76
82
|
}
|
|
77
83
|
get nodes() {
|
|
78
84
|
return this._nodes;
|
package/data-models/graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","sources":["../../src/data-models/graph.ts"],"sourcesContent":["import { isNumber, isUndefined, cloneDeep, isFunction, without, isString, isObject, isEqual } from 'utils/data'\n\n// Types\nimport { GraphInputLink, GraphInputNode, GraphLinkCore, GraphNodeCore } from 'types/graph'\n\n// Core Data Model\nimport { CoreDataModel } from './core'\n\nexport type GraphData<N extends GraphInputNode, L extends GraphInputLink> = {\n nodes: N[];\n links?: L[];\n}\n\nexport class GraphDataModel<\n N extends GraphInputNode,\n L extends GraphInputLink,\n OutNode extends GraphNodeCore<N, L> = GraphNodeCore<N, L>,\n OutLink extends GraphLinkCore<N, L> = GraphLinkCore<N, L>,\n> extends CoreDataModel<GraphData<N, L>> {\n private _nonConnectedNodes: OutNode[]\n private _connectedNodes: OutNode[]\n private _nodes: OutNode[] = []\n private _links: OutLink[] = []\n private _inputNodesMap = new Map<OutNode, N>()\n private _nodesMap = new Map<string | number, OutNode>()\n\n // Model configuration\n public nodeId: ((n: N) => string | undefined) = n => (isString(n.id) || isFinite(n.id as number)) ? `${n.id}` : undefined\n public linkId: ((n: L) => string | undefined) = l => (isString(l.id) || isFinite(l.id as number)) ? `${l.id}` : undefined\n public nodeSort: ((a: N, b: N) => number)\n\n public getNodeById (id: string | number): OutNode {\n return this._nodesMap.get(id)\n }\n\n get data (): GraphData<N, L> {\n return this._data\n }\n\n set data (inputData: GraphData<N, L>) {\n if (!inputData) return\n this._data = inputData\n const prevNodes = this.nodes\n const prevLinks = this.links\n\n this._inputNodesMap.clear()\n this._nodesMap.clear()\n\n // Todo: Figure out why TypeScript complains about types\n const nodes = cloneDeep(inputData?.nodes ?? []) as undefined as OutNode[]\n const links = cloneDeep(inputData?.links ?? []) as undefined as OutLink[]\n\n // Every node or link can have a private state used for rendering needs\n // On data update we transfer state between objects with same ids\n this.transferState(nodes, prevNodes, this.nodeId)\n this.transferState(links, prevLinks, this.linkId)\n\n // Set node `_id` and `_index`\n nodes.forEach((node, i) => {\n node._index = i\n node._id = this.nodeId(node) || `${i}`\n this._inputNodesMap.set(node, inputData.nodes[i])\n this._nodesMap.set(node._id, node)\n })\n\n // Sort nodes\n if (isFunction(this.nodeSort)) nodes.sort(this.nodeSort)\n\n // Fill link source and target\n links.forEach((link, i) => {\n link._indexGlobal = i\n link.source = this.findNode(nodes, link.source)\n link.target = this.findNode(nodes, link.target)\n })\n\n // Set link index for multiple link rendering\n links.forEach((link, i) => {\n if (!isUndefined(link._index) && !isUndefined(link._neighbours)) return\n\n const linksFiltered = links.filter(l =>\n ((link.source === l.source) && (link.target === l.target)) ||\n ((link.source === l.target) && (link.target === l.source))\n )\n\n linksFiltered.forEach((l, i) => {\n l._index = i\n l._id = this.linkId(l) || `${l.source?._id}-${l.target?._id}-${i}`\n l._neighbours = linksFiltered.length\n l._direction = ((link.source === l.source) && (link.target === l.target)) ? 1 : -1\n })\n })\n\n nodes.forEach(d => {\n // Determine if a node is connected or not and store it as a property\n d.links = links.filter(l => (l.source === d) || (l.target === d))\n d._isConnected = d.links.length !== 0\n })\n\n this._nonConnectedNodes = nodes.filter(d => !d._isConnected)\n this._connectedNodes = without(nodes, ...this._nonConnectedNodes)\n\n this._nodes = nodes\n this._links = links.filter(l => l.source && l.target)\n }\n\n get nodes (): OutNode[] {\n return this._nodes\n }\n\n get links (): OutLink[] {\n return this._links\n }\n\n get connectedNodes (): OutNode[] {\n return this._connectedNodes\n }\n\n get nonConnectedNodes (): OutNode[] {\n return this._nonConnectedNodes\n }\n\n private findNode (nodes: OutNode[], nodeIdentifier: number | string | N): OutNode | undefined {\n let foundNode: OutNode | undefined\n\n if (isNumber(nodeIdentifier)) foundNode = nodes[nodeIdentifier as number]\n else if (isString(nodeIdentifier)) foundNode = nodes.find(node => this.nodeId(node) === nodeIdentifier)\n else if (isObject(nodeIdentifier)) foundNode = nodes.find(node => isEqual(this._inputNodesMap.get(node), nodeIdentifier))\n\n if (!foundNode) {\n console.warn(`Unovis | Graph Data Model: Node ${nodeIdentifier} is missing from the nodes list`)\n }\n\n return foundNode\n }\n\n private transferState<T extends { _state: Record<string, any>}> (\n items: T[],\n itemsPrev: T[],\n getId: (d: T) => string\n ): void {\n for (const item of items) {\n const dPrev = itemsPrev.find((dp) => getId(dp) === getId(item))\n if (dPrev) item._state = { ...dPrev._state }\n else item._state = {}\n }\n }\n\n public setNodeStateById (id: string, state: Record<string, any>): void {\n const node = this.getNodeById(id)\n if (!node) {\n console.warn(`Unovis | Graph Data Model: Node ${id} not found`)\n return\n }\n\n node._state = state\n }\n}\n"],"names":[],"mappings":";;;AAaM,MAAO,cAKX,SAAQ,aAA8B,CAAA;AALxC,IAAA,WAAA,GAAA;;QAQU,IAAM,CAAA,MAAA,GAAc,EAAE,CAAA;QACtB,IAAM,CAAA,MAAA,GAAc,EAAE,CAAA;AACtB,QAAA,IAAA,CAAA,cAAc,GAAG,IAAI,GAAG,EAAc,CAAA;AACtC,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAA;;AAGhD,QAAA,IAAA,CAAA,MAAM,GAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAY,CAAC,IAAI,CAAG,EAAA,CAAC,CAAC,EAAE,CAAE,CAAA,GAAG,SAAS,CAAA;AAClH,QAAA,IAAA,CAAA,MAAM,GAAmC,CAAC,IAAI,CAAC,QAAQ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,CAAC,EAAE,cAAc,CAAC,CAAC,CAAA;QAEzH,IAAI,CAAC,SAAS,EAAE;AACd,YAAA,OAAO,CAAC,IAAI,CAAC,mCAAmC,cAAc,CAAA,+BAAA,CAAiC,CAAC,CAAA;AACjG,SAAA;AAED,QAAA,OAAO,SAAS,CAAA;KACjB;AAEO,IAAA,aAAa,CACnB,KAAU,EACV,SAAc,EACd,KAAuB,EAAA;AAEvB,QAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AAC/D,YAAA,IAAI,KAAK;AAAE,gBAAA,IAAI,CAAC,MAAM,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,KAAK,CAAC,MAAM,CAAE,CAAA;;AACvC,gBAAA,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;AACtB,SAAA;KACF;IAEM,gBAAgB,CAAE,EAAU,EAAE,KAA0B,EAAA;QAC7D,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,EAAE;AACT,YAAA,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,CAAA,UAAA,CAAY,CAAC,CAAA;YAC/D,OAAM;AACP,SAAA;AAED,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;KACpB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"graph.js","sources":["../../src/data-models/graph.ts"],"sourcesContent":["import { isNumber, isUndefined, cloneDeep, isFunction, without, isString, isObject, isEqual } from 'utils/data'\n\n// Types\nimport { GraphInputLink, GraphInputNode, GraphLinkCore, GraphNodeCore } from 'types/graph'\n\n// Core Data Model\nimport { CoreDataModel } from './core'\n\nexport type GraphData<N extends GraphInputNode, L extends GraphInputLink> = {\n nodes: N[];\n links?: L[];\n}\n\nexport class GraphDataModel<\n N extends GraphInputNode,\n L extends GraphInputLink,\n OutNode extends GraphNodeCore<N, L> = GraphNodeCore<N, L>,\n OutLink extends GraphLinkCore<N, L> = GraphLinkCore<N, L>,\n> extends CoreDataModel<GraphData<N, L>> {\n private _nonConnectedNodes: OutNode[]\n private _connectedNodes: OutNode[]\n private _nodes: OutNode[] = []\n private _links: OutLink[] = []\n private _inputNodesMap = new Map<OutNode, N>()\n private _nodesMap = new Map<string | number, OutNode>()\n\n // Model configuration\n public nodeId: ((n: N) => string | undefined) = n => (isString(n.id) || isFinite(n.id as number)) ? `${n.id}` : undefined\n public linkId: ((n: L) => string | undefined) = l => (isString(l.id) || isFinite(l.id as number)) ? `${l.id}` : undefined\n public nodeSort: ((a: N, b: N) => number)\n\n public getNodeById (id: string | number): OutNode {\n return this._nodesMap.get(id)\n }\n\n get data (): GraphData<N, L> {\n return this._data\n }\n\n set data (inputData: GraphData<N, L>) {\n if (!inputData) return\n this._data = inputData\n const prevNodes = this.nodes\n const prevLinks = this.links\n\n this._inputNodesMap.clear()\n this._nodesMap.clear()\n\n // Todo: Figure out why TypeScript complains about types\n const nodes = cloneDeep(inputData?.nodes ?? []) as undefined as OutNode[]\n const links = cloneDeep(inputData?.links ?? []) as undefined as OutLink[]\n\n // Every node or link can have a private state used for rendering needs\n // On data update we transfer state between objects with same ids\n this.transferState(nodes, prevNodes, this.nodeId)\n this.transferState(links, prevLinks, this.linkId)\n\n // Set node `_id` and `_index`\n nodes.forEach((node, i) => {\n node._index = i\n node._id = this.nodeId(node) || `${i}`\n this._inputNodesMap.set(node, inputData.nodes[i])\n this._nodesMap.set(node._id, node)\n })\n\n // Sort nodes\n if (isFunction(this.nodeSort)) nodes.sort(this.nodeSort)\n\n // Fill link source and target\n links.forEach((link, i) => {\n link._indexGlobal = i\n link.source = this.findNode(nodes, link.source)\n link.target = this.findNode(nodes, link.target)\n })\n\n // Set link index for multiple link rendering\n links.forEach((link, i) => {\n if (!isUndefined(link._index) && !isUndefined(link._neighbours)) return\n\n const linksFiltered = links.filter(l =>\n ((link.source === l.source) && (link.target === l.target)) ||\n ((link.source === l.target) && (link.target === l.source))\n )\n\n linksFiltered.forEach((l, i) => {\n l._index = i\n l._id = this.linkId(l) || `${l.source?._id}-${l.target?._id}-${i}`\n l._neighbours = linksFiltered.length\n l._direction = ((link.source === l.source) && (link.target === l.target)) ? 1 : -1\n })\n })\n\n nodes.forEach(d => {\n // Determine if a node is connected or not and store it as a property\n d.links = links.filter(l => (l.source === d) || (l.target === d))\n d._isConnected = d.links.length !== 0\n })\n\n this._nonConnectedNodes = nodes.filter(d => !d._isConnected)\n this._connectedNodes = without(nodes, ...this._nonConnectedNodes)\n\n this._nodes = nodes\n\n this._links = links.filter(l => {\n if (l.source === l.target) {\n console.warn(`Unovis | Graph Data Model: Skipping link ${l._id} because it has the same source and target`)\n return false\n }\n\n return l.source && l.target\n })\n }\n\n get nodes (): OutNode[] {\n return this._nodes\n }\n\n get links (): OutLink[] {\n return this._links\n }\n\n get connectedNodes (): OutNode[] {\n return this._connectedNodes\n }\n\n get nonConnectedNodes (): OutNode[] {\n return this._nonConnectedNodes\n }\n\n private findNode (nodes: OutNode[], nodeIdentifier: number | string | N): OutNode | undefined {\n let foundNode: OutNode | undefined\n\n if (isNumber(nodeIdentifier)) foundNode = nodes[nodeIdentifier as number]\n else if (isString(nodeIdentifier)) foundNode = nodes.find(node => this.nodeId(node) === nodeIdentifier)\n else if (isObject(nodeIdentifier)) foundNode = nodes.find(node => isEqual(this._inputNodesMap.get(node), nodeIdentifier))\n\n if (!foundNode) {\n console.warn(`Unovis | Graph Data Model: Node ${nodeIdentifier} is missing from the nodes list`)\n }\n\n return foundNode\n }\n\n private transferState<T extends { _state: Record<string, any>}> (\n items: T[],\n itemsPrev: T[],\n getId: (d: T) => string\n ): void {\n for (const item of items) {\n const dPrev = itemsPrev.find((dp) => getId(dp) === getId(item))\n if (dPrev) item._state = { ...dPrev._state }\n else item._state = {}\n }\n }\n\n public setNodeStateById (id: string, state: Record<string, any>): void {\n const node = this.getNodeById(id)\n if (!node) {\n console.warn(`Unovis | Graph Data Model: Node ${id} not found`)\n return\n }\n\n node._state = state\n }\n}\n"],"names":[],"mappings":";;;AAaM,MAAO,cAKX,SAAQ,aAA8B,CAAA;AALxC,IAAA,WAAA,GAAA;;QAQU,IAAM,CAAA,MAAA,GAAc,EAAE,CAAA;QACtB,IAAM,CAAA,MAAA,GAAc,EAAE,CAAA;AACtB,QAAA,IAAA,CAAA,cAAc,GAAG,IAAI,GAAG,EAAc,CAAA;AACtC,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAA;;AAGhD,QAAA,IAAA,CAAA,MAAM,GAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAY,CAAC,IAAI,CAAG,EAAA,CAAC,CAAC,EAAE,CAAE,CAAA,GAAG,SAAS,CAAA;AAClH,QAAA,IAAA,CAAA,MAAM,GAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAY,CAAC,IAAI,CAAG,EAAA,CAAC,CAAC,EAAE,CAAE,CAAA,GAAG,SAAS,CAAA;KAwI1H;AArIQ,IAAA,WAAW,CAAE,EAAmB,EAAA;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;KAC9B;AAED,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;KAClB;IAED,IAAI,IAAI,CAAE,SAA0B,EAAA;;AAClC,QAAA,IAAI,CAAC,SAAS;YAAE,OAAM;AACtB,QAAA,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;AACtB,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAA;AAC5B,QAAA,MAAM,SAAS,GAAG,IAAI,CA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,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AAC/D,YAAA,IAAI,KAAK;AAAE,gBAAA,IAAI,CAAC,MAAM,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,KAAK,CAAC,MAAM,CAAE,CAAA;;AACvC,gBAAA,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;AACtB,SAAA;KACF;IAEM,gBAAgB,CAAE,EAAU,EAAE,KAA0B,EAAA;QAC7D,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,EAAE;AACT,YAAA,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,CAAA,UAAA,CAAY,CAAC,CAAA;YAC/D,OAAM;AACP,SAAA;AAED,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;KACpB;AACF;;;;"}
|
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export { Axis } from './components/axis/index.js';
|
|
|
18
18
|
export { Scatter } from './components/scatter/index.js';
|
|
19
19
|
export { Brush } from './components/brush/index.js';
|
|
20
20
|
export { BulletLegend } from './components/bullet-legend/index.js';
|
|
21
|
+
export { RollingPinLegend } from './components/rolling-pin-legend/index.js';
|
|
21
22
|
export { FlowLegend } from './components/flow-legend/index.js';
|
|
22
23
|
export { Crosshair } from './components/crosshair/index.js';
|
|
23
24
|
export { Timeline } from './components/timeline/index.js';
|
|
@@ -35,6 +36,9 @@ export { FreeBrush } from './components/free-brush/index.js';
|
|
|
35
36
|
export { XYLabels } from './components/xy-labels/index.js';
|
|
36
37
|
export { NestedDonut } from './components/nested-donut/index.js';
|
|
37
38
|
export { Annotations } from './components/annotations/index.js';
|
|
39
|
+
export { Plotband } from './components/plotband/index.js';
|
|
40
|
+
export { Plotline } from './components/plotline/index.js';
|
|
41
|
+
export { Treemap } from './components/treemap/index.js';
|
|
38
42
|
export { DONUT_HALF_ANGLE_RANGES, DONUT_HALF_ANGLE_RANGE_BOTTOM, DONUT_HALF_ANGLE_RANGE_LEFT, DONUT_HALF_ANGLE_RANGE_RIGHT, DONUT_HALF_ANGLE_RANGE_TOP } from './components/donut/constants.js';
|
|
39
43
|
export { GraphDataModel } from './data-models/graph.js';
|
|
40
44
|
export { MapGraphDataModel } from './data-models/map-graph.js';
|
|
@@ -47,6 +51,7 @@ export { Arrangement, Orientation, Position, PositionStrategy } from './types/po
|
|
|
47
51
|
export { Shape } from './types/shape.js';
|
|
48
52
|
export { ComponentType, Sizing } from './types/component.js';
|
|
49
53
|
export { FitMode, TextAlign, TrimMode, VerticalAlign } from './types/text.js';
|
|
54
|
+
export { FindNearestDirection } from './types/data.js';
|
|
50
55
|
export { Direction } from './types/direction.js';
|
|
51
56
|
export { AxisType } from './components/axis/types.js';
|
|
52
57
|
export { ChordLabelAlignment } from './components/chord-diagram/types.js';
|
|
@@ -59,11 +64,13 @@ export { FreeBrushMode } from './components/free-brush/types.js';
|
|
|
59
64
|
export { BulletLegendOrientation, BulletShape } from './components/bullet-legend/types.js';
|
|
60
65
|
export { XYLabelPositioning } from './components/xy-labels/types.js';
|
|
61
66
|
export { NestedDonutDirection, NestedDonutSegmentLabelAlignment } from './components/nested-donut/types.js';
|
|
67
|
+
export { PlotlineLabelOrientation, PlotlineLabelPosition, PlotlineLineStylePresets } from './components/plotline/types.js';
|
|
68
|
+
export { PlotbandLabelOrientation, PlotbandLabelPosition } from './components/plotband/types.js';
|
|
62
69
|
export { arrayOfIndices, clamp, clean, cloneDeep, countUnique, ensureArray, filterDataByRange, flatten, getBoolean, getExtent, getMax, getMin, getNearest, getNumber, getStackedData, getStackedExtent, getStackedValues, getString, getValue, groupBy, isAClassInstance, isArray, isEmpty, isEqual, isFunction, isNil, isNumber, isNumberWithinRange, isObject, isPlainObject, isString, isUndefined, merge, omit, shallowDiff, sortBy, throttle, unique, without } from './utils/data.js';
|
|
63
|
-
export { allowedSvgTextTags, escapeStringKeepHash, estimateStringPixelLength, estimateTextSize, estimateWrappedTextHeight, getPreciseStringLengthPx, getWrappedText, kebabCase, kebabCaseToCamel, renderTextIntoFrame, renderTextToSvgTextElement, splitString, trimSVGText, trimString, trimStringEnd, trimStringMiddle, trimStringStart, wrapSVGText } from './utils/text.js';
|
|
70
|
+
export { allowedSvgTextTags, escapeStringKeepHash, estimateStringPixelLength, estimateTextSize, estimateWrappedTextHeight, getPreciseStringLengthPx, getWrappedText, kebabCase, kebabCaseToCamel, renderTextIntoFrame, renderTextToSvgTextElement, splitString, textAlignToAnchor, trimSVGText, trimString, trimStringEnd, trimStringMiddle, trimStringStart, wrapSVGText } from './utils/text.js';
|
|
64
71
|
export { allowedSvgTags, getTransformValues, isStringSvg, sanitizeSvgString, transformValuesToString } from './utils/svg.js';
|
|
65
|
-
export { getColor, getHexValue, hexToBrightness, hexToRgb, rgbToBrightness, rgbaToRgb } from './utils/color.js';
|
|
66
|
-
export { circlePath, convertLineToArc, polygon, roundedRectPath, scoreRectPath } from './utils/path.js';
|
|
72
|
+
export { brighter, getColor, getHexValue, hexToBrightness, hexToRgb, rgbToBrightness, rgbaToRgb } from './utils/color.js';
|
|
73
|
+
export { arrowPolylinePath, circlePath, convertLineToArc, polygon, roundedRectPath, scoreRectPath } from './utils/path.js';
|
|
67
74
|
export { getCSSVariableValue, getCSSVariableValueInPixels, getHref, getPixelValue, guid, isStringCSSVariable, parseUnit, rectIntersect, stringToHtmlId } from './utils/misc.js';
|
|
68
75
|
export { DefaultRange } from './utils/scale.js';
|
|
69
76
|
export { smartTransition } from './utils/d3.js';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unovis/ts",
|
|
3
3
|
"description": "Modular data visualization framework for React, Angular, Svelte, Vue, Solid, and vanilla TypeScript or JavaScript",
|
|
4
|
-
"version": "1.6.0
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"packageManager": "npm@10.9.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"d3-geo-projection": "^4.0.0",
|
|
76
76
|
"d3-interpolate-path": "^2.2.3",
|
|
77
77
|
"d3-sankey": "^0.12.3",
|
|
78
|
-
"elkjs": "^0.
|
|
78
|
+
"elkjs": "^0.10.0",
|
|
79
79
|
"geojson": "^0.5.0",
|
|
80
80
|
"leaflet": "1.7.1",
|
|
81
81
|
"maplibre-gl": "^2.1.9",
|
package/styles/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const UNOVIS_FONT_WH_RATIO_DEFAULT = (globalThis === null || globalThis === void
|
|
|
8
8
|
const UNOVIS_TEXT_SEPARATOR_DEFAULT = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.UNOVIS_TEXT_SEPARATOR_DEFAULT) || [' ', '-', '.', ','];
|
|
9
9
|
const UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT) || '-';
|
|
10
10
|
const UNOVIS_TEXT_DEFAULT = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.UNOVIS_TEXT_DEFAULT) || {
|
|
11
|
+
// If you change these defaults, don't forget to update the values in the `UnovisText` type in `types/text.ts`
|
|
11
12
|
text: '',
|
|
12
13
|
fontSize: 12,
|
|
13
14
|
fontFamily: 'var(--vis-font-family)',
|
package/styles/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/styles/index.ts"],"sourcesContent":["import { injectGlobal } from '@emotion/css'\nimport { getCSSVariableValue } from 'utils/misc'\nimport { UnovisText } from 'types/text'\nimport { colors, colorsDark, getCSSColorVariable, getLighterColor, getDarkerColor } from './colors'\nimport { fills, lines, getPatternVariable } from './patterns'\n\nexport const UNOVIS_ICON_FONT_FAMILY_DEFAULT = globalThis?.UNOVIS_ICON_FONT_FAMILY || 'FontAwesome'\nexport const UNOVIS_FONT_WH_RATIO_DEFAULT: number = globalThis?.UNOVIS_FONT_W2H_RATIO_DEFAULT || 0.5\nexport const UNOVIS_TEXT_SEPARATOR_DEFAULT: string[] = globalThis?.UNOVIS_TEXT_SEPARATOR_DEFAULT || [' ', '-', '.', ',']\nexport const UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT: string = globalThis?.UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT || '-'\nexport const UNOVIS_TEXT_DEFAULT: UnovisText = globalThis?.UNOVIS_TEXT_DEFAULT || {\n text: '',\n fontSize: 12,\n fontFamily: 'var(--vis-font-family)',\n lineHeight: 1.25,\n marginTop: 0,\n marginBottom: 0,\n}\n\nexport const variables = injectGlobal`\n :root {\n label: vis-root-styles;\n --vis-font-family: Inter, Arial, \"Helvetica Neue\", Helvetica, sans-serif;\n --vis-font-wh-ratio: ${UNOVIS_FONT_WH_RATIO_DEFAULT};\n --vis-color-main: var(${getCSSColorVariable(0)});\n --vis-color-main-light: ${getLighterColor(colors[0])};\n --vis-color-main-dark: ${getDarkerColor(colors[0])};\n --vis-color-grey: #2a2a2a;\n ${colors.map((c, i) => `${getCSSColorVariable(i)}: ${c};`)}\n ${colorsDark.map((c, i) => `--vis-dark-color${i}: ${c};`)}\n ${fills.map((p, i) => `\n --${getPatternVariable(p)}: url(#${getPatternVariable(p)});\n --vis-pattern-fill${i}: var(--${getPatternVariable(p)});\n `)}\n ${lines.map((p, i) => `\n --${getPatternVariable(p)}: url(#${getPatternVariable(p)});\n --vis-pattern-marker${i}: var(--${getPatternVariable(p)});\n --vis-pattern-dasharray${i}: ${p.dashArray?.join(' ')};\n `)}\n\n body.theme-dark {\n ${colors.map((c, i) => `${getCSSColorVariable(i)}: var(--vis-dark-color${i});`)}\n }\n\n body.theme-patterns {\n ${fills.map((_, i) => `path[style*=\"fill: var(${getCSSColorVariable(i)})\"] {\n mask: var(--vis-pattern-fill${i});\n }`)}\n ${lines.map((_, i) => `\n path[stroke=\"var(${getCSSColorVariable(i)})\"]:not([style*=\"fill\"]),\n path[style*=\"stroke: var(${getCSSColorVariable(i)})\"]:not([style*=\"fill\"]) {\n marker: var(--vis-pattern-marker${i});\n stroke-dasharray: var(--vis-pattern-dasharray${i});\n }\n `)}\n}\n`\n\nexport function getFontWidthToHeightRatio (context: HTMLElement | SVGGElement | undefined = window?.document.body): number {\n return context ? +getCSSVariableValue('var(--vis-font-wh-ratio)', context) : UNOVIS_FONT_WH_RATIO_DEFAULT\n}\n"],"names":[],"mappings":";;;;;AAMO,MAAM,+BAA+B,GAAG,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,uBAAuB,KAAI,cAAa;AAC5F,MAAM,4BAA4B,GAAW,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,6BAA6B,KAAI,IAAG;MACvF,6BAA6B,GAAa,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,6BAA6B,KAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAC;AACjH,MAAM,oCAAoC,GAAW,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,oCAAoC,KAAI,IAAG;AAC5G,MAAM,mBAAmB,GAAe,CAAA,UAAU,KAAV,IAAA,IAAA,UAAU,KAAV,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,UAAU,CAAE,mBAAmB,KAAI
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/styles/index.ts"],"sourcesContent":["import { injectGlobal } from '@emotion/css'\nimport { getCSSVariableValue } from 'utils/misc'\nimport { UnovisText } from 'types/text'\nimport { colors, colorsDark, getCSSColorVariable, getLighterColor, getDarkerColor } from './colors'\nimport { fills, lines, getPatternVariable } from './patterns'\n\nexport const UNOVIS_ICON_FONT_FAMILY_DEFAULT = globalThis?.UNOVIS_ICON_FONT_FAMILY || 'FontAwesome'\nexport const UNOVIS_FONT_WH_RATIO_DEFAULT: number = globalThis?.UNOVIS_FONT_W2H_RATIO_DEFAULT || 0.5\nexport const UNOVIS_TEXT_SEPARATOR_DEFAULT: string[] = globalThis?.UNOVIS_TEXT_SEPARATOR_DEFAULT || [' ', '-', '.', ',']\nexport const UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT: string = globalThis?.UNOVIS_TEXT_HYPHEN_CHARACTER_DEFAULT || '-'\nexport const UNOVIS_TEXT_DEFAULT: UnovisText = globalThis?.UNOVIS_TEXT_DEFAULT || {\n // If you change these defaults, don't forget to update the values in the `UnovisText` type in `types/text.ts`\n text: '',\n fontSize: 12,\n fontFamily: 'var(--vis-font-family)',\n lineHeight: 1.25,\n marginTop: 0,\n marginBottom: 0,\n}\n\nexport const variables = injectGlobal`\n :root {\n label: vis-root-styles;\n --vis-font-family: Inter, Arial, \"Helvetica Neue\", Helvetica, sans-serif;\n --vis-font-wh-ratio: ${UNOVIS_FONT_WH_RATIO_DEFAULT};\n --vis-color-main: var(${getCSSColorVariable(0)});\n --vis-color-main-light: ${getLighterColor(colors[0])};\n --vis-color-main-dark: ${getDarkerColor(colors[0])};\n --vis-color-grey: #2a2a2a;\n ${colors.map((c, i) => `${getCSSColorVariable(i)}: ${c};`)}\n ${colorsDark.map((c, i) => `--vis-dark-color${i}: ${c};`)}\n ${fills.map((p, i) => `\n --${getPatternVariable(p)}: url(#${getPatternVariable(p)});\n --vis-pattern-fill${i}: var(--${getPatternVariable(p)});\n `)}\n ${lines.map((p, i) => `\n --${getPatternVariable(p)}: url(#${getPatternVariable(p)});\n --vis-pattern-marker${i}: var(--${getPatternVariable(p)});\n --vis-pattern-dasharray${i}: ${p.dashArray?.join(' ')};\n `)}\n\n body.theme-dark {\n ${colors.map((c, i) => `${getCSSColorVariable(i)}: var(--vis-dark-color${i});`)}\n }\n\n body.theme-patterns {\n ${fills.map((_, i) => `path[style*=\"fill: var(${getCSSColorVariable(i)})\"] {\n mask: var(--vis-pattern-fill${i});\n }`)}\n ${lines.map((_, i) => `\n path[stroke=\"var(${getCSSColorVariable(i)})\"]:not([style*=\"fill\"]),\n path[style*=\"stroke: var(${getCSSColorVariable(i)})\"]:not([style*=\"fill\"]) {\n marker: var(--vis-pattern-marker${i});\n stroke-dasharray: var(--vis-pattern-dasharray${i});\n }\n `)}\n}\n`\n\nexport function getFontWidthToHeightRatio (context: HTMLElement | SVGGElement | undefined = window?.document.body): number {\n return context ? +getCSSVariableValue('var(--vis-font-wh-ratio)', context) : UNOVIS_FONT_WH_RATIO_DEFAULT\n}\n"],"names":[],"mappings":";;;;;AAMO,MAAM,+BAA+B,GAAG,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,uBAAuB,KAAI,cAAa;AAC5F,MAAM,4BAA4B,GAAW,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,6BAA6B,KAAI,IAAG;MACvF,6BAA6B,GAAa,CAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAV,UAAU,CAAE,6BAA6B,KAAI,CAAC,GAAG,E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OAAO,CAAC,GAAG,4BAA4B,CAAA;AAC3G;;;;"}
|
package/types/data.d.ts
CHANGED
|
@@ -4,3 +4,8 @@ export declare type GenericDataRecord = Record<string, unknown>;
|
|
|
4
4
|
export declare type StackValuesRecord = Array<[number, number]> & {
|
|
5
5
|
isMostlyNegative: boolean;
|
|
6
6
|
};
|
|
7
|
+
export declare enum FindNearestDirection {
|
|
8
|
+
Left = "left",
|
|
9
|
+
Right = "right",
|
|
10
|
+
Auto = "auto"
|
|
11
|
+
}
|
package/types/data.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
var FindNearestDirection;
|
|
2
|
+
(function (FindNearestDirection) {
|
|
3
|
+
FindNearestDirection["Left"] = "left";
|
|
4
|
+
FindNearestDirection["Right"] = "right";
|
|
5
|
+
FindNearestDirection["Auto"] = "auto";
|
|
6
|
+
})(FindNearestDirection || (FindNearestDirection = {}));
|
|
1
7
|
|
|
8
|
+
export { FindNearestDirection };
|
|
2
9
|
//# sourceMappingURL=data.js.map
|
package/types/data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"data.js","sources":["../../src/types/data.ts"],"sourcesContent":["/** The most generic data record: an object with unknown properties */\nexport type GenericDataRecord = Record<string, unknown>\n\n/** Extension of a numbers array that carries additional information required for plotting stacked data */\nexport type StackValuesRecord = Array<[number, number]> & { isMostlyNegative: boolean }\n\nexport enum FindNearestDirection {\n Left = 'left',\n Right = 'right',\n Auto = 'auto',\n}\n"],"names":[],"mappings":"IAMY,qBAIX;AAJD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,oBAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACf,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,GAI/B,EAAA,CAAA,CAAA;;;;"}
|
package/types/position.d.ts
CHANGED
package/types/position.js
CHANGED
package/types/position.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.js","sources":["../../src/types/position.ts"],"sourcesContent":["export enum Position {\n Top = 'top',\n Bottom = 'bottom',\n Left = 'left',\n Right = 'right',\n Center = 'center',\n Auto = 'auto',\n}\n\nexport enum PositionStrategy {\n Absolute = 'absolute',\n Fixed = 'fixed',\n}\n\nexport enum Arrangement {\n Inside = 'inside',\n Outside = 'outside',\n}\n\nexport enum Orientation {\n Horizontal = 'horizontal',\n Vertical = 'vertical',\n}\n"],"names":[],"mappings":"IAAY,SAOX;AAPD,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,QAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,QAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,QAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,QAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACf,CAAC,EAPW,QAAQ,KAAR,QAAQ,GAOnB,EAAA,CAAA,CAAA,CAAA;IAEW,iBAGX;AAHD,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,gBAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,GAG3B,EAAA,CAAA,CAAA,CAAA;IAEW,
|
|
1
|
+
{"version":3,"file":"position.js","sources":["../../src/types/position.ts"],"sourcesContent":["export enum Position {\n Top = 'top',\n Bottom = 'bottom',\n Left = 'left',\n Right = 'right',\n Center = 'center',\n Auto = 'auto',\n}\n\nexport enum PositionStrategy {\n Absolute = 'absolute',\n Fixed = 'fixed',\n}\n\nexport enum Arrangement {\n Inside = 'inside',\n Outside = 'outside',\n Center = 'center',\n}\n\nexport enum Orientation {\n Horizontal = 'horizontal',\n Vertical = 'vertical',\n}\n"],"names":[],"mappings":"IAAY,SAOX;AAPD,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,QAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,QAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,QAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,QAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACf,CAAC,EAPW,QAAQ,KAAR,QAAQ,GAOnB,EAAA,CAAA,CAAA,CAAA;IAEW,iBAGX;AAHD,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,gBAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,GAG3B,EAAA,CAAA,CAAA,CAAA;IAEW,YAIX;AAJD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW,GAItB,EAAA,CAAA,CAAA,CAAA;IAEW,YAGX;AAHD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,YAAA,CAAA,GAAA,YAAyB,CAAA;AACzB,IAAA,WAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EAHW,WAAW,KAAX,WAAW,GAGtB,EAAA,CAAA,CAAA;;;;"}
|
package/types/text.d.ts
CHANGED
package/types/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sources":["../../src/types/text.ts"],"sourcesContent":["export enum TrimMode {\n Start = 'start',\n Middle = 'middle',\n End = 'end',\n}\n\nexport enum VerticalAlign {\n Top = 'top',\n Middle = 'middle',\n Bottom = 'bottom',\n}\n\nexport enum FitMode {\n Wrap = 'wrap',\n Trim = 'trim',\n}\n\nexport enum TextAlign {\n Left = 'left',\n Center = 'center',\n Right = 'right',\n}\n\nexport type UnovisText = {\n // The text content to be displayed.\n text: string;\n // The font size of the text in pixels
|
|
1
|
+
{"version":3,"file":"text.js","sources":["../../src/types/text.ts"],"sourcesContent":["export enum TrimMode {\n Start = 'start',\n Middle = 'middle',\n End = 'end',\n}\n\nexport enum VerticalAlign {\n Top = 'top',\n Middle = 'middle',\n Bottom = 'bottom',\n}\n\nexport enum FitMode {\n Wrap = 'wrap',\n Trim = 'trim',\n}\n\nexport enum TextAlign {\n Left = 'left',\n Center = 'center',\n Right = 'right',\n}\n\nexport type UnovisText = {\n // The text content to be displayed.\n text: string;\n // The font size of the text in pixels (optional). Default: `12`.\n fontSize?: number;\n // The font family of the text (optional). Default: `'var(--vis-font-family)'`.\n fontFamily?: string;\n // The font weight of the text (optional).\n fontWeight?: number;\n // The color of the text (optional).\n color?: string;\n // The line height scaling factor for the text (optional). Default: `1.25`.\n lineHeight?: number;\n // The top margin of the text block in pixels (optional). Default: `0`.\n marginTop?: number;\n // The bottom margin of the text block in pixels (optional). Default: `0`.\n marginBottom?: number;\n // The font width-to-height ratio (optional).\n fontWidthToHeightRatio?: number;\n}\n\nexport type UnovisWrappedText = UnovisText & {\n // An array of text lines, where each element represents a single line of text.\n _lines: string[];\n // Maximum width of any line of text in this text block\n _maxWidth: number;\n // Estimated height of this text block\n _estimatedHeight: number;\n}\n\nexport type UnovisTextOptions = {\n // Optional X coordinates of the text.\n x?: number;\n // Optional Y coordinates of the text.\n y?: number;\n // The maximum width of the text in pixels.\n width?: number;\n // The word separator(s) used to split the text into words.\n separator?: string | string[];\n // The vertical alignment of the text ('top', 'middle', or 'bottom').\n verticalAlign?: VerticalAlign | string;\n // The horizontal text alignment ('left', 'center', or 'right').\n textAlign?: TextAlign | string;\n // Text rotation\n textRotationAngle?: number;\n // Whether to use a fast estimation method or a more accurate one for text calculations.\n fastMode?: boolean;\n // Force word break if they don't fit into the width\n wordBreak?: boolean;\n}\n\nexport type UnovisTextFrameOptions = UnovisTextOptions & {\n height?: number;\n}\n"],"names":[],"mappings":"IAAY,SAIX;AAJD,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,QAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,QAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACb,CAAC,EAJW,QAAQ,KAAR,QAAQ,GAInB,EAAA,CAAA,CAAA,CAAA;IAEW,cAIX;AAJD,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,KAAb,aAAa,GAIxB,EAAA,CAAA,CAAA,CAAA;IAEW,QAGX;AAHD,CAAA,UAAY,OAAO,EAAA;AACjB,IAAA,OAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,OAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACf,CAAC,EAHW,OAAO,KAAP,OAAO,GAGlB,EAAA,CAAA,CAAA,CAAA;IAEW,UAIX;AAJD,CAAA,UAAY,SAAS,EAAA;AACnB,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,SAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACjB,CAAC,EAJW,SAAS,KAAT,SAAS,GAIpB,EAAA,CAAA,CAAA;;;;"}
|
package/types.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export * from "./components/sankey/types";
|
|
|
23
23
|
export * from "./components/vis-controls/types";
|
|
24
24
|
export * from "./components/free-brush/types";
|
|
25
25
|
export * from "./components/bullet-legend/types";
|
|
26
|
+
export * from "./components/rolling-pin-legend/types";
|
|
26
27
|
export * from "./components/xy-labels/types";
|
|
27
28
|
export * from "./components/nested-donut/types";
|
|
28
29
|
export * from "./components/annotations/types";
|
|
30
|
+
export * from "./components/plotline/types";
|
|
31
|
+
export * from "./components/timeline/types";
|
|
32
|
+
export * from "./components/plotband/types";
|
|
33
|
+
export * from "./components/treemap/types";
|
package/types.js
CHANGED
|
@@ -9,7 +9,7 @@ export { FitMode, TextAlign, TrimMode, VerticalAlign } from './types/text.js';
|
|
|
9
9
|
import './types/map.js';
|
|
10
10
|
import './types/spacing.js';
|
|
11
11
|
import './types/graph.js';
|
|
12
|
-
|
|
12
|
+
export { FindNearestDirection } from './types/data.js';
|
|
13
13
|
export { Direction } from './types/direction.js';
|
|
14
14
|
import './core/component/types.js';
|
|
15
15
|
import './components/crosshair/types.js';
|
|
@@ -23,9 +23,14 @@ export { SankeyEnterTransitionType, SankeyExitTransitionType, SankeyLayout, Sank
|
|
|
23
23
|
export { VisControlsOrientation } from './components/vis-controls/types.js';
|
|
24
24
|
export { FreeBrushMode } from './components/free-brush/types.js';
|
|
25
25
|
export { BulletLegendOrientation, BulletShape } from './components/bullet-legend/types.js';
|
|
26
|
+
import './components/rolling-pin-legend/types.js';
|
|
26
27
|
export { XYLabelPositioning } from './components/xy-labels/types.js';
|
|
27
28
|
export { NestedDonutDirection, NestedDonutSegmentLabelAlignment } from './components/nested-donut/types.js';
|
|
28
29
|
import './components/annotations/types.js';
|
|
30
|
+
export { PlotlineLabelOrientation, PlotlineLabelPosition, PlotlineLineStylePresets } from './components/plotline/types.js';
|
|
31
|
+
import './components/timeline/types.js';
|
|
32
|
+
export { PlotbandLabelOrientation, PlotbandLabelPosition } from './components/plotband/types.js';
|
|
33
|
+
import './components/treemap/types.js';
|
|
29
34
|
|
|
30
35
|
/* eslint-disable max-len */
|
|
31
36
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-len */\n// Global Types\nexport * from 'types/accessor'\nexport * from 'types/curve'\nexport * from 'types/symbol'\nexport * from 'types/scale'\nexport * from 'types/position'\nexport * from 'types/shape'\nexport * from 'types/component'\nexport * from 'types/text'\nexport * from 'types/map'\nexport * from 'types/spacing'\nexport * from 'types/graph'\nexport * from 'types/data'\nexport * from 'types/direction'\n\n// Component Types\nexport * from 'core/component/types'\nexport * from 'components/crosshair/types'\nexport * from 'components/axis/types'\nexport * from 'components/chord-diagram/types'\nexport * from 'components/topojson-map/types'\nexport * from 'components/leaflet-map/types'\nexport * from 'components/leaflet-map/renderer/map-style'\nexport * from 'components/graph/types'\nexport * from 'components/sankey/types'\nexport * from 'components/vis-controls/types'\nexport * from 'components/free-brush/types'\nexport * from 'components/bullet-legend/types'\nexport * from 'components/xy-labels/types'\nexport * from 'components/nested-donut/types'\nexport * from 'components/annotations/types'\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-len */\n// Global Types\nexport * from 'types/accessor'\nexport * from 'types/curve'\nexport * from 'types/symbol'\nexport * from 'types/scale'\nexport * from 'types/position'\nexport * from 'types/shape'\nexport * from 'types/component'\nexport * from 'types/text'\nexport * from 'types/map'\nexport * from 'types/spacing'\nexport * from 'types/graph'\nexport * from 'types/data'\nexport * from 'types/direction'\n\n// Component Types\nexport * from 'core/component/types'\nexport * from 'components/crosshair/types'\nexport * from 'components/axis/types'\nexport * from 'components/chord-diagram/types'\nexport * from 'components/topojson-map/types'\nexport * from 'components/leaflet-map/types'\nexport * from 'components/leaflet-map/renderer/map-style'\nexport * from 'components/graph/types'\nexport * from 'components/sankey/types'\nexport * from 'components/vis-controls/types'\nexport * from 'components/free-brush/types'\nexport * from 'components/bullet-legend/types'\nexport * from 'components/rolling-pin-legend/types'\nexport * from 'components/xy-labels/types'\nexport * from 'components/nested-donut/types'\nexport * from 'components/annotations/types'\nexport * from 'components/plotline/types'\nexport * from 'components/timeline/types'\nexport * from 'components/plotband/types'\nexport * from 'components/treemap/types'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
|
package/utils/color.d.ts
CHANGED
|
@@ -11,4 +11,11 @@ export declare function rgbToBrightness(rgb: RGBColor): number;
|
|
|
11
11
|
export declare function hexToBrightness(hex: string): number;
|
|
12
12
|
export declare function getHexValue(s: string, context: HTMLElement | SVGElement): string;
|
|
13
13
|
export declare function rgbaToRgb(rgba: string, backgroundColor?: string): RGBColor;
|
|
14
|
+
/**
|
|
15
|
+
* Makes a color brighter by a certain amount
|
|
16
|
+
* @param inputColor - The color to brighten (hex, rgb, or rgba)
|
|
17
|
+
* @param amount - Amount to brighten by (0-1)
|
|
18
|
+
* @returns The brightened color in hex format
|
|
19
|
+
*/
|
|
20
|
+
export declare function brighter(inputColor: string, amount: number): string;
|
|
14
21
|
export {};
|
package/utils/color.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { color } from 'd3-color';
|
|
1
|
+
import { color, hcl } from 'd3-color';
|
|
2
2
|
import { getCSSColorVariable } from '../styles/colors.js';
|
|
3
3
|
import { getString, isNumber } from './data.js';
|
|
4
4
|
import { isStringCSSVariable, getCSSVariableValue } from './misc.js';
|
|
@@ -42,7 +42,19 @@ function rgbaToRgb(rgba, backgroundColor) {
|
|
|
42
42
|
g: Math.round((rgb.opacity * (rgb.g / 255) + (alpha * (bg.g / 255))) * 255),
|
|
43
43
|
b: Math.round((rgb.opacity * (rgb.b / 255) + (alpha * (bg.b / 255))) * 255),
|
|
44
44
|
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Makes a color brighter by a certain amount
|
|
48
|
+
* @param inputColor - The color to brighten (hex, rgb, or rgba)
|
|
49
|
+
* @param amount - Amount to brighten by (0-1)
|
|
50
|
+
* @returns The brightened color in hex format
|
|
51
|
+
*/
|
|
52
|
+
function brighter(inputColor, amount) {
|
|
53
|
+
const c = hcl(inputColor);
|
|
54
|
+
if (!c)
|
|
55
|
+
return inputColor;
|
|
56
|
+
return c.brighter(amount).formatHex();
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
export { getColor, getHexValue, hexToBrightness, hexToRgb, rgbToBrightness, rgbaToRgb };
|
|
59
|
+
export { brighter, getColor, getHexValue, hexToBrightness, hexToRgb, rgbToBrightness, rgbaToRgb };
|
|
48
60
|
//# sourceMappingURL=color.js.map
|
package/utils/color.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.js","sources":["../../src/utils/color.ts"],"sourcesContent":["import { color } from 'd3-color'\n\n// Core\nimport { getCSSColorVariable } from 'styles/colors'\n\n// Utils\nimport { ColorAccessor, StringAccessor } from 'types/accessor'\nimport { getString, isNumber } from 'utils/data'\nimport { isStringCSSVariable, getCSSVariableValue } from 'utils/misc'\n\ntype RGBColor = { r: number; g: number; b: number }\n\n/** Retrieves color from the data if provided, fallbacks to CSS variables if the index was passed */\nexport function getColor<T> (\n d: T,\n accessor: ColorAccessor<T>,\n index?: number,\n dontFallbackToCssVar?: boolean\n): string | null {\n if (Array.isArray(accessor) && isFinite(index)) return accessor[index % accessor.length]\n\n const value = getString(d, accessor as StringAccessor<T>, index)\n return (value || ((isNumber(index) && !dontFallbackToCssVar) ? `var(${getCSSColorVariable(index)})` : null))\n}\n\nexport function hexToRgb (hex: string): RGBColor {\n const parsed = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n return parsed ? {\n r: parseInt(parsed[1], 16),\n g: parseInt(parsed[2], 16),\n b: parseInt(parsed[3], 16),\n } : { r: 0, g: 0, b: 0 }\n}\n\nexport function rgbToBrightness (rgb: RGBColor): number {\n return (0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b) / 255\n}\n\nexport function hexToBrightness (hex: string): number {\n const rgb = hexToRgb(hex)\n return rgbToBrightness(rgb)\n}\n\nexport function getHexValue (s: string, context: HTMLElement | SVGElement): string {\n const hex = isStringCSSVariable(s) ? getCSSVariableValue(s, context) : s\n return color(hex)?.formatHex()\n}\n\nexport function rgbaToRgb (rgba: string, backgroundColor?: string): RGBColor {\n const rgb = color(rgba)?.rgb()\n if (!rgb || rgb.opacity === 1) return rgb\n const alpha = 1 - rgb.opacity\n const bg = color(backgroundColor ?? '#fff').rgb()\n return {\n r: Math.round((rgb.opacity * (rgb.r / 255) + (alpha * (bg.r / 255))) * 255),\n g: Math.round((rgb.opacity * (rgb.g / 255) + (alpha * (bg.g / 255))) * 255),\n b: Math.round((rgb.opacity * (rgb.b / 255) + (alpha * (bg.b / 255))) * 255),\n }\n}\n"],"names":[],"mappings":";;;;;AAYA;AACM,SAAU,QAAQ,CACtB,CAAI,EACJ,QAA0B,EAC1B,KAAc,EACd,oBAA8B,EAAA;IAE9B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IAExF,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,EAAE,QAA6B,EAAE,KAAK,C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C5E,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"color.js","sources":["../../src/utils/color.ts"],"sourcesContent":["import { color, hcl } from 'd3-color'\n\n// Core\nimport { getCSSColorVariable } from 'styles/colors'\n\n// Utils\nimport { ColorAccessor, StringAccessor } from 'types/accessor'\nimport { getString, isNumber } from 'utils/data'\nimport { isStringCSSVariable, getCSSVariableValue } from 'utils/misc'\n\ntype RGBColor = { r: number; g: number; b: number }\n\n/** Retrieves color from the data if provided, fallbacks to CSS variables if the index was passed */\nexport function getColor<T> (\n d: T,\n accessor: ColorAccessor<T>,\n index?: number,\n dontFallbackToCssVar?: boolean\n): string | null {\n if (Array.isArray(accessor) && isFinite(index)) return accessor[index % accessor.length]\n\n const value = getString(d, accessor as StringAccessor<T>, index)\n return (value || ((isNumber(index) && !dontFallbackToCssVar) ? `var(${getCSSColorVariable(index)})` : null))\n}\n\nexport function hexToRgb (hex: string): RGBColor {\n const parsed = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n return parsed ? {\n r: parseInt(parsed[1], 16),\n g: parseInt(parsed[2], 16),\n b: parseInt(parsed[3], 16),\n } : { r: 0, g: 0, b: 0 }\n}\n\nexport function rgbToBrightness (rgb: RGBColor): number {\n return (0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b) / 255\n}\n\nexport function hexToBrightness (hex: string): number {\n const rgb = hexToRgb(hex)\n return rgbToBrightness(rgb)\n}\n\nexport function getHexValue (s: string, context: HTMLElement | SVGElement): string {\n const hex = isStringCSSVariable(s) ? getCSSVariableValue(s, context) : s\n return color(hex)?.formatHex()\n}\n\nexport function rgbaToRgb (rgba: string, backgroundColor?: string): RGBColor {\n const rgb = color(rgba)?.rgb()\n if (!rgb || rgb.opacity === 1) return rgb\n const alpha = 1 - rgb.opacity\n const bg = color(backgroundColor ?? '#fff').rgb()\n return {\n r: Math.round((rgb.opacity * (rgb.r / 255) + (alpha * (bg.r / 255))) * 255),\n g: Math.round((rgb.opacity * (rgb.g / 255) + (alpha * (bg.g / 255))) * 255),\n b: Math.round((rgb.opacity * (rgb.b / 255) + (alpha * (bg.b / 255))) * 255),\n }\n}\n\n/**\n * Makes a color brighter by a certain amount\n * @param inputColor - The color to brighten (hex, rgb, or rgba)\n * @param amount - Amount to brighten by (0-1)\n * @returns The brightened color in hex format\n */\nexport function brighter (inputColor: string, amount: number): string {\n const c = hcl(inputColor)\n if (!c) return inputColor\n return c.brighter(amount).formatHex()\n}\n"],"names":[],"mappings":";;;;;AAYA;AACM,SAAU,QAAQ,CACtB,CAAI,EACJ,QAA0B,EAC1B,KAAc,EACd,oBAA8B,EAAA;IAE9B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IAExF,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,EAAE,QAA6B,EAAE,KAAK,CAAC,CAAA;AAChE,IAAA,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAO,IAAA,EAAA,mBAAmB,CAAC,KAAK,CAAC,CAAA,CAAA,CAAG,GAAG,IAAI,CAAC,EAAC;AAC9G,CAAC;AAEK,SAAU,QAAQ,CAAE,GAAW,EAAA;IACnC,MAAM,MAAM,GAAG,2CAA2C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpE,OAAO,MAAM,GAAG;QACd,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC1B,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC1B,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC3B,KAAA,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE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AI,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;IACjD,OAAO;AACL,QAAA,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC;AAC3E,QAAA,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC;AAC3E,QAAA,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC;KAC5E,CAAA;AACH,CAAC;AAED;;;;;AAKG;AACa,SAAA,QAAQ,CAAE,UAAkB,EAAE,MAAc,EAAA;AAC1D,IAAA,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAA;AACzB,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,OAAO,UAAU,CAAA;IACzB,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAA;AACvC;;;;"}
|
package/utils/data.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { throttle as _throttle } from 'throttle-debounce';
|
|
2
2
|
import { NumericAccessor, StringAccessor, BooleanAccessor, ColorAccessor, GenericAccessor } from "../types/accessor";
|
|
3
|
-
import { StackValuesRecord } from "../types/data";
|
|
3
|
+
import { FindNearestDirection, StackValuesRecord } from "../types/data";
|
|
4
4
|
export declare const isNumber: <T>(a: T) => a is T extends number ? T : never;
|
|
5
5
|
export declare const isFunction: <T>(a: T) => a is T extends Function ? T : never;
|
|
6
6
|
export declare const isUndefined: <T>(a: T) => a is T extends undefined ? T : never;
|
|
@@ -17,7 +17,7 @@ export declare const flatten: <T>(arr: (T | T[])[]) => T[];
|
|
|
17
17
|
export declare const cloneDeep: <T>(obj: T, stack?: Map<any, any>) => T;
|
|
18
18
|
export declare const merge: <T, K>(obj1: T, obj2: K, visited?: Map<any, any>) => T & K;
|
|
19
19
|
export declare const omit: <T extends Record<string | number | symbol, unknown>>(obj: T, props: (keyof T)[]) => Partial<T>;
|
|
20
|
-
export declare const groupBy: <T extends Record<string | number, any>>(arr: T[], accessor: (a: T) => string | number) => Record<string | number, T[]>;
|
|
20
|
+
export declare const groupBy: <T extends Record<string | number, any>>(arr: T[], accessor: (a: T, index: number) => string | number) => Record<string | number, T[]>;
|
|
21
21
|
export declare const sortBy: <T>(arr: T[], accessor: (a: T) => string | number) => T[];
|
|
22
22
|
export declare const throttle: <T extends (...args: any[]) => any>(f: T, delay: number, options?: {
|
|
23
23
|
noTrailing?: boolean;
|
|
@@ -40,7 +40,7 @@ export declare function getStackedData<Datum>(data: Datum[], baseline: NumericAc
|
|
|
40
40
|
export declare function getMin<Datum>(data: Datum[], ...acs: NumericAccessor<Datum>[]): number | undefined;
|
|
41
41
|
export declare function getMax<Datum>(data: Datum[], ...acs: NumericAccessor<Datum>[]): number | undefined;
|
|
42
42
|
export declare function getExtent<Datum>(data: Datum[], ...acs: NumericAccessor<Datum>[]): (number | undefined)[];
|
|
43
|
-
export declare function getNearest<Datum>(data: Datum[], value: number, accessor: NumericAccessor<Datum
|
|
44
|
-
export declare function filterDataByRange<Datum>(data: Datum[], range: [number, number], accessor: NumericAccessor<Datum
|
|
43
|
+
export declare function getNearest<Datum>(data: Datum[], value: number, accessor: NumericAccessor<Datum>, direction?: FindNearestDirection): Datum;
|
|
44
|
+
export declare function filterDataByRange<Datum>(data: Datum[], range: [number, number], accessor: NumericAccessor<Datum>, includeNeighbors?: boolean): Datum[];
|
|
45
45
|
export declare function isNumberWithinRange(value: number, range: [number, number]): boolean;
|
|
46
46
|
export declare const ensureArray: <T>(value: T | T[]) => T[];
|
package/utils/data.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { mean, min, max,
|
|
1
|
+
import { mean, min, max, bisectLeft, bisectRight } from 'd3-array';
|
|
2
2
|
import { throttle as throttle$1 } from 'throttle-debounce';
|
|
3
|
+
import { FindNearestDirection } from '../types/data.js';
|
|
3
4
|
|
|
4
5
|
const isNumber = (a) => typeof a === 'number';
|
|
5
6
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -122,7 +123,7 @@ const omit = (obj, props) => {
|
|
|
122
123
|
return obj;
|
|
123
124
|
};
|
|
124
125
|
const groupBy = (arr, accessor) => {
|
|
125
|
-
return arr.reduce((grouped, v, i, a, k = accessor(v)) => (((grouped[k] || (grouped[k] = [])).push(v), grouped)), {});
|
|
126
|
+
return arr.reduce((grouped, v, i, a, k = accessor(v, i)) => (((grouped[k] || (grouped[k] = [])).push(v), grouped)), {});
|
|
126
127
|
};
|
|
127
128
|
const sortBy = (arr, accessor) => {
|
|
128
129
|
return arr.concat() // The native sort method modifies the array in place. We use `.concat()` to copy the array first
|
|
@@ -250,24 +251,54 @@ function getMax(data, ...acs) {
|
|
|
250
251
|
function getExtent(data, ...acs) {
|
|
251
252
|
return [getMin(data, ...acs), getMax(data, ...acs)];
|
|
252
253
|
}
|
|
253
|
-
function getNearest(data, value, accessor) {
|
|
254
|
+
function getNearest(data, value, accessor, direction = FindNearestDirection.Auto) {
|
|
254
255
|
if (data.length <= 1)
|
|
255
256
|
return data[0];
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
257
|
+
const dataWithIndex = data.map((d, i) => ([d, i]));
|
|
258
|
+
const dataWithIndexSorted = dataWithIndex
|
|
259
|
+
.sort(([a, i], [b, j]) => getNumber(a, accessor, i) - getNumber(b, accessor, j));
|
|
260
|
+
const values = dataWithIndexSorted.map(([d, i]) => getNumber(d, accessor, i));
|
|
261
|
+
const index = direction === FindNearestDirection.Right
|
|
262
|
+
? bisectLeft(values, value, 0, data.length - 1)
|
|
263
|
+
: bisectRight(values, value, 1, data.length);
|
|
264
|
+
if (direction === FindNearestDirection.Right) {
|
|
265
|
+
return dataWithIndexSorted[index][0];
|
|
266
|
+
}
|
|
267
|
+
else if (direction === FindNearestDirection.Left) {
|
|
268
|
+
return dataWithIndexSorted[index - 1][0];
|
|
269
|
+
}
|
|
270
|
+
// By default (`FindNearestDirection.Auto`) return the nearest value
|
|
271
|
+
return value - values[index - 1] > values[index] - value ? dataWithIndexSorted[index][0] : dataWithIndexSorted[index - 1][0];
|
|
261
272
|
}
|
|
262
|
-
function filterDataByRange(data, range, accessor) {
|
|
273
|
+
function filterDataByRange(data, range, accessor, includeNeighbors = false) {
|
|
274
|
+
if (!accessor)
|
|
275
|
+
return [];
|
|
263
276
|
const filteredData = data.filter((d, i) => {
|
|
264
277
|
const value = getNumber(d, accessor, i);
|
|
265
278
|
return (value >= range[0]) && (value <= range[1]);
|
|
266
279
|
});
|
|
280
|
+
if (includeNeighbors) {
|
|
281
|
+
// If `filteredData` is empty and `includeNeighbors` is true, try to find nearest points
|
|
282
|
+
if (filteredData.length === 0) {
|
|
283
|
+
const nearestLeft = getNearest(data, range[0], accessor, FindNearestDirection.Left);
|
|
284
|
+
const nearestRight = getNearest(data, range[1], accessor, FindNearestDirection.Right);
|
|
285
|
+
return [nearestLeft, nearestRight].filter(Boolean);
|
|
286
|
+
}
|
|
287
|
+
// Find indices of first and last filtered points in original data
|
|
288
|
+
const firstFilteredItem = filteredData[0];
|
|
289
|
+
const lastFilteredItem = filteredData[filteredData.length - 1];
|
|
290
|
+
const firstFilteredIndex = data.findIndex((d) => d === firstFilteredItem);
|
|
291
|
+
const lastFilteredIndex = data.findIndex((d) => d === lastFilteredItem);
|
|
292
|
+
// Include neighbors (if they exist)
|
|
293
|
+
const startIndex = Math.max(0, firstFilteredIndex - 1);
|
|
294
|
+
const endIndex = Math.min(data.length - 1, lastFilteredIndex + 1);
|
|
295
|
+
// Return data from startIndex to endIndex (inclusive)
|
|
296
|
+
return data.slice(startIndex, endIndex + 1);
|
|
297
|
+
}
|
|
267
298
|
return filteredData;
|
|
268
299
|
}
|
|
269
300
|
function isNumberWithinRange(value, range) {
|
|
270
|
-
return (value >= range[0]
|
|
301
|
+
return (value >= range[0] && value <= range[1]) || (value >= range[1] && value <= range[0]);
|
|
271
302
|
}
|
|
272
303
|
const ensureArray = (value) => {
|
|
273
304
|
if (value === null || value === undefined) {
|