@carbon/charts 0.54.0 → 0.54.1
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/components/essentials/color-scale-legend.d.ts +1 -1
- package/components/essentials/color-scale-legend.d.ts +1 -1
- package/components/essentials/color-scale-legend.js +1 -1
- package/components/essentials/color-scale-legend.js.map +1 -1
- package/package.json +1 -1
- package/services/canvas-zoom.js +1 -1
- package/services/canvas-zoom.js.map +1 -1
- package/tsconfig.tsbuildinfo +12 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.54.1](https://github.com/carbon-design-system/carbon-charts/compare/v0.54.0...v0.54.1) (2022-01-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** remove circular dependencies inheritance from heatmap legend & canvas zoom files ([#1260](https://github.com/carbon-design-system/carbon-charts/issues/1260)) ([1abc4d9](https://github.com/carbon-design-system/carbon-charts/commit/1abc4d9ebf8ce80226df23371c4b9baa669f4c7f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.54.0](https://github.com/carbon-design-system/carbon-charts/compare/v0.53.5...v0.54.0) (2021-12-24)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
import { Tools } from '../../tools';
|
|
16
16
|
import { ColorLegendType, Events, RenderTypes } from '../../interfaces';
|
|
17
17
|
import * as Configuration from '../../configuration';
|
|
18
|
-
import { Legend } from '
|
|
18
|
+
import { Legend } from './legend';
|
|
19
19
|
import { DOMUtils } from '../../services';
|
|
20
20
|
// D3 imports
|
|
21
21
|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ED,kCAAO,GAAP;QACC,0BAA0B;QAC1B,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,cAAc,CAAC,mBAAmB,CACjC,MAAM,CAAC,IAAI,CAAC,eAAe,EAC3B,IAAI,CAAC,kBAAkB,CACvB,CAAC;IACH,CAAC;IACF,uBAAC;AAAD,CAAC,AArVD,CAAsC,MAAM,GAqV3C","sourcesContent":["// Internal Imports\nimport { Tools } from '../../tools';\nimport { ColorLegendType, Events, RenderTypes, Roles } from '../../interfaces';\nimport * as Configuration from '../../configuration';\nimport { Legend } from '../';\nimport { DOMUtils } from '../../services';\n\n// D3 imports\nimport { axisBottom } from 'd3-axis';\nimport { scaleBand, scaleLinear } from 'd3-scale';\nimport { interpolateRound, quantize } from 'd3-interpolate';\n\nexport class ColorScaleLegend extends Legend {\n\ttype = 'color-legend';\n\trenderType = RenderTypes.SVG;\n\n\tprivate gradient_id =\n\t\t'gradient-id-' + Math.floor(Math.random() * 99999999999);\n\n\tinit() {\n\t\tconst eventsFragment = this.services.events;\n\n\t\t// Highlight correct circle on legend item hovers\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Axis.RENDER_COMPLETE,\n\t\t\tthis.handleAxisComplete\n\t\t);\n\t}\n\n\thandleAxisComplete = (event: CustomEvent) => {\n\t\tconst svg = this.getComponentContainer();\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\tif (width > Configuration.legend.color.barWidth && !isDataLoading) {\n\t\t\tconst title = Tools.getProperty(\n\t\t\t\tthis.getOptions(),\n\t\t\t\t'heatmap',\n\t\t\t\t'colorLegend',\n\t\t\t\t'title'\n\t\t\t);\n\n\t\t\tconst { cartesianScales } = this.services;\n\t\t\t// Get available chart area\n\t\t\tconst mainXScale = cartesianScales.getMainXScale();\n\n\t\t\tconst xDimensions = mainXScale.range();\n\n\t\t\t// Align legend with the axis\n\t\t\tif (xDimensions[0] > 1) {\n\t\t\t\tsvg.select('g.legend').attr(\n\t\t\t\t\t'transform',\n\t\t\t\t\t`translate(${xDimensions[0]}, 0)`\n\t\t\t\t);\n\n\t\t\t\tif (title) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\twidth: textWidth,\n\t\t\t\t\t} = DOMUtils.getSVGElementSize(\n\t\t\t\t\t\tsvg.select('g.legend-title').select('text'),\n\t\t\t\t\t\t{ useBBox: true }\n\t\t\t\t\t);\n\n\t\t\t\t\t// -9 since LEFT y-axis labels are moved towards the left by 9 by d3\n\t\t\t\t\tconst availableSpace = xDimensions[0] - textWidth - 9;\n\n\t\t\t\t\t// If space is available align the the label with the axis labels\n\t\t\t\t\tif (availableSpace > 1) {\n\t\t\t\t\t\tsvg.select('g.legend-title').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${availableSpace}, 0)`\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Move the legend down by 16 pixels to display legend text on top\n\t\t\t\t\t\tsvg.select('g.legend').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${xDimensions[0]}, 16)`\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Align legend title with start of axis\n\t\t\t\t\t\tsvg.select('g.legend-title').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${xDimensions[0]}, 0)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\trender(animate = false) {\n\t\tconst options = this.getOptions();\n\n\t\tconst customColors = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'gradient',\n\t\t\t'colors'\n\t\t);\n\n\t\tconst colorScaleType = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'heatmap',\n\t\t\t'colorLegend',\n\t\t\t'type'\n\t\t);\n\n\t\tlet colorPairingOption = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'pairing',\n\t\t\t'option'\n\t\t);\n\n\t\tconst title = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'heatmap',\n\t\t\t'colorLegend',\n\t\t\t'title'\n\t\t);\n\n\t\tconst customColorsEnabled = !Tools.isEmpty(customColors);\n\t\tconst domain = this.model.getValueDomain();\n\n\t\tconst svg = this.getComponentContainer();\n\n\t\t// Clear DOM if loading\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\tif (isDataLoading) {\n\t\t\tsvg.html('');\n\t\t\treturn;\n\t\t}\n\n\t\tconst legend = DOMUtils.appendOrSelect(svg, 'g.legend');\n\t\tconst axis = DOMUtils.appendOrSelect(legend, 'g.legend-axis');\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tlet barWidth = Configuration.legend.color.barWidth;\n\t\tif (width <= Configuration.legend.color.barWidth) {\n\t\t\tbarWidth = width;\n\t\t}\n\n\t\tif (title) {\n\t\t\tconst legendTitleGroup = DOMUtils.appendOrSelect(\n\t\t\t\tsvg,\n\t\t\t\t'g.legend-title'\n\t\t\t);\n\t\t\tconst legendTitle = DOMUtils.appendOrSelect(\n\t\t\t\tlegendTitleGroup,\n\t\t\t\t'text'\n\t\t\t);\n\t\t\tlegendTitle.text(title).attr('dy', '0.7em');\n\n\t\t\t// Move the legend down by 16 pixels to display legend text on top\n\t\t\tlegend.attr('transform', `translate(0, 16)`);\n\t\t}\n\n\t\t// If domain consists of negative and positive values, use diverging palettes\n\t\tconst colorScheme = domain[0] < 0 && domain[1] > 0 ? 'diverge' : 'mono';\n\n\t\t// Use default color pairing options if not in defined range\n\t\tif (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 4 &&\n\t\t\tcolorScheme === 'mono'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t} else if (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 2 &&\n\t\t\tcolorScheme === 'diverge'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t}\n\n\t\tlet colorPairing = [];\n\t\t// Carbon charts has 11 colors for a single monochromatic palette & 17 for a divergent palette\n\t\tlet colorGroupingLength = colorScheme === 'diverge' ? 17 : 11;\n\n\t\tif (!customColorsEnabled) {\n\t\t\t// Add class names to list and the amount based on the color scheme\n\t\t\tfor (let i = 1; i < colorGroupingLength + 1; i++) {\n\t\t\t\tcolorPairing.push(\n\t\t\t\t\tcolorScaleType === ColorLegendType.LINEAR\n\t\t\t\t\t\t? `stop-color-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t\t\t: `fill-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\t// Use custom colors\n\t\t\tcolorPairing = customColors;\n\t\t}\n\n\t\tif (colorScaleType === ColorLegendType.LINEAR) {\n\t\t\tconst stopLengthPercentage = 100 / (colorPairing.length - 1);\n\n\t\t\t// Generate the gradient\n\t\t\tconst linearGradient = DOMUtils.appendOrSelect(\n\t\t\t\tlegend,\n\t\t\t\t'linearGradient'\n\t\t\t);\n\t\t\tlinearGradient\n\t\t\t\t.attr('id', `${this.gradient_id}-legend`)\n\t\t\t\t.selectAll('stop')\n\t\t\t\t.data(colorPairing)\n\t\t\t\t.enter()\n\t\t\t\t.append('stop')\n\t\t\t\t.attr('offset', (_, i) => `${i * stopLengthPercentage}%`)\n\t\t\t\t.attr('class', (_, i) => colorPairing[i])\n\t\t\t\t.attr('stop-color', (d) => d);\n\n\t\t\t// Create the legend container\n\t\t\tconst rectangle = DOMUtils.appendOrSelect(legend, 'rect');\n\t\t\trectangle\n\t\t\t\t.attr('width', barWidth)\n\t\t\t\t.attr('height', Configuration.legend.color.barHeight)\n\t\t\t\t.style('fill', `url(#${this.gradient_id}-legend)`);\n\n\t\t\t// Create scale & ticks\n\t\t\tconst linearScale = scaleLinear()\n\t\t\t\t.domain(domain)\n\t\t\t\t.range([0, barWidth]);\n\t\t\tdomain.splice(1, 0, (domain[0] + domain[1]) / 2);\n\n\t\t\tconst xAxis = axisBottom(linearScale)\n\t\t\t\t.tickSize(0)\n\t\t\t\t.tickValues(domain);\n\n\t\t\t// Align axes at the bottom of the rectangle and delete the domain line\n\t\t\taxis.attr(\n\t\t\t\t'transform',\n\t\t\t\t`translate(0,${Configuration.legend.color.axisYTranslation})`\n\t\t\t).call(xAxis);\n\n\t\t\t// Remove domain\n\t\t\taxis.select('.domain').remove();\n\n\t\t\t// Align text to fit in container\n\t\t\taxis.style('text-anchor', 'start');\n\t\t} else if (colorScaleType === ColorLegendType.QUANTIZE) {\n\t\t\t// Generate equal chunks between range to act as ticks\n\t\t\tconst interpolator = interpolateRound(domain[0], domain[1]);\n\t\t\tconst quant = quantize(interpolator, colorPairing.length);\n\n\t\t\t// If divergent && non-custom color, remove 0/white from being displayed\n\t\t\tif (!customColorsEnabled && colorScheme === 'diverge') {\n\t\t\t\tcolorPairing.splice(colorPairing.length / 2, 1);\n\t\t\t}\n\n\t\t\tconst colorScaleBand = scaleBand()\n\t\t\t\t.domain(colorPairing)\n\t\t\t\t.range([0, barWidth]);\n\n\t\t\t// Render the quantized rectangles\n\t\t\tconst rectangle = DOMUtils.appendOrSelect(\n\t\t\t\tlegend,\n\t\t\t\t'g.quantized-rect'\n\t\t\t);\n\n\t\t\trectangle\n\t\t\t\t.selectAll('rect')\n\t\t\t\t.data(colorScaleBand.domain())\n\t\t\t\t.join('rect')\n\t\t\t\t.attr('x', (d) => colorScaleBand(d))\n\t\t\t\t.attr('y', 0)\n\t\t\t\t.attr('width', Math.max(0, colorScaleBand.bandwidth()) - 1)\n\t\t\t\t.attr('height', Configuration.legend.color.barHeight)\n\t\t\t\t.attr('class', (d) => d)\n\t\t\t\t.attr('fill', (d) => d);\n\n\t\t\tconst xAxis = axisBottom(colorScaleBand)\n\t\t\t\t.tickSize(0)\n\t\t\t\t.tickValues(colorPairing)\n\t\t\t\t.tickFormat((_, i) => {\n\t\t\t\t\t// Display every other tick to create space\n\t\t\t\t\tif (\n\t\t\t\t\t\t!customColorsEnabled &&\n\t\t\t\t\t\t((i + 1) % 2 === 0 || i === colorPairing.length - 1)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Use the quant interpolators as ticks\n\t\t\t\t\treturn quant[i].toString();\n\t\t\t\t});\n\n\t\t\t// Align axis to match bandwidth start after initial (white)\n\t\t\tconst axisTranslation = colorScaleBand.bandwidth() / 2;\n\t\t\taxis.attr(\n\t\t\t\t'transform',\n\t\t\t\t`translate(${\n\t\t\t\t\t!customColorsEnabled && colorScheme === 'diverge' ? '-' : ''\n\t\t\t\t}${axisTranslation}, ${\n\t\t\t\t\tConfiguration.legend.color.axisYTranslation\n\t\t\t\t})`\n\t\t\t).call(xAxis);\n\n\t\t\t// Append the last tick\n\t\t\tconst firstTick = axis.select('g.tick').clone(true);\n\t\t\tfirstTick\n\t\t\t\t.attr(\n\t\t\t\t\t'transform',\n\t\t\t\t\t`translate(${\n\t\t\t\t\t\tbarWidth +\n\t\t\t\t\t\t(!customColorsEnabled && colorScheme === 'diverge'\n\t\t\t\t\t\t\t? axisTranslation\n\t\t\t\t\t\t\t: -axisTranslation)\n\t\t\t\t\t}, 0)`\n\t\t\t\t)\n\t\t\t\t.classed('final-tick', true)\n\t\t\t\t.select('text')\n\t\t\t\t.text(quant[quant.length - 1]);\n\n\t\t\taxis.enter().append(firstTick.node());\n\t\t\taxis.select('.domain').remove();\n\t\t} else {\n\t\t\tthrow Error('Entered color legend type is not supported.');\n\t\t}\n\n\t\t// Translate last axis tick if barWidth equals chart width\n\t\tif (width <= Configuration.legend.color.barWidth) {\n\t\t\tconst lastTick = axis.select('g.tick:last-of-type text');\n\t\t\tconst { width } = DOMUtils.getSVGElementSize(lastTick, {\n\t\t\t\tuseBBox: true,\n\t\t\t});\n\t\t\tlastTick.attr('x', `-${width}`);\n\t\t}\n\t}\n\n\tdestroy() {\n\t\t// Remove legend listeners\n\t\tconst eventsFragment = this.services.events;\n\t\teventsFragment.removeEventListener(\n\t\t\tEvents.Axis.RENDER_COMPLETE,\n\t\t\tthis.handleAxisComplete\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"color-scale-legend.js","sourceRoot":"","sources":["color-scale-legend.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE5D;IAAsC,oCAAM;IAA5C;QAAA,qEAqVC;QApVA,UAAI,GAAG,cAAc,CAAC;QACtB,gBAAU,GAAG,WAAW,CAAC,GAAG,CAAC;QAErB,iBAAW,GAClB,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC;QAY1D,wBAAkB,GAAG,UAAC,KAAkB;YACvC,IAAM,GAAG,GAAG,KAAI,CAAC,qBAAqB,EAAE,CAAC;YAEjC,IAAA;;oBAAK,CAEV;YAEH,IAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAC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K,IAAI,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE;YACjD,IAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;YACjD,IAAA;;oBAAK,CAEV;YACH,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,MAAI,OAAO,CAAC,CAAC;SAChC;IACF,CAAC;IAED,kCAAO,GAAP;QACC,0BAA0B;QAC1B,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,cAAc,CAAC,mBAAmB,CACjC,MAAM,CAAC,IAAI,CAAC,eAAe,EAC3B,IAAI,CAAC,kBAAkB,CACvB,CAAC;IACH,CAAC;IACF,uBAAC;AAAD,CAAC,AArVD,CAAsC,MAAM,GAqV3C","sourcesContent":["// Internal Imports\nimport { Tools } from '../../tools';\nimport { ColorLegendType, Events, RenderTypes } from '../../interfaces';\nimport * as Configuration from '../../configuration';\nimport { Legend } from './legend';\nimport { DOMUtils } from '../../services';\n\n// D3 imports\nimport { axisBottom } from 'd3-axis';\nimport { scaleBand, scaleLinear } from 'd3-scale';\nimport { interpolateRound, quantize } from 'd3-interpolate';\n\nexport class ColorScaleLegend extends Legend {\n\ttype = 'color-legend';\n\trenderType = RenderTypes.SVG;\n\n\tprivate gradient_id =\n\t\t'gradient-id-' + Math.floor(Math.random() * 99999999999);\n\n\tinit() {\n\t\tconst eventsFragment = this.services.events;\n\n\t\t// Highlight correct circle on legend item hovers\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Axis.RENDER_COMPLETE,\n\t\t\tthis.handleAxisComplete\n\t\t);\n\t}\n\n\thandleAxisComplete = (event: CustomEvent) => {\n\t\tconst svg = this.getComponentContainer();\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\tif (width > Configuration.legend.color.barWidth && !isDataLoading) {\n\t\t\tconst title = Tools.getProperty(\n\t\t\t\tthis.getOptions(),\n\t\t\t\t'heatmap',\n\t\t\t\t'colorLegend',\n\t\t\t\t'title'\n\t\t\t);\n\n\t\t\tconst { cartesianScales } = this.services;\n\t\t\t// Get available chart area\n\t\t\tconst mainXScale = cartesianScales.getMainXScale();\n\n\t\t\tconst xDimensions = mainXScale.range();\n\n\t\t\t// Align legend with the axis\n\t\t\tif (xDimensions[0] > 1) {\n\t\t\t\tsvg.select('g.legend').attr(\n\t\t\t\t\t'transform',\n\t\t\t\t\t`translate(${xDimensions[0]}, 0)`\n\t\t\t\t);\n\n\t\t\t\tif (title) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\twidth: textWidth,\n\t\t\t\t\t} = DOMUtils.getSVGElementSize(\n\t\t\t\t\t\tsvg.select('g.legend-title').select('text'),\n\t\t\t\t\t\t{ useBBox: true }\n\t\t\t\t\t);\n\n\t\t\t\t\t// -9 since LEFT y-axis labels are moved towards the left by 9 by d3\n\t\t\t\t\tconst availableSpace = xDimensions[0] - textWidth - 9;\n\n\t\t\t\t\t// If space is available align the the label with the axis labels\n\t\t\t\t\tif (availableSpace > 1) {\n\t\t\t\t\t\tsvg.select('g.legend-title').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${availableSpace}, 0)`\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Move the legend down by 16 pixels to display legend text on top\n\t\t\t\t\t\tsvg.select('g.legend').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${xDimensions[0]}, 16)`\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Align legend title with start of axis\n\t\t\t\t\t\tsvg.select('g.legend-title').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${xDimensions[0]}, 0)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\trender(animate = false) {\n\t\tconst options = this.getOptions();\n\n\t\tconst customColors = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'gradient',\n\t\t\t'colors'\n\t\t);\n\n\t\tconst colorScaleType = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'heatmap',\n\t\t\t'colorLegend',\n\t\t\t'type'\n\t\t);\n\n\t\tlet colorPairingOption = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'pairing',\n\t\t\t'option'\n\t\t);\n\n\t\tconst title = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'heatmap',\n\t\t\t'colorLegend',\n\t\t\t'title'\n\t\t);\n\n\t\tconst customColorsEnabled = !Tools.isEmpty(customColors);\n\t\tconst domain = this.model.getValueDomain();\n\n\t\tconst svg = this.getComponentContainer();\n\n\t\t// Clear DOM if loading\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\tif (isDataLoading) {\n\t\t\tsvg.html('');\n\t\t\treturn;\n\t\t}\n\n\t\tconst legend = DOMUtils.appendOrSelect(svg, 'g.legend');\n\t\tconst axis = DOMUtils.appendOrSelect(legend, 'g.legend-axis');\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tlet barWidth = Configuration.legend.color.barWidth;\n\t\tif (width <= Configuration.legend.color.barWidth) {\n\t\t\tbarWidth = width;\n\t\t}\n\n\t\tif (title) {\n\t\t\tconst legendTitleGroup = DOMUtils.appendOrSelect(\n\t\t\t\tsvg,\n\t\t\t\t'g.legend-title'\n\t\t\t);\n\t\t\tconst legendTitle = DOMUtils.appendOrSelect(\n\t\t\t\tlegendTitleGroup,\n\t\t\t\t'text'\n\t\t\t);\n\t\t\tlegendTitle.text(title).attr('dy', '0.7em');\n\n\t\t\t// Move the legend down by 16 pixels to display legend text on top\n\t\t\tlegend.attr('transform', `translate(0, 16)`);\n\t\t}\n\n\t\t// If domain consists of negative and positive values, use diverging palettes\n\t\tconst colorScheme = domain[0] < 0 && domain[1] > 0 ? 'diverge' : 'mono';\n\n\t\t// Use default color pairing options if not in defined range\n\t\tif (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 4 &&\n\t\t\tcolorScheme === 'mono'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t} else if (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 2 &&\n\t\t\tcolorScheme === 'diverge'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t}\n\n\t\tlet colorPairing = [];\n\t\t// Carbon charts has 11 colors for a single monochromatic palette & 17 for a divergent palette\n\t\tlet colorGroupingLength = colorScheme === 'diverge' ? 17 : 11;\n\n\t\tif (!customColorsEnabled) {\n\t\t\t// Add class names to list and the amount based on the color scheme\n\t\t\tfor (let i = 1; i < colorGroupingLength + 1; i++) {\n\t\t\t\tcolorPairing.push(\n\t\t\t\t\tcolorScaleType === ColorLegendType.LINEAR\n\t\t\t\t\t\t? `stop-color-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t\t\t: `fill-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\t// Use custom colors\n\t\t\tcolorPairing = customColors;\n\t\t}\n\n\t\tif (colorScaleType === ColorLegendType.LINEAR) {\n\t\t\tconst stopLengthPercentage = 100 / (colorPairing.length - 1);\n\n\t\t\t// Generate the gradient\n\t\t\tconst linearGradient = DOMUtils.appendOrSelect(\n\t\t\t\tlegend,\n\t\t\t\t'linearGradient'\n\t\t\t);\n\t\t\tlinearGradient\n\t\t\t\t.attr('id', `${this.gradient_id}-legend`)\n\t\t\t\t.selectAll('stop')\n\t\t\t\t.data(colorPairing)\n\t\t\t\t.enter()\n\t\t\t\t.append('stop')\n\t\t\t\t.attr('offset', (_, i) => `${i * stopLengthPercentage}%`)\n\t\t\t\t.attr('class', (_, i) => colorPairing[i])\n\t\t\t\t.attr('stop-color', (d) => d);\n\n\t\t\t// Create the legend container\n\t\t\tconst rectangle = DOMUtils.appendOrSelect(legend, 'rect');\n\t\t\trectangle\n\t\t\t\t.attr('width', barWidth)\n\t\t\t\t.attr('height', Configuration.legend.color.barHeight)\n\t\t\t\t.style('fill', `url(#${this.gradient_id}-legend)`);\n\n\t\t\t// Create scale & ticks\n\t\t\tconst linearScale = scaleLinear()\n\t\t\t\t.domain(domain)\n\t\t\t\t.range([0, barWidth]);\n\t\t\tdomain.splice(1, 0, (domain[0] + domain[1]) / 2);\n\n\t\t\tconst xAxis = axisBottom(linearScale)\n\t\t\t\t.tickSize(0)\n\t\t\t\t.tickValues(domain);\n\n\t\t\t// Align axes at the bottom of the rectangle and delete the domain line\n\t\t\taxis.attr(\n\t\t\t\t'transform',\n\t\t\t\t`translate(0,${Configuration.legend.color.axisYTranslation})`\n\t\t\t).call(xAxis);\n\n\t\t\t// Remove domain\n\t\t\taxis.select('.domain').remove();\n\n\t\t\t// Align text to fit in container\n\t\t\taxis.style('text-anchor', 'start');\n\t\t} else if (colorScaleType === ColorLegendType.QUANTIZE) {\n\t\t\t// Generate equal chunks between range to act as ticks\n\t\t\tconst interpolator = interpolateRound(domain[0], domain[1]);\n\t\t\tconst quant = quantize(interpolator, colorPairing.length);\n\n\t\t\t// If divergent && non-custom color, remove 0/white from being displayed\n\t\t\tif (!customColorsEnabled && colorScheme === 'diverge') {\n\t\t\t\tcolorPairing.splice(colorPairing.length / 2, 1);\n\t\t\t}\n\n\t\t\tconst colorScaleBand = scaleBand()\n\t\t\t\t.domain(colorPairing)\n\t\t\t\t.range([0, barWidth]);\n\n\t\t\t// Render the quantized rectangles\n\t\t\tconst rectangle = DOMUtils.appendOrSelect(\n\t\t\t\tlegend,\n\t\t\t\t'g.quantized-rect'\n\t\t\t);\n\n\t\t\trectangle\n\t\t\t\t.selectAll('rect')\n\t\t\t\t.data(colorScaleBand.domain())\n\t\t\t\t.join('rect')\n\t\t\t\t.attr('x', (d) => colorScaleBand(d))\n\t\t\t\t.attr('y', 0)\n\t\t\t\t.attr('width', Math.max(0, colorScaleBand.bandwidth()) - 1)\n\t\t\t\t.attr('height', Configuration.legend.color.barHeight)\n\t\t\t\t.attr('class', (d) => d)\n\t\t\t\t.attr('fill', (d) => d);\n\n\t\t\tconst xAxis = axisBottom(colorScaleBand)\n\t\t\t\t.tickSize(0)\n\t\t\t\t.tickValues(colorPairing)\n\t\t\t\t.tickFormat((_, i) => {\n\t\t\t\t\t// Display every other tick to create space\n\t\t\t\t\tif (\n\t\t\t\t\t\t!customColorsEnabled &&\n\t\t\t\t\t\t((i + 1) % 2 === 0 || i === colorPairing.length - 1)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Use the quant interpolators as ticks\n\t\t\t\t\treturn quant[i].toString();\n\t\t\t\t});\n\n\t\t\t// Align axis to match bandwidth start after initial (white)\n\t\t\tconst axisTranslation = colorScaleBand.bandwidth() / 2;\n\t\t\taxis.attr(\n\t\t\t\t'transform',\n\t\t\t\t`translate(${\n\t\t\t\t\t!customColorsEnabled && colorScheme === 'diverge' ? '-' : ''\n\t\t\t\t}${axisTranslation}, ${\n\t\t\t\t\tConfiguration.legend.color.axisYTranslation\n\t\t\t\t})`\n\t\t\t).call(xAxis);\n\n\t\t\t// Append the last tick\n\t\t\tconst firstTick = axis.select('g.tick').clone(true);\n\t\t\tfirstTick\n\t\t\t\t.attr(\n\t\t\t\t\t'transform',\n\t\t\t\t\t`translate(${\n\t\t\t\t\t\tbarWidth +\n\t\t\t\t\t\t(!customColorsEnabled && colorScheme === 'diverge'\n\t\t\t\t\t\t\t? axisTranslation\n\t\t\t\t\t\t\t: -axisTranslation)\n\t\t\t\t\t}, 0)`\n\t\t\t\t)\n\t\t\t\t.classed('final-tick', true)\n\t\t\t\t.select('text')\n\t\t\t\t.text(quant[quant.length - 1]);\n\n\t\t\taxis.enter().append(firstTick.node());\n\t\t\taxis.select('.domain').remove();\n\t\t} else {\n\t\t\tthrow Error('Entered color legend type is not supported.');\n\t\t}\n\n\t\t// Translate last axis tick if barWidth equals chart width\n\t\tif (width <= Configuration.legend.color.barWidth) {\n\t\t\tconst lastTick = axis.select('g.tick:last-of-type text');\n\t\t\tconst { width } = DOMUtils.getSVGElementSize(lastTick, {\n\t\t\t\tuseBBox: true,\n\t\t\t});\n\t\t\tlastTick.attr('x', `-${width}`);\n\t\t}\n\t}\n\n\tdestroy() {\n\t\t// Remove legend listeners\n\t\tconst eventsFragment = this.services.events;\n\t\teventsFragment.removeEventListener(\n\t\t\tEvents.Axis.RENDER_COMPLETE,\n\t\t\tthis.handleAxisComplete\n\t\t);\n\t}\n}\n"]}
|
package/package.json
CHANGED
package/services/canvas-zoom.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Service } from './service';
|
|
|
16
16
|
import { Events } from './../interfaces/enums';
|
|
17
17
|
import * as Configuration from '../configuration';
|
|
18
18
|
// Services
|
|
19
|
-
import { DOMUtils } from './
|
|
19
|
+
import { DOMUtils } from './essentials/dom-utils';
|
|
20
20
|
import { select } from 'd3-selection';
|
|
21
21
|
var CanvasZoom = /** @class */ (function (_super) {
|
|
22
22
|
__extends(CanvasZoom, _super);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-zoom.js","sourceRoot":"","sources":["canvas-zoom.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas-zoom.js","sourceRoot":"","sources":["canvas-zoom.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AA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;QACpC,cAAc;aACZ,UAAU,EAAE;aACZ,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;aAC3B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;aACnB,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAExB,iCAAiC;QACjC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IACvE,CAAC;IACF,iBAAC;AAAD,CAAC,AA5DD,CAAgC,OAAO,GA4DtC","sourcesContent":["// Internal Imports\nimport { Service } from './service';\nimport { Events } from './../interfaces/enums';\nimport * as Configuration from '../configuration';\n// Services\nimport { DOMUtils } from './essentials/dom-utils';\nimport { select } from 'd3-selection';\n\nexport class CanvasZoom extends Service {\n\tprotected model: any;\n\n\t/**\n\t * focal: object to zoom into\n\t * canvasElements: all the elements to translate and zoom on the chart area\n\t * zoomSettings: object containing duration, easing and zoomlevel for the zoom behaviours\n\t * */\n\tzoomIn(focal, canvasElements, zoomSettings?) {\n\t\tlet x;\n\t\tlet y;\n\t\tlet zoomLevel;\n\t\tconst settings = zoomSettings\n\t\t\t? zoomSettings\n\t\t\t: Configuration.canvasZoomSettings;\n\n\t\tif (focal) {\n\t\t\tx = focal.x;\n\t\t\ty = focal.y;\n\t\t\tzoomLevel = 2;\n\t\t}\n\n\t\t// the 'viewport' size of the chart\n\t\tconst { width, height } = DOMUtils.getSVGElementSize(\n\t\t\tthis.services.domUtils.getHolder(),\n\t\t\t{\n\t\t\t\tuseClientDimensions: true,\n\t\t\t}\n\t\t);\n\n\t\tcanvasElements\n\t\t\t.transition()\n\t\t\t.duration(settings.duration)\n\t\t\t.ease(settings.ease)\n\t\t\t.attr(\n\t\t\t\t'transform',\n\t\t\t\t`translate(${width / 2}, ${\n\t\t\t\t\theight / 2\n\t\t\t\t}) scale(${zoomLevel}) translate(${-x},${-y})`\n\t\t\t);\n\n\t\t// Dispatch canvas zoom in event\n\t\tthis.services.events.dispatchEvent(Events.CanvasZoom.CANVAS_ZOOM_IN, {\n\t\t\telement: select(focal),\n\t\t});\n\t}\n\n\tzoomOut(canvasElements, zoomSettings?) {\n\t\tconst settings = zoomSettings\n\t\t\t? zoomSettings\n\t\t\t: Configuration.canvasZoomSettings;\n\t\tcanvasElements\n\t\t\t.transition()\n\t\t\t.duration(settings.duration)\n\t\t\t.ease(settings.ease)\n\t\t\t.attr('transform', '');\n\n\t\t// Dispatch canvas zoom out event\n\t\tthis.services.events.dispatchEvent(Events.CanvasZoom.CANVAS_ZOOM_OUT);\n\t}\n}\n"]}
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
"signature": "3c43121dd89697d1b1967c164d7ce5658d6b6af57a1fbd46b8d17013593b22de"
|
|
227
227
|
},
|
|
228
228
|
"../src/services/canvas-zoom.ts": {
|
|
229
|
-
"version": "
|
|
229
|
+
"version": "f99876e9ab0cfd7506464c82a926de35af93ce15bf8edb9c90a774c01b0456c5",
|
|
230
230
|
"signature": "e2d65b58ff6a327d9aa2d9bc86473d8d3a4c09f333f9ee53f744c8d89da283c3"
|
|
231
231
|
},
|
|
232
232
|
"../src/services/index.ts": {
|
|
@@ -282,8 +282,8 @@
|
|
|
282
282
|
"signature": "3f334008cdefb90399f7a0ba3f213fe0941c6536da30eb38655f0ed714971772"
|
|
283
283
|
},
|
|
284
284
|
"../src/components/essentials/color-scale-legend.ts": {
|
|
285
|
-
"version": "
|
|
286
|
-
"signature": "
|
|
285
|
+
"version": "98f162af385c747383e4926e88fd1b6039a3655faa9ffba8a4afb2a3e5fe9a6c",
|
|
286
|
+
"signature": "bb004e9a26aeb3aa93c401d60eb542b5d039a8fe9a65a77f7e9face0591bc9ed"
|
|
287
287
|
},
|
|
288
288
|
"../src/components/essentials/modal.ts": {
|
|
289
289
|
"version": "8c3e8782ec7f6762231df11d4ca4927783aa11f7c9e02bc40d60811076f97106",
|
|
@@ -1346,10 +1346,9 @@
|
|
|
1346
1346
|
],
|
|
1347
1347
|
"../src/services/canvas-zoom.ts": [
|
|
1348
1348
|
"../src/services/service.ts",
|
|
1349
|
-
"../src/tools.ts",
|
|
1350
1349
|
"../src/interfaces/enums.ts",
|
|
1351
1350
|
"../src/configuration.ts",
|
|
1352
|
-
"../src/services/
|
|
1351
|
+
"../src/services/essentials/dom-utils.ts",
|
|
1353
1352
|
"../../../node_modules/@types/d3-selection/index.d.ts",
|
|
1354
1353
|
"../../../node_modules/date-fns/typings.d.ts",
|
|
1355
1354
|
"../node_modules/@types/node/fs.d.ts",
|
|
@@ -1493,7 +1492,7 @@
|
|
|
1493
1492
|
"../src/tools.ts",
|
|
1494
1493
|
"../src/interfaces/index.ts",
|
|
1495
1494
|
"../src/configuration.ts",
|
|
1496
|
-
"../src/components/
|
|
1495
|
+
"../src/components/essentials/legend.ts",
|
|
1497
1496
|
"../src/services/index.ts",
|
|
1498
1497
|
"../../../node_modules/@types/d3-axis/index.d.ts",
|
|
1499
1498
|
"../../../node_modules/@types/d3-scale/index.d.ts",
|
|
@@ -3580,10 +3579,6 @@
|
|
|
3580
3579
|
"../src/components/diagrams/buildPaths.ts",
|
|
3581
3580
|
"../src/components/diagrams/markerDefinitions.ts"
|
|
3582
3581
|
],
|
|
3583
|
-
"../src/components/essentials/color-scale-legend.ts": [
|
|
3584
|
-
"../src/interfaces/index.ts",
|
|
3585
|
-
"../src/components/index.ts"
|
|
3586
|
-
],
|
|
3587
3582
|
"../src/components/axes/zero-line.ts": [
|
|
3588
3583
|
"../src/interfaces/index.ts",
|
|
3589
3584
|
"../src/components/component.ts"
|
|
@@ -3766,6 +3761,10 @@
|
|
|
3766
3761
|
"../src/model/model.ts",
|
|
3767
3762
|
"../src/components/component.ts"
|
|
3768
3763
|
],
|
|
3764
|
+
"../src/components/essentials/color-scale-legend.ts": [
|
|
3765
|
+
"../src/interfaces/index.ts",
|
|
3766
|
+
"../src/components/essentials/legend.ts"
|
|
3767
|
+
],
|
|
3769
3768
|
"../src/components/essentials/legend.ts": [
|
|
3770
3769
|
"../src/interfaces/index.ts",
|
|
3771
3770
|
"../src/components/component.ts"
|
|
@@ -3829,9 +3828,6 @@
|
|
|
3829
3828
|
"../src/services/zoom.ts",
|
|
3830
3829
|
"../src/services/canvas-zoom.ts"
|
|
3831
3830
|
],
|
|
3832
|
-
"../src/services/canvas-zoom.ts": [
|
|
3833
|
-
"../src/services/service.ts"
|
|
3834
|
-
],
|
|
3835
3831
|
"../src/services/essentials/gradient-utils.ts": [
|
|
3836
3832
|
"../src/services/service.ts"
|
|
3837
3833
|
],
|
|
@@ -3865,6 +3861,9 @@
|
|
|
3865
3861
|
"../../../node_modules/@types/d3-selection/index.d.ts",
|
|
3866
3862
|
"../src/services/service.ts"
|
|
3867
3863
|
],
|
|
3864
|
+
"../src/services/canvas-zoom.ts": [
|
|
3865
|
+
"../src/services/service.ts"
|
|
3866
|
+
],
|
|
3868
3867
|
"../src/model/model.ts": [
|
|
3869
3868
|
"../../../node_modules/@types/d3-array/index.d.ts",
|
|
3870
3869
|
"../src/interfaces/index.ts"
|