@carbon/charts 0.34.4 → 0.34.8

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.
Files changed (180) hide show
  1. package/CHANGELOG.md +34 -16
  2. package/axis-chart.d.ts +2 -2
  3. package/axis-chart.js +27 -4
  4. package/axis-chart.js.map +1 -1
  5. package/build/demo/data/bar.d.ts +23 -0
  6. package/build/demo/data/zoom-bar.d.ts +74 -0
  7. package/build/src/axis-chart.d.ts +2 -2
  8. package/build/src/components/axes/axis.d.ts +4 -0
  9. package/build/src/components/axes/chart-clip.d.ts +11 -0
  10. package/build/src/components/axes/grid-brush.d.ts +8 -0
  11. package/build/src/components/axes/ruler-stacked-bar.d.ts +1 -0
  12. package/build/src/components/axes/zoom-bar.d.ts +20 -0
  13. package/build/src/components/component.d.ts +3 -1
  14. package/build/src/components/essentials/tooltip.d.ts +1 -1
  15. package/build/src/components/graphs/bar.d.ts +1 -0
  16. package/build/src/components/graphs/scatter.d.ts +1 -0
  17. package/build/src/components/index.d.ts +3 -0
  18. package/build/src/configuration.d.ts +4 -0
  19. package/build/src/interfaces/charts.d.ts +5 -1
  20. package/build/src/interfaces/components.d.ts +26 -0
  21. package/build/src/interfaces/events.d.ts +9 -0
  22. package/build/src/model.d.ts +2 -2
  23. package/build/src/services/index.d.ts +1 -0
  24. package/build/src/services/scales-cartesian.d.ts +7 -4
  25. package/build/src/services/zoom.d.ts +5 -0
  26. package/build/src/tools.d.ts +1 -0
  27. package/bundle.js +1 -1
  28. package/chart.js +5 -4
  29. package/chart.js.map +1 -1
  30. package/charts/area-stacked.js.map +1 -1
  31. package/charts/area.js.map +1 -1
  32. package/charts/bar-grouped.js.map +1 -1
  33. package/charts/bar-simple.js.map +1 -1
  34. package/charts/bar-stacked.js.map +1 -1
  35. package/charts/bubble.js.map +1 -1
  36. package/charts/donut.js.map +1 -1
  37. package/charts/line.js.map +1 -1
  38. package/charts/meter.js +7 -15
  39. package/charts/meter.js.map +1 -1
  40. package/charts/pie.js.map +1 -1
  41. package/charts/radar.js +3 -1
  42. package/charts/radar.js.map +1 -1
  43. package/charts/scatter.js.map +1 -1
  44. package/components/axes/axis.d.ts +4 -0
  45. package/components/axes/axis.js +45 -12
  46. package/components/axes/axis.js.map +1 -1
  47. package/components/axes/chart-clip.d.ts +11 -0
  48. package/components/axes/chart-clip.js +59 -0
  49. package/components/axes/chart-clip.js.map +1 -0
  50. package/components/axes/grid-brush.d.ts +8 -0
  51. package/components/axes/grid-brush.js +163 -0
  52. package/components/axes/grid-brush.js.map +1 -0
  53. package/components/axes/ruler-stacked-bar.d.ts +1 -0
  54. package/components/axes/ruler-stacked-bar.js +8 -0
  55. package/components/axes/ruler-stacked-bar.js.map +1 -1
  56. package/components/axes/ruler.js +19 -10
  57. package/components/axes/ruler.js.map +1 -1
  58. package/components/axes/two-dimensional-axes.js +4 -0
  59. package/components/axes/two-dimensional-axes.js.map +1 -1
  60. package/components/axes/zoom-bar.d.ts +20 -0
  61. package/components/axes/zoom-bar.js +312 -0
  62. package/components/axes/zoom-bar.js.map +1 -0
  63. package/components/component.d.ts +3 -1
  64. package/components/component.js +11 -2
  65. package/components/component.js.map +1 -1
  66. package/components/essentials/legend.js.map +1 -1
  67. package/components/essentials/threshold.js +2 -1
  68. package/components/essentials/threshold.js.map +1 -1
  69. package/components/essentials/title-meter.js +28 -17
  70. package/components/essentials/title-meter.js.map +1 -1
  71. package/components/essentials/title.js +2 -1
  72. package/components/essentials/title.js.map +1 -1
  73. package/components/essentials/tooltip-axis.js +4 -1
  74. package/components/essentials/tooltip-axis.js.map +1 -1
  75. package/components/essentials/tooltip.d.ts +1 -1
  76. package/components/essentials/tooltip.js +30 -37
  77. package/components/essentials/tooltip.js.map +1 -1
  78. package/components/graphs/area-stacked.js +1 -1
  79. package/components/graphs/area-stacked.js.map +1 -1
  80. package/components/graphs/area.js +1 -1
  81. package/components/graphs/area.js.map +1 -1
  82. package/components/graphs/bar-grouped.js +5 -1
  83. package/components/graphs/bar-grouped.js.map +1 -1
  84. package/components/graphs/bar-simple.js +5 -1
  85. package/components/graphs/bar-simple.js.map +1 -1
  86. package/components/graphs/bar-stacked.js +5 -1
  87. package/components/graphs/bar-stacked.js.map +1 -1
  88. package/components/graphs/bar.d.ts +1 -0
  89. package/components/graphs/bar.js +21 -1
  90. package/components/graphs/bar.js.map +1 -1
  91. package/components/graphs/line.js +1 -1
  92. package/components/graphs/line.js.map +1 -1
  93. package/components/graphs/meter.js +13 -12
  94. package/components/graphs/meter.js.map +1 -1
  95. package/components/graphs/pie.js +17 -10
  96. package/components/graphs/pie.js.map +1 -1
  97. package/components/graphs/radar.js.map +1 -1
  98. package/components/graphs/scatter-stacked.js +1 -1
  99. package/components/graphs/scatter-stacked.js.map +1 -1
  100. package/components/graphs/scatter.d.ts +1 -0
  101. package/components/graphs/scatter.js +14 -1
  102. package/components/graphs/scatter.js.map +1 -1
  103. package/components/index.d.ts +3 -0
  104. package/components/index.js +3 -0
  105. package/components/index.js.map +1 -1
  106. package/configuration.d.ts +4 -0
  107. package/configuration.js +10 -1
  108. package/configuration.js.map +1 -1
  109. package/demo/data/bar.d.ts +23 -0
  110. package/demo/data/bar.js +34 -0
  111. package/demo/data/bar.js.map +1 -1
  112. package/demo/data/bundle.js +1 -1
  113. package/demo/data/donut.js.map +1 -1
  114. package/demo/data/index.js +78 -0
  115. package/demo/data/index.js.map +1 -1
  116. package/demo/data/line.js.map +1 -1
  117. package/demo/data/meter.js.map +1 -1
  118. package/demo/data/pie.js.map +1 -1
  119. package/demo/data/radar.js.map +1 -1
  120. package/demo/data/time-series-axis.js +6 -6
  121. package/demo/data/time-series-axis.js.map +1 -1
  122. package/demo/data/zoom-bar.d.ts +74 -0
  123. package/demo/data/zoom-bar.js +77 -0
  124. package/demo/data/zoom-bar.js.map +1 -0
  125. package/demo/styles.css +352 -4
  126. package/demo/styles.css.map +1 -1
  127. package/demo/styles.min.css +1 -1
  128. package/demo/styles.min.css.map +1 -1
  129. package/demo/tsconfig.tsbuildinfo +41 -21
  130. package/interfaces/axis-scales.js.map +1 -1
  131. package/interfaces/charts.d.ts +5 -1
  132. package/interfaces/charts.js.map +1 -1
  133. package/interfaces/components.d.ts +26 -0
  134. package/interfaces/components.js.map +1 -1
  135. package/interfaces/events.d.ts +9 -0
  136. package/interfaces/events.js +10 -0
  137. package/interfaces/events.js.map +1 -1
  138. package/model-meter.js +3 -1
  139. package/model-meter.js.map +1 -1
  140. package/model.d.ts +2 -2
  141. package/model.js +10 -8
  142. package/model.js.map +1 -1
  143. package/package.json +1 -1
  144. package/services/essentials/dom-utils.js +9 -4
  145. package/services/essentials/dom-utils.js.map +1 -1
  146. package/services/index.d.ts +1 -0
  147. package/services/index.js +1 -0
  148. package/services/index.js.map +1 -1
  149. package/services/scales-cartesian.d.ts +7 -4
  150. package/services/scales-cartesian.js +27 -12
  151. package/services/scales-cartesian.js.map +1 -1
  152. package/services/zoom.d.ts +5 -0
  153. package/services/zoom.js +73 -0
  154. package/services/zoom.js.map +1 -0
  155. package/styles/components/_grid-brush.scss +18 -0
  156. package/styles/components/_meter-title.scss +5 -1
  157. package/styles/components/_zoom-bar.scss +38 -0
  158. package/styles/components/index.scss +2 -0
  159. package/styles/graphs/_meter.scss +5 -1
  160. package/styles/styles.scss +1 -1
  161. package/styles-g10.css +41 -1
  162. package/styles-g10.css.map +1 -1
  163. package/styles-g10.min.css +1 -1
  164. package/styles-g10.min.css.map +1 -1
  165. package/styles-g100.css +41 -1
  166. package/styles-g100.css.map +1 -1
  167. package/styles-g100.min.css +1 -1
  168. package/styles-g100.min.css.map +1 -1
  169. package/styles-g90.css +41 -1
  170. package/styles-g90.css.map +1 -1
  171. package/styles-g90.min.css +1 -1
  172. package/styles-g90.min.css.map +1 -1
  173. package/styles.css +41 -1
  174. package/styles.css.map +1 -1
  175. package/styles.min.css +1 -1
  176. package/styles.min.css.map +1 -1
  177. package/tools.d.ts +1 -0
  178. package/tools.js +16 -0
  179. package/tools.js.map +1 -1
  180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AAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,4BAAY,GAAZ;QACC,IAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QAExB,IAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC;QACjE,IAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC;QAE3D,IAAA,uBAA6C,EAA5C,mBAAW,EAAE,iBAA+B,CAAC;QAC9C,IAAA,uBAA6C,EAA5C,iBAAS,EAAE,mBAAiC,CAAC;QAEpD,2BAA2B;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC;QACxE,IAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAC3C,IAAI,CAAC,QAAQ,EACb,0BAA0B,CAC1B,CAAC;QAEF,IAAI,CAAC,QAAQ;aACX,KAAK,CAAC,YAAY,CAAC;aACnB,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;aACtB,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;aACtB,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,WAAW,CAAC;aACtC,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,WAAW,CAAC;aACvC,KAAK,EAAE,CAAC;QAEV,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IACF,YAAC;AAAD,CAAC,AAlND,CAA2B,SAAS,GAkNnC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { DOMUtils } from \"../../services\";\nimport { CartesianOrientations, Events } from \"../../interfaces\";\nimport { Tools } from \"../../tools\";\n\n// D3 Imports\nimport { mouse, Selection } from \"d3-selection\";\n\ntype GenericSvgSelection = Selection<SVGElement, any, SVGElement, any>;\n\nconst THRESHOLD = 5;\n\n/** check if x is inside threshold area extents */\nfunction pointIsWithinThreshold(dx: number, x: number) {\n\treturn dx > x - THRESHOLD && dx < x + THRESHOLD;\n}\n\nexport class Ruler extends Component {\n\ttype = \"ruler\";\n\tbackdrop: GenericSvgSelection;\n\telementsToHighlight: GenericSvgSelection;\n\tpointsWithinLine: {\n\t\tdomainValue: number;\n\t\toriginalData: any;\n\t}[];\n\n\trender() {\n\t\tthis.drawBackdrop();\n\t\tthis.addBackdropEventListeners();\n\t}\n\n\tformatTooltipData(tooltipData) {\n\t\treturn tooltipData;\n\t}\n\n\tshowRuler([x, y]: [number, number]) {\n\t\tconst svg = this.parent;\n\t\tconst orientation: CartesianOrientations = this.services.cartesianScales.getOrientation();\n\t\tconst mouseCoordinate =\n\t\t\torientation === CartesianOrientations.HORIZONTAL ? y : x;\n\t\tconst ruler = DOMUtils\n\t\t\t.appendOrSelect(svg, \"g.ruler\")\n\t\t\t.attr(\"aria-label\", \"ruler\");\n\t\tconst rulerLine = DOMUtils.appendOrSelect(ruler, \"line.ruler-line\");\n\t\tconst dataPointElements: GenericSvgSelection = svg.selectAll(\n\t\t\t\"[role=graphics-symbol]\"\n\t\t);\n\t\tconst displayData = this.model.getDisplayData();\n\t\tconst rangeScale = this.services.cartesianScales.getRangeScale();\n\t\tconst [yScaleEnd, yScaleStart] = rangeScale.range();\n\n\t\tconst pointsWithinLine = displayData\n\t\t\t.map((d) => ({\n\t\t\t\tdomainValue: this.services.cartesianScales.getDomainValue(d),\n\t\t\t\toriginalData: d\n\t\t\t}))\n\t\t\t.filter((d) =>\n\t\t\t\tpointIsWithinThreshold(d.domainValue, mouseCoordinate)\n\t\t\t);\n\n\t\tif (\n\t\t\tthis.pointsWithinLine &&\n\t\t\tpointsWithinLine.length === this.pointsWithinLine.length &&\n\t\t\tpointsWithinLine.map((point) => point.domainValue).join() ===\n\t\t\t\tthis.pointsWithinLine.map((point) => point.domainValue).join()\n\t\t) {\n\t\t\tthis.pointsWithinLine = pointsWithinLine;\n\t\t\treturn this.services.events.dispatchEvent(Events.Tooltip.MOVE);\n\t\t}\n\n\t\tthis.pointsWithinLine = pointsWithinLine;\n\n\t\t/**\n\t\t * Find matches, reduce is used instead of filter\n\t\t * to only get elements which belong to the same axis coordinate\n\t\t */\n\t\tconst dataPointsMatchingRulerLine: {\n\t\t\tdomainValue: number;\n\t\t\toriginalData: any;\n\t\t}[] = this.pointsWithinLine.reduce((accum, currentValue) => {\n\t\t\tif (accum.length === 0) {\n\t\t\t\taccum.push(currentValue);\n\t\t\t\treturn accum;\n\t\t\t}\n\n\t\t\t// store the first element of the accumulator array to compare it with current element being processed\n\t\t\tconst sampleAccumValue = accum[0].domainValue;\n\n\t\t\tconst distanceToCurrentValue = Math.abs(\n\t\t\t\tmouseCoordinate - currentValue.domainValue\n\t\t\t);\n\t\t\tconst distanceToAccumValue = Math.abs(\n\t\t\t\tmouseCoordinate - sampleAccumValue\n\t\t\t);\n\n\t\t\tif (distanceToCurrentValue > distanceToAccumValue) {\n\t\t\t\t// if distance with current value is bigger than already existing value in the accumulator, skip current iteration\n\t\t\t\treturn accum;\n\t\t\t} else if (distanceToCurrentValue < distanceToAccumValue) {\n\t\t\t\t// currentValue data point is closer to mouse inside the threshold area, so reinstantiate array\n\t\t\t\taccum = [currentValue];\n\t\t\t} else {\n\t\t\t\t// currentValue is equal to already stored values, which means there's another match on the same coordinate\n\t\t\t\taccum.push(currentValue);\n\t\t\t}\n\n\t\t\treturn accum;\n\t\t}, []);\n\n\t\t// some data point match\n\t\tif (dataPointsMatchingRulerLine.length > 0) {\n\t\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\t\t\tconst tooltipData = dataPointsMatchingRulerLine\n\t\t\t\t.map((d) => d.originalData)\n\t\t\t\t.filter((d) => {\n\t\t\t\t\tconst value = d[rangeIdentifier];\n\t\t\t\t\treturn value !== null && value !== undefined;\n\t\t\t\t});\n\n\t\t\t// get elements on which we should trigger mouse events\n\t\t\tconst domainValuesMatchingRulerLine = dataPointsMatchingRulerLine.map(\n\t\t\t\t(d) => d.domainValue\n\t\t\t);\n\t\t\tconst elementsToHighlight = dataPointElements.filter((d) => {\n\t\t\t\tconst domainValue = this.services.cartesianScales.getDomainValue(\n\t\t\t\t\td\n\t\t\t\t);\n\t\t\t\treturn domainValuesMatchingRulerLine.includes(domainValue);\n\t\t\t});\n\n\t\t\t/** if we pass from a trigger area to another one\n\t\t\t * mouseout on previous elements won't get dispatched\n\t\t\t * so we need to do it manually\n\t\t\t */\n\t\t\tif (\n\t\t\t\tthis.elementsToHighlight &&\n\t\t\t\tthis.elementsToHighlight.size() > 0 &&\n\t\t\t\t!Tools.isEqual(this.elementsToHighlight, elementsToHighlight)\n\t\t\t) {\n\t\t\t\tthis.hideRuler();\n\t\t\t}\n\n\t\t\telementsToHighlight.dispatch(\"mouseover\");\n\n\t\t\t// set current hovered elements\n\t\t\tthis.elementsToHighlight = elementsToHighlight;\n\n\t\t\tthis.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\thoveredElement: rulerLine,\n\t\t\t\tdata: this.formatTooltipData(tooltipData)\n\t\t\t});\n\n\t\t\truler.attr(\"opacity\", 1);\n\n\t\t\t// line snaps to matching point\n\t\t\tconst sampleMatch = dataPointsMatchingRulerLine[0];\n\t\t\tif (orientation === \"horizontal\") {\n\t\t\t\trulerLine\n\t\t\t\t\t.attr(\"x1\", yScaleStart)\n\t\t\t\t\t.attr(\"x2\", yScaleEnd)\n\t\t\t\t\t.attr(\"y1\", sampleMatch.domainValue)\n\t\t\t\t\t.attr(\"y2\", sampleMatch.domainValue);\n\t\t\t} else {\n\t\t\t\trulerLine\n\t\t\t\t\t.attr(\"y1\", yScaleStart)\n\t\t\t\t\t.attr(\"y2\", yScaleEnd)\n\t\t\t\t\t.attr(\"x1\", sampleMatch.domainValue)\n\t\t\t\t\t.attr(\"x2\", sampleMatch.domainValue);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.hideRuler();\n\t\t}\n\t}\n\n\thideRuler() {\n\t\tconst svg = this.parent;\n\t\tconst ruler = DOMUtils.appendOrSelect(svg, \"g.ruler\");\n\t\tconst dataPointElements = svg.selectAll(\"[role=graphics-symbol]\");\n\n\t\tdataPointElements.dispatch(\"mouseout\");\n\t\tthis.services.events.dispatchEvent(Events.Tooltip.HIDE);\n\t\truler.attr(\"opacity\", 0);\n\t}\n\n\t/**\n\t * Adds the listener on the X grid to trigger multiple point tooltips along the x axis.\n\t */\n\taddBackdropEventListeners() {\n\t\tconst self = this;\n\n\t\tthis.backdrop\n\t\t\t.on(\"mousemove mouseover\", function () {\n\t\t\t\tconst pos = mouse(self.parent.node());\n\n\t\t\t\tself.showRuler(pos);\n\t\t\t})\n\t\t\t.on(\"mouseout\", function () {\n\t\t\t\tself.hideRuler();\n\t\t\t});\n\t}\n\n\tdrawBackdrop() {\n\t\tconst svg = this.parent;\n\n\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tconst [yScaleEnd, yScaleStart] = mainYScale.range();\n\n\t\t// Get height from the grid\n\t\tthis.backdrop = DOMUtils.appendOrSelect(svg, \"svg.chart-grid-backdrop\");\n\t\tconst backdropRect = DOMUtils.appendOrSelect(\n\t\t\tthis.backdrop,\n\t\t\t\"rect.chart-grid-backdrop\"\n\t\t);\n\n\t\tthis.backdrop\n\t\t\t.merge(backdropRect)\n\t\t\t.attr(\"x\", xScaleStart)\n\t\t\t.attr(\"y\", yScaleStart)\n\t\t\t.attr(\"width\", xScaleEnd - xScaleStart)\n\t\t\t.attr(\"height\", yScaleEnd - yScaleStart)\n\t\t\t.lower();\n\n\t\tbackdropRect.attr(\"width\", \"100%\").attr(\"height\", \"100%\");\n\t}\n}\n"]}
