@carbon/charts 0.40.13 → 0.40.14
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/CHANGELOG.md +11 -0
- package/build/src/tools.d.ts +1 -0
- package/bundle.js +1 -1
- package/components/axes/zoom-bar.js +1 -2
- package/components/axes/zoom-bar.js.map +1 -1
- package/demo/tsconfig.tsbuildinfo +2 -2
- package/package.json +1 -1
- package/tools.d.ts +1 -0
- package/tools.js +2 -1
- package/tools.js.map +1 -1
- package/tsconfig.tsbuildinfo +3 -584
|
@@ -17,7 +17,6 @@ import { Tools } from "../../tools";
|
|
|
17
17
|
import { AxisPositions, Events, ScaleTypes, ZoomBarTypes } from "../../interfaces";
|
|
18
18
|
import { DOMUtils } from "../../services";
|
|
19
19
|
import * as Configuration from "../../configuration";
|
|
20
|
-
import isEmpty from "lodash/isEmpty";
|
|
21
20
|
// D3 Imports
|
|
22
21
|
import { extent } from "d3-array";
|
|
23
22
|
import { brushX } from "d3-brush";
|
|
@@ -101,7 +100,7 @@ var ZoomBar = /** @class */ (function (_super) {
|
|
|
101
100
|
var mainXScaleType = cartesianScales.getMainXScaleType();
|
|
102
101
|
if (mainXScale && mainXScaleType === ScaleTypes.TIME) {
|
|
103
102
|
var zoomBarData = this.services.zoom.getZoomBarData();
|
|
104
|
-
if (isEmpty(zoomBarData)) {
|
|
103
|
+
if (Tools.isEmpty(zoomBarData)) {
|
|
105
104
|
// if there's no zoom bar data we can't do anything
|
|
106
105
|
return;
|
|
107
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoom-bar.js","sourceRoot":"","sources":["zoom-bar.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACN,aAAa,EACb,MAAM,EACN,UAAU,EACV,YAA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AAC,gBAAgB,CAAC,CAAC,EAC5D;YACD,IAAM,QAAQ,GAAG,EAAE,CAAC;YACpB,QAAQ,CAAC,gBAAgB,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YAC9C,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC9B,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC3B;QACD,OAAO,WAAW,CAAC;IACpB,CAAC;IAED,yBAAO,GAAP;QACC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,wBAAwB;QAChE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CACvC,MAAM,CAAC,OAAO,CAAC,MAAM,EACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CACtB,CAAC;IACH,CAAC;IACF,cAAC;AAAD,CAAC,AApjBD,CAA6B,SAAS,GAojBrC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { ChartModelCartesian } from \"../../model-cartesian-charts\";\nimport { Tools } from \"../../tools\";\nimport {\n\tAxisPositions,\n\tEvents,\n\tScaleTypes,\n\tZoomBarTypes\n} from \"../../interfaces\";\nimport { DOMUtils } from \"../../services\";\nimport * as Configuration from \"../../configuration\";\nimport isEmpty from \"lodash/isEmpty\";\n\n// D3 Imports\nimport { extent } from \"d3-array\";\nimport { brushX } from \"d3-brush\";\nimport { area, line } from \"d3-shape\";\nimport { event } from \"d3-selection\";\n\nexport class ZoomBar extends Component {\n\tprotected model: ChartModelCartesian;\n\ttype = \"zoom-bar\";\n\n\t// The minimum selection x range to trigger handler update\n\t// Smaller number may introduce a handler flash during initialization\n\t// Bigger number may not trigger handler update while selection area on chart is very small\n\tMIN_SELECTION_DIFF = 9e-10;\n\n\t// needs to match the style in _zoom-bar.scss\n\tbrushSelector = \"g.zoom-bar-brush\";\n\n\t// The max allowed selection range, will be updated soon in render()\n\tmaxSelectionRange: [0, 0];\n\n\t// Give every zoomBarClip a distinct ID\n\t// so they don't interfere the other zoom bars in a page\n\tclipId = \"zoomBarClip-\" + Math.floor(Math.random() * 99999999999);\n\n\tbrush = brushX();\n\txScale: any;\n\tyScale: any;\n\n\tinit() {\n\t\tthis.services.events.addEventListener(\n\t\t\tEvents.ZoomBar.UPDATE,\n\t\t\tthis.render.bind(this)\n\t\t);\n\t\t// check if pre-defined zoom bar data exists\n\t\tconst definedZoomBarData = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"data\"\n\t\t);\n\n\t\t// load up the zoomBarData into this model\n\t\tthis.model.setZoomBarData(definedZoomBarData);\n\t}\n\n\trender(animate = true) {\n\t\tconst svg = this.getContainerSVG();\n\n\t\tconst isTopZoomBarLoading = this.services.zoom.isZoomBarLoading(\n\t\t\tAxisPositions.TOP\n\t\t);\n\t\tconst isTopZoomBarLocked = this.services.zoom.isZoomBarLocked(\n\t\t\tAxisPositions.TOP\n\t\t);\n\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\n\t\tconst zoombarHeight = Configuration.zoomBar.height[zoombarType];\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(this.parent, {\n\t\t\tuseAttrs: true\n\t\t});\n\n\t\t// get axes margins\n\t\tlet axesLeftMargin = 0;\n\t\tconst axesMargins = this.model.get(\"axesMargins\");\n\t\tif (axesMargins && axesMargins.left) {\n\t\t\taxesLeftMargin = axesMargins.left;\n\t\t}\n\n\t\tconst container = DOMUtils.appendOrSelect(svg, \"svg.zoom-container\")\n\t\t\t.attr(\"width\", \"100%\")\n\t\t\t.attr(\"height\", zoombarHeight)\n\t\t\t.attr(\"opacity\", 1);\n\n\t\tconst spacer = DOMUtils.appendOrSelect(svg, \"rect.zoom-spacer\")\n\t\t\t.attr(\"x\", 0)\n\t\t\t.attr(\"y\", zoombarHeight)\n\t\t\t.attr(\"width\", \"100%\")\n\t\t\t.attr(\"height\", Configuration.zoomBar.spacerHeight)\n\t\t\t.attr(\"opacity\", 1)\n\t\t\t.attr(\"fill\", \"none\");\n\n\t\tif (zoombarType === ZoomBarTypes.GRAPH_VIEW) {\n\t\t\t// Draw zoombar background rectangle\n\t\t\tDOMUtils.appendOrSelect(container, \"rect.zoom-bg\")\n\t\t\t\t.attr(\"x\", axesLeftMargin)\n\t\t\t\t.attr(\"y\", 0)\n\t\t\t\t.attr(\"width\", width - axesLeftMargin)\n\t\t\t\t.attr(\"height\", \"100%\");\n\t\t} else if (zoombarType === ZoomBarTypes.SLIDER_VIEW) {\n\t\t\t// Draw zoombar background line\n\t\t\tDOMUtils.appendOrSelect(container, \"rect.zoom-slider-bg\")\n\t\t\t\t.attr(\"x\", axesLeftMargin)\n\t\t\t\t.attr(\"y\", zoombarHeight / 2 - 1)\n\t\t\t\t.attr(\"width\", width - axesLeftMargin)\n\t\t\t\t.attr(\"height\", 2);\n\t\t}\n\n\t\tif (isTopZoomBarLoading) {\n\t\t\t// TODO - zoom bar skeleton could be improved in the future\n\t\t\treturn;\n\t\t}\n\n\t\tconst { cartesianScales } = this.services;\n\t\tconst mainXScale = cartesianScales.getMainXScale();\n\t\tconst mainYScale = cartesianScales.getMainYScale();\n\t\tconst mainXScaleType = cartesianScales.getMainXScaleType();\n\n\t\tif (mainXScale && mainXScaleType === ScaleTypes.TIME) {\n\t\t\tlet zoomBarData = this.services.zoom.getZoomBarData();\n\t\t\tif (isEmpty(zoomBarData)) {\n\t\t\t\t// if there's no zoom bar data we can't do anything\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.xScale = mainXScale.copy();\n\t\t\tthis.yScale = mainYScale.copy();\n\n\t\t\tconst defaultDomain = this.services.zoom.getDefaultZoomBarDomain(\n\t\t\t\tzoomBarData\n\t\t\t);\n\n\t\t\t// add value 0 to the extended domain for zoom bar area graph\n\t\t\tzoomBarData = this.compensateDataForDefaultDomain(\n\t\t\t\tzoomBarData,\n\t\t\t\tdefaultDomain\n\t\t\t);\n\n\t\t\t// get old initialZoomDomain from model\n\t\t\tconst oldInitialZoomDomain = this.model.get(\"initialZoomDomain\");\n\t\t\t// get new initialZoomDomain from option\n\t\t\tconst newInitialZoomDomain = Tools.getProperty(\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\"zoomBar\",\n\t\t\t\tAxisPositions.TOP,\n\t\t\t\t\"initialZoomDomain\"\n\t\t\t);\n\t\t\t// change string date to Date object if necessary\n\t\t\tif (\n\t\t\t\tnewInitialZoomDomain &&\n\t\t\t\tnewInitialZoomDomain[0] &&\n\t\t\t\tnewInitialZoomDomain[1]\n\t\t\t) {\n\t\t\t\tnewInitialZoomDomain[0] = new Date(newInitialZoomDomain[0]);\n\t\t\t\tnewInitialZoomDomain[1] = new Date(newInitialZoomDomain[1]);\n\t\t\t}\n\t\t\t// update initialZoomDomain and set zoomDomain in model only if the option is changed\n\t\t\t// not the same object, and both start date and end date are not equal\n\t\t\tif (\n\t\t\t\t!(\n\t\t\t\t\toldInitialZoomDomain === newInitialZoomDomain ||\n\t\t\t\t\t(oldInitialZoomDomain &&\n\t\t\t\t\t\tnewInitialZoomDomain &&\n\t\t\t\t\t\toldInitialZoomDomain[0].valueOf() ===\n\t\t\t\t\t\t\tnewInitialZoomDomain[0].valueOf() &&\n\t\t\t\t\t\toldInitialZoomDomain[1].valueOf() ===\n\t\t\t\t\t\t\tnewInitialZoomDomain[1].valueOf())\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthis.model.set(\n\t\t\t\t\t{\n\t\t\t\t\t\tinitialZoomDomain: newInitialZoomDomain,\n\t\t\t\t\t\tzoomDomain: newInitialZoomDomain\n\t\t\t\t\t\t\t? newInitialZoomDomain\n\t\t\t\t\t\t\t: defaultDomain\n\t\t\t\t\t},\n\t\t\t\t\t{ skipUpdate: true }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.xScale.range([axesLeftMargin, width]).domain(defaultDomain);\n\n\t\t\t// keep max selection range\n\t\t\tthis.maxSelectionRange = this.xScale.range();\n\n\t\t\tthis.yScale\n\t\t\t\t.range([0, zoombarHeight - 6])\n\t\t\t\t.domain(extent(zoomBarData, (d: any) => d.value));\n\n\t\t\tconst zoomDomain = this.model.get(\"zoomDomain\");\n\n\t\t\tif (zoombarType === ZoomBarTypes.GRAPH_VIEW) {\n\t\t\t\tthis.renderZoomBarArea(\n\t\t\t\t\tcontainer,\n\t\t\t\t\t\"path.zoom-graph-area-unselected\",\n\t\t\t\t\tzoomBarData,\n\t\t\t\t\tnull\n\t\t\t\t);\n\t\t\t\tthis.updateClipPath(svg, this.clipId, 0, 0, 0, 0);\n\t\t\t\tthis.renderZoomBarArea(\n\t\t\t\t\tcontainer,\n\t\t\t\t\t\"path.zoom-graph-area\",\n\t\t\t\t\tzoomBarData,\n\t\t\t\t\tthis.clipId\n\t\t\t\t);\n\n\t\t\t\t// Draw the zoom base line\n\t\t\t\tconst baselineGenerator = line()([\n\t\t\t\t\t[axesLeftMargin, zoombarHeight],\n\t\t\t\t\t[width, zoombarHeight]\n\t\t\t\t]);\n\t\t\t\tconst zoomBaseline = DOMUtils.appendOrSelect(\n\t\t\t\t\tcontainer,\n\t\t\t\t\t\"path.zoom-bg-baseline\"\n\t\t\t\t).attr(\"d\", baselineGenerator);\n\t\t\t}\n\n\t\t\t// Attach brushing event listeners\n\t\t\tthis.addBrushEventListener(zoomDomain, axesLeftMargin, width);\n\n\t\t\t// Draw the brushing area\n\t\t\tconst brushArea = DOMUtils.appendOrSelect(\n\t\t\t\tsvg,\n\t\t\t\tthis.brushSelector\n\t\t\t).call(this.brush);\n\n\t\t\tif (zoomDomain === undefined) {\n\t\t\t\t// do nothing, initialization not completed yet\n\t\t\t\t// don't update brushHandle to avoid flash\n\t\t\t} else if (zoomDomain[0].valueOf() === zoomDomain[1].valueOf()) {\n\t\t\t\tbrushArea.call(this.brush.move, this.xScale.range()); // default to full range\n\t\t\t\tthis.updateBrushHandle(\n\t\t\t\t\tthis.getContainerSVG(),\n\t\t\t\t\tthis.xScale.range(),\n\t\t\t\t\tthis.xScale.domain()\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst selected = zoomDomain.map((domain) =>\n\t\t\t\t\tthis.xScale(domain)\n\t\t\t\t);\n\t\t\t\tif (selected[1] - selected[0] < this.MIN_SELECTION_DIFF) {\n\t\t\t\t\t// initialization not completed yet\n\t\t\t\t\t// don't update brushHandle to avoid flash\n\t\t\t\t} else {\n\t\t\t\t\tbrushArea.call(this.brush.move, selected); // set brush to correct position\n\t\t\t\t\tthis.updateBrushHandle(\n\t\t\t\t\t\tthis.getContainerSVG(),\n\t\t\t\t\t\tselected,\n\t\t\t\t\t\tzoomDomain\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isTopZoomBarLocked) {\n\t\t\t\tthis.brush.filter(() => {\n\t\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t\t// reset all cursor to auto\n\t\t\t\tbrushArea.selectAll(\"rect\").attr(\"cursor\", \"auto\");\n\t\t\t}\n\t\t}\n\t}\n\n\taddBrushEventListener(zoomDomain, axesLeftMargin, width) {\n\t\tconst brushEventListener = () => {\n\t\t\tconst selection = event.selection;\n\t\t\t// follow d3 behavior: when selection is null, reset default full range\n\t\t\t// select behavior is completed, but nothing selected\n\t\t\tif (selection === null) {\n\t\t\t\tthis.handleBrushedEvent(\n\t\t\t\t\tzoomDomain,\n\t\t\t\t\tthis.xScale,\n\t\t\t\t\tthis.xScale.range()\n\t\t\t\t);\n\t\t\t} else if (selection[0] === selection[1]) {\n\t\t\t\t// select behavior is not completed yet, do nothing\n\t\t\t} else {\n\t\t\t\tthis.handleBrushedEvent(zoomDomain, this.xScale, selection);\n\t\t\t}\n\t\t};\n\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\t\tconst zoombarHeight = Configuration.zoomBar.height[zoombarType];\n\n\t\t// Initialize the d3 brush\n\t\tthis.brush\n\t\t\t.extent([\n\t\t\t\t[axesLeftMargin, 0],\n\t\t\t\t[width, zoombarHeight]\n\t\t\t])\n\t\t\t.on(\"start brush end\", null) // remove old listener first\n\t\t\t.on(\"start brush end\", brushEventListener);\n\t}\n\n\t// brush event listener\n\thandleBrushedEvent(zoomDomain, scale, selection) {\n\t\tconst newDomain = [\n\t\t\tscale.invert(selection[0]),\n\t\t\tscale.invert(selection[1])\n\t\t];\n\n\t\t// update brush handle position\n\t\tthis.updateBrushHandle(this.getContainerSVG(), selection, newDomain);\n\n\t\t// be aware that the value of d3.event changes during an event!\n\t\t// update zoomDomain only if the event comes from mouse/touch event\n\t\tif (\n\t\t\tevent.sourceEvent != null &&\n\t\t\t(event.sourceEvent.type === \"mousemove\" ||\n\t\t\t\tevent.sourceEvent.type === \"mouseup\" ||\n\t\t\t\tevent.sourceEvent.type === \"mousedown\" ||\n\t\t\t\tevent.sourceEvent.type === \"touchstart\" ||\n\t\t\t\tevent.sourceEvent.type === \"touchmove\" ||\n\t\t\t\tevent.sourceEvent.type === \"touchend\")\n\t\t) {\n\t\t\t// only if zoomDomain is never set or needs update\n\t\t\tif (\n\t\t\t\tzoomDomain === undefined ||\n\t\t\t\tzoomDomain[0] !== newDomain[0] ||\n\t\t\t\tzoomDomain[1] !== newDomain[1]\n\t\t\t) {\n\t\t\t\t// don't dispatch event for all event types\n\t\t\t\t// let the following code to dispatch necessary events\n\t\t\t\tthis.services.zoom.handleDomainChange(newDomain, {\n\t\t\t\t\tdispatchEvent: false\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// dispatch selection events\n\t\t\tlet zoomBarEventType;\n\t\t\tif (event.type === \"start\") {\n\t\t\t\tzoomBarEventType = Events.ZoomBar.SELECTION_START;\n\t\t\t} else if (event.type === \"brush\") {\n\t\t\t\tzoomBarEventType = Events.ZoomBar.SELECTION_IN_PROGRESS;\n\t\t\t} else if (event.type === \"end\") {\n\t\t\t\tzoomBarEventType = Events.ZoomBar.SELECTION_END;\n\t\t\t}\n\t\t\tthis.services.events.dispatchEvent(zoomBarEventType, {\n\t\t\t\tselection,\n\t\t\t\tnewDomain\n\t\t\t});\n\t\t}\n\t}\n\n\tupdateBrushHandle(svg, selection, domain) {\n\t\tconst self = this;\n\t\tconst handleWidth = Configuration.zoomBar.handleWidth;\n\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\t\tconst handleHeight = Configuration.zoomBar.height[zoombarType];\n\t\tconst handleXDiff = -handleWidth / 2;\n\n\t\tconst handleBarWidth = Configuration.zoomBar.handleBarWidth;\n\t\tconst handleBarHeight =\n\t\t\tzoombarType === ZoomBarTypes.GRAPH_VIEW\n\t\t\t\t? Configuration.zoomBar.handleBarHeight\n\t\t\t\t: 6;\n\t\tconst handleBarXDiff = -handleBarWidth / 2;\n\t\tconst handleYBarDiff = (handleHeight - handleBarHeight) / 2;\n\n\t\t// handle\n\t\tsvg.select(this.brushSelector)\n\t\t\t.selectAll(\"rect.handle\")\n\t\t\t.data([{ type: \"w\" }, { type: \"e\" }])\n\t\t\t.attr(\"x\", function (d) {\n\t\t\t\tif (d.type === \"w\") {\n\t\t\t\t\t// handle should not exceed zoom bar range\n\t\t\t\t\treturn Math.max(\n\t\t\t\t\t\tselection[0] + handleXDiff,\n\t\t\t\t\t\tself.maxSelectionRange[0]\n\t\t\t\t\t);\n\t\t\t\t} else if (d.type === \"e\") {\n\t\t\t\t\t// handle should not exceed zoom bar range\n\t\t\t\t\treturn Math.min(\n\t\t\t\t\t\tselection[1] + handleXDiff,\n\t\t\t\t\t\tself.maxSelectionRange[1] - handleWidth\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.attr(\"y\", 0)\n\t\t\t.attr(\"width\", handleWidth)\n\t\t\t.attr(\"height\", handleHeight)\n\t\t\t.attr(\"cursor\", \"ew-resize\")\n\t\t\t.style(\"display\", null); // always display\n\n\t\t// handle-bar\n\t\tconst handleBars = svg\n\t\t\t.select(this.brushSelector)\n\t\t\t.selectAll(\"rect.handle-bar\")\n\t\t\t.data([{ type: \"w\" }, { type: \"e\" }]);\n\t\t// create rect if not exists\n\t\thandleBars\n\t\t\t.enter()\n\t\t\t.append(\"rect\")\n\t\t\t.attr(\"class\", function (d) {\n\t\t\t\treturn \"handle-bar handle-bar--\" + d.type;\n\t\t\t});\n\t\t// update positions\n\t\thandleBars\n\t\t\t.attr(\"x\", function (d) {\n\t\t\t\tif (d.type === \"w\") {\n\t\t\t\t\treturn Math.max(\n\t\t\t\t\t\tselection[0] + handleBarXDiff,\n\t\t\t\t\t\tself.maxSelectionRange[0] - handleXDiff + handleBarXDiff\n\t\t\t\t\t);\n\t\t\t\t} else if (d.type === \"e\") {\n\t\t\t\t\treturn Math.min(\n\t\t\t\t\t\tselection[1] + handleBarXDiff,\n\t\t\t\t\t\tself.maxSelectionRange[1] + handleXDiff + handleBarXDiff\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.attr(\"y\", handleYBarDiff)\n\t\t\t.attr(\"width\", handleBarWidth)\n\t\t\t.attr(\"height\", handleBarHeight)\n\t\t\t.attr(\"cursor\", \"ew-resize\");\n\n\t\t// Update slider selected area\n\t\tif (zoombarType === ZoomBarTypes.SLIDER_VIEW) {\n\t\t\tthis.updateSliderSelectedArea(selection);\n\t\t}\n\n\t\tthis.updateClipPath(\n\t\t\tsvg,\n\t\t\tthis.clipId,\n\t\t\tselection[0],\n\t\t\t0,\n\t\t\tselection[1] - selection[0],\n\t\t\thandleHeight\n\t\t);\n\t}\n\n\tupdateSliderSelectedArea(selection) {\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\t\tconst zoombarHeight = Configuration.zoomBar.height[zoombarType];\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(this.parent, {\n\t\t\tuseAttrs: true\n\t\t});\n\n\t\t// get axes margins\n\t\tlet axesLeftMargin = 0;\n\t\tconst axesMargins = this.model.get(\"axesMargins\");\n\t\tif (axesMargins && axesMargins.left) {\n\t\t\taxesLeftMargin = axesMargins.left;\n\t\t}\n\n\t\tconst svg = this.getContainerSVG();\n\t\tconst container = svg.select(\"svg.zoom-container\");\n\n\t\t// Draw zoombar background line\n\t\tDOMUtils.appendOrSelect(container, \"rect.zoom-slider-selected-area\")\n\t\t\t.attr(\"x\", selection[0])\n\t\t\t.attr(\"y\", zoombarHeight / 2 - 1)\n\t\t\t.attr(\"width\", selection[1] - selection[0])\n\t\t\t.attr(\"height\", 2);\n\t}\n\n\trenderZoomBarArea(container, querySelector, data, clipId) {\n\t\tconst { cartesianScales } = this.services;\n\t\tconst mainXAxisPosition = cartesianScales.getMainXAxisPosition();\n\t\tconst mainYAxisPosition = cartesianScales.getMainYAxisPosition();\n\t\tconst mainXScaleType = cartesianScales.getMainXScaleType();\n\t\tconst mainYScaleType = cartesianScales.getMainYScaleType();\n\n\t\tconst accessorFunction = (scale, scaleType, axisPosition) => {\n\t\t\treturn (d, i) => {\n\t\t\t\treturn cartesianScales.getValueFromScale(\n\t\t\t\t\tscale,\n\t\t\t\t\tscaleType,\n\t\t\t\t\taxisPosition,\n\t\t\t\t\td,\n\t\t\t\t\ti\n\t\t\t\t);\n\t\t\t};\n\t\t};\n\n\t\tconst xAccessor = accessorFunction(\n\t\t\tthis.xScale,\n\t\t\tmainXScaleType,\n\t\t\tmainXAxisPosition\n\t\t);\n\t\tconst yAccessor = accessorFunction(\n\t\t\tthis.yScale,\n\t\t\tmainYScaleType,\n\t\t\tmainYAxisPosition\n\t\t);\n\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\t\tconst zoombarHeight = Configuration.zoomBar.height[zoombarType];\n\t\tconst areaGenerator = area()\n\t\t\t.x((d, i) => xAccessor(d, i))\n\t\t\t.y0(zoombarHeight)\n\t\t\t.y1((d, i) => zoombarHeight - yAccessor(d, i));\n\n\t\tconst areaGraph = DOMUtils.appendOrSelect(container, querySelector)\n\t\t\t.datum(data)\n\t\t\t.attr(\"d\", areaGenerator);\n\n\t\tif (clipId) {\n\t\t\tareaGraph.attr(\"clip-path\", `url(#${clipId})`);\n\t\t}\n\t}\n\n\tupdateClipPath(svg, clipId, x, y, width, height) {\n\t\tconst zoomBarClipPath = DOMUtils.appendOrSelect(svg, `clipPath`).attr(\n\t\t\t\"id\",\n\t\t\tclipId\n\t\t);\n\t\tDOMUtils.appendOrSelect(zoomBarClipPath, \"rect\")\n\t\t\t.attr(\"x\", x)\n\t\t\t.attr(\"y\", y)\n\t\t\t.attr(\"width\", width)\n\t\t\t.attr(\"height\", height);\n\t}\n\n\t// assume the domains in data are already sorted\n\tcompensateDataForDefaultDomain(data, defaultDomain) {\n\t\tif (!data || data.length < 2) {\n\t\t\treturn;\n\t\t}\n\t\tconst zoomBarData = Tools.clone(data);\n\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\t// if min domain is extended\n\t\tif (\n\t\t\tNumber(defaultDomain[0]) < Number(zoomBarData[0][domainIdentifier])\n\t\t) {\n\t\t\tconst newDatum = {};\n\t\t\tnewDatum[domainIdentifier] = defaultDomain[0];\n\t\t\tnewDatum[rangeIdentifier] = 0;\n\t\t\tzoomBarData.unshift(newDatum);\n\t\t}\n\t\t// if max domain is extended\n\t\tif (\n\t\t\tNumber(defaultDomain[1]) >\n\t\t\tNumber(zoomBarData[zoomBarData.length - 1][domainIdentifier])\n\t\t) {\n\t\t\tconst newDatum = {};\n\t\t\tnewDatum[domainIdentifier] = defaultDomain[1];\n\t\t\tnewDatum[rangeIdentifier] = 0;\n\t\t\tzoomBarData.push(newDatum);\n\t\t}\n\t\treturn zoomBarData;\n\t}\n\n\tdestroy() {\n\t\tthis.brush.on(\"start brush end\", null); // remove event listener\n\t\tthis.services.events.removeEventListener(\n\t\t\tEvents.ZoomBar.UPDATE,\n\t\t\tthis.render.bind(this)\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"zoom-bar.js","sourceRoot":"","sources":["zoom-bar.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACN,aAAa,EACb,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AAErD,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC;IAA6B,2BAAS;IAAtC;QAAA,qEAojBC;QAljBA,UAAI,GAAG,UAAU,CAAC;QAElB,0DAA0D;QAC1D,qEAAqE;QACrE,2FAA2F;QAC3F,wBAAkB,GAAG,KAAK,CAAC;QAE3B,6CAA6C;QAC7C,mBAAa,GAAG,kBAAkB,CAAC;QAKnC,uCAAuC;QACvC,wDAAwD;QACxD,YAAM,GAAG,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,WAAW,CAA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AAQ,CAAC,eAAe,CAAC,kBAAkB,EAAE,CAAC;QAE3E,4BAA4B;QAC5B,IACC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAClE;YACD,IAAM,QAAQ,GAAG,EAAE,CAAC;YACpB,QAAQ,CAAC,gBAAgB,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YAC9C,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC9B,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SAC9B;QACD,4BAA4B;QAC5B,IACC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAC5D;YACD,IAAM,QAAQ,GAAG,EAAE,CAAC;YACpB,QAAQ,CAAC,gBAAgB,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YAC9C,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC9B,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC3B;QACD,OAAO,WAAW,CAAC;IACpB,CAAC;IAED,yBAAO,GAAP;QACC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,wBAAwB;QAChE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CACvC,MAAM,CAAC,OAAO,CAAC,MAAM,EACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CACtB,CAAC;IACH,CAAC;IACF,cAAC;AAAD,CAAC,AApjBD,CAA6B,SAAS,GAojBrC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { ChartModelCartesian } from \"../../model-cartesian-charts\";\nimport { Tools } from \"../../tools\";\nimport {\n\tAxisPositions,\n\tEvents,\n\tScaleTypes,\n\tZoomBarTypes\n} from \"../../interfaces\";\nimport { DOMUtils } from \"../../services\";\nimport * as Configuration from \"../../configuration\";\n\n// D3 Imports\nimport { extent } from \"d3-array\";\nimport { brushX } from \"d3-brush\";\nimport { area, line } from \"d3-shape\";\nimport { event } from \"d3-selection\";\n\nexport class ZoomBar extends Component {\n\tprotected model: ChartModelCartesian;\n\ttype = \"zoom-bar\";\n\n\t// The minimum selection x range to trigger handler update\n\t// Smaller number may introduce a handler flash during initialization\n\t// Bigger number may not trigger handler update while selection area on chart is very small\n\tMIN_SELECTION_DIFF = 9e-10;\n\n\t// needs to match the style in _zoom-bar.scss\n\tbrushSelector = \"g.zoom-bar-brush\";\n\n\t// The max allowed selection range, will be updated soon in render()\n\tmaxSelectionRange: [0, 0];\n\n\t// Give every zoomBarClip a distinct ID\n\t// so they don't interfere the other zoom bars in a page\n\tclipId = \"zoomBarClip-\" + Math.floor(Math.random() * 99999999999);\n\n\tbrush = brushX();\n\txScale: any;\n\tyScale: any;\n\n\tinit() {\n\t\tthis.services.events.addEventListener(\n\t\t\tEvents.ZoomBar.UPDATE,\n\t\t\tthis.render.bind(this)\n\t\t);\n\t\t// check if pre-defined zoom bar data exists\n\t\tconst definedZoomBarData = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"data\"\n\t\t);\n\n\t\t// load up the zoomBarData into this model\n\t\tthis.model.setZoomBarData(definedZoomBarData);\n\t}\n\n\trender(animate = true) {\n\t\tconst svg = this.getContainerSVG();\n\n\t\tconst isTopZoomBarLoading = this.services.zoom.isZoomBarLoading(\n\t\t\tAxisPositions.TOP\n\t\t);\n\t\tconst isTopZoomBarLocked = this.services.zoom.isZoomBarLocked(\n\t\t\tAxisPositions.TOP\n\t\t);\n\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\n\t\tconst zoombarHeight = Configuration.zoomBar.height[zoombarType];\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(this.parent, {\n\t\t\tuseAttrs: true\n\t\t});\n\n\t\t// get axes margins\n\t\tlet axesLeftMargin = 0;\n\t\tconst axesMargins = this.model.get(\"axesMargins\");\n\t\tif (axesMargins && axesMargins.left) {\n\t\t\taxesLeftMargin = axesMargins.left;\n\t\t}\n\n\t\tconst container = DOMUtils.appendOrSelect(svg, \"svg.zoom-container\")\n\t\t\t.attr(\"width\", \"100%\")\n\t\t\t.attr(\"height\", zoombarHeight)\n\t\t\t.attr(\"opacity\", 1);\n\n\t\tconst spacer = DOMUtils.appendOrSelect(svg, \"rect.zoom-spacer\")\n\t\t\t.attr(\"x\", 0)\n\t\t\t.attr(\"y\", zoombarHeight)\n\t\t\t.attr(\"width\", \"100%\")\n\t\t\t.attr(\"height\", Configuration.zoomBar.spacerHeight)\n\t\t\t.attr(\"opacity\", 1)\n\t\t\t.attr(\"fill\", \"none\");\n\n\t\tif (zoombarType === ZoomBarTypes.GRAPH_VIEW) {\n\t\t\t// Draw zoombar background rectangle\n\t\t\tDOMUtils.appendOrSelect(container, \"rect.zoom-bg\")\n\t\t\t\t.attr(\"x\", axesLeftMargin)\n\t\t\t\t.attr(\"y\", 0)\n\t\t\t\t.attr(\"width\", width - axesLeftMargin)\n\t\t\t\t.attr(\"height\", \"100%\");\n\t\t} else if (zoombarType === ZoomBarTypes.SLIDER_VIEW) {\n\t\t\t// Draw zoombar background line\n\t\t\tDOMUtils.appendOrSelect(container, \"rect.zoom-slider-bg\")\n\t\t\t\t.attr(\"x\", axesLeftMargin)\n\t\t\t\t.attr(\"y\", zoombarHeight / 2 - 1)\n\t\t\t\t.attr(\"width\", width - axesLeftMargin)\n\t\t\t\t.attr(\"height\", 2);\n\t\t}\n\n\t\tif (isTopZoomBarLoading) {\n\t\t\t// TODO - zoom bar skeleton could be improved in the future\n\t\t\treturn;\n\t\t}\n\n\t\tconst { cartesianScales } = this.services;\n\t\tconst mainXScale = cartesianScales.getMainXScale();\n\t\tconst mainYScale = cartesianScales.getMainYScale();\n\t\tconst mainXScaleType = cartesianScales.getMainXScaleType();\n\n\t\tif (mainXScale && mainXScaleType === ScaleTypes.TIME) {\n\t\t\tlet zoomBarData = this.services.zoom.getZoomBarData();\n\t\t\tif (Tools.isEmpty(zoomBarData)) {\n\t\t\t\t// if there's no zoom bar data we can't do anything\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.xScale = mainXScale.copy();\n\t\t\tthis.yScale = mainYScale.copy();\n\n\t\t\tconst defaultDomain = this.services.zoom.getDefaultZoomBarDomain(\n\t\t\t\tzoomBarData\n\t\t\t);\n\n\t\t\t// add value 0 to the extended domain for zoom bar area graph\n\t\t\tzoomBarData = this.compensateDataForDefaultDomain(\n\t\t\t\tzoomBarData,\n\t\t\t\tdefaultDomain\n\t\t\t);\n\n\t\t\t// get old initialZoomDomain from model\n\t\t\tconst oldInitialZoomDomain = this.model.get(\"initialZoomDomain\");\n\t\t\t// get new initialZoomDomain from option\n\t\t\tconst newInitialZoomDomain = Tools.getProperty(\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\"zoomBar\",\n\t\t\t\tAxisPositions.TOP,\n\t\t\t\t\"initialZoomDomain\"\n\t\t\t);\n\t\t\t// change string date to Date object if necessary\n\t\t\tif (\n\t\t\t\tnewInitialZoomDomain &&\n\t\t\t\tnewInitialZoomDomain[0] &&\n\t\t\t\tnewInitialZoomDomain[1]\n\t\t\t) {\n\t\t\t\tnewInitialZoomDomain[0] = new Date(newInitialZoomDomain[0]);\n\t\t\t\tnewInitialZoomDomain[1] = new Date(newInitialZoomDomain[1]);\n\t\t\t}\n\t\t\t// update initialZoomDomain and set zoomDomain in model only if the option is changed\n\t\t\t// not the same object, and both start date and end date are not equal\n\t\t\tif (\n\t\t\t\t!(\n\t\t\t\t\toldInitialZoomDomain === newInitialZoomDomain ||\n\t\t\t\t\t(oldInitialZoomDomain &&\n\t\t\t\t\t\tnewInitialZoomDomain &&\n\t\t\t\t\t\toldInitialZoomDomain[0].valueOf() ===\n\t\t\t\t\t\t\tnewInitialZoomDomain[0].valueOf() &&\n\t\t\t\t\t\toldInitialZoomDomain[1].valueOf() ===\n\t\t\t\t\t\t\tnewInitialZoomDomain[1].valueOf())\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthis.model.set(\n\t\t\t\t\t{\n\t\t\t\t\t\tinitialZoomDomain: newInitialZoomDomain,\n\t\t\t\t\t\tzoomDomain: newInitialZoomDomain\n\t\t\t\t\t\t\t? newInitialZoomDomain\n\t\t\t\t\t\t\t: defaultDomain\n\t\t\t\t\t},\n\t\t\t\t\t{ skipUpdate: true }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.xScale.range([axesLeftMargin, width]).domain(defaultDomain);\n\n\t\t\t// keep max selection range\n\t\t\tthis.maxSelectionRange = this.xScale.range();\n\n\t\t\tthis.yScale\n\t\t\t\t.range([0, zoombarHeight - 6])\n\t\t\t\t.domain(extent(zoomBarData, (d: any) => d.value));\n\n\t\t\tconst zoomDomain = this.model.get(\"zoomDomain\");\n\n\t\t\tif (zoombarType === ZoomBarTypes.GRAPH_VIEW) {\n\t\t\t\tthis.renderZoomBarArea(\n\t\t\t\t\tcontainer,\n\t\t\t\t\t\"path.zoom-graph-area-unselected\",\n\t\t\t\t\tzoomBarData,\n\t\t\t\t\tnull\n\t\t\t\t);\n\t\t\t\tthis.updateClipPath(svg, this.clipId, 0, 0, 0, 0);\n\t\t\t\tthis.renderZoomBarArea(\n\t\t\t\t\tcontainer,\n\t\t\t\t\t\"path.zoom-graph-area\",\n\t\t\t\t\tzoomBarData,\n\t\t\t\t\tthis.clipId\n\t\t\t\t);\n\n\t\t\t\t// Draw the zoom base line\n\t\t\t\tconst baselineGenerator = line()([\n\t\t\t\t\t[axesLeftMargin, zoombarHeight],\n\t\t\t\t\t[width, zoombarHeight]\n\t\t\t\t]);\n\t\t\t\tconst zoomBaseline = DOMUtils.appendOrSelect(\n\t\t\t\t\tcontainer,\n\t\t\t\t\t\"path.zoom-bg-baseline\"\n\t\t\t\t).attr(\"d\", baselineGenerator);\n\t\t\t}\n\n\t\t\t// Attach brushing event listeners\n\t\t\tthis.addBrushEventListener(zoomDomain, axesLeftMargin, width);\n\n\t\t\t// Draw the brushing area\n\t\t\tconst brushArea = DOMUtils.appendOrSelect(\n\t\t\t\tsvg,\n\t\t\t\tthis.brushSelector\n\t\t\t).call(this.brush);\n\n\t\t\tif (zoomDomain === undefined) {\n\t\t\t\t// do nothing, initialization not completed yet\n\t\t\t\t// don't update brushHandle to avoid flash\n\t\t\t} else if (zoomDomain[0].valueOf() === zoomDomain[1].valueOf()) {\n\t\t\t\tbrushArea.call(this.brush.move, this.xScale.range()); // default to full range\n\t\t\t\tthis.updateBrushHandle(\n\t\t\t\t\tthis.getContainerSVG(),\n\t\t\t\t\tthis.xScale.range(),\n\t\t\t\t\tthis.xScale.domain()\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst selected = zoomDomain.map((domain) =>\n\t\t\t\t\tthis.xScale(domain)\n\t\t\t\t);\n\t\t\t\tif (selected[1] - selected[0] < this.MIN_SELECTION_DIFF) {\n\t\t\t\t\t// initialization not completed yet\n\t\t\t\t\t// don't update brushHandle to avoid flash\n\t\t\t\t} else {\n\t\t\t\t\tbrushArea.call(this.brush.move, selected); // set brush to correct position\n\t\t\t\t\tthis.updateBrushHandle(\n\t\t\t\t\t\tthis.getContainerSVG(),\n\t\t\t\t\t\tselected,\n\t\t\t\t\t\tzoomDomain\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isTopZoomBarLocked) {\n\t\t\t\tthis.brush.filter(() => {\n\t\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t\t// reset all cursor to auto\n\t\t\t\tbrushArea.selectAll(\"rect\").attr(\"cursor\", \"auto\");\n\t\t\t}\n\t\t}\n\t}\n\n\taddBrushEventListener(zoomDomain, axesLeftMargin, width) {\n\t\tconst brushEventListener = () => {\n\t\t\tconst selection = event.selection;\n\t\t\t// follow d3 behavior: when selection is null, reset default full range\n\t\t\t// select behavior is completed, but nothing selected\n\t\t\tif (selection === null) {\n\t\t\t\tthis.handleBrushedEvent(\n\t\t\t\t\tzoomDomain,\n\t\t\t\t\tthis.xScale,\n\t\t\t\t\tthis.xScale.range()\n\t\t\t\t);\n\t\t\t} else if (selection[0] === selection[1]) {\n\t\t\t\t// select behavior is not completed yet, do nothing\n\t\t\t} else {\n\t\t\t\tthis.handleBrushedEvent(zoomDomain, this.xScale, selection);\n\t\t\t}\n\t\t};\n\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\t\tconst zoombarHeight = Configuration.zoomBar.height[zoombarType];\n\n\t\t// Initialize the d3 brush\n\t\tthis.brush\n\t\t\t.extent([\n\t\t\t\t[axesLeftMargin, 0],\n\t\t\t\t[width, zoombarHeight]\n\t\t\t])\n\t\t\t.on(\"start brush end\", null) // remove old listener first\n\t\t\t.on(\"start brush end\", brushEventListener);\n\t}\n\n\t// brush event listener\n\thandleBrushedEvent(zoomDomain, scale, selection) {\n\t\tconst newDomain = [\n\t\t\tscale.invert(selection[0]),\n\t\t\tscale.invert(selection[1])\n\t\t];\n\n\t\t// update brush handle position\n\t\tthis.updateBrushHandle(this.getContainerSVG(), selection, newDomain);\n\n\t\t// be aware that the value of d3.event changes during an event!\n\t\t// update zoomDomain only if the event comes from mouse/touch event\n\t\tif (\n\t\t\tevent.sourceEvent != null &&\n\t\t\t(event.sourceEvent.type === \"mousemove\" ||\n\t\t\t\tevent.sourceEvent.type === \"mouseup\" ||\n\t\t\t\tevent.sourceEvent.type === \"mousedown\" ||\n\t\t\t\tevent.sourceEvent.type === \"touchstart\" ||\n\t\t\t\tevent.sourceEvent.type === \"touchmove\" ||\n\t\t\t\tevent.sourceEvent.type === \"touchend\")\n\t\t) {\n\t\t\t// only if zoomDomain is never set or needs update\n\t\t\tif (\n\t\t\t\tzoomDomain === undefined ||\n\t\t\t\tzoomDomain[0] !== newDomain[0] ||\n\t\t\t\tzoomDomain[1] !== newDomain[1]\n\t\t\t) {\n\t\t\t\t// don't dispatch event for all event types\n\t\t\t\t// let the following code to dispatch necessary events\n\t\t\t\tthis.services.zoom.handleDomainChange(newDomain, {\n\t\t\t\t\tdispatchEvent: false\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// dispatch selection events\n\t\t\tlet zoomBarEventType;\n\t\t\tif (event.type === \"start\") {\n\t\t\t\tzoomBarEventType = Events.ZoomBar.SELECTION_START;\n\t\t\t} else if (event.type === \"brush\") {\n\t\t\t\tzoomBarEventType = Events.ZoomBar.SELECTION_IN_PROGRESS;\n\t\t\t} else if (event.type === \"end\") {\n\t\t\t\tzoomBarEventType = Events.ZoomBar.SELECTION_END;\n\t\t\t}\n\t\t\tthis.services.events.dispatchEvent(zoomBarEventType, {\n\t\t\t\tselection,\n\t\t\t\tnewDomain\n\t\t\t});\n\t\t}\n\t}\n\n\tupdateBrushHandle(svg, selection, domain) {\n\t\tconst self = this;\n\t\tconst handleWidth = Configuration.zoomBar.handleWidth;\n\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\t\tconst handleHeight = Configuration.zoomBar.height[zoombarType];\n\t\tconst handleXDiff = -handleWidth / 2;\n\n\t\tconst handleBarWidth = Configuration.zoomBar.handleBarWidth;\n\t\tconst handleBarHeight =\n\t\t\tzoombarType === ZoomBarTypes.GRAPH_VIEW\n\t\t\t\t? Configuration.zoomBar.handleBarHeight\n\t\t\t\t: 6;\n\t\tconst handleBarXDiff = -handleBarWidth / 2;\n\t\tconst handleYBarDiff = (handleHeight - handleBarHeight) / 2;\n\n\t\t// handle\n\t\tsvg.select(this.brushSelector)\n\t\t\t.selectAll(\"rect.handle\")\n\t\t\t.data([{ type: \"w\" }, { type: \"e\" }])\n\t\t\t.attr(\"x\", function (d) {\n\t\t\t\tif (d.type === \"w\") {\n\t\t\t\t\t// handle should not exceed zoom bar range\n\t\t\t\t\treturn Math.max(\n\t\t\t\t\t\tselection[0] + handleXDiff,\n\t\t\t\t\t\tself.maxSelectionRange[0]\n\t\t\t\t\t);\n\t\t\t\t} else if (d.type === \"e\") {\n\t\t\t\t\t// handle should not exceed zoom bar range\n\t\t\t\t\treturn Math.min(\n\t\t\t\t\t\tselection[1] + handleXDiff,\n\t\t\t\t\t\tself.maxSelectionRange[1] - handleWidth\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.attr(\"y\", 0)\n\t\t\t.attr(\"width\", handleWidth)\n\t\t\t.attr(\"height\", handleHeight)\n\t\t\t.attr(\"cursor\", \"ew-resize\")\n\t\t\t.style(\"display\", null); // always display\n\n\t\t// handle-bar\n\t\tconst handleBars = svg\n\t\t\t.select(this.brushSelector)\n\t\t\t.selectAll(\"rect.handle-bar\")\n\t\t\t.data([{ type: \"w\" }, { type: \"e\" }]);\n\t\t// create rect if not exists\n\t\thandleBars\n\t\t\t.enter()\n\t\t\t.append(\"rect\")\n\t\t\t.attr(\"class\", function (d) {\n\t\t\t\treturn \"handle-bar handle-bar--\" + d.type;\n\t\t\t});\n\t\t// update positions\n\t\thandleBars\n\t\t\t.attr(\"x\", function (d) {\n\t\t\t\tif (d.type === \"w\") {\n\t\t\t\t\treturn Math.max(\n\t\t\t\t\t\tselection[0] + handleBarXDiff,\n\t\t\t\t\t\tself.maxSelectionRange[0] - handleXDiff + handleBarXDiff\n\t\t\t\t\t);\n\t\t\t\t} else if (d.type === \"e\") {\n\t\t\t\t\treturn Math.min(\n\t\t\t\t\t\tselection[1] + handleBarXDiff,\n\t\t\t\t\t\tself.maxSelectionRange[1] + handleXDiff + handleBarXDiff\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.attr(\"y\", handleYBarDiff)\n\t\t\t.attr(\"width\", handleBarWidth)\n\t\t\t.attr(\"height\", handleBarHeight)\n\t\t\t.attr(\"cursor\", \"ew-resize\");\n\n\t\t// Update slider selected area\n\t\tif (zoombarType === ZoomBarTypes.SLIDER_VIEW) {\n\t\t\tthis.updateSliderSelectedArea(selection);\n\t\t}\n\n\t\tthis.updateClipPath(\n\t\t\tsvg,\n\t\t\tthis.clipId,\n\t\t\tselection[0],\n\t\t\t0,\n\t\t\tselection[1] - selection[0],\n\t\t\thandleHeight\n\t\t);\n\t}\n\n\tupdateSliderSelectedArea(selection) {\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\t\tconst zoombarHeight = Configuration.zoomBar.height[zoombarType];\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(this.parent, {\n\t\t\tuseAttrs: true\n\t\t});\n\n\t\t// get axes margins\n\t\tlet axesLeftMargin = 0;\n\t\tconst axesMargins = this.model.get(\"axesMargins\");\n\t\tif (axesMargins && axesMargins.left) {\n\t\t\taxesLeftMargin = axesMargins.left;\n\t\t}\n\n\t\tconst svg = this.getContainerSVG();\n\t\tconst container = svg.select(\"svg.zoom-container\");\n\n\t\t// Draw zoombar background line\n\t\tDOMUtils.appendOrSelect(container, \"rect.zoom-slider-selected-area\")\n\t\t\t.attr(\"x\", selection[0])\n\t\t\t.attr(\"y\", zoombarHeight / 2 - 1)\n\t\t\t.attr(\"width\", selection[1] - selection[0])\n\t\t\t.attr(\"height\", 2);\n\t}\n\n\trenderZoomBarArea(container, querySelector, data, clipId) {\n\t\tconst { cartesianScales } = this.services;\n\t\tconst mainXAxisPosition = cartesianScales.getMainXAxisPosition();\n\t\tconst mainYAxisPosition = cartesianScales.getMainYAxisPosition();\n\t\tconst mainXScaleType = cartesianScales.getMainXScaleType();\n\t\tconst mainYScaleType = cartesianScales.getMainYScaleType();\n\n\t\tconst accessorFunction = (scale, scaleType, axisPosition) => {\n\t\t\treturn (d, i) => {\n\t\t\t\treturn cartesianScales.getValueFromScale(\n\t\t\t\t\tscale,\n\t\t\t\t\tscaleType,\n\t\t\t\t\taxisPosition,\n\t\t\t\t\td,\n\t\t\t\t\ti\n\t\t\t\t);\n\t\t\t};\n\t\t};\n\n\t\tconst xAccessor = accessorFunction(\n\t\t\tthis.xScale,\n\t\t\tmainXScaleType,\n\t\t\tmainXAxisPosition\n\t\t);\n\t\tconst yAccessor = accessorFunction(\n\t\t\tthis.yScale,\n\t\t\tmainYScaleType,\n\t\t\tmainYAxisPosition\n\t\t);\n\n\t\tconst zoombarType = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\tAxisPositions.TOP,\n\t\t\t\"type\"\n\t\t);\n\t\tconst zoombarHeight = Configuration.zoomBar.height[zoombarType];\n\t\tconst areaGenerator = area()\n\t\t\t.x((d, i) => xAccessor(d, i))\n\t\t\t.y0(zoombarHeight)\n\t\t\t.y1((d, i) => zoombarHeight - yAccessor(d, i));\n\n\t\tconst areaGraph = DOMUtils.appendOrSelect(container, querySelector)\n\t\t\t.datum(data)\n\t\t\t.attr(\"d\", areaGenerator);\n\n\t\tif (clipId) {\n\t\t\tareaGraph.attr(\"clip-path\", `url(#${clipId})`);\n\t\t}\n\t}\n\n\tupdateClipPath(svg, clipId, x, y, width, height) {\n\t\tconst zoomBarClipPath = DOMUtils.appendOrSelect(svg, `clipPath`).attr(\n\t\t\t\"id\",\n\t\t\tclipId\n\t\t);\n\t\tDOMUtils.appendOrSelect(zoomBarClipPath, \"rect\")\n\t\t\t.attr(\"x\", x)\n\t\t\t.attr(\"y\", y)\n\t\t\t.attr(\"width\", width)\n\t\t\t.attr(\"height\", height);\n\t}\n\n\t// assume the domains in data are already sorted\n\tcompensateDataForDefaultDomain(data, defaultDomain) {\n\t\tif (!data || data.length < 2) {\n\t\t\treturn;\n\t\t}\n\t\tconst zoomBarData = Tools.clone(data);\n\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\t// if min domain is extended\n\t\tif (\n\t\t\tNumber(defaultDomain[0]) < Number(zoomBarData[0][domainIdentifier])\n\t\t) {\n\t\t\tconst newDatum = {};\n\t\t\tnewDatum[domainIdentifier] = defaultDomain[0];\n\t\t\tnewDatum[rangeIdentifier] = 0;\n\t\t\tzoomBarData.unshift(newDatum);\n\t\t}\n\t\t// if max domain is extended\n\t\tif (\n\t\t\tNumber(defaultDomain[1]) >\n\t\t\tNumber(zoomBarData[zoomBarData.length - 1][domainIdentifier])\n\t\t) {\n\t\t\tconst newDatum = {};\n\t\t\tnewDatum[domainIdentifier] = defaultDomain[1];\n\t\t\tnewDatum[rangeIdentifier] = 0;\n\t\t\tzoomBarData.push(newDatum);\n\t\t}\n\t\treturn zoomBarData;\n\t}\n\n\tdestroy() {\n\t\tthis.brush.on(\"start brush end\", null); // remove event listener\n\t\tthis.services.events.removeEventListener(\n\t\t\tEvents.ZoomBar.UPDATE,\n\t\t\tthis.render.bind(this)\n\t\t);\n\t}\n}\n"]}
|
|
@@ -342,8 +342,8 @@
|
|
|
342
342
|
"signature": "76155b4beaf0aa54eb99042bf954e56d47f803147ea42fefb4758e39f222b3d6"
|
|
343
343
|
},
|
|
344
344
|
"../../src/tools.ts": {
|
|
345
|
-
"version": "
|
|
346
|
-
"signature": "
|
|
345
|
+
"version": "9dbeb225d361fb3fd4952e568bfdc97d391d177a320182c3d51b15e2e919bbf8",
|
|
346
|
+
"signature": "9dbeb225d361fb3fd4952e568bfdc97d391d177a320182c3d51b15e2e919bbf8"
|
|
347
347
|
},
|
|
348
348
|
"../../demo/data/step.ts": {
|
|
349
349
|
"version": "d251a1aec312e986930f31622c4e98bedb8eedc84c5540997ff43432956a0eaf",
|
package/package.json
CHANGED
package/tools.d.ts
CHANGED
package/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Internal imports
|
|
2
2
|
import { CartesianOrientations, ScaleTypes, TruncationTypes } from "./interfaces";
|
|
3
|
-
import { debounce as lodashDebounce, merge as lodashMerge, cloneDeep as lodashCloneDeep, uniq as lodashUnique, clamp as lodashClamp, isEqual as lodashIsEqual, flatMapDeep as lodashFlatMapDeep, kebabCase as lodashKebabCase, fromPairs as lodashFromPairs, some as lodashSome } from "lodash-es";
|
|
3
|
+
import { debounce as lodashDebounce, merge as lodashMerge, cloneDeep as lodashCloneDeep, uniq as lodashUnique, clamp as lodashClamp, isEmpty as lodashIsEmpty, isEqual as lodashIsEqual, flatMapDeep as lodashFlatMapDeep, kebabCase as lodashKebabCase, fromPairs as lodashFromPairs, some as lodashSome } from "lodash-es";
|
|
4
4
|
import { mouse } from "d3-selection";
|
|
5
5
|
// Functions
|
|
6
6
|
export var Tools;
|
|
@@ -11,6 +11,7 @@ export var Tools;
|
|
|
11
11
|
Tools.merge = lodashMerge;
|
|
12
12
|
Tools.removeArrayDuplicates = lodashUnique;
|
|
13
13
|
Tools.clamp = lodashClamp;
|
|
14
|
+
Tools.isEmpty = lodashIsEmpty;
|
|
14
15
|
Tools.isEqual = lodashIsEqual;
|
|
15
16
|
Tools.flatMapDeep = lodashFlatMapDeep;
|
|
16
17
|
Tools.kebabCase = lodashKebabCase;
|
package/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["tools.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,EAEN,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,QAAQ,IAAI,cAAc,EAC1B,KAAK,IAAI,WAAW,EACpB,SAAS,IAAI,eAAe,EAC5B,IAAI,IAAI,YAAY,EACpB,KAAK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AnYgB,KAAK,KAAL,KAAK,QAmYrB","sourcesContent":["// Internal imports\nimport {\n\tAxisChartOptions,\n\tCartesianOrientations,\n\tScaleTypes,\n\tTruncationTypes\n} from \"./interfaces\";\n\nimport {\n\tdebounce as lodashDebounce,\n\tmerge as lodashMerge,\n\tcloneDeep as lodashCloneDeep,\n\tuniq as lodashUnique,\n\tclamp as lodashClamp,\n\tisEqual as lodashIsEqual,\n\tflatMapDeep as lodashFlatMapDeep,\n\tkebabCase as lodashKebabCase,\n\tfromPairs as lodashFromPairs,\n\tsome as lodashSome,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tCancelable,\n\tDebounceSettings\n} from \"lodash-es\";\n\nimport { mouse } from \"d3-selection\";\nimport { Numeric } from \"d3\";\n\n// Functions\nexport namespace Tools {\n\t// Export these functions from lodash\n\texport const debounce = lodashDebounce;\n\texport const clone = lodashCloneDeep;\n\texport const merge = lodashMerge;\n\texport const removeArrayDuplicates = lodashUnique;\n\texport const clamp = lodashClamp;\n\texport const isEqual = lodashIsEqual;\n\texport const flatMapDeep = lodashFlatMapDeep;\n\texport const kebabCase = lodashKebabCase;\n\texport const fromPairs = lodashFromPairs;\n\texport const some = lodashSome;\n\n\texport function debounceWithD3MousePosition(fn, delay, element) {\n\t\tvar timer = null;\n\t\treturn function () {\n\t\t\tconst context = this;\n\t\t\tconst args = arguments;\n\n\t\t\t//we get the D3 event here\n\t\t\tcontext.mousePosition = mouse(element);\n\n\t\t\tclearTimeout(timer);\n\n\t\t\ttimer = setTimeout(function () {\n\t\t\t\t//and use the reference here\n\t\t\t\tfn.apply(context, args);\n\t\t\t}, delay);\n\t\t};\n\t}\n\n\t/**\n\t * Returns default chart options merged with provided options,\n\t * with special cases for axes.\n\t * Axes object will not merge the not provided axes.\n\t *\n\t * @export\n\t * @param {AxisChartOptions} defaultOptions Configuration.options[chartType]\n\t * @param {AxisChartOptions} providedOptions user provided options\n\t * @returns merged options\n\t */\n\texport function mergeDefaultChartOptions(\n\t\tdefaultOptions: any,\n\t\tprovidedOptions: any\n\t) {\n\t\tdefaultOptions = Tools.clone(defaultOptions);\n\t\tconst providedAxesNames = Object.keys(providedOptions.axes || {});\n\n\t\tif (providedAxesNames.length === 0) {\n\t\t\tdelete defaultOptions.axes;\n\t\t}\n\n\t\t// Update deprecated options to work with the tabular data format\n\t\t// Similar to the functionality in model.transformToTabularData()\n\t\tfor (const axisName in defaultOptions.axes) {\n\t\t\tif (providedAxesNames.includes(axisName)) {\n\t\t\t\tconst providedAxisOptions = providedOptions.axes[axisName];\n\n\t\t\t\tif (\n\t\t\t\t\tprovidedAxisOptions[\"primary\"] ||\n\t\t\t\t\tprovidedAxisOptions[\"secondary\"]\n\t\t\t\t) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\"`primary` & `secondary` are no longer needed for axis configurations. Read more here https://carbon-design-system.github.io/carbon-charts/?path=/story/tutorials--tabular-data-format\"\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst identifier = providedAxisOptions[\"mapsTo\"];\n\t\t\t\tif (identifier === undefined || identifier === null) {\n\t\t\t\t\tconst scaleType = providedAxisOptions[\"scaleType\"];\n\n\t\t\t\t\tif (scaleType === undefined || scaleType === null) {\n\t\t\t\t\t\tprovidedAxisOptions[\"mapsTo\"] = \"value\";\n\t\t\t\t\t} else if (scaleType === ScaleTypes.TIME) {\n\t\t\t\t\t\tprovidedAxisOptions[\"mapsTo\"] = \"date\";\n\t\t\t\t\t} else if (scaleType === ScaleTypes.LABELS) {\n\t\t\t\t\t\tprovidedAxisOptions[\"mapsTo\"] = \"key\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdelete defaultOptions.axes[axisName];\n\t\t\t}\n\t\t}\n\n\t\treturn Tools.merge(defaultOptions, providedOptions);\n\t}\n\n\t/**************************************\n\t * DOM-related operations *\n\t *************************************/\n\n\t/**\n\t * Get width & height of an element\n\t *\n\t * @export\n\t * @param {any} el element to get dimensions from\n\t * @returns an object containing the width and height of el\n\t */\n\texport function getDimensions(el) {\n\t\treturn {\n\t\t\twidth: parseFloat(\n\t\t\t\tel.style.width.replace(\"px\", \"\") || el.offsetWidth\n\t\t\t),\n\t\t\theight: parseFloat(\n\t\t\t\tel.style.height.replace(\"px\", \"\") || el.offsetHeight\n\t\t\t)\n\t\t};\n\t}\n\n\t/**\n\t * Gets elements's x and y translations from transform attribute or returns null\n\t *\n\t * @param {HTMLElement} element\n\t * @returns an object containing the translated x and y values or null\n\t */\n\texport function getTranslationValues(elementRef: HTMLElement) {\n\t\tif (!elementRef) {\n\t\t\treturn;\n\t\t}\n\n\t\t// regex to ONLY get values for translate (instead of all rotate, translate, skew, etc)\n\t\tconst translateRegex = /translate\\([0-9]+\\.?[0-9]*,[0-9]+\\.?[0-9]*\\)/;\n\n\t\tconst transformStr = elementRef\n\t\t\t.getAttribute(\"transform\")\n\t\t\t.match(translateRegex);\n\t\tif (!transformStr) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// check for the match\n\t\tif (transformStr[0]) {\n\t\t\tconst transforms = transformStr[0]\n\t\t\t\t.replace(/translate\\(/, \"\")\n\t\t\t\t.replace(/\\)/, \"\")\n\t\t\t\t.split(\",\");\n\n\t\t\treturn {\n\t\t\t\ttx: transforms[0],\n\t\t\t\tty: transforms[1]\n\t\t\t};\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**************************************\n\t * Formatting & calculations *\n\t *************************************/\n\n\t/**\n\t * Gets x and y coordinates from HTML transform attribute\n\t *\n\t * @export\n\t * @param {any} string the transform attribute string ie. transform(x,y)\n\t * @returns Returns an object with x and y offsets of the transform\n\t */\n\texport function getTranformOffsets(string) {\n\t\tconst regExp = /\\(([^)]+)\\)/;\n\t\tconst match = regExp.exec(string)[1];\n\t\tconst xyString = match.split(\",\");\n\n\t\treturn {\n\t\t\tx: parseFloat(xyString[0]),\n\t\t\ty: parseFloat(xyString[1])\n\t\t};\n\t}\n\n\t/**\n\t * Returns string value for height/width using pixels if there isn't a specified unit of measure\n\t *\n\t * @param value string or number value to be checked for unit of measure\n\t */\n\texport function formatWidthHeightValues(value) {\n\t\tconst stringValue = value.toString();\n\n\t\t// If the value provided contains any letters\n\t\t// Return it the same way\n\t\tif (stringValue.match(/[a-z]/i)) {\n\t\t\treturn stringValue;\n\t\t}\n\n\t\treturn stringValue + \"px\";\n\t}\n\n\t/**\n\t * Capitalizes first letter of a string\n\t *\n\t * @export\n\t * @param {any} string the input string to perform first letter capitalization with\n\t * @returns The transformed string after first letter is capitalized\n\t */\n\texport function capitalizeFirstLetter(string) {\n\t\treturn string[0].toUpperCase() + string.slice(1);\n\t}\n\n\t/**\n\t * Get the percentage of a datapoint compared to the entire dataset.\n\t * @export\n\t * @param {any} item\n\t * @param {any} fullData\n\t * @returns The percentage in the form of a number (1 significant digit if necessary)\n\t */\n\texport function convertValueToPercentage(item, fullData) {\n\t\tconst percentage =\n\t\t\t(item / fullData.reduce((accum, val) => accum + val.value, 0)) *\n\t\t\t100;\n\t\t// if the value has any significant figures, keep 1\n\t\treturn percentage % 1 !== 0\n\t\t\t? parseFloat(percentage.toFixed(1))\n\t\t\t: percentage;\n\t}\n\n\t/**\n\t * Truncate the labels\n\t * @export\n\t * @param {any} fullText\n\t * @param {any} truncationType\n\t * @param {any} numCharacter\n\t * @returns Truncated text\n\t */\n\texport function truncateLabel(fullText, truncationType, numCharacter) {\n\t\tif (numCharacter > fullText.length) {\n\t\t\treturn fullText;\n\t\t}\n\t\tif (truncationType === TruncationTypes.MID_LINE) {\n\t\t\treturn (\n\t\t\t\tfullText.substr(0, numCharacter / 2) +\n\t\t\t\t\"...\" +\n\t\t\t\tfullText.substr(-numCharacter / 2)\n\t\t\t);\n\t\t} else if (truncationType === TruncationTypes.FRONT_LINE) {\n\t\t\treturn \"...\" + fullText.substr(-numCharacter);\n\t\t} else if (truncationType === TruncationTypes.END_LINE) {\n\t\t\treturn fullText.substr(0, numCharacter) + \"...\";\n\t\t}\n\t}\n\n\t/**************************************\n\t * Object/array related checks *\n\t *************************************/\n\n\t/**\n\t * Compares two arrays to return the difference between two arrays' items.\n\t *\n\t * @export\n\t * @param {any[]} oldArray the array to check for missing items\n\t * @param {any[]} newArray the array to check for newly added items\n\t * @returns An object containing items missing (existing in oldArray but not newArray)\n\t * and items added (existing in newArray but not in oldArray). Object is of the form { missing: [], added: [] }\n\t */\n\texport function arrayDifferences(oldArray: any[], newArray: any[]) {\n\t\tconst difference = {\n\t\t\tmissing: [],\n\t\t\tadded: []\n\t\t};\n\n\t\toldArray.forEach((element) => {\n\t\t\tif (newArray.indexOf(element) === -1) {\n\t\t\t\tdifference.missing.push(element);\n\t\t\t}\n\t\t});\n\n\t\tnewArray.forEach((element) => {\n\t\t\tif (oldArray.indexOf(element) === -1) {\n\t\t\t\tdifference.added.push(element);\n\t\t\t}\n\t\t});\n\n\t\treturn difference;\n\t}\n\n\t/**\n\t * Gets the duplicated keys from an array of data\n\t *\n\t * @export\n\t * @param {*} data - array of data\n\t * @returns A list of the duplicated keys in data\n\t */\n\texport function getDuplicateValues(arr: any) {\n\t\tconst values = [];\n\t\tconst duplicateValues = [];\n\n\t\tarr.forEach((value) => {\n\t\t\tif (\n\t\t\t\tvalues.indexOf(value) !== -1 &&\n\t\t\t\tduplicateValues.indexOf(value) === -1\n\t\t\t) {\n\t\t\t\tduplicateValues.push(value);\n\t\t\t}\n\n\t\t\tvalues.push(value);\n\t\t});\n\n\t\treturn duplicateValues;\n\t}\n\n\t// ================================================================================\n\t// D3 Extensions\n\t// ================================================================================\n\n\t/**\n\t * In D3, moves an element to the front of the canvas\n\t *\n\t * @export\n\t * @param {any} element input element to moved in front\n\t * @returns The function to be used by D3 to push element to the top of the canvas\n\t */\n\texport function moveToFront(element) {\n\t\treturn element.each(function () {\n\t\t\tthis.parentNode.appendChild(this);\n\t\t});\n\t}\n\n\t// ================================================================================\n\t// Style Helpers\n\t// ================================================================================\n\n\t/**\n\t * Gets a speicified property from within an object.\n\t *\n\t * @param object the object containing the property to retrieve\n\t * @param propPath nested properties used to extract the final property from within the object\n\t * (i.e \"style\", \"color\" would retrieve the color property from within an object that has \"color\" nested within \"style\")\n\t */\n\texport const getProperty = (object, ...propPath) => {\n\t\tlet position = object;\n\t\tif (position) {\n\t\t\tfor (const prop of propPath) {\n\t\t\t\tif (position[prop] !== null && position[prop] !== undefined) {\n\t\t\t\t\tposition = position[prop];\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn position;\n\t\t}\n\n\t\treturn null;\n\t};\n\n\tinterface SVGPathCoordinates {\n\t\tx0: number;\n\t\tx1: number;\n\t\ty0: number;\n\t\ty1: number;\n\t}\n\n\texport const flipSVGCoordinatesBasedOnOrientation = (\n\t\tverticalCoordinates: SVGPathCoordinates,\n\t\torientation?: CartesianOrientations\n\t) => {\n\t\tif (orientation === CartesianOrientations.HORIZONTAL) {\n\t\t\treturn {\n\t\t\t\ty0: verticalCoordinates.x0,\n\t\t\t\ty1: verticalCoordinates.x1,\n\t\t\t\tx0: verticalCoordinates.y0,\n\t\t\t\tx1: verticalCoordinates.y1\n\t\t\t};\n\t\t}\n\n\t\treturn verticalCoordinates;\n\t};\n\n\texport const generateSVGPathString = (\n\t\tverticalCoordinates: SVGPathCoordinates,\n\t\torientation?: CartesianOrientations\n\t) => {\n\t\tconst { x0, x1, y0, y1 } = flipSVGCoordinatesBasedOnOrientation(\n\t\t\tverticalCoordinates,\n\t\t\torientation\n\t\t);\n\n\t\treturn `M${x0},${y0}L${x0},${y1}L${x1},${y1}L${x1},${y0}L${x0},${y0}`;\n\t};\n\n\texport function flipDomainAndRangeBasedOnOrientation<D, R>(\n\t\tdomain: D,\n\t\trange: R,\n\t\torientation?: CartesianOrientations\n\t): [D, R] | [R, D] {\n\t\treturn orientation === CartesianOrientations.VERTICAL\n\t\t\t? [domain, range]\n\t\t\t: [range, domain];\n\t}\n\n\texport const compareNumeric = (a: Numeric, b: Numeric) =>\n\t\tNumber(a) === Number(b);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WAAmC;QAEnC,OAAO,WAAW,KAAK,qBAAqB,CAAC,QAAQ;YACpD,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC;YACjB,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACpB,CAAC;IARe,0CAAoC,uCAQnD,CAAA;IAEY,oBAAc,GAAG,UAAC,CAAU,EAAE,CAAU;QACpD,OAAA,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;IAAvB,CAAuB,CAAC;AAC1B,CAAC,EApYgB,KAAK,KAAL,KAAK,QAoYrB","sourcesContent":["// Internal imports\nimport {\n\tAxisChartOptions,\n\tCartesianOrientations,\n\tScaleTypes,\n\tTruncationTypes\n} from \"./interfaces\";\n\nimport {\n\tdebounce as lodashDebounce,\n\tmerge as lodashMerge,\n\tcloneDeep as lodashCloneDeep,\n\tuniq as lodashUnique,\n\tclamp as lodashClamp,\n\tisEmpty as lodashIsEmpty,\n\tisEqual as lodashIsEqual,\n\tflatMapDeep as lodashFlatMapDeep,\n\tkebabCase as lodashKebabCase,\n\tfromPairs as lodashFromPairs,\n\tsome as lodashSome,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tCancelable,\n\tDebounceSettings\n} from \"lodash-es\";\n\nimport { mouse } from \"d3-selection\";\nimport { Numeric } from \"d3\";\n\n// Functions\nexport namespace Tools {\n\t// Export these functions from lodash\n\texport const debounce = lodashDebounce;\n\texport const clone = lodashCloneDeep;\n\texport const merge = lodashMerge;\n\texport const removeArrayDuplicates = lodashUnique;\n\texport const clamp = lodashClamp;\n\texport const isEmpty = lodashIsEmpty;\n\texport const isEqual = lodashIsEqual;\n\texport const flatMapDeep = lodashFlatMapDeep;\n\texport const kebabCase = lodashKebabCase;\n\texport const fromPairs = lodashFromPairs;\n\texport const some = lodashSome;\n\n\texport function debounceWithD3MousePosition(fn, delay, element) {\n\t\tvar timer = null;\n\t\treturn function () {\n\t\t\tconst context = this;\n\t\t\tconst args = arguments;\n\n\t\t\t//we get the D3 event here\n\t\t\tcontext.mousePosition = mouse(element);\n\n\t\t\tclearTimeout(timer);\n\n\t\t\ttimer = setTimeout(function () {\n\t\t\t\t//and use the reference here\n\t\t\t\tfn.apply(context, args);\n\t\t\t}, delay);\n\t\t};\n\t}\n\n\t/**\n\t * Returns default chart options merged with provided options,\n\t * with special cases for axes.\n\t * Axes object will not merge the not provided axes.\n\t *\n\t * @export\n\t * @param {AxisChartOptions} defaultOptions Configuration.options[chartType]\n\t * @param {AxisChartOptions} providedOptions user provided options\n\t * @returns merged options\n\t */\n\texport function mergeDefaultChartOptions(\n\t\tdefaultOptions: any,\n\t\tprovidedOptions: any\n\t) {\n\t\tdefaultOptions = Tools.clone(defaultOptions);\n\t\tconst providedAxesNames = Object.keys(providedOptions.axes || {});\n\n\t\tif (providedAxesNames.length === 0) {\n\t\t\tdelete defaultOptions.axes;\n\t\t}\n\n\t\t// Update deprecated options to work with the tabular data format\n\t\t// Similar to the functionality in model.transformToTabularData()\n\t\tfor (const axisName in defaultOptions.axes) {\n\t\t\tif (providedAxesNames.includes(axisName)) {\n\t\t\t\tconst providedAxisOptions = providedOptions.axes[axisName];\n\n\t\t\t\tif (\n\t\t\t\t\tprovidedAxisOptions[\"primary\"] ||\n\t\t\t\t\tprovidedAxisOptions[\"secondary\"]\n\t\t\t\t) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\"`primary` & `secondary` are no longer needed for axis configurations. Read more here https://carbon-design-system.github.io/carbon-charts/?path=/story/tutorials--tabular-data-format\"\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst identifier = providedAxisOptions[\"mapsTo\"];\n\t\t\t\tif (identifier === undefined || identifier === null) {\n\t\t\t\t\tconst scaleType = providedAxisOptions[\"scaleType\"];\n\n\t\t\t\t\tif (scaleType === undefined || scaleType === null) {\n\t\t\t\t\t\tprovidedAxisOptions[\"mapsTo\"] = \"value\";\n\t\t\t\t\t} else if (scaleType === ScaleTypes.TIME) {\n\t\t\t\t\t\tprovidedAxisOptions[\"mapsTo\"] = \"date\";\n\t\t\t\t\t} else if (scaleType === ScaleTypes.LABELS) {\n\t\t\t\t\t\tprovidedAxisOptions[\"mapsTo\"] = \"key\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdelete defaultOptions.axes[axisName];\n\t\t\t}\n\t\t}\n\n\t\treturn Tools.merge(defaultOptions, providedOptions);\n\t}\n\n\t/**************************************\n\t * DOM-related operations *\n\t *************************************/\n\n\t/**\n\t * Get width & height of an element\n\t *\n\t * @export\n\t * @param {any} el element to get dimensions from\n\t * @returns an object containing the width and height of el\n\t */\n\texport function getDimensions(el) {\n\t\treturn {\n\t\t\twidth: parseFloat(\n\t\t\t\tel.style.width.replace(\"px\", \"\") || el.offsetWidth\n\t\t\t),\n\t\t\theight: parseFloat(\n\t\t\t\tel.style.height.replace(\"px\", \"\") || el.offsetHeight\n\t\t\t)\n\t\t};\n\t}\n\n\t/**\n\t * Gets elements's x and y translations from transform attribute or returns null\n\t *\n\t * @param {HTMLElement} element\n\t * @returns an object containing the translated x and y values or null\n\t */\n\texport function getTranslationValues(elementRef: HTMLElement) {\n\t\tif (!elementRef) {\n\t\t\treturn;\n\t\t}\n\n\t\t// regex to ONLY get values for translate (instead of all rotate, translate, skew, etc)\n\t\tconst translateRegex = /translate\\([0-9]+\\.?[0-9]*,[0-9]+\\.?[0-9]*\\)/;\n\n\t\tconst transformStr = elementRef\n\t\t\t.getAttribute(\"transform\")\n\t\t\t.match(translateRegex);\n\t\tif (!transformStr) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// check for the match\n\t\tif (transformStr[0]) {\n\t\t\tconst transforms = transformStr[0]\n\t\t\t\t.replace(/translate\\(/, \"\")\n\t\t\t\t.replace(/\\)/, \"\")\n\t\t\t\t.split(\",\");\n\n\t\t\treturn {\n\t\t\t\ttx: transforms[0],\n\t\t\t\tty: transforms[1]\n\t\t\t};\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**************************************\n\t * Formatting & calculations *\n\t *************************************/\n\n\t/**\n\t * Gets x and y coordinates from HTML transform attribute\n\t *\n\t * @export\n\t * @param {any} string the transform attribute string ie. transform(x,y)\n\t * @returns Returns an object with x and y offsets of the transform\n\t */\n\texport function getTranformOffsets(string) {\n\t\tconst regExp = /\\(([^)]+)\\)/;\n\t\tconst match = regExp.exec(string)[1];\n\t\tconst xyString = match.split(\",\");\n\n\t\treturn {\n\t\t\tx: parseFloat(xyString[0]),\n\t\t\ty: parseFloat(xyString[1])\n\t\t};\n\t}\n\n\t/**\n\t * Returns string value for height/width using pixels if there isn't a specified unit of measure\n\t *\n\t * @param value string or number value to be checked for unit of measure\n\t */\n\texport function formatWidthHeightValues(value) {\n\t\tconst stringValue = value.toString();\n\n\t\t// If the value provided contains any letters\n\t\t// Return it the same way\n\t\tif (stringValue.match(/[a-z]/i)) {\n\t\t\treturn stringValue;\n\t\t}\n\n\t\treturn stringValue + \"px\";\n\t}\n\n\t/**\n\t * Capitalizes first letter of a string\n\t *\n\t * @export\n\t * @param {any} string the input string to perform first letter capitalization with\n\t * @returns The transformed string after first letter is capitalized\n\t */\n\texport function capitalizeFirstLetter(string) {\n\t\treturn string[0].toUpperCase() + string.slice(1);\n\t}\n\n\t/**\n\t * Get the percentage of a datapoint compared to the entire dataset.\n\t * @export\n\t * @param {any} item\n\t * @param {any} fullData\n\t * @returns The percentage in the form of a number (1 significant digit if necessary)\n\t */\n\texport function convertValueToPercentage(item, fullData) {\n\t\tconst percentage =\n\t\t\t(item / fullData.reduce((accum, val) => accum + val.value, 0)) *\n\t\t\t100;\n\t\t// if the value has any significant figures, keep 1\n\t\treturn percentage % 1 !== 0\n\t\t\t? parseFloat(percentage.toFixed(1))\n\t\t\t: percentage;\n\t}\n\n\t/**\n\t * Truncate the labels\n\t * @export\n\t * @param {any} fullText\n\t * @param {any} truncationType\n\t * @param {any} numCharacter\n\t * @returns Truncated text\n\t */\n\texport function truncateLabel(fullText, truncationType, numCharacter) {\n\t\tif (numCharacter > fullText.length) {\n\t\t\treturn fullText;\n\t\t}\n\t\tif (truncationType === TruncationTypes.MID_LINE) {\n\t\t\treturn (\n\t\t\t\tfullText.substr(0, numCharacter / 2) +\n\t\t\t\t\"...\" +\n\t\t\t\tfullText.substr(-numCharacter / 2)\n\t\t\t);\n\t\t} else if (truncationType === TruncationTypes.FRONT_LINE) {\n\t\t\treturn \"...\" + fullText.substr(-numCharacter);\n\t\t} else if (truncationType === TruncationTypes.END_LINE) {\n\t\t\treturn fullText.substr(0, numCharacter) + \"...\";\n\t\t}\n\t}\n\n\t/**************************************\n\t * Object/array related checks *\n\t *************************************/\n\n\t/**\n\t * Compares two arrays to return the difference between two arrays' items.\n\t *\n\t * @export\n\t * @param {any[]} oldArray the array to check for missing items\n\t * @param {any[]} newArray the array to check for newly added items\n\t * @returns An object containing items missing (existing in oldArray but not newArray)\n\t * and items added (existing in newArray but not in oldArray). Object is of the form { missing: [], added: [] }\n\t */\n\texport function arrayDifferences(oldArray: any[], newArray: any[]) {\n\t\tconst difference = {\n\t\t\tmissing: [],\n\t\t\tadded: []\n\t\t};\n\n\t\toldArray.forEach((element) => {\n\t\t\tif (newArray.indexOf(element) === -1) {\n\t\t\t\tdifference.missing.push(element);\n\t\t\t}\n\t\t});\n\n\t\tnewArray.forEach((element) => {\n\t\t\tif (oldArray.indexOf(element) === -1) {\n\t\t\t\tdifference.added.push(element);\n\t\t\t}\n\t\t});\n\n\t\treturn difference;\n\t}\n\n\t/**\n\t * Gets the duplicated keys from an array of data\n\t *\n\t * @export\n\t * @param {*} data - array of data\n\t * @returns A list of the duplicated keys in data\n\t */\n\texport function getDuplicateValues(arr: any) {\n\t\tconst values = [];\n\t\tconst duplicateValues = [];\n\n\t\tarr.forEach((value) => {\n\t\t\tif (\n\t\t\t\tvalues.indexOf(value) !== -1 &&\n\t\t\t\tduplicateValues.indexOf(value) === -1\n\t\t\t) {\n\t\t\t\tduplicateValues.push(value);\n\t\t\t}\n\n\t\t\tvalues.push(value);\n\t\t});\n\n\t\treturn duplicateValues;\n\t}\n\n\t// ================================================================================\n\t// D3 Extensions\n\t// ================================================================================\n\n\t/**\n\t * In D3, moves an element to the front of the canvas\n\t *\n\t * @export\n\t * @param {any} element input element to moved in front\n\t * @returns The function to be used by D3 to push element to the top of the canvas\n\t */\n\texport function moveToFront(element) {\n\t\treturn element.each(function () {\n\t\t\tthis.parentNode.appendChild(this);\n\t\t});\n\t}\n\n\t// ================================================================================\n\t// Style Helpers\n\t// ================================================================================\n\n\t/**\n\t * Gets a speicified property from within an object.\n\t *\n\t * @param object the object containing the property to retrieve\n\t * @param propPath nested properties used to extract the final property from within the object\n\t * (i.e \"style\", \"color\" would retrieve the color property from within an object that has \"color\" nested within \"style\")\n\t */\n\texport const getProperty = (object, ...propPath) => {\n\t\tlet position = object;\n\t\tif (position) {\n\t\t\tfor (const prop of propPath) {\n\t\t\t\tif (position[prop] !== null && position[prop] !== undefined) {\n\t\t\t\t\tposition = position[prop];\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn position;\n\t\t}\n\n\t\treturn null;\n\t};\n\n\tinterface SVGPathCoordinates {\n\t\tx0: number;\n\t\tx1: number;\n\t\ty0: number;\n\t\ty1: number;\n\t}\n\n\texport const flipSVGCoordinatesBasedOnOrientation = (\n\t\tverticalCoordinates: SVGPathCoordinates,\n\t\torientation?: CartesianOrientations\n\t) => {\n\t\tif (orientation === CartesianOrientations.HORIZONTAL) {\n\t\t\treturn {\n\t\t\t\ty0: verticalCoordinates.x0,\n\t\t\t\ty1: verticalCoordinates.x1,\n\t\t\t\tx0: verticalCoordinates.y0,\n\t\t\t\tx1: verticalCoordinates.y1\n\t\t\t};\n\t\t}\n\n\t\treturn verticalCoordinates;\n\t};\n\n\texport const generateSVGPathString = (\n\t\tverticalCoordinates: SVGPathCoordinates,\n\t\torientation?: CartesianOrientations\n\t) => {\n\t\tconst { x0, x1, y0, y1 } = flipSVGCoordinatesBasedOnOrientation(\n\t\t\tverticalCoordinates,\n\t\t\torientation\n\t\t);\n\n\t\treturn `M${x0},${y0}L${x0},${y1}L${x1},${y1}L${x1},${y0}L${x0},${y0}`;\n\t};\n\n\texport function flipDomainAndRangeBasedOnOrientation<D, R>(\n\t\tdomain: D,\n\t\trange: R,\n\t\torientation?: CartesianOrientations\n\t): [D, R] | [R, D] {\n\t\treturn orientation === CartesianOrientations.VERTICAL\n\t\t\t? [domain, range]\n\t\t\t: [range, domain];\n\t}\n\n\texport const compareNumeric = (a: Numeric, b: Numeric) =>\n\t\tNumber(a) === Number(b);\n}\n"]}
|