1
+ {"version":3,"file":"ruler.js","sourceRoot":"","sources":["ruler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AAC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AAQ,EAAE,SAAS,GAAG,WAAW,CAAC;aACvC,KAAK,EAAE,CAAC;QAEV,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IACF,YAAC;AAAD,CAAC,AApOD,CAA2B,SAAS,GAoOnC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { DOMUtils } from \"../../services\";\nimport { CartesianOrientations, Events } from \"../../interfaces\";\nimport { Tools } from \"../../tools\";\n\n// D3 Imports\nimport { Selection, mouse } from \"d3-selection\";\n\ntype GenericSvgSelection = Selection<SVGElement, any, SVGElement, any>;\n\nconst THRESHOLD = 5;\n\n/** check if x is inside threshold area extents */\nfunction pointIsWithinThreshold(dx: number, x: number) {\n\treturn dx > x - THRESHOLD && dx < x + THRESHOLD;\n}\n\nexport class Ruler extends Component {\n\ttype = \"ruler\";\n\tbackdrop: GenericSvgSelection;\n\telementsToHighlight: GenericSvgSelection;\n\tpointsWithinLine: {\n\t\tdomainValue: number;\n\t\toriginalData: any;\n\t}[];\n\n\trender() {\n\t\tthis.drawBackdrop();\n\t\tthis.addBackdropEventListeners();\n\t}\n\n\tformatTooltipData(tooltipData) {\n\t\treturn tooltipData;\n\t}\n\n\tshowRuler([x, y]: [number, number]) {\n\t\tconst svg = this.parent;\n\t\tconst orientation: CartesianOrientations = this.services.cartesianScales.getOrientation();\n\t\tconst mouseCoordinate =\n\t\t\torientation === CartesianOrientations.HORIZONTAL ? y : x;\n\t\tconst ruler = DOMUtils.appendOrSelect(svg, \"g.ruler\").attr(\n\t\t\t\"aria-label\",\n\t\t\t\"ruler\"\n\t\t);\n\t\tconst rulerLine = DOMUtils.appendOrSelect(ruler, \"line.ruler-line\");\n\t\tconst dataPointElements: GenericSvgSelection = svg.selectAll(\n\t\t\t\"[role=graphics-symbol]\"\n\t\t);\n\t\tconst displayData = this.model.getDisplayData();\n\t\tconst rangeScale = this.services.cartesianScales.getRangeScale();\n\t\tconst [yScaleEnd, yScaleStart] = rangeScale.range();\n\n\t\tconst pointsWithinLine = displayData\n\t\t\t.map((d) => ({\n\t\t\t\tdomainValue: this.services.cartesianScales.getDomainValue(d),\n\t\t\t\toriginalData: d\n\t\t\t}))\n\t\t\t.filter((d) =>\n\t\t\t\tpointIsWithinThreshold(d.domainValue, mouseCoordinate)\n\t\t\t);\n\n\t\tif (\n\t\t\tthis.pointsWithinLine &&\n\t\t\tpointsWithinLine.length === this.pointsWithinLine.length &&\n\t\t\tpointsWithinLine.map((point) => point.domainValue).join() ===\n\t\t\t\tthis.pointsWithinLine.map((point) => point.domainValue).join()\n\t\t) {\n\t\t\tthis.pointsWithinLine = pointsWithinLine;\n\t\t\treturn this.services.events.dispatchEvent(Events.Tooltip.MOVE, {\n\t\t\t\tmousePosition: [x, y]\n\t\t\t});\n\t\t}\n\n\t\tthis.pointsWithinLine = pointsWithinLine;\n\n\t\t/**\n\t\t * Find matches, reduce is used instead of filter\n\t\t * to only get elements which belong to the same axis coordinate\n\t\t */\n\t\tconst dataPointsMatchingRulerLine: {\n\t\t\tdomainValue: number;\n\t\t\toriginalData: any;\n\t\t}[] = this.pointsWithinLine.reduce((accum, currentValue) => {\n\t\t\tif (accum.length === 0) {\n\t\t\t\taccum.push(currentValue);\n\t\t\t\treturn accum;\n\t\t\t}\n\n\t\t\t// store the first element of the accumulator array to compare it with current element being processed\n\t\t\tconst sampleAccumValue = accum[0].domainValue;\n\n\t\t\tconst distanceToCurrentValue = Math.abs(\n\t\t\t\tmouseCoordinate - currentValue.domainValue\n\t\t\t);\n\t\t\tconst distanceToAccumValue = Math.abs(\n\t\t\t\tmouseCoordinate - sampleAccumValue\n\t\t\t);\n\n\t\t\tif (distanceToCurrentValue > distanceToAccumValue) {\n\t\t\t\t// if distance with current value is bigger than already existing value in the accumulator, skip current iteration\n\t\t\t\treturn accum;\n\t\t\t} else if (distanceToCurrentValue < distanceToAccumValue) {\n\t\t\t\t// currentValue data point is closer to mouse inside the threshold area, so reinstantiate array\n\t\t\t\taccum = [currentValue];\n\t\t\t} else {\n\t\t\t\t// currentValue is equal to already stored values, which means there's another match on the same coordinate\n\t\t\t\taccum.push(currentValue);\n\t\t\t}\n\n\t\t\treturn accum;\n\t\t}, []);\n\n\t\t// some data point match\n\t\tif (dataPointsMatchingRulerLine.length > 0) {\n\t\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\t\t\tconst tooltipData = dataPointsMatchingRulerLine\n\t\t\t\t.map((d) => d.originalData)\n\t\t\t\t.filter((d) => {\n\t\t\t\t\tconst value = d[rangeIdentifier];\n\t\t\t\t\treturn value !== null && value !== undefined;\n\t\t\t\t});\n\n\t\t\t// get elements on which we should trigger mouse events\n\t\t\tconst domainValuesMatchingRulerLine = dataPointsMatchingRulerLine.map(\n\t\t\t\t(d) => d.domainValue\n\t\t\t);\n\t\t\tconst elementsToHighlight = dataPointElements.filter((d) => {\n\t\t\t\tconst domainValue = this.services.cartesianScales.getDomainValue(\n\t\t\t\t\td\n\t\t\t\t);\n\t\t\t\treturn domainValuesMatchingRulerLine.includes(domainValue);\n\t\t\t});\n\n\t\t\t/** if we pass from a trigger area to another one\n\t\t\t * mouseout on previous elements won't get dispatched\n\t\t\t * so we need to do it manually\n\t\t\t */\n\t\t\tif (\n\t\t\t\tthis.elementsToHighlight &&\n\t\t\t\tthis.elementsToHighlight.size() > 0 &&\n\t\t\t\t!Tools.isEqual(this.elementsToHighlight, elementsToHighlight)\n\t\t\t) {\n\t\t\t\tthis.hideRuler();\n\t\t\t}\n\n\t\t\telementsToHighlight.dispatch(\"mouseover\");\n\n\t\t\t// set current hovered elements\n\t\t\tthis.elementsToHighlight = elementsToHighlight;\n\n\t\t\tthis.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\tmousePosition: [x, y],\n\t\t\t\thoveredElement: rulerLine,\n\t\t\t\tdata: this.formatTooltipData(tooltipData)\n\t\t\t});\n\n\t\t\truler.attr(\"opacity\", 1);\n\n\t\t\t// line snaps to matching point\n\t\t\tconst sampleMatch = dataPointsMatchingRulerLine[0];\n\t\t\tif (orientation === \"horizontal\") {\n\t\t\t\trulerLine\n\t\t\t\t\t.attr(\"x1\", yScaleStart)\n\t\t\t\t\t.attr(\"x2\", yScaleEnd)\n\t\t\t\t\t.attr(\"y1\", sampleMatch.domainValue)\n\t\t\t\t\t.attr(\"y2\", sampleMatch.domainValue);\n\t\t\t} else {\n\t\t\t\trulerLine\n\t\t\t\t\t.attr(\"y1\", yScaleStart)\n\t\t\t\t\t.attr(\"y2\", yScaleEnd)\n\t\t\t\t\t.attr(\"x1\", sampleMatch.domainValue)\n\t\t\t\t\t.attr(\"x2\", sampleMatch.domainValue);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.hideRuler();\n\t\t}\n\t}\n\n\thideRuler() {\n\t\tconst svg = this.parent;\n\t\tconst ruler = DOMUtils.appendOrSelect(svg, \"g.ruler\");\n\t\tconst dataPointElements = svg.selectAll(\"[role=graphics-symbol]\");\n\n\t\tdataPointElements.dispatch(\"mouseout\");\n\t\tthis.services.events.dispatchEvent(Events.Tooltip.HIDE);\n\t\truler.attr(\"opacity\", 0);\n\t}\n\n\t/**\n\t * Adds the listener on the X grid to trigger multiple point tooltips along the x axis.\n\t */\n\taddBackdropEventListeners() {\n\t\tconst self = this;\n\t\tconst displayData = this.model.getDisplayData();\n\n\t\tlet mouseMoveCallback = function () {\n\t\t\tconst pos = mouse(self.parent.node());\n\t\t\tself.showRuler(pos);\n\t\t};\n\n\t\t// Debounce mouseMoveCallback if there are more than 100 datapoints\n\t\tif (displayData.length > 100) {\n\t\t\tconst debounceThreshold = (displayData.length % 50) * 12.5;\n\n\t\t\tmouseMoveCallback = Tools.debounceWithD3MousePosition(\n\t\t\t\tfunction () {\n\t\t\t\t\tconst { mousePosition } = this;\n\t\t\t\t\tself.showRuler(mousePosition);\n\t\t\t\t},\n\t\t\t\tdebounceThreshold,\n\t\t\t\tthis.parent.node()\n\t\t\t);\n\t\t}\n\n\t\tthis.backdrop\n\t\t\t.on(\"mousemove mouseover\", mouseMoveCallback)\n\t\t\t.on(\"mouseout\", this.hideRuler.bind(this));\n\t}\n\n\tdrawBackdrop() {\n\t\tconst svg = this.parent;\n\n\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tconst [yScaleEnd, yScaleStart] = mainYScale.range();\n\n\t\t// Get height from the grid\n\t\tthis.backdrop = DOMUtils.appendOrSelect(svg, \"svg.chart-grid-backdrop\");\n\t\tconst backdropRect = DOMUtils.appendOrSelect(\n\t\t\tthis.backdrop,\n\t\t\t\"rect.chart-grid-backdrop\"\n\t\t);\n\n\t\tthis.backdrop\n\t\t\t.merge(backdropRect)\n\t\t\t.attr(\"x\", xScaleStart)\n\t\t\t.attr(\"y\", yScaleStart)\n\t\t\t.attr(\"width\", xScaleEnd - xScaleStart)\n\t\t\t.attr(\"height\", yScaleEnd - yScaleStart)\n\t\t\t.lower();\n\n\t\tbackdropRect.attr(\"width\", \"100%\").attr(\"height\", \"100%\");\n\t}\n}\n"]}
@@ -29,6 +29,7 @@ import { Axis } from "./axis";
29
29
  import { Tools } from "../../tools";
30
30
  import { DOMUtils } from "../../services";
31
31
  import { Threshold } from "../essentials/threshold";
32
+ import { Events } from "./../../interfaces";
32
33
  var TwoDimensionalAxes = /** @class */ (function (_super) {
33
34
  __extends(TwoDimensionalAxes, _super);
34
35
  function TwoDimensionalAxes() {
@@ -121,6 +122,9 @@ var TwoDimensionalAxes = /** @class */ (function (_super) {
121
122
  });
122
123
  if (isNotEqual) {
123
124
  this.margins = Object.assign(this.margins, margins);
125
+ // also set new margins to model to allow external components to access
126
+ this.model.set({ axesMargins: this.margins }, { skipUpdate: true });
127
+ this.services.events.dispatchEvent(Events.ZoomBar.UPDATE);
124
128
  Object.keys(this.children).forEach(function (childKey) {
125
129
  var child = _this.children[childKey];
126
130
  child.margins = _this.margins;
@@ -1 +1 @@
1
- {"version":3,"file":"two-dimensional-axes.js","sourceRoot":"","sources":["two-dimensional-axes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAA2B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;IAAwC,sCAAS;IAAjD;QAAA,qEA6IC;QA5IA,UAAI,GAAG,SAAS,CAAC;QAEjB,cAAQ,GAAQ,EAAE,CAAC;QAEnB,gBAAU,GAAgB,EAAE,CAAC;QAE7B,aAAO,GAAG;YACT,GAAG,EAAE,CAAC;YACN,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,CAAC;SACP,CAAC;;IAiIH,CAAC;IA/HA,mCAAM,GAAN,UAAO,OAAe;QAAtB,iBAqGC;QArGM,wBAAA,EAAA,eAAe;QACrB,IAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,IAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAAC;QAEvE,aAAa,CAAC,OAAO,CAAC,UAAC,YAAY;YAClC,IAAM,WAAW,GAAG,WAAW,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;YAC7D,IAAI,WAAW,EAAE;gBAChB,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,GAAG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AAD,CAAC,AA7ID,CAAwC,SAAS,GA6IhD","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { AxisPositions, ScaleTypes, AxesOptions } from \"../../interfaces\";\nimport { Axis } from \"./axis\";\nimport { Tools } from \"../../tools\";\nimport { DOMUtils } from \"../../services\";\nimport { Threshold } from \"../essentials/threshold\";\n\nexport class TwoDimensionalAxes extends Component {\n\ttype = \"2D-axes\";\n\n\tchildren: any = {};\n\n\tthresholds: Threshold[] = [];\n\n\tmargins = {\n\t\ttop: 0,\n\t\tright: 0,\n\t\tbottom: 0,\n\t\tleft: 0\n\t};\n\n\trender(animate = false) {\n\t\tconst axes = {};\n\t\tconst axisPositions = Object.keys(AxisPositions);\n\t\tconst axesOptions = Tools.getProperty(this.model.getOptions(), \"axes\");\n\n\t\taxisPositions.forEach((axisPosition) => {\n\t\t\tconst axisOptions = axesOptions[AxisPositions[axisPosition]];\n\t\t\tif (axisOptions) {\n\t\t\t\taxes[AxisPositions[axisPosition]] = true;\n\t\t\t}\n\t\t});\n\n\t\tthis.configs.axes = axes;\n\n\t\t// Check the configs to know which axes need to be rendered\n\t\taxisPositions.forEach((axisPositionKey) => {\n\t\t\tconst axisPosition = AxisPositions[axisPositionKey];\n\t\t\tif (\n\t\t\t\tthis.configs.axes[axisPosition] &&\n\t\t\t\t!this.children[axisPosition]\n\t\t\t) {\n\t\t\t\tconst axisComponent = new Axis(this.model, this.services, {\n\t\t\t\t\tposition: axisPosition,\n\t\t\t\t\taxes: this.configs.axes,\n\t\t\t\t\tmargins: this.margins\n\t\t\t\t});\n\n\t\t\t\t// Set model, services & parent for the new axis component\n\t\t\t\taxisComponent.setModel(this.model);\n\t\t\t\taxisComponent.setServices(this.services);\n\t\t\t\taxisComponent.setParent(this.parent);\n\n\t\t\t\tthis.children[axisPosition] = axisComponent;\n\t\t\t}\n\t\t});\n\n\t\tObject.keys(this.children).forEach((childKey) => {\n\t\t\tconst child = this.children[childKey];\n\t\t\tchild.render(animate);\n\t\t});\n\n\t\tconst margins = {} as any;\n\n\t\tObject.keys(this.children).forEach((childKey) => {\n\t\t\tconst child = this.children[childKey];\n\t\t\tconst axisPosition = child.configs.position;\n\n\t\t\t// Grab the invisibly rendered axis' width & height, and set margins\n\t\t\t// Based off of that\n\t\t\t// We draw the invisible axis because of the async nature of d3 transitions\n\t\t\t// To be able to tell the final width & height of the axis when initiaing the transition\n\t\t\t// The invisible axis is updated instantly and without a transition\n\t\t\tconst invisibleAxisRef = child.getInvisibleAxisRef();\n\t\t\tconst {\n\t\t\t\twidth,\n\t\t\t\theight\n\t\t\t} = DOMUtils.getSVGElementSize(invisibleAxisRef, { useBBox: true });\n\n\t\t\tlet offset;\n\t\t\tif (child.getTitleRef().empty()) {\n\t\t\t\toffset = 0;\n\t\t\t} else {\n\t\t\t\toffset = DOMUtils.getSVGElementSize(child.getTitleRef(), {\n\t\t\t\t\tuseBBox: true\n\t\t\t\t}).height;\n\t\t\t}\n\n\t\t\tswitch (axisPosition) {\n\t\t\t\tcase AxisPositions.TOP:\n\t\t\t\t\tmargins.top = height + offset;\n\t\t\t\t\tbreak;\n\t\t\t\tcase AxisPositions.BOTTOM:\n\t\t\t\t\tmargins.bottom = height + offset;\n\t\t\t\t\tbreak;\n\t\t\t\tcase AxisPositions.LEFT:\n\t\t\t\t\tmargins.left = width + offset;\n\t\t\t\t\tbreak;\n\t\t\t\tcase AxisPositions.RIGHT:\n\t\t\t\t\tmargins.right = width + offset;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Add thresholds\n\t\t\tthis.addAxisThresholds(animate, axisPosition);\n\t\t});\n\n\t\t// If the new margins are different than the existing ones\n\t\tconst isNotEqual = Object.keys(margins).some((marginKey) => {\n\t\t\treturn this.margins[marginKey] !== margins[marginKey];\n\t\t});\n\n\t\tif (isNotEqual) {\n\t\t\tthis.margins = Object.assign(this.margins, margins);\n\n\t\t\tObject.keys(this.children).forEach((childKey) => {\n\t\t\t\tconst child = this.children[childKey];\n\t\t\t\tchild.margins = this.margins;\n\t\t\t});\n\n\t\t\tthis.render(true);\n\t\t}\n\t}\n\n\taddAxisThresholds(animate, axisPosition) {\n\t\tconst axesOptions = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"axes\",\n\t\t\taxisPosition\n\t\t);\n\t\tconst { thresholds } = axesOptions;\n\n\t\tif (thresholds) {\n\t\t\tthresholds.forEach((thresholdConfig, i) => {\n\t\t\t\tconst thresholdComponent = new Threshold(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t{ ...thresholdConfig, axisPosition, index: i }\n\t\t\t\t);\n\t\t\t\tthis.thresholds.push(thresholdComponent);\n\t\t\t});\n\n\t\t\tthis.thresholds.forEach((threshold) => {\n\t\t\t\tthreshold.setParent(this.parent);\n\t\t\t\tthreshold.render(animate);\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"two-dimensional-axes.js","sourceRoot":"","sources":["two-dimensional-axes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAA2B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;IAAwC,sCAAS;IAAjD;QAAA,qEAiJC;QAhJA,UAAI,GAAG,SAAS,CAAC;QAEjB,cAAQ,GAAQ,EAAE,CAAC;QAEnB,gBAAU,GAAgB,EAAE,CAAC;QAE7B,aAAO,GAAG;YACT,GAAG,EAAE,CAAC;YACN,KAAK,EAAE,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I,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAClB;IACF,CAAC;IAED,8CAAiB,GAAjB,UAAkB,OAAO,EAAE,YAAY;QAAvC,iBAuBC;QAtBA,IAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CACpC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EACvB,MAAM,EACN,YAAY,CACZ,CAAC;QACM,IAAA,mCAAU,CAAiB;QAEnC,IAAI,UAAU,EAAE;YACf,UAAU,CAAC,OAAO,CAAC,UAAC,eAAe,EAAE,CAAC;gBACrC,IAAM,kBAAkB,GAAG,IAAI,SAAS,CACvC,KAAI,CAAC,KAAK,EACV,KAAI,CAAC,QAAQ,wBACR,eAAe,KAAE,YAAY,cAAA,EAAE,KAAK,EAAE,CAAC,IAC5C,CAAC;gBACF,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,SAAS;gBACjC,SAAS,CAAC,SAAS,CAAC,KAAI,CAAC,MAAM,CAAC,CAAC;gBACjC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;SACH;IACF,CAAC;IACF,yBAAC;AAAD,CAAC,AAjJD,CAAwC,SAAS,GAiJhD","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { AxisPositions, ScaleTypes, AxesOptions } from \"../../interfaces\";\nimport { Axis } from \"./axis\";\nimport { Tools } from \"../../tools\";\nimport { DOMUtils } from \"../../services\";\nimport { Threshold } from \"../essentials/threshold\";\nimport { Events } from \"./../../interfaces\";\n\nexport class TwoDimensionalAxes extends Component {\n\ttype = \"2D-axes\";\n\n\tchildren: any = {};\n\n\tthresholds: Threshold[] = [];\n\n\tmargins = {\n\t\ttop: 0,\n\t\tright: 0,\n\t\tbottom: 0,\n\t\tleft: 0\n\t};\n\n\trender(animate = false) {\n\t\tconst axes = {};\n\t\tconst axisPositions = Object.keys(AxisPositions);\n\t\tconst axesOptions = Tools.getProperty(this.model.getOptions(), \"axes\");\n\n\t\taxisPositions.forEach((axisPosition) => {\n\t\t\tconst axisOptions = axesOptions[AxisPositions[axisPosition]];\n\t\t\tif (axisOptions) {\n\t\t\t\taxes[AxisPositions[axisPosition]] = true;\n\t\t\t}\n\t\t});\n\n\t\tthis.configs.axes = axes;\n\n\t\t// Check the configs to know which axes need to be rendered\n\t\taxisPositions.forEach((axisPositionKey) => {\n\t\t\tconst axisPosition = AxisPositions[axisPositionKey];\n\t\t\tif (\n\t\t\t\tthis.configs.axes[axisPosition] &&\n\t\t\t\t!this.children[axisPosition]\n\t\t\t) {\n\t\t\t\tconst axisComponent = new Axis(this.model, this.services, {\n\t\t\t\t\tposition: axisPosition,\n\t\t\t\t\taxes: this.configs.axes,\n\t\t\t\t\tmargins: this.margins\n\t\t\t\t});\n\n\t\t\t\t// Set model, services & parent for the new axis component\n\t\t\t\taxisComponent.setModel(this.model);\n\t\t\t\taxisComponent.setServices(this.services);\n\t\t\t\taxisComponent.setParent(this.parent);\n\n\t\t\t\tthis.children[axisPosition] = axisComponent;\n\t\t\t}\n\t\t});\n\n\t\tObject.keys(this.children).forEach((childKey) => {\n\t\t\tconst child = this.children[childKey];\n\t\t\tchild.render(animate);\n\t\t});\n\n\t\tconst margins = {} as any;\n\n\t\tObject.keys(this.children).forEach((childKey) => {\n\t\t\tconst child = this.children[childKey];\n\t\t\tconst axisPosition = child.configs.position;\n\n\t\t\t// Grab the invisibly rendered axis' width & height, and set margins\n\t\t\t// Based off of that\n\t\t\t// We draw the invisible axis because of the async nature of d3 transitions\n\t\t\t// To be able to tell the final width & height of the axis when initiaing the transition\n\t\t\t// The invisible axis is updated instantly and without a transition\n\t\t\tconst invisibleAxisRef = child.getInvisibleAxisRef();\n\t\t\tconst {\n\t\t\t\twidth,\n\t\t\t\theight\n\t\t\t} = DOMUtils.getSVGElementSize(invisibleAxisRef, { useBBox: true });\n\n\t\t\tlet offset;\n\t\t\tif (child.getTitleRef().empty()) {\n\t\t\t\toffset = 0;\n\t\t\t} else {\n\t\t\t\toffset = DOMUtils.getSVGElementSize(child.getTitleRef(), {\n\t\t\t\t\tuseBBox: true\n\t\t\t\t}).height;\n\t\t\t}\n\n\t\t\tswitch (axisPosition) {\n\t\t\t\tcase AxisPositions.TOP:\n\t\t\t\t\tmargins.top = height + offset;\n\t\t\t\t\tbreak;\n\t\t\t\tcase AxisPositions.BOTTOM:\n\t\t\t\t\tmargins.bottom = height + offset;\n\t\t\t\t\tbreak;\n\t\t\t\tcase AxisPositions.LEFT:\n\t\t\t\t\tmargins.left = width + offset;\n\t\t\t\t\tbreak;\n\t\t\t\tcase AxisPositions.RIGHT:\n\t\t\t\t\tmargins.right = width + offset;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Add thresholds\n\t\t\tthis.addAxisThresholds(animate, axisPosition);\n\t\t});\n\n\t\t// If the new margins are different than the existing ones\n\t\tconst isNotEqual = Object.keys(margins).some((marginKey) => {\n\t\t\treturn this.margins[marginKey] !== margins[marginKey];\n\t\t});\n\n\t\tif (isNotEqual) {\n\t\t\tthis.margins = Object.assign(this.margins, margins);\n\n\t\t\t// also set new margins to model to allow external components to access\n\t\t\tthis.model.set({ axesMargins: this.margins }, { skipUpdate: true });\n\t\t\tthis.services.events.dispatchEvent(Events.ZoomBar.UPDATE);\n\n\t\t\tObject.keys(this.children).forEach((childKey) => {\n\t\t\t\tconst child = this.children[childKey];\n\t\t\t\tchild.margins = this.margins;\n\t\t\t});\n\n\t\t\tthis.render(true);\n\t\t}\n\t}\n\n\taddAxisThresholds(animate, axisPosition) {\n\t\tconst axesOptions = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"axes\",\n\t\t\taxisPosition\n\t\t);\n\t\tconst { thresholds } = axesOptions;\n\n\t\tif (thresholds) {\n\t\t\tthresholds.forEach((thresholdConfig, i) => {\n\t\t\t\tconst thresholdComponent = new Threshold(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t{ ...thresholdConfig, axisPosition, index: i }\n\t\t\t\t);\n\t\t\t\tthis.thresholds.push(thresholdComponent);\n\t\t\t});\n\n\t\t\tthis.thresholds.forEach((threshold) => {\n\t\t\t\tthreshold.setParent(this.parent);\n\t\t\t\tthreshold.render(animate);\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { Component } from "../component";
2
+ export declare class ZoomBar extends Component {
3
+ type: string;
4
+ MIN_SELECTION_DIFF: number;
5
+ brushSelector: string;
6
+ maxSelectionRange: [0, 0];
7
+ clipId: string;
8
+ brush: import("d3-brush").BrushBehavior<unknown>;
9
+ xScale: any;
10
+ yScale: any;
11
+ init(): void;
12
+ render(animate?: boolean): void;
13
+ addBrushEventListener(zoomDomain: any, axesLeftMargin: any, width: any): void;
14
+ handleBrushedEvent(zoomDomain: any, scale: any, selection: any): void;
15
+ updateBrushHandle(svg: any, selection: any, domain: any): void;
16
+ renderZoomBarArea(container: any, querySelector: any, data: any, clipId: any): void;
17
+ updateClipPath(svg: any, clipId: any, x: any, y: any, width: any, height: any): void;
18
+ compensateDataForDefaultDomain(data: any, defaultDomain: any): void;
19
+ destroy(): void;
20
+ }
@@ -0,0 +1,312 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ // Internal Imports
15
+ import { Component } from "../component";
16
+ import { Tools } from "../../tools";
17
+ import { Events, ScaleTypes } from "../../interfaces";
18
+ import { DOMUtils } from "../../services";
19
+ import * as Configuration from "../../configuration";
20
+ // D3 Imports
21
+ import { extent } from "d3-array";
22
+ import { brushX } from "d3-brush";
23
+ import { area, line } from "d3-shape";
24
+ import { event } from "d3-selection";
25
+ var ZoomBar = /** @class */ (function (_super) {
26
+ __extends(ZoomBar, _super);
27
+ function ZoomBar() {
28
+ var _this = _super !== null && _super.apply(this, arguments) || this;
29
+ _this.type = "zoom-bar";
30
+ // The minimum selection x range to trigger handler update
31
+ // Smaller number may introduce a handler flash during initialization
32
+ // Bigger number may not trigger handler update while selection area on chart is very small
33
+ _this.MIN_SELECTION_DIFF = 9e-10;
34
+ // needs to match the style in _zoom-bar.scss
35
+ _this.brushSelector = "g.zoom-bar-brush";
36
+ // Give every zoomBarClip a distinct ID
37
+ // so they don't interfere the other zoom bars in a page
38
+ _this.clipId = "zoomBarClip-" + Math.floor(Math.random() * 99999999999);
39
+ _this.brush = brushX();
40
+ return _this;
41
+ }
42
+ ZoomBar.prototype.init = function () {
43
+ this.services.events.addEventListener(Events.ZoomBar.UPDATE, this.render.bind(this));
44
+ // get initZoomDomain
45
+ var initialZoomDomain = Tools.getProperty(this.model.getOptions(), "zoomBar", "top", "initialZoomDomain");
46
+ if (initialZoomDomain !== null) {
47
+ this.model.set({ zoomDomain: initialZoomDomain }, { skipUpdate: true });
48
+ }
49
+ };
50
+ ZoomBar.prototype.render = function (animate) {
51
+ var _this = this;
52
+ if (animate === void 0) { animate = true; }
53
+ var svg = this.getContainerSVG();
54
+ var isDataLoading = Tools.getProperty(this.model.getOptions(), "data", "loading");
55
+ var width = DOMUtils.getSVGElementSize(this.parent, {
56
+ useAttrs: true
57
+ }).width;
58
+ // get axes margins
59
+ var axesLeftMargin = 0;
60
+ var axesMargins = this.model.get("axesMargins");
61
+ if (axesMargins && axesMargins.left) {
62
+ axesLeftMargin = axesMargins.left;
63
+ }
64
+ var container = DOMUtils.appendOrSelect(svg, "svg.zoom-container")
65
+ .attr("width", "100%")
66
+ .attr("height", Configuration.zoomBar.height)
67
+ .attr("opacity", 1);
68
+ var spacer = DOMUtils.appendOrSelect(svg, "rect.zoom-spacer")
69
+ .attr("x", 0)
70
+ .attr("y", Configuration.zoomBar.height)
71
+ .attr("width", "100%")
72
+ .attr("height", Configuration.zoomBar.spacerHeight)
73
+ .attr("opacity", 1)
74
+ .attr("fill", "none");
75
+ var zoomBG = DOMUtils.appendOrSelect(container, "rect.zoom-bg")
76
+ .attr("x", axesLeftMargin)
77
+ .attr("y", 0)
78
+ .attr("width", width - axesLeftMargin)
79
+ .attr("height", "100%");
80
+ if (isDataLoading) {
81
+ // TODO - zoom bar skeleton could be improved in the future
82
+ return;
83
+ }
84
+ var cartesianScales = this.services.cartesianScales;
85
+ var mainXScale = cartesianScales.getMainXScale();
86
+ var mainYScale = cartesianScales.getMainYScale();
87
+ var mainXScaleType = cartesianScales.getMainXScaleType();
88
+ if (mainXScale && mainXScaleType === ScaleTypes.TIME) {
89
+ var zoomBarData = this.services.zoom.getZoomBarData();
90
+ this.xScale = mainXScale.copy();
91
+ this.yScale = mainYScale.copy();
92
+ var defaultDomain = this.services.zoom.getDefaultZoomBarDomain();
93
+ // add value 0 to the extended domain for zoom bar area graph
94
+ this.compensateDataForDefaultDomain(zoomBarData, defaultDomain);
95
+ this.xScale.range([axesLeftMargin, width]).domain(defaultDomain);
96
+ // keep max selection range
97
+ this.maxSelectionRange = this.xScale.range();
98
+ this.yScale
99
+ .range([0, Configuration.zoomBar.height - 6])
100
+ .domain(extent(zoomBarData, function (d) { return d.value; }));
101
+ var zoomDomain = this.model.get("zoomDomain");
102
+ this.renderZoomBarArea(container, "path.zoom-graph-area-unselected", zoomBarData, null);
103
+ this.updateClipPath(svg, this.clipId, 0, 0, 0, 0);
104
+ this.renderZoomBarArea(container, "path.zoom-graph-area", zoomBarData, this.clipId);
105
+ // Draw the zoom base line
106
+ var baselineGenerator = line()([
107
+ [axesLeftMargin, Configuration.zoomBar.height],
108
+ [width, Configuration.zoomBar.height]
109
+ ]);
110
+ var zoomBaseline = DOMUtils.appendOrSelect(container, "path.zoom-bg-baseline").attr("d", baselineGenerator);
111
+ // Attach brushing event listeners
112
+ this.addBrushEventListener(zoomDomain, axesLeftMargin, width);
113
+ // Draw the brushing area
114
+ var brushArea = DOMUtils.appendOrSelect(svg, this.brushSelector).call(this.brush);
115
+ if (zoomDomain === undefined) {
116
+ // do nothing, initialization not completed yet
117
+ // don't update brushHandle to avoid flash
118
+ }
119
+ else if (zoomDomain[0].valueOf() === zoomDomain[1].valueOf()) {
120
+ brushArea.call(this.brush.move, this.xScale.range()); // default to full range
121
+ this.updateBrushHandle(this.getContainerSVG(), this.xScale.range(), this.xScale.domain());
122
+ }
123
+ else {
124
+ var selected = zoomDomain.map(function (domain) {
125
+ return _this.xScale(domain);
126
+ });
127
+ if (selected[1] - selected[0] < this.MIN_SELECTION_DIFF) {
128
+ // initialization not completed yet
129
+ // don't update brushHandle to avoid flash
130
+ }
131
+ else {
132
+ brushArea.call(this.brush.move, selected); // set brush to correct position
133
+ this.updateBrushHandle(this.getContainerSVG(), selected, zoomDomain);
134
+ }
135
+ }
136
+ }
137
+ };
138
+ ZoomBar.prototype.addBrushEventListener = function (zoomDomain, axesLeftMargin, width) {
139
+ var _this = this;
140
+ var brushEventListener = function () {
141
+ var selection = event.selection;
142
+ // follow d3 behavior: when selection is null, reset default full range
143
+ // select behavior is completed, but nothing selected
144
+ if (selection === null) {
145
+ _this.handleBrushedEvent(zoomDomain, _this.xScale, _this.xScale.range());
146
+ }
147
+ else if (selection[0] === selection[1]) {
148
+ // select behavior is not completed yet, do nothing
149
+ }
150
+ else {
151
+ _this.handleBrushedEvent(zoomDomain, _this.xScale, selection);
152
+ }
153
+ };
154
+ // Initialize the d3 brush
155
+ this.brush
156
+ .extent([
157
+ [axesLeftMargin, 0],
158
+ [width, Configuration.zoomBar.height]
159
+ ])
160
+ .on("start brush end", null) // remove old listener first
161
+ .on("start brush end", brushEventListener);
162
+ };
163
+ // brush event listener
164
+ ZoomBar.prototype.handleBrushedEvent = function (zoomDomain, scale, selection) {
165
+ var newDomain = [
166
+ scale.invert(selection[0]),
167
+ scale.invert(selection[1])
168
+ ];
169
+ // update brush handle position
170
+ this.updateBrushHandle(this.getContainerSVG(), selection, newDomain);
171
+ // be aware that the value of d3.event changes during an event!
172
+ // update zoomDomain only if the event comes from mouse event
173
+ if (event.sourceEvent != null &&
174
+ (event.sourceEvent.type === "mousemove" ||
175
+ event.sourceEvent.type === "mouseup" ||
176
+ event.sourceEvent.type === "mousedown")) {
177
+ // only if zoomDomain is never set or needs update
178
+ if (zoomDomain === undefined ||
179
+ zoomDomain[0] !== newDomain[0] ||
180
+ zoomDomain[1] !== newDomain[1]) {
181
+ this.model.set({ zoomDomain: newDomain }, { animate: false });
182
+ }
183
+ // dispatch selection events
184
+ var zoomBarEventType = void 0;
185
+ if (event.type === "start") {
186
+ zoomBarEventType = Events.ZoomBar.SELECTION_START;
187
+ }
188
+ else if (event.type === "brush") {
189
+ zoomBarEventType = Events.ZoomBar.SELECTION_IN_PROGRESS;
190
+ }
191
+ else if (event.type === "end") {
192
+ zoomBarEventType = Events.ZoomBar.SELECTION_END;
193
+ }
194
+ this.services.events.dispatchEvent(zoomBarEventType, {
195
+ selection: selection,
196
+ newDomain: newDomain
197
+ });
198
+ }
199
+ };
200
+ ZoomBar.prototype.updateBrushHandle = function (svg, selection, domain) {
201
+ var self = this;
202
+ var handleWidth = 5;
203
+ var handleHeight = Configuration.zoomBar.height;
204
+ var handleXDiff = -handleWidth / 2;
205
+ var handleBarWidth = 1;
206
+ var handleBarHeight = 12;
207
+ var handleBarXDiff = -handleBarWidth / 2;
208
+ var handleYBarDiff = (handleHeight - handleBarHeight) / 2;
209
+ // handle
210
+ svg.select(this.brushSelector)
211
+ .selectAll("rect.handle")
212
+ .data([{ type: "w" }, { type: "e" }])
213
+ .attr("x", function (d) {
214
+ if (d.type === "w") {
215
+ // handle should not exceed zoom bar range
216
+ return Math.max(selection[0] + handleXDiff, self.maxSelectionRange[0]);
217
+ }
218
+ else if (d.type === "e") {
219
+ // handle should not exceed zoom bar range
220
+ return Math.min(selection[1] + handleXDiff, self.maxSelectionRange[1] - handleWidth);
221
+ }
222
+ })
223
+ .attr("y", 0)
224
+ .attr("width", handleWidth)
225
+ .attr("height", handleHeight)
226
+ .attr("cursor", "pointer")
227
+ .style("display", null); // always display
228
+ // handle-bar
229
+ svg.select(this.brushSelector)
230
+ .selectAll("rect.handle-bar")
231
+ .data([{ type: "w" }, { type: "e" }])
232
+ .join("rect")
233
+ .attr("class", function (d) {
234
+ return "handle-bar handle-bar--" + d.type;
235
+ })
236
+ .attr("x", function (d) {
237
+ if (d.type === "w") {
238
+ return Math.max(selection[0] + handleBarXDiff, self.maxSelectionRange[0] - handleXDiff + handleBarXDiff);
239
+ }
240
+ else if (d.type === "e") {
241
+ return Math.min(selection[1] + handleBarXDiff, self.maxSelectionRange[1] + handleXDiff + handleBarXDiff);
242
+ }
243
+ })
244
+ .attr("y", handleYBarDiff)
245
+ .attr("width", handleBarWidth)
246
+ .attr("height", handleBarHeight)
247
+ .attr("cursor", "pointer");
248
+ this.updateClipPath(svg, this.clipId, selection[0], 0, selection[1] - selection[0], Configuration.zoomBar.height);
249
+ };
250
+ ZoomBar.prototype.renderZoomBarArea = function (container, querySelector, data, clipId) {
251
+ var cartesianScales = this.services.cartesianScales;
252
+ var mainXAxisPosition = cartesianScales.getMainXAxisPosition();
253
+ var mainYAxisPosition = cartesianScales.getMainYAxisPosition();
254
+ var mainXScaleType = cartesianScales.getMainXScaleType();
255
+ var mainYScaleType = cartesianScales.getMainYScaleType();
256
+ var accessorFunction = function (scale, scaleType, axisPosition) {
257
+ return function (d, i) {
258
+ return cartesianScales.getValueFromScale(scale, scaleType, axisPosition, d, i);
259
+ };
260
+ };
261
+ var xAccessor = accessorFunction(this.xScale, mainXScaleType, mainXAxisPosition);
262
+ var yAccessor = accessorFunction(this.yScale, mainYScaleType, mainYAxisPosition);
263
+ var areaGenerator = area()
264
+ .x(function (d, i) { return xAccessor(d, i); })
265
+ .y0(Configuration.zoomBar.height)
266
+ .y1(function (d, i) { return Configuration.zoomBar.height - yAccessor(d, i); });
267
+ var areaGraph = DOMUtils.appendOrSelect(container, querySelector)
268
+ .datum(data)
269
+ .attr("d", areaGenerator);
270
+ if (clipId) {
271
+ areaGraph.attr("clip-path", "url(#" + clipId + ")");
272
+ }
273
+ };
274
+ ZoomBar.prototype.updateClipPath = function (svg, clipId, x, y, width, height) {
275
+ var zoomBarClipPath = DOMUtils.appendOrSelect(svg, "clipPath").attr("id", clipId);
276
+ DOMUtils.appendOrSelect(zoomBarClipPath, "rect")
277
+ .attr("x", x)
278
+ .attr("y", y)
279
+ .attr("width", width)
280
+ .attr("height", height);
281
+ };
282
+ // assume the domains in data are already sorted
283
+ ZoomBar.prototype.compensateDataForDefaultDomain = function (data, defaultDomain) {
284
+ if (!data || data.length < 2) {
285
+ return;
286
+ }
287
+ var domainIdentifier = this.services.cartesianScales.getDomainIdentifier();
288
+ var rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();
289
+ // if min domain is extended
290
+ if (Number(defaultDomain[0]) < Number(data[0][domainIdentifier])) {
291
+ var newDatum = {};
292
+ newDatum[domainIdentifier] = defaultDomain[0];
293
+ newDatum[rangeIdentifier] = 0;
294
+ data.unshift(newDatum);
295
+ }
296
+ // if max domain is extended
297
+ if (Number(defaultDomain[1]) >
298
+ Number(data[data.length - 1][domainIdentifier])) {
299
+ var newDatum = {};
300
+ newDatum[domainIdentifier] = defaultDomain[1];
301
+ newDatum[rangeIdentifier] = 0;
302
+ data.push(newDatum);
303
+ }
304
+ };
305
+ ZoomBar.prototype.destroy = function () {
306
+ this.brush.on("start brush end", null); // remove event listener
307
+ this.services.events.removeEventListener(Events.ZoomBar.UPDATE, this.render.bind(this));
308
+ };
309
+ return ZoomBar;
310
+ }(Component));
311
+ export { ZoomBar };
312
+ //# sourceMappingURL=../../../src/components/axes/zo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IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACpB;IACF,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,AAvZD,CAA6B,SAAS,GAuZrC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { Tools } from \"../../tools\";\nimport { Events, ScaleTypes } 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\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\n\t\t// get initZoomDomain\n\t\tconst initialZoomDomain = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"zoomBar\",\n\t\t\t\"top\",\n\t\t\t\"initialZoomDomain\"\n\t\t);\n\t\tif (initialZoomDomain !== null) {\n\t\t\tthis.model.set(\n\t\t\t\t{ zoomDomain: initialZoomDomain },\n\t\t\t\t{ skipUpdate: true }\n\t\t\t);\n\t\t}\n\t}\n\n\trender(animate = true) {\n\t\tconst svg = this.getContainerSVG();\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.model.getOptions(),\n\t\t\t\"data\",\n\t\t\t\"loading\"\n\t\t);\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\", Configuration.zoomBar.height)\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\", Configuration.zoomBar.height)\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\tconst zoomBG = DOMUtils.appendOrSelect(container, \"rect.zoom-bg\")\n\t\t\t.attr(\"x\", axesLeftMargin)\n\t\t\t.attr(\"y\", 0)\n\t\t\t.attr(\"width\", width - axesLeftMargin)\n\t\t\t.attr(\"height\", \"100%\");\n\n\t\tif (isDataLoading) {\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\tconst zoomBarData = this.services.zoom.getZoomBarData();\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\n\t\t\t// add value 0 to the extended domain for zoom bar area graph\n\t\t\tthis.compensateDataForDefaultDomain(zoomBarData, defaultDomain);\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, Configuration.zoomBar.height - 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\tthis.renderZoomBarArea(\n\t\t\t\tcontainer,\n\t\t\t\t\"path.zoom-graph-area-unselected\",\n\t\t\t\tzoomBarData,\n\t\t\t\tnull\n\t\t\t);\n\t\t\tthis.updateClipPath(svg, this.clipId, 0, 0, 0, 0);\n\t\t\tthis.renderZoomBarArea(\n\t\t\t\tcontainer,\n\t\t\t\t\"path.zoom-graph-area\",\n\t\t\t\tzoomBarData,\n\t\t\t\tthis.clipId\n\t\t\t);\n\n\t\t\t// Draw the zoom base line\n\t\t\tconst baselineGenerator = line()([\n\t\t\t\t[axesLeftMargin, Configuration.zoomBar.height],\n\t\t\t\t[width, Configuration.zoomBar.height]\n\t\t\t]);\n\t\t\tconst zoomBaseline = DOMUtils.appendOrSelect(\n\t\t\t\tcontainer,\n\t\t\t\t\"path.zoom-bg-baseline\"\n\t\t\t).attr(\"d\", baselineGenerator);\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}\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\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, Configuration.zoomBar.height]\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 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) {\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\tthis.model.set({ zoomDomain: newDomain }, { animate: false });\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 = 5;\n\t\tconst handleHeight = Configuration.zoomBar.height;\n\t\tconst handleXDiff = -handleWidth / 2;\n\n\t\tconst handleBarWidth = 1;\n\t\tconst handleBarHeight = 12;\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\", \"pointer\")\n\t\t\t.style(\"display\", null); // always display\n\n\t\t// handle-bar\n\t\tsvg.select(this.brushSelector)\n\t\t\t.selectAll(\"rect.handle-bar\")\n\t\t\t.data([{ type: \"w\" }, { type: \"e\" }])\n\t\t\t.join(\"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\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\", \"pointer\");\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\tConfiguration.zoomBar.height\n\t\t);\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\t\tconst areaGenerator = area()\n\t\t\t.x((d, i) => xAccessor(d, i))\n\t\t\t.y0(Configuration.zoomBar.height)\n\t\t\t.y1((d, i) => Configuration.zoomBar.height - 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\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 (Number(defaultDomain[0]) < Number(data[0][domainIdentifier])) {\n\t\t\tconst newDatum = {};\n\t\t\tnewDatum[domainIdentifier] = defaultDomain[0];\n\t\t\tnewDatum[rangeIdentifier] = 0;\n\t\t\tdata.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(data[data.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\tdata.push(newDatum);\n\t\t}\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"]}
@@ -13,5 +13,7 @@ export declare class Component {
13
13
  setServices(newObj: any): void;
14
14
  setParent(parent: any): void;
15
15
  getParent(): any;
16
- getContainerSVG(): any;
16
+ getContainerSVG(configs?: {
17
+ withinChartClip: boolean;
18
+ }): any;
17
19
  }
@@ -48,10 +48,19 @@ var Component = /** @class */ (function () {
48
48
  Component.prototype.getParent = function () {
49
49
  return this.parent;
50
50
  };
51
- Component.prototype.getContainerSVG = function () {
51
+ Component.prototype.getContainerSVG = function (configs) {
52
+ if (configs === void 0) { configs = { withinChartClip: false }; }
52
53
  if (this.type) {
53
54
  var chartprefix = Tools.getProperty(this.model.getOptions(), "style", "prefix");
54
- return DOMUtils.appendOrSelect(this.parent, "g." + settings.prefix + "--" + chartprefix + "--" + this.type);
55
+ var svg = DOMUtils.appendOrSelect(this.parent, "g." + settings.prefix + "--" + chartprefix + "--" + this.type);
56
+ if (configs.withinChartClip) {
57
+ // get unique chartClipId int this chart from model
58
+ var chartClipId = this.model.get("chartClipId");
59
+ if (chartClipId) {
60
+ svg.attr("clip-path", "url(#" + chartClipId + ")");
61
+ }
62
+ }
63
+ return svg;
55
64
  }
56
65
  return this.parent;
57
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,yCAAyC;AACzC,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAEhE;IAUC,mBAAY,KAAiB,EAAE,QAAa,EAAE,OAAa;QALjD,YAAO,GAAQ,EAAE,CAAC;QAM3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,OAAO,EAAE;YACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;SACvB;QAED,oEAAoE;QACpE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACjB,IAAI,CAAC,SAAS,CAAC,MA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I,EAAE;YACd,IAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CACpC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EACvB,OAAO,EACP,QAAQ,CACR,CAAC;YACF,OAAO,QAAQ,CAAC,cAAc,CAC7B,IAAI,CAAC,MAAM,EACX,OAAK,QAAQ,CAAC,MAAM,UAAK,WAAW,UAAK,IAAI,CAAC,IAAM,CACpD,CAAC;SACF;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACF,gBAAC;AAAD,CAAC,AAzFD,IAyFC","sourcesContent":["// Internal Imports\nimport { ChartModel } from \"../model\";\nimport { DOMUtils } from \"../services\";\nimport { Tools } from \"../tools\";\n\n// D3 Imports\nimport { select } from \"d3-selection\";\n\n// import the settings for the css prefix\nimport settings from \"carbon-components/es/globals/js/settings\";\n\nexport class Component {\n\tpublic type: string;\n\n\tprotected parent: any;\n\n\tprotected configs: any = {};\n\n\tprotected model: ChartModel;\n\tprotected services: any;\n\n\tconstructor(model: ChartModel, services: any, configs?: any) {\n\t\tthis.model = model;\n\t\tthis.services = services;\n\n\t\tif (configs) {\n\t\t\tthis.configs = configs;\n\t\t}\n\n\t\t// Set parent element to shell SVG if no parent exists for component\n\t\tif (!this.parent) {\n\t\t\tthis.setParent(select(this.services.domUtils.getMainSVG()));\n\t\t}\n\t}\n\n\tinit() {}\n\n\trender(animate = true) {\n\t\tconsole.error(\"render() method is not implemented\");\n\t}\n\n\tdestroy() {}\n\n\t// Used to pass down information to the components\n\tsetModel(newObj) {\n\t\tthis.model = newObj;\n\t}\n\n\t// Used to pass down information to the components\n\tsetServices(newObj) {\n\t\tthis.services = newObj;\n\t}\n\n\tsetParent(parent) {\n\t\tconst oldParent = this.parent;\n\t\tthis.parent = parent;\n\n\t\tif (oldParent && oldParent.node() === parent.node()) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.type) {\n\t\t\tconst chartprefix = Tools.getProperty(\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\"style\",\n\t\t\t\t\"prefix\"\n\t\t\t);\n\t\t\tthis.parent.classed(\n\t\t\t\t`${settings.prefix}--${chartprefix}--${this.type}`,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif (oldParent) {\n\t\t\t\toldParent.classed(\n\t\t\t\t\t`${settings.prefix}--${chartprefix}--${this.type}`,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tgetParent() {\n\t\treturn this.parent;\n\t}\n\n\tgetContainerSVG() {\n\t\tif (this.type) {\n\t\t\tconst chartprefix = Tools.getProperty(\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\"style\",\n\t\t\t\t\"prefix\"\n\t\t\t);\n\t\t\treturn DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t`g.${settings.prefix}--${chartprefix}--${this.type}`\n\t\t\t);\n\t\t}\n\n\t\treturn this.parent;\n\t}\n}\n"]}
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,yCAAyC;AACzC,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAEhE;IAUC,mBAAY,KAAiB,EAAE,QAAa,EAAE,OAAa;QALjD,YAAO,GAAQ,EAAE,CAAC;QAM3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,OAAO,EAAE;YACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;SACvB;QAED,oEAAoE;QACpE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC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AE;QACnD,IAAI,IAAI,CAAC,IAAI,EAAE;YACd,IAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CACpC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EACvB,OAAO,EACP,QAAQ,CACR,CAAC;YAEF,IAAM,GAAG,GAAG,QAAQ,CAAC,cAAc,CAClC,IAAI,CAAC,MAAM,EACX,OAAK,QAAQ,CAAC,MAAM,UAAK,WAAW,UAAK,IAAI,CAAC,IAAM,CACpD,CAAC;YAEF,IAAI,OAAO,CAAC,eAAe,EAAE;gBAC5B,mDAAmD;gBACnD,IAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAClD,IAAI,WAAW,EAAE;oBAChB,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,UAAQ,WAAW,MAAG,CAAC,CAAC;iBAC9C;aACD;YAED,OAAO,GAAG,CAAC;SACX;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACF,gBAAC;AAAD,CAAC,AApGD,IAoGC","sourcesContent":["// Internal Imports\nimport { ChartModel } from \"../model\";\nimport { DOMUtils } from \"../services\";\nimport { Tools } from \"../tools\";\n\n// D3 Imports\nimport { select } from \"d3-selection\";\n\n// import the settings for the css prefix\nimport settings from \"carbon-components/es/globals/js/settings\";\n\nexport class Component {\n\tpublic type: string;\n\n\tprotected parent: any;\n\n\tprotected configs: any = {};\n\n\tprotected model: ChartModel;\n\tprotected services: any;\n\n\tconstructor(model: ChartModel, services: any, configs?: any) {\n\t\tthis.model = model;\n\t\tthis.services = services;\n\n\t\tif (configs) {\n\t\t\tthis.configs = configs;\n\t\t}\n\n\t\t// Set parent element to shell SVG if no parent exists for component\n\t\tif (!this.parent) {\n\t\t\tthis.setParent(select(this.services.domUtils.getMainSVG()));\n\t\t}\n\t}\n\n\tinit() {}\n\n\trender(animate = true) {\n\t\tconsole.error(\"render() method is not implemented\");\n\t}\n\n\tdestroy() {}\n\n\t// Used to pass down information to the components\n\tsetModel(newObj) {\n\t\tthis.model = newObj;\n\t}\n\n\t// Used to pass down information to the components\n\tsetServices(newObj) {\n\t\tthis.services = newObj;\n\t}\n\n\tsetParent(parent) {\n\t\tconst oldParent = this.parent;\n\t\tthis.parent = parent;\n\n\t\tif (oldParent && oldParent.node() === parent.node()) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.type) {\n\t\t\tconst chartprefix = Tools.getProperty(\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\"style\",\n\t\t\t\t\"prefix\"\n\t\t\t);\n\t\t\tthis.parent.classed(\n\t\t\t\t`${settings.prefix}--${chartprefix}--${this.type}`,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif (oldParent) {\n\t\t\t\toldParent.classed(\n\t\t\t\t\t`${settings.prefix}--${chartprefix}--${this.type}`,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tgetParent() {\n\t\treturn this.parent;\n\t}\n\n\tgetContainerSVG(configs = { withinChartClip: false }) {\n\t\tif (this.type) {\n\t\t\tconst chartprefix = Tools.getProperty(\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\"style\",\n\t\t\t\t\"prefix\"\n\t\t\t);\n\n\t\t\tconst svg = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t`g.${settings.prefix}--${chartprefix}--${this.type}`\n\t\t\t);\n\n\t\t\tif (configs.withinChartClip) {\n\t\t\t\t// get unique chartClipId int this chart from model\n\t\t\t\tconst chartClipId = this.model.get(\"chartClipId\");\n\t\t\t\tif (chartClipId) {\n\t\t\t\t\tsvg.attr(\"clip-path\", `url(#${chartClipId})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn svg;\n\t\t}\n\n\t\treturn this.parent;\n\t}\n}\n"]}