@carbon/charts 0.44.1 → 0.46.4
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 +65 -18
- package/README.md +2 -2
- package/build/demo/data/donut.d.ts +11 -0
- package/build/demo/data/meter.d.ts +31 -0
- package/build/demo/data/pie.d.ts +11 -0
- package/build/src/components/essentials/title-meter.d.ts +2 -0
- package/build/src/components/graphs/meter.d.ts +3 -0
- package/build/src/components/index.d.ts +0 -1
- package/build/src/configuration-non-customizable.d.ts +8 -0
- package/build/src/configuration.d.ts +2 -1
- package/build/src/interfaces/charts.d.ts +17 -0
- package/build/src/interfaces/events.d.ts +9 -0
- package/build/src/model/meter.d.ts +1 -2
- package/build/src/tools.d.ts +2 -1
- package/bundle.js +1 -1
- package/charts/histogram.js.map +1 -1
- package/charts/meter.js +7 -3
- package/charts/meter.js.map +1 -1
- package/components/axes/ruler-binned.js.map +1 -1
- package/components/essentials/title-meter.d.ts +2 -0
- package/components/essentials/title-meter.js +123 -24
- package/components/essentials/title-meter.js.map +1 -1
- package/components/essentials/title.js +3 -1
- package/components/essentials/title.js.map +1 -1
- package/components/graphs/bar-stacked.js +1 -1
- package/components/graphs/bar-stacked.js.map +1 -1
- package/components/graphs/donut.js +1 -1
- package/components/graphs/donut.js.map +1 -1
- package/components/graphs/histogram.js.map +1 -1
- package/components/graphs/meter.d.ts +3 -0
- package/components/graphs/meter.js +176 -21
- package/components/graphs/meter.js.map +1 -1
- package/components/graphs/pie.js +10 -9
- package/components/graphs/pie.js.map +1 -1
- package/components/index.d.ts +0 -1
- package/components/index.js +0 -1
- package/components/index.js.map +1 -1
- package/configuration-non-customizable.d.ts +8 -0
- package/configuration-non-customizable.js +8 -0
- package/configuration-non-customizable.js.map +1 -1
- package/configuration.d.ts +2 -1
- package/configuration.js +9 -1
- package/configuration.js.map +1 -1
- package/demo/create-codesandbox.js +6 -5
- package/demo/create-codesandbox.js.map +1 -1
- package/demo/data/bundle.js +1 -1
- package/demo/data/donut.d.ts +11 -0
- package/demo/data/donut.js +10 -1
- package/demo/data/donut.js.map +1 -1
- package/demo/data/histogram.js +2 -2
- package/demo/data/histogram.js.map +1 -1
- package/demo/data/index.js +25 -0
- package/demo/data/index.js.map +1 -1
- package/demo/data/meter.d.ts +31 -0
- package/demo/data/meter.js +35 -0
- package/demo/data/meter.js.map +1 -1
- package/demo/data/pie.d.ts +11 -0
- package/demo/data/pie.js +16 -0
- package/demo/data/pie.js.map +1 -1
- package/demo/styles.css +46 -0
- package/demo/styles.css.map +1 -1
- package/demo/styles.min.css +1 -1
- package/demo/styles.min.css.map +1 -1
- package/demo/tsconfig.tsbuildinfo +9 -9
- package/interfaces/axis-scales.js.map +1 -1
- package/interfaces/charts.d.ts +17 -0
- package/interfaces/charts.js.map +1 -1
- package/interfaces/events.d.ts +9 -0
- package/interfaces/events.js +10 -0
- package/interfaces/events.js.map +1 -1
- package/model/meter.d.ts +1 -2
- package/model/meter.js +4 -14
- package/model/meter.js.map +1 -1
- package/package.json +1 -1
- package/styles/components/_legend.scss +4 -1
- package/styles/components/_meter-title.scss +4 -0
- package/styles/graphs/_meter.scss +12 -0
- package/styles-g10.css +11 -0
- package/styles-g10.css.map +1 -1
- package/styles-g10.min.css +1 -1
- package/styles-g10.min.css.map +1 -1
- package/styles-g100.css +12 -0
- package/styles-g100.css.map +1 -1
- package/styles-g100.min.css +1 -1
- package/styles-g100.min.css.map +1 -1
- package/styles-g90.css +12 -0
- package/styles-g90.css.map +1 -1
- package/styles-g90.min.css +1 -1
- package/styles-g90.min.css.map +1 -1
- package/styles.css +11 -0
- package/styles.css.map +1 -1
- package/styles.min.css +1 -1
- package/styles.min.css.map +1 -1
- package/tools.d.ts +2 -1
- package/tools.js +16 -9
- package/tools.js.map +1 -1
- package/tsconfig.tsbuildinfo +30 -50
- package/build/src/components/essentials/tooltip-histogram.d.ts +0 -26
- package/components/essentials/tooltip-histogram.d.ts +0 -26
- package/components/essentials/tooltip-histogram.js +0 -154
- package/components/essentials/tooltip-histogram.js.map +0 -1
package/charts/histogram.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram.js","sourceRoot":"","sources":["histogram.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EACN,IAAI,EACJ,SAAS,EACT,WAAW,EACX,kBAAkB,
|
|
1
|
+
{"version":3,"file":"histogram.js","sourceRoot":"","sources":["histogram.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EACN,IAAI,EACJ,SAAS,EACT,WAAW,EACX,kBAAkB,GAKlB,MAAM,qBAAqB,CAAC;AAE7B;IAAoC,kCAAS;IAG5C,wBACC,MAAe,EACf,YAAgD;QAFjD,YAIC,kBAAM,MAAM,EAAE,YAAY,CAAC,SAe3B;QArBD,WAAK,GAAG,IAAI,gBAAgB,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;QAQ3C,2CAA2C;QAC3C,iCAAiC;QACjC,KAAI,CAAC,KAAK,CAAC,UAAU,CACpB,KAAK,CAAC,wBAAwB,CAC7B,aAAa,CAAC,OAAO,CAAC,cAAc,EACpC,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QAEF,6CAA6C;QAC7C,KAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAEhC,KAAI,CAAC,MAAM,EAAE,CAAC;;IACf,CAAC;IAED,sCAAa,GAAb;QACC,gDAAgD;QAChD,IAAM,oBAAoB,GAAG;YAC5B,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACjD,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACnC,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YAC1C,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;SACxC,CAAC;QAEF,IAAM,UAAU,GAAU,IAAI,CAAC,sBAAsB,CACpD,oBAAoB,CACpB,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,qBAAC;AAAD,CAAC,AAvCD,CAAoC,SAAS,GAuC5C","sourcesContent":["// Internal Imports\nimport { ChartModelBinned } from '../model/binned-charts';\nimport { AxisChart } from '../axis-chart';\nimport * as Configuration from '../configuration';\nimport { ChartConfig, HistogramChartOptions } from '../interfaces/index';\nimport { Tools } from '../tools';\n\n// Components\nimport {\n\tGrid,\n\tHistogram,\n\tBinnedRuler,\n\tTwoDimensionalAxes,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tTooltip,\n\tLegend,\n\tLayoutComponent,\n} from '../components/index';\n\nexport class HistogramChart extends AxisChart {\n\tmodel = new ChartModelBinned(this.services);\n\n\tconstructor(\n\t\tholder: Element,\n\t\tchartConfigs: ChartConfig<HistogramChartOptions>\n\t) {\n\t\tsuper(holder, chartConfigs);\n\n\t\t// Merge the default options for this chart\n\t\t// With the user provided options\n\t\tthis.model.setOptions(\n\t\t\tTools.mergeDefaultChartOptions(\n\t\t\t\tConfiguration.options.histogramChart,\n\t\t\t\tchartConfigs.options\n\t\t\t)\n\t\t);\n\n\t\t// Initialize data, services, components etc.\n\t\tthis.init(holder, chartConfigs);\n\n\t\tthis.update();\n\t}\n\n\tgetComponents() {\n\t\t// Specify what to render inside the graph-frame\n\t\tconst graphFrameComponents = [\n\t\t\tnew TwoDimensionalAxes(this.model, this.services),\n\t\t\tnew Grid(this.model, this.services),\n\t\t\tnew BinnedRuler(this.model, this.services),\n\t\t\tnew Histogram(this.model, this.services),\n\t\t];\n\n\t\tconst components: any[] = this.getAxisChartComponents(\n\t\t\tgraphFrameComponents\n\t\t);\n\n\t\treturn components;\n\t}\n}\n"]}
|
package/charts/meter.js
CHANGED
|
@@ -25,9 +25,13 @@ var MeterChart = /** @class */ (function (_super) {
|
|
|
25
25
|
function MeterChart(holder, chartConfigs) {
|
|
26
26
|
var _this = _super.call(this, holder, chartConfigs) || this;
|
|
27
27
|
_this.model = new MeterChartModel(_this.services);
|
|
28
|
+
// use prop meter options or regular meter options
|
|
29
|
+
var options = chartConfigs.options.meter.proportional
|
|
30
|
+
? Tools.merge(Tools.clone(Configuration.options.proportionalMeterChart), chartConfigs.options)
|
|
31
|
+
: Tools.merge(Tools.clone(Configuration.options.meterChart), chartConfigs.options);
|
|
28
32
|
// Merge the default options for this chart
|
|
29
33
|
// With the user provided options
|
|
30
|
-
_this.model.setOptions(
|
|
34
|
+
_this.model.setOptions(options);
|
|
31
35
|
// Initialize data, services, components etc.
|
|
32
36
|
_this.init(holder, chartConfigs);
|
|
33
37
|
return _this;
|
|
@@ -44,14 +48,14 @@ var MeterChart = /** @class */ (function (_super) {
|
|
|
44
48
|
var titleComponent = {
|
|
45
49
|
id: 'meter-title',
|
|
46
50
|
components: [new MeterTitle(this.model, this.services)],
|
|
47
|
-
growth: LayoutGrowth.
|
|
51
|
+
growth: LayoutGrowth.STRETCH,
|
|
48
52
|
renderType: RenderTypes.SVG,
|
|
49
53
|
};
|
|
50
54
|
// create the title spacer
|
|
51
55
|
var titleSpacerComponent = {
|
|
52
56
|
id: 'spacer',
|
|
53
57
|
components: [new Spacer(this.model, this.services, { size: 8 })],
|
|
54
|
-
growth: LayoutGrowth.
|
|
58
|
+
growth: LayoutGrowth.STRETCH,
|
|
55
59
|
};
|
|
56
60
|
// the graph frame for meter includes the custom title (and spacer)
|
|
57
61
|
var graphFrame = [
|
package/charts/meter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter.js","sourceRoot":"","sources":["meter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAGN,YAAY,EACZ,eAAe,EACf,WAAW,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAErD,aAAa;AACb,OAAO,EAKN,eAAe,EACf,UAAU,EACV,MAAM,GACN,MAAM,qBAAqB,CAAC;AAE7B;IAAgC,8BAAK;IAGpC,oBAAY,MAAe,EAAE,YAA4C;QAAzE,YACC,kBAAM,MAAM,EAAE,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"meter.js","sourceRoot":"","sources":["meter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAGN,YAAY,EACZ,eAAe,EACf,WAAW,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAErD,aAAa;AACb,OAAO,EAKN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AU,EAAE,WAAW,CAAC,GAAG;SAC3B,CAAC;QAEF,0BAA0B;QAC1B,IAAM,oBAAoB,GAAG;YAC5B,EAAE,EAAE,QAAQ;YACZ,UAAU,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YAChE,MAAM,EAAE,YAAY,CAAC,OAAO;SAC5B,CAAC;QAEF,mEAAmE;QACnE,IAAM,UAAU,GAAG;YAClB,IAAI,eAAe,CAClB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EACb,CAAC,cAAc,EAAE,oBAAoB,EAAE,KAAK,CAAC,EAC7C;gBACC,SAAS,EAAE,eAAe,CAAC,MAAM;aACjC,CACD;SACD,CAAC;QAEF,+CAA+C;QAC/C,IAAM,UAAU,GAAU,IAAI,CAAC,kBAAkB,CAChD,UAAU,EACV,WAAW,CAAC,IAAI,CAChB,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,iBAAC;AAAD,CAAC,AArED,CAAgC,KAAK,GAqEpC","sourcesContent":["// Internal Imports\nimport { MeterChartModel } from '../model/meter';\nimport { Chart } from '../chart';\nimport * as Configuration from '../configuration';\nimport {\n\tChartConfig,\n\tMeterChartOptions,\n\tLayoutGrowth,\n\tLayoutDirection,\n\tRenderTypes,\n} from '../interfaces/index';\nimport { Tools } from '../tools';\nimport { Meter } from './../components/graphs/meter';\n\n// Components\nimport {\n\tPie,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tTooltip,\n\tLegend,\n\tLayoutComponent,\n\tMeterTitle,\n\tSpacer,\n} from '../components/index';\n\nexport class MeterChart extends Chart {\n\tmodel = new MeterChartModel(this.services);\n\n\tconstructor(holder: Element, chartConfigs: ChartConfig<MeterChartOptions>) {\n\t\tsuper(holder, chartConfigs);\n\n\t\t// use prop meter options or regular meter options\n\t\tlet options = chartConfigs.options.meter.proportional\n\t\t\t? Tools.merge(\n\t\t\t\t\tTools.clone(Configuration.options.proportionalMeterChart),\n\t\t\t\t\tchartConfigs.options\n\t\t\t )\n\t\t\t: Tools.merge(\n\t\t\t\t\tTools.clone(Configuration.options.meterChart),\n\t\t\t\t\tchartConfigs.options\n\t\t\t );\n\n\t\t// Merge the default options for this chart\n\t\t// With the user provided options\n\t\tthis.model.setOptions(options);\n\n\t\t// Initialize data, services, components etc.\n\t\tthis.init(holder, chartConfigs);\n\t}\n\n\tgetComponents() {\n\t\t// Specify what to render inside the graph only\n\t\tconst graph = {\n\t\t\tid: 'meter-graph',\n\t\t\tcomponents: [new Meter(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t\trenderType: RenderTypes.SVG,\n\t\t};\n\n\t\t// Meter has an unique dataset title within the graph\n\t\tconst titleComponent = {\n\t\t\tid: 'meter-title',\n\t\t\tcomponents: [new MeterTitle(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t\trenderType: RenderTypes.SVG,\n\t\t};\n\n\t\t// create the title spacer\n\t\tconst titleSpacerComponent = {\n\t\t\tid: 'spacer',\n\t\t\tcomponents: [new Spacer(this.model, this.services, { size: 8 })],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\t// the graph frame for meter includes the custom title (and spacer)\n\t\tconst graphFrame = [\n\t\t\tnew LayoutComponent(\n\t\t\t\tthis.model,\n\t\t\t\tthis.services,\n\t\t\t\t[titleComponent, titleSpacerComponent, graph],\n\t\t\t\t{\n\t\t\t\t\tdirection: LayoutDirection.COLUMN,\n\t\t\t\t}\n\t\t\t),\n\t\t];\n\n\t\t// add the meter title as a top level component\n\t\tconst components: any[] = this.getChartComponents(\n\t\t\tgraphFrame,\n\t\t\tRenderTypes.HTML\n\t\t);\n\n\t\treturn components;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruler-binned.js","sourceRoot":"","sources":["ruler-binned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N,IAAI,CAAC,SAAS,EAAE,CAAC;aACjB;SACD;aAAM;YACN,IAAI,CAAC,SAAS,EAAE,CAAC;SACjB;IACF,CAAC;IACF,kBAAC;AAAD,CAAC,AA/ID,CAAiC,KAAK,GA+IrC","sourcesContent":["// Internal Imports\nimport { GenericSvgSelection, Ruler } from './ruler';\nimport { DOMUtils } from '../../services';\nimport {\n\tCartesianOrientations,\n\tColorClassNameTypes,\n\tEvents,\n\tRenderTypes,\n} from '../../interfaces';\nimport { Tools } from '../../tools';\n\n// D3 Imports\nimport { select } from 'd3-selection';\n\nimport { get } from 'lodash-es';\n\nexport class BinnedRuler extends Ruler {\n\ttype = 'ruler-binned';\n\trenderType = RenderTypes.SVG;\n\n\tshowRuler(event, [x, y]: [number, number]) {\n\t\tconst svg = this.parent;\n\n\t\tconst options = this.model.getOptions();\n\n\t\tconst orientation: CartesianOrientations = this.services.cartesianScales.getOrientation();\n\n\t\tconst rangeScale = this.services.cartesianScales.getRangeScale();\n\t\tconst [yScaleEnd, yScaleStart] = rangeScale.range();\n\n\t\tconst domainScale = this.services.cartesianScales.getDomainScale();\n\t\tconst correspondingDomainValue = domainScale.invert(\n\t\t\torientation === CartesianOrientations.VERTICAL ? x : y\n\t\t);\n\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\n\t\tconst dataPointElements: GenericSvgSelection = svg.selectAll(\n\t\t\t'[role=graphics-symbol]'\n\t\t);\n\n\t\tconst elementsToHighlight = dataPointElements.filter((d) => {\n\t\t\tif (\n\t\t\t\tparseFloat(get(d, 'data.x0')) <= correspondingDomainValue &&\n\t\t\t\tparseFloat(get(d, 'data.x1')) >= correspondingDomainValue\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t});\n\n\t\t// some data point match\n\t\tif (elementsToHighlight.size() > 0) {\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\tconst sampleMatchData = select(\n\t\t\t\telementsToHighlight.nodes()[0]\n\t\t\t).datum();\n\n\t\t\tconst x0 = parseFloat(get(sampleMatchData, 'data.x0'));\n\t\t\tconst x1 = parseFloat(get(sampleMatchData, 'data.x1'));\n\n\t\t\tconst activeDataGroupNames = this.model.getActiveDataGroupNames();\n\n\t\t\tconst tooltipDataGroups = activeDataGroupNames\n\t\t\t\t.reverse()\n\t\t\t\t.map((dataGroupName) => ({\n\t\t\t\t\tlabel: 'Group',\n\t\t\t\t\tvalue: get(sampleMatchData, `data.${dataGroupName}`),\n\t\t\t\t\tclass: this.model.getColorClassName({\n\t\t\t\t\t\tclassNameTypes: [ColorClassNameTypes.TOOLTIP],\n\t\t\t\t\t\tdataGroupName,\n\t\t\t\t\t}),\n\t\t\t\t}))\n\t\t\t\t.filter((d) => d.value !== 0);\n\t\t\tconst thereIsMatchingData = tooltipDataGroups.length > 0;\n\n\t\t\tif (thereIsMatchingData) {\n\t\t\t\tthis.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\t\tmousePosition: [x, y],\n\t\t\t\t\thoveredElement: rulerLine,\n\t\t\t\t\titems: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: get(options, 'bins.rangeLabel') || 'Range',\n\t\t\t\t\t\t\tvalue: `${x0} – ${x1}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...tooltipDataGroups,\n\t\t\t\t\t\t...(Tools.getProperty(\n\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\t'tooltip',\n\t\t\t\t\t\t\t'showTotal'\n\t\t\t\t\t\t) === true\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel:\n\t\t\t\t\t\t\t\t\t\t\tget(\n\t\t\t\t\t\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\t\t\t\t\t\t'tooltip.totalLabel'\n\t\t\t\t\t\t\t\t\t\t\t) || 'Total',\n\t\t\t\t\t\t\t\t\t\tvalue: activeDataGroupNames.reduce(\n\t\t\t\t\t\t\t\t\t\t\t(accum, currentValue) =>\n\t\t\t\t\t\t\t\t\t\t\t\taccum +\n\t\t\t\t\t\t\t\t\t\t\t\tparseFloat(\n\t\t\t\t\t\t\t\t\t\t\t\t\tget(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsampleMatchData,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`data.${currentValue}`\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t],\n\t\t\t\t});\n\n\t\t\t\truler.attr('opacity', 1);\n\n\t\t\t\tconst rulerPosition = domainScale((x0 + x1) / 2);\n\n\t\t\t\t// line snaps to matching point\n\t\t\t\tif (orientation === 'horizontal') {\n\t\t\t\t\trulerLine\n\t\t\t\t\t\t.attr('x1', yScaleStart)\n\t\t\t\t\t\t.attr('x2', yScaleEnd)\n\t\t\t\t\t\t.attr('y1', rulerPosition)\n\t\t\t\t\t\t.attr('y2', rulerPosition);\n\t\t\t\t} else {\n\t\t\t\t\trulerLine\n\t\t\t\t\t\t.attr('y1', yScaleStart)\n\t\t\t\t\t\t.attr('y2', yScaleEnd)\n\t\t\t\t\t\t.attr('x1', rulerPosition)\n\t\t\t\t\t\t.attr('x2', rulerPosition);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.hideRuler();\n\t\t\t}\n\t\t} else {\n\t\t\tthis.hideRuler();\n\t\t}\n\t}\n}\n"]}
|
|
@@ -26,37 +26,124 @@ var MeterTitle = /** @class */ (function (_super) {
|
|
|
26
26
|
return _this;
|
|
27
27
|
}
|
|
28
28
|
MeterTitle.prototype.render = function () {
|
|
29
|
-
var dataset = this.model.getDisplayData();
|
|
29
|
+
var dataset = Tools.getProperty(this.model.getDisplayData(), 0);
|
|
30
30
|
var options = this.getOptions();
|
|
31
|
-
var svg = this.getComponentContainer()
|
|
32
|
-
.attr('width', '100%')
|
|
33
|
-
.attr('height', '100%');
|
|
31
|
+
var svg = this.getComponentContainer();
|
|
34
32
|
var groupMapsTo = options.data.groupMapsTo;
|
|
35
|
-
|
|
33
|
+
var proportional = Tools.getProperty(options, 'meter', 'proportional');
|
|
34
|
+
if (proportional) {
|
|
35
|
+
this.displayTotal();
|
|
36
|
+
this.displayBreakdownTitle();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// the title for a meter, is the label for that dataset
|
|
40
|
+
var title = svg
|
|
41
|
+
.selectAll('text.meter-title')
|
|
42
|
+
.data([dataset[groupMapsTo]]);
|
|
43
|
+
title
|
|
44
|
+
.enter()
|
|
45
|
+
.append('text')
|
|
46
|
+
.classed('meter-title', true)
|
|
47
|
+
.merge(title)
|
|
48
|
+
.attr('x', 0)
|
|
49
|
+
.attr('y', '1em')
|
|
50
|
+
.text(function (d) { return d; });
|
|
51
|
+
title.exit().remove();
|
|
52
|
+
// appends the associated percentage after title
|
|
53
|
+
this.appendPercentage();
|
|
54
|
+
// if status ranges are provided (custom or default), display indicator
|
|
55
|
+
this.displayStatus();
|
|
56
|
+
}
|
|
57
|
+
// get the max width of a title (with consideration for the status/percentage)
|
|
58
|
+
var maxWidth = this.getMaxTitleWidth();
|
|
59
|
+
var titleElement = DOMUtils.appendOrSelect(svg, 'text.meter-title');
|
|
60
|
+
if (maxWidth > 0 &&
|
|
61
|
+
titleElement.node().getComputedTextLength() > maxWidth) {
|
|
62
|
+
this.truncateTitle(titleElement, maxWidth);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
MeterTitle.prototype.displayBreakdownTitle = function () {
|
|
66
|
+
var self = this;
|
|
67
|
+
var svg = this.getComponentContainer();
|
|
68
|
+
var options = this.getOptions();
|
|
69
|
+
var datasetsTotal = this.model.getMaximumDomain(this.model.getDisplayData());
|
|
70
|
+
var total = Tools.getProperty(options, 'meter', 'proportional', 'total');
|
|
71
|
+
var unit = Tools.getProperty(options, 'meter', 'proportional', 'unit')
|
|
72
|
+
? Tools.getProperty(options, 'meter', 'proportional', 'unit')
|
|
73
|
+
: '';
|
|
74
|
+
var data;
|
|
75
|
+
if (datasetsTotal === total) {
|
|
76
|
+
data = null;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
var difference = total !== null ? total - datasetsTotal : datasetsTotal;
|
|
80
|
+
//breakdownFormatter
|
|
81
|
+
var breakdownFormatter = Tools.getProperty(options, 'meter', 'proportional', 'breakdownFormatter');
|
|
82
|
+
data =
|
|
83
|
+
breakdownFormatter !== null
|
|
84
|
+
? breakdownFormatter({
|
|
85
|
+
datasetsTotal: datasetsTotal,
|
|
86
|
+
total: total,
|
|
87
|
+
})
|
|
88
|
+
: datasetsTotal + " " + unit + " used (" + difference + " " + unit + " available)";
|
|
89
|
+
}
|
|
90
|
+
// the breakdown part to whole of the datasets to the overall total
|
|
36
91
|
var title = svg
|
|
37
|
-
.selectAll('text.meter-title')
|
|
38
|
-
.data([
|
|
92
|
+
.selectAll('text.proportional-meter-title')
|
|
93
|
+
.data([data]);
|
|
39
94
|
title
|
|
40
95
|
.enter()
|
|
41
96
|
.append('text')
|
|
42
|
-
.classed('meter-title', true)
|
|
97
|
+
.classed('proportional-meter-title', true)
|
|
43
98
|
.merge(title)
|
|
44
99
|
.attr('x', 0)
|
|
45
100
|
.attr('y', '1em')
|
|
46
101
|
.text(function (d) { return d; });
|
|
47
102
|
title.exit().remove();
|
|
48
|
-
// appends the associated percentage after title
|
|
49
|
-
this.appendPercentage();
|
|
50
|
-
// if status ranges are provided (custom or default), display indicator
|
|
51
|
-
this.displayStatus();
|
|
52
|
-
// get the max width of a title (with consideration for the status/percentage)
|
|
53
103
|
var maxWidth = this.getMaxTitleWidth();
|
|
54
|
-
var titleElement = DOMUtils.appendOrSelect(svg, 'text.meter-title');
|
|
104
|
+
var titleElement = DOMUtils.appendOrSelect(svg, 'text.proportional-meter-title');
|
|
55
105
|
if (maxWidth > 0 &&
|
|
56
106
|
titleElement.node().getComputedTextLength() > maxWidth) {
|
|
57
107
|
this.truncateTitle(titleElement, maxWidth);
|
|
58
108
|
}
|
|
59
109
|
};
|
|
110
|
+
// show the total for prop meter
|
|
111
|
+
MeterTitle.prototype.displayTotal = function () {
|
|
112
|
+
var self = this;
|
|
113
|
+
var svg = this.getComponentContainer();
|
|
114
|
+
var options = this.getOptions();
|
|
115
|
+
var total = Tools.getProperty(options, 'meter', 'proportional', 'total');
|
|
116
|
+
var totalValue = total
|
|
117
|
+
? Tools.getProperty(options, 'meter', 'proportional', 'total')
|
|
118
|
+
: this.model.getMaximumDomain(this.model.getDisplayData());
|
|
119
|
+
var unit = Tools.getProperty(options, 'meter', 'proportional', 'unit')
|
|
120
|
+
? Tools.getProperty(options, 'meter', 'proportional', 'unit')
|
|
121
|
+
: '';
|
|
122
|
+
// totalFormatter function
|
|
123
|
+
var totalFormatter = Tools.getProperty(options, 'meter', 'proportional', 'totalFormatter');
|
|
124
|
+
var totalString = totalFormatter !== null
|
|
125
|
+
? totalFormatter(totalValue)
|
|
126
|
+
: total + " " + unit + " total";
|
|
127
|
+
var containerBounds = DOMUtils.getSVGElementSize(this.services.domUtils.getMainContainer(), { useAttr: true });
|
|
128
|
+
// need to check if the width is 0, and try to use the parent attribute
|
|
129
|
+
// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions
|
|
130
|
+
var containerWidth = containerBounds.width
|
|
131
|
+
? containerBounds.width
|
|
132
|
+
: this.parent.node().getAttribute('width');
|
|
133
|
+
var title = svg
|
|
134
|
+
.selectAll('text.proportional-meter-total')
|
|
135
|
+
.data([totalString]);
|
|
136
|
+
title
|
|
137
|
+
.enter()
|
|
138
|
+
.append('text')
|
|
139
|
+
.classed('proportional-meter-total', true)
|
|
140
|
+
.merge(title)
|
|
141
|
+
.attr('x', containerWidth)
|
|
142
|
+
.attr('y', '1em')
|
|
143
|
+
.attr('text-anchor', 'end')
|
|
144
|
+
.text(function (d) { return d; });
|
|
145
|
+
title.exit().remove();
|
|
146
|
+
};
|
|
60
147
|
/**
|
|
61
148
|
* Appends the corresponding status based on the value and the peak.
|
|
62
149
|
*/
|
|
@@ -68,7 +155,7 @@ var MeterTitle = /** @class */ (function (_super) {
|
|
|
68
155
|
// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions
|
|
69
156
|
var containerWidth = containerBounds.width
|
|
70
157
|
? containerBounds.width
|
|
71
|
-
:
|
|
158
|
+
: 0;
|
|
72
159
|
// get the status from the model
|
|
73
160
|
var status = this.model.getStatus();
|
|
74
161
|
var radius = Configuration.meter.status.indicatorSize / 2;
|
|
@@ -100,7 +187,7 @@ var MeterTitle = /** @class */ (function (_super) {
|
|
|
100
187
|
* Appends the associated percentage to the end of the title
|
|
101
188
|
*/
|
|
102
189
|
MeterTitle.prototype.appendPercentage = function () {
|
|
103
|
-
var dataValue = this.model.getDisplayData()
|
|
190
|
+
var dataValue = Tools.getProperty(this.model.getDisplayData(), 0, 'value');
|
|
104
191
|
// use the title's position to append the percentage to the end
|
|
105
192
|
var svg = this.getComponentContainer();
|
|
106
193
|
var title = DOMUtils.appendOrSelect(svg, 'text.meter-title');
|
|
@@ -144,18 +231,30 @@ var MeterTitle = /** @class */ (function (_super) {
|
|
|
144
231
|
MeterTitle.prototype.getMaxTitleWidth = function () {
|
|
145
232
|
// get a reference to the title elements to calculate the size the title can be
|
|
146
233
|
var containerBounds = DOMUtils.getHTMLElementSize(this.services.domUtils.getMainContainer());
|
|
234
|
+
var proportional = Tools.getProperty(this.getOptions(), 'meter', 'proportional');
|
|
147
235
|
// need to check if the width is 0, and try to use the parent attribute
|
|
148
236
|
var containerWidth = containerBounds.width
|
|
149
237
|
? containerBounds.width
|
|
150
238
|
: this.parent.node().getAttribute('width');
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
239
|
+
if (proportional !== null) {
|
|
240
|
+
var total = DOMUtils.appendOrSelect(this.parent, 'text.proportional-meter-total').node();
|
|
241
|
+
var totalWidth = DOMUtils.getSVGElementSize(total, {
|
|
242
|
+
useBBox: true,
|
|
243
|
+
}).width;
|
|
244
|
+
return (containerWidth -
|
|
245
|
+
totalWidth -
|
|
246
|
+
Configuration.meter.total.paddingLeft);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
var percentage = DOMUtils.appendOrSelect(this.parent, 'text.percent-value');
|
|
250
|
+
// the title needs to fit the width of the container without crowding the status, and percentage value
|
|
251
|
+
var offset = Configuration.meter.statusBar.paddingRight;
|
|
252
|
+
var percentageWidth = percentage.node().getComputedTextLength();
|
|
253
|
+
var statusGroup = DOMUtils.appendOrSelect(this.parent, 'g.status-indicator').node();
|
|
254
|
+
var statusWidth = DOMUtils.getSVGElementSize(statusGroup, { useBBox: true })
|
|
255
|
+
.width + Configuration.meter.status.paddingLeft;
|
|
256
|
+
return containerWidth - percentageWidth - offset - statusWidth;
|
|
257
|
+
}
|
|
159
258
|
};
|
|
160
259
|
/**
|
|
161
260
|
* Get the associated status icon for the data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title-meter.js","sourceRoot":"","sources":["title-meter.ts"],"names":[],"mappings":";;;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AChE,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;QAExC,OAAO,cAAc,GAAG,eAAe,GAAG,MAAM,GAAG,WAAW,CAAC;IAChE,CAAC;IAED;;;OAGG;IACO,4CAAuB,GAAjC,UAAkC,MAAM;QACvC,QAAQ,MAAM,EAAE;YACf,KAAK,QAAQ,CAAC,OAAO;gBACpB,OAAO,mFAAmF,CAAC;YAC5F,KAAK,QAAQ,CAAC,MAAM;gBACnB,OAAO,wCAAwC,CAAC;YACjD,KAAK,QAAQ,CAAC,OAAO;gBACpB,OAAO,0PAA0P,CAAC;SACnQ;IACF,CAAC;IACF,iBAAC;AAAD,CAAC,AAxND,CAAgC,KAAK,GAwNpC","sourcesContent":["// Internal Imports\nimport { Title } from './title';\nimport { DOMUtils } from '../../services';\nimport { Tools } from '../../tools';\nimport { RenderTypes, Statuses } from './../../interfaces/enums';\nimport * as Configuration from '../../configuration';\n\nexport class MeterTitle extends Title {\n\ttype = 'meter-title';\n\trenderType = RenderTypes.SVG;\n\n\trender() {\n\t\tconst dataset = this.model.getDisplayData();\n\t\tconst options = this.getOptions();\n\t\tconst svg = this.getComponentContainer()\n\t\t\t.attr('width', '100%')\n\t\t\t.attr('height', '100%');\n\t\tconst { groupMapsTo } = options.data;\n\n\t\t// the title for a meter, is the label for that dataset\n\t\tconst title = svg\n\t\t\t.selectAll('text.meter-title')\n\t\t\t.data([dataset[groupMapsTo]]);\n\n\t\ttitle\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('meter-title', true)\n\t\t\t.merge(title)\n\t\t\t.attr('x', 0)\n\t\t\t.attr('y', '1em')\n\t\t\t.text((d) => d);\n\n\t\ttitle.exit().remove();\n\n\t\t// appends the associated percentage after title\n\t\tthis.appendPercentage();\n\n\t\t// if status ranges are provided (custom or default), display indicator\n\t\tthis.displayStatus();\n\n\t\t// get the max width of a title (with consideration for the status/percentage)\n\t\tconst maxWidth = this.getMaxTitleWidth();\n\t\tconst titleElement = DOMUtils.appendOrSelect(svg, 'text.meter-title');\n\n\t\tif (\n\t\t\tmaxWidth > 0 &&\n\t\t\ttitleElement.node().getComputedTextLength() > maxWidth\n\t\t) {\n\t\t\tthis.truncateTitle(titleElement, maxWidth);\n\t\t}\n\t}\n\n\t/**\n\t * Appends the corresponding status based on the value and the peak.\n\t */\n\tdisplayStatus() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\t// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: this.parent.node().getAttribute('width');\n\n\t\t// get the status from the model\n\t\tconst status = this.model.getStatus();\n\t\tconst radius = Configuration.meter.status.indicatorSize / 2;\n\n\t\t// create a group for the icon/inner path\n\t\tconst statusGroup = DOMUtils.appendOrSelect(svg, `g.status-indicator`)\n\t\t\t.attr(\n\t\t\t\t'class',\n\t\t\t\tstatus !== null ? `status-indicator status--${status}` : ''\n\t\t\t)\n\t\t\t.attr('transform', `translate(${containerWidth - radius}, 0)`);\n\n\t\tconst data = status ? [status] : [];\n\t\tconst icon = statusGroup.selectAll('circle.status').data(data);\n\n\t\ticon.enter()\n\t\t\t.append('circle')\n\t\t\t.merge(icon)\n\t\t\t.attr('class', 'status')\n\t\t\t.attr('r', radius)\n\t\t\t.attr('cx', 0)\n\t\t\t.attr('cy', `calc(1em / 2)`);\n\n\t\tconst innerIcon = statusGroup.selectAll('path.innerFill').data(data);\n\n\t\tinnerIcon\n\t\t\t.enter()\n\t\t\t.append('path')\n\t\t\t.merge(innerIcon)\n\t\t\t.attr('d', self.getStatusIconPathString(status))\n\t\t\t.attr('transform', `translate(-${radius}, 0)`)\n\t\t\t.attr('class', 'innerFill');\n\n\t\tinnerIcon.exit().remove();\n\t\ticon.exit().remove();\n\t}\n\n\t/**\n\t * Appends the associated percentage to the end of the title\n\t */\n\tappendPercentage() {\n\t\tconst dataValue = this.model.getDisplayData().value;\n\n\t\t// use the title's position to append the percentage to the end\n\t\tconst svg = this.getComponentContainer();\n\t\tconst title = DOMUtils.appendOrSelect(svg, 'text.meter-title');\n\n\t\t// check if it is enabled\n\t\tconst data =\n\t\t\tTools.getProperty(\n\t\t\t\tthis.getOptions(),\n\t\t\t\t'meter',\n\t\t\t\t'statusBar',\n\t\t\t\t'percentageIndicator',\n\t\t\t\t'enabled'\n\t\t\t) === true\n\t\t\t\t? [dataValue]\n\t\t\t\t: [];\n\n\t\t// append a percentage if it is enabled, update it\n\t\tconst percentage = svg.selectAll('text.percent-value').data(data);\n\n\t\t// the horizontal offset of the percentage value from the title\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\n\t\tpercentage\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('percent-value', true)\n\t\t\t.merge(percentage)\n\t\t\t.text((d) => `${d}%`)\n\t\t\t.attr(\n\t\t\t\t'x',\n\t\t\t\t+title.attr('x') + title.node().getComputedTextLength() + offset\n\t\t\t) // set the position to after the title\n\t\t\t.attr('y', title.attr('y'));\n\n\t\tpercentage.exit().remove();\n\t}\n\n\t/**\n\t * Uses the parent class truncate logic\n\t * @param title d3 selection of title element that will be truncated\n\t * @param titlestring the original string that needs truncation\n\t * @param maxWidth the max width the title can take\n\t */\n\ttruncateTitle(title, maxWidth) {\n\t\tsuper.truncateTitle(title, maxWidth);\n\n\t\t// update the position on the percentage to be inline with the title\n\t\tconst tspan = DOMUtils.appendOrSelect(this.parent, 'tspan');\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\t\tconst tspanLength = Math.ceil(tspan.node().getComputedTextLength());\n\n\t\tconst percentage = DOMUtils.appendOrSelect(\n\t\t\tthis.parent,\n\t\t\t'text.percent-value'\n\t\t);\n\t\tpercentage.attr(\n\t\t\t'x',\n\t\t\t+title.attr('x') +\n\t\t\t\ttitle.node().getComputedTextLength() +\n\t\t\t\ttspanLength +\n\t\t\t\toffset\n\t\t);\n\t}\n\n\t// computes the maximum space a title can take\n\tprotected getMaxTitleWidth() {\n\t\t// get a reference to the title elements to calculate the size the title can be\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: this.parent.node().getAttribute('width');\n\n\t\tconst percentage = DOMUtils.appendOrSelect(\n\t\t\tthis.parent,\n\t\t\t'text.percent-value'\n\t\t);\n\t\t// the title needs to fit the width of the container without crowding the status, and percentage value\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\t\tconst percentageWidth = percentage.node().getComputedTextLength();\n\n\t\tconst statusGroup = DOMUtils.appendOrSelect(\n\t\t\tthis.parent,\n\t\t\t'g.status-indicator'\n\t\t).node();\n\n\t\tconst statusWidth =\n\t\t\tDOMUtils.getSVGElementSize(statusGroup, { useBBox: true }).width +\n\t\t\tConfiguration.meter.status.paddingLeft;\n\n\t\treturn containerWidth - percentageWidth - offset - statusWidth;\n\t}\n\n\t/**\n\t * Get the associated status icon for the data\n\t * @param status the active status for the meter chart\n\t */\n\tprotected getStatusIconPathString(status) {\n\t\tswitch (status) {\n\t\t\tcase Statuses.SUCCESS:\n\t\t\t\treturn 'M6.875 11.3125 3.75 8.1875 4.74375 7.25 6.875 9.34375 11.50625 4.75 12.5 5.7375 Z';\n\t\t\tcase Statuses.DANGER:\n\t\t\t\treturn 'M10.7 11.5 4.5 5.3 5.3 4.5 11.5 10.7 Z';\n\t\t\tcase Statuses.WARNING:\n\t\t\t\treturn 'M7.9375,11.125 C7.41973305,11.125 7,11.544733 7,12.0625 C7,12.580267 7.41973305,13 7.9375,13 C8.45526695,13 8.875,12.580267 8.875,12.0625 C8.875,11.544733 8.45526695,11.125 7.9375,11.125 M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;IACF,CAAC;IACF,iBAAC;AAAD,CAAC,AA7XD,CAAgC,KAAK,GA6XpC","sourcesContent":["// Internal Imports\nimport { Title } from './title';\nimport { DOMUtils } from '../../services';\nimport { Tools } from '../../tools';\nimport { RenderTypes, Statuses } from './../../interfaces/enums';\nimport * as Configuration from '../../configuration';\n\nexport class MeterTitle extends Title {\n\ttype = 'meter-title';\n\trenderType = RenderTypes.SVG;\n\n\trender() {\n\t\tconst dataset = Tools.getProperty(this.model.getDisplayData(), 0);\n\t\tconst options = this.getOptions();\n\t\tconst svg = this.getComponentContainer();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst proportional = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional'\n\t\t);\n\n\t\tif (proportional) {\n\t\t\tthis.displayTotal();\n\t\t\tthis.displayBreakdownTitle();\n\t\t} else {\n\t\t\t// the title for a meter, is the label for that dataset\n\t\t\tconst title = svg\n\t\t\t\t.selectAll('text.meter-title')\n\t\t\t\t.data([dataset[groupMapsTo]]);\n\n\t\t\ttitle\n\t\t\t\t.enter()\n\t\t\t\t.append('text')\n\t\t\t\t.classed('meter-title', true)\n\t\t\t\t.merge(title)\n\t\t\t\t.attr('x', 0)\n\t\t\t\t.attr('y', '1em')\n\t\t\t\t.text((d) => d);\n\n\t\t\ttitle.exit().remove();\n\n\t\t\t// appends the associated percentage after title\n\t\t\tthis.appendPercentage();\n\n\t\t\t// if status ranges are provided (custom or default), display indicator\n\t\t\tthis.displayStatus();\n\t\t}\n\t\t// get the max width of a title (with consideration for the status/percentage)\n\t\tconst maxWidth = this.getMaxTitleWidth();\n\t\tconst titleElement = DOMUtils.appendOrSelect(svg, 'text.meter-title');\n\n\t\tif (\n\t\t\tmaxWidth > 0 &&\n\t\t\ttitleElement.node().getComputedTextLength() > maxWidth\n\t\t) {\n\t\t\tthis.truncateTitle(titleElement, maxWidth);\n\t\t}\n\t}\n\n\tdisplayBreakdownTitle() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\t\tconst options = this.getOptions();\n\t\tconst datasetsTotal = this.model.getMaximumDomain(\n\t\t\tthis.model.getDisplayData()\n\t\t);\n\t\tconst total = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'total'\n\t\t);\n\t\tconst unit = Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t: '';\n\n\t\tlet data;\n\t\tif (datasetsTotal === total) {\n\t\t\tdata = null;\n\t\t} else {\n\t\t\tconst difference =\n\t\t\t\ttotal !== null ? total - datasetsTotal : datasetsTotal;\n\t\t\t//breakdownFormatter\n\t\t\tconst breakdownFormatter = Tools.getProperty(\n\t\t\t\toptions,\n\t\t\t\t'meter',\n\t\t\t\t'proportional',\n\t\t\t\t'breakdownFormatter'\n\t\t\t);\n\t\t\tdata =\n\t\t\t\tbreakdownFormatter !== null\n\t\t\t\t\t? breakdownFormatter({\n\t\t\t\t\t\t\tdatasetsTotal: datasetsTotal,\n\t\t\t\t\t\t\ttotal: total,\n\t\t\t\t\t })\n\t\t\t\t\t: `${datasetsTotal} ${unit} used (${difference} ${unit} available)`;\n\t\t}\n\n\t\t// the breakdown part to whole of the datasets to the overall total\n\t\tconst title = svg\n\t\t\t.selectAll('text.proportional-meter-title')\n\t\t\t.data([data]);\n\n\t\ttitle\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('proportional-meter-title', true)\n\t\t\t.merge(title)\n\t\t\t.attr('x', 0)\n\t\t\t.attr('y', '1em')\n\t\t\t.text((d) => d);\n\n\t\ttitle.exit().remove();\n\n\t\tconst maxWidth = this.getMaxTitleWidth();\n\t\tconst titleElement = DOMUtils.appendOrSelect(\n\t\t\tsvg,\n\t\t\t'text.proportional-meter-title'\n\t\t);\n\n\t\tif (\n\t\t\tmaxWidth > 0 &&\n\t\t\ttitleElement.node().getComputedTextLength() > maxWidth\n\t\t) {\n\t\t\tthis.truncateTitle(titleElement, maxWidth);\n\t\t}\n\t}\n\n\t// show the total for prop meter\n\tdisplayTotal() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\t\tconst options = this.getOptions();\n\n\t\tconst total = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'total'\n\t\t);\n\n\t\tconst totalValue = total\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'total')\n\t\t\t: this.model.getMaximumDomain(this.model.getDisplayData());\n\n\t\tconst unit = Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t: '';\n\n\t\t// totalFormatter function\n\t\tconst totalFormatter = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'totalFormatter'\n\t\t);\n\n\t\tconst totalString =\n\t\t\ttotalFormatter !== null\n\t\t\t\t? totalFormatter(totalValue)\n\t\t\t\t: `${total} ${unit} total`;\n\n\t\tconst containerBounds = DOMUtils.getSVGElementSize(\n\t\t\tthis.services.domUtils.getMainContainer(),\n\t\t\t{ useAttr: true }\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\t// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: this.parent.node().getAttribute('width');\n\n\t\tconst title = svg\n\t\t\t.selectAll('text.proportional-meter-total')\n\t\t\t.data([totalString]);\n\n\t\ttitle\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('proportional-meter-total', true)\n\t\t\t.merge(title)\n\t\t\t.attr('x', containerWidth)\n\t\t\t.attr('y', '1em')\n\t\t\t.attr('text-anchor', 'end')\n\t\t\t.text((d) => d);\n\n\t\ttitle.exit().remove();\n\t}\n\n\t/**\n\t * Appends the corresponding status based on the value and the peak.\n\t */\n\tdisplayStatus() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\t// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: 0;\n\n\t\t// get the status from the model\n\t\tconst status = this.model.getStatus();\n\t\tconst radius = Configuration.meter.status.indicatorSize / 2;\n\n\t\t// create a group for the icon/inner path\n\t\tconst statusGroup = DOMUtils.appendOrSelect(svg, `g.status-indicator`)\n\t\t\t.attr(\n\t\t\t\t'class',\n\t\t\t\tstatus !== null ? `status-indicator status--${status}` : ''\n\t\t\t)\n\t\t\t.attr('transform', `translate(${containerWidth - radius}, 0)`);\n\n\t\tconst data = status ? [status] : [];\n\t\tconst icon = statusGroup.selectAll('circle.status').data(data);\n\n\t\ticon.enter()\n\t\t\t.append('circle')\n\t\t\t.merge(icon)\n\t\t\t.attr('class', 'status')\n\t\t\t.attr('r', radius)\n\t\t\t.attr('cx', 0)\n\t\t\t.attr('cy', `calc(1em / 2)`);\n\n\t\tconst innerIcon = statusGroup.selectAll('path.innerFill').data(data);\n\n\t\tinnerIcon\n\t\t\t.enter()\n\t\t\t.append('path')\n\t\t\t.merge(innerIcon)\n\t\t\t.attr('d', self.getStatusIconPathString(status))\n\t\t\t.attr('transform', `translate(-${radius}, 0)`)\n\t\t\t.attr('class', 'innerFill');\n\n\t\tinnerIcon.exit().remove();\n\t\ticon.exit().remove();\n\t}\n\n\t/**\n\t * Appends the associated percentage to the end of the title\n\t */\n\tappendPercentage() {\n\t\tconst dataValue = Tools.getProperty(\n\t\t\tthis.model.getDisplayData(),\n\t\t\t0,\n\t\t\t'value'\n\t\t);\n\n\t\t// use the title's position to append the percentage to the end\n\t\tconst svg = this.getComponentContainer();\n\t\tconst title = DOMUtils.appendOrSelect(svg, 'text.meter-title');\n\n\t\t// check if it is enabled\n\t\tconst data =\n\t\t\tTools.getProperty(\n\t\t\t\tthis.getOptions(),\n\t\t\t\t'meter',\n\t\t\t\t'statusBar',\n\t\t\t\t'percentageIndicator',\n\t\t\t\t'enabled'\n\t\t\t) === true\n\t\t\t\t? [dataValue]\n\t\t\t\t: [];\n\n\t\t// append a percentage if it is enabled, update it\n\t\tconst percentage = svg.selectAll('text.percent-value').data(data);\n\n\t\t// the horizontal offset of the percentage value from the title\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\n\t\tpercentage\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('percent-value', true)\n\t\t\t.merge(percentage)\n\t\t\t.text((d) => `${d}%`)\n\t\t\t.attr(\n\t\t\t\t'x',\n\t\t\t\t+title.attr('x') + title.node().getComputedTextLength() + offset\n\t\t\t) // set the position to after the title\n\t\t\t.attr('y', title.attr('y'));\n\n\t\tpercentage.exit().remove();\n\t}\n\n\t/**\n\t * Uses the parent class truncate logic\n\t * @param title d3 selection of title element that will be truncated\n\t * @param titlestring the original string that needs truncation\n\t * @param maxWidth the max width the title can take\n\t */\n\ttruncateTitle(title, maxWidth) {\n\t\tsuper.truncateTitle(title, maxWidth);\n\n\t\t// update the position on the percentage to be inline with the title\n\t\tconst tspan = DOMUtils.appendOrSelect(this.parent, 'tspan');\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\t\tconst tspanLength = Math.ceil(tspan.node().getComputedTextLength());\n\n\t\tconst percentage = DOMUtils.appendOrSelect(\n\t\t\tthis.parent,\n\t\t\t'text.percent-value'\n\t\t);\n\t\tpercentage.attr(\n\t\t\t'x',\n\t\t\t+title.attr('x') +\n\t\t\t\ttitle.node().getComputedTextLength() +\n\t\t\t\ttspanLength +\n\t\t\t\toffset\n\t\t);\n\t}\n\n\t// computes the maximum space a title can take\n\tprotected getMaxTitleWidth() {\n\t\t// get a reference to the title elements to calculate the size the title can be\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\tconst proportional = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'meter',\n\t\t\t'proportional'\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: this.parent.node().getAttribute('width');\n\n\t\tif (proportional !== null) {\n\t\t\tconst total = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'text.proportional-meter-total'\n\t\t\t).node();\n\n\t\t\tconst totalWidth = DOMUtils.getSVGElementSize(total, {\n\t\t\t\tuseBBox: true,\n\t\t\t}).width;\n\n\t\t\treturn (\n\t\t\t\tcontainerWidth -\n\t\t\t\ttotalWidth -\n\t\t\t\tConfiguration.meter.total.paddingLeft\n\t\t\t);\n\t\t} else {\n\t\t\tconst percentage = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'text.percent-value'\n\t\t\t);\n\t\t\t// the title needs to fit the width of the container without crowding the status, and percentage value\n\t\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\t\t\tconst percentageWidth = percentage.node().getComputedTextLength();\n\n\t\t\tconst statusGroup = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'g.status-indicator'\n\t\t\t).node();\n\t\t\tconst statusWidth =\n\t\t\t\tDOMUtils.getSVGElementSize(statusGroup, { useBBox: true })\n\t\t\t\t\t.width + Configuration.meter.status.paddingLeft;\n\n\t\t\treturn containerWidth - percentageWidth - offset - statusWidth;\n\t\t}\n\t}\n\n\t/**\n\t * Get the associated status icon for the data\n\t * @param status the active status for the meter chart\n\t */\n\tprotected getStatusIconPathString(status) {\n\t\tswitch (status) {\n\t\t\tcase Statuses.SUCCESS:\n\t\t\t\treturn 'M6.875 11.3125 3.75 8.1875 4.74375 7.25 6.875 9.34375 11.50625 4.75 12.5 5.7375 Z';\n\t\t\tcase Statuses.DANGER:\n\t\t\t\treturn 'M10.7 11.5 4.5 5.3 5.3 4.5 11.5 10.7 Z';\n\t\t\tcase Statuses.WARNING:\n\t\t\t\treturn 'M7.9375,11.125 C7.41973305,11.125 7,11.544733 7,12.0625 C7,12.580267 7.41973305,13 7.9375,13 C8.45526695,13 8.875,12.580267 8.875,12.0625 C8.875,11.544733 8.45526695,11.125 7.9375,11.125 M7.3125, 3 8.5625, 3 8.5625, 9.875 7.3125, 9.875, 7.3125, 3 Z';\n\t\t}\n\t}\n}\n"]}
|
|
@@ -15,6 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
import { Component } from '../component';
|
|
16
16
|
import { DOMUtils } from '../../services';
|
|
17
17
|
import { Events, RenderTypes } from './../../interfaces';
|
|
18
|
+
import { Tools } from '../../tools';
|
|
18
19
|
var Title = /** @class */ (function (_super) {
|
|
19
20
|
__extends(Title, _super);
|
|
20
21
|
function Title() {
|
|
@@ -25,7 +26,8 @@ var Title = /** @class */ (function (_super) {
|
|
|
25
26
|
}
|
|
26
27
|
Title.prototype.render = function () {
|
|
27
28
|
var svg = this.getComponentContainer();
|
|
28
|
-
var
|
|
29
|
+
var title = Tools.getProperty(this.getOptions(), 'title');
|
|
30
|
+
var text = svg.selectAll('p.title').data([title]);
|
|
29
31
|
text.enter()
|
|
30
32
|
.append('p')
|
|
31
33
|
.classed('title', true)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.js","sourceRoot":"","sources":["title.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"title.js","sourceRoot":"","sources":["title.ts"],"names":[],"mappings":";;;;;;;;;;;;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AAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE;YAC7C,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;SACxD;aAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE;YACpD,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE;gBACjD,OAAO,GAAG,CAAC;aACX;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;SACtD;aAAM;YACN,OAAO,GAAG,CAAC;SACX;IACF,CAAC;IACF,YAAC;AAAD,CAAC,AAhID,CAA2B,SAAS,GAgInC","sourcesContent":["// Internal Imports\nimport { Component } from '../component';\nimport { DOMUtils } from '../../services';\nimport { Events, RenderTypes } from './../../interfaces';\nimport { Tools } from '../../tools';\n\nexport class Title extends Component {\n\ttype = 'title';\n\trenderType = RenderTypes.HTML;\n\n\trender() {\n\t\tconst svg = this.getComponentContainer();\n\t\tconst title = Tools.getProperty(this.getOptions(), 'title');\n\n\t\tconst text = svg.selectAll('p.title').data([title]);\n\n\t\ttext.enter()\n\t\t\t.append('p')\n\t\t\t.classed('title', true)\n\t\t\t.merge(text)\n\t\t\t.attr('x', 0)\n\t\t\t.attr('y', '1em')\n\t\t\t.html((d) => d);\n\n\t\t// check if title needs truncation (and tooltip support)\n\t\tif (text.node() && text.node().offsetWidth < text.node().scrollWidth) {\n\t\t\t// add events for displaying the tooltip with the title\n\t\t\tconst self = this;\n\t\t\ttext.on('mouseover', function (event) {\n\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\t\tevent,\n\t\t\t\t\thoveredElement: text,\n\t\t\t\t\tcontent: text.text(),\n\t\t\t\t});\n\t\t\t})\n\t\t\t\t.on('mousemove', function (event) {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.MOVE, {\n\t\t\t\t\t\tevent,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.on('mouseout', function () {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.HIDE);\n\t\t\t\t});\n\t\t}\n\n\t\ttext.exit().remove();\n\t}\n\n\t/**\n\t * Truncates title creating ellipses and attaching tooltip for exposing full title.\n\t */\n\ttruncateTitle(title, maxWidth) {\n\t\t// sanity check to prevent stack overflow on binary search\n\t\tif (maxWidth <= 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst untruncatedTitle = title.text();\n\t\t// check if the title is too big for the containing svg\n\t\tif (title.node().getComputedTextLength() > maxWidth) {\n\t\t\t// append the ellipses to their own tspan to calculate the text length\n\t\t\ttitle.append('tspan').text('...');\n\n\t\t\t// get the bounding width including the elipses '...'\n\t\t\tconst tspanLength = DOMUtils.appendOrSelect(title, 'tspan')\n\t\t\t\t.node()\n\t\t\t\t.getComputedTextLength();\n\n\t\t\t// with elipses\n\t\t\tconst titleString = title.text();\n\n\t\t\t// get the index for creating the max length substring that fit within the svg\n\t\t\t// use one less than the index to avoid crowding (the elipsis)\n\t\t\tconst substringIndex = this.getSubstringIndex(\n\t\t\t\ttitle.node(),\n\t\t\t\t0,\n\t\t\t\ttitleString.length - 1,\n\t\t\t\tmaxWidth - tspanLength\n\t\t\t);\n\n\t\t\t// use the substring as the title\n\t\t\ttitle\n\t\t\t\t.html(titleString.substring(0, substringIndex - 1))\n\t\t\t\t.append('tspan')\n\t\t\t\t.text('...');\n\n\t\t\t// add events for displaying the tooltip with the title\n\t\t\tconst self = this;\n\t\t\ttitle\n\t\t\t\t.on('mouseover', function (event) {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\thoveredElement: title,\n\t\t\t\t\t\tcontent: untruncatedTitle,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.on('mousemove', function (event) {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.MOVE, {\n\t\t\t\t\t\tevent,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.on('mouseout', function () {\n\t\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.HIDE);\n\t\t\t\t});\n\t\t}\n\t}\n\n\t// computes the maximum space a title can take\n\tprotected getMaxTitleWidth() {\n\t\treturn DOMUtils.getSVGElementSize(this.parent.node(), {\n\t\t\tuseAttr: true,\n\t\t}).width;\n\t}\n\n\t/**\n\t * Returns the index for a maximum length substring that is less than the width parameter.\n\t * @param title the title node used for getting the text lengths of substrings\n\t * @param start the start index for the binary search\n\t * @param end the end index for the binary search\n\t * @param width the width of the svg container that holds the title\n\t */\n\tprotected getSubstringIndex(title, start, end, width) {\n\t\tconst mid = Math.floor((end + start) / 2);\n\t\tif (title.getSubStringLength(0, mid) > width) {\n\t\t\treturn this.getSubstringIndex(title, start, mid, width);\n\t\t} else if (title.getSubStringLength(0, mid) < width) {\n\t\t\tif (title.getSubStringLength(0, mid + 1) > width) {\n\t\t\t\treturn mid;\n\t\t\t}\n\t\t\treturn this.getSubstringIndex(title, mid, end, width);\n\t\t} else {\n\t\t\treturn mid;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -60,7 +60,7 @@ var StackedBar = /** @class */ (function (_super) {
|
|
|
60
60
|
// Create the data and keys that'll be used by the stack layout
|
|
61
61
|
var stackData = this.model.getStackedData({
|
|
62
62
|
groups: this.configs.groups,
|
|
63
|
-
divergent: true
|
|
63
|
+
divergent: true,
|
|
64
64
|
});
|
|
65
65
|
var activeDataGroupNames = this.model.getActiveDataGroupNames();
|
|
66
66
|
// Update data on all bar groups
|
|
@@ -1 +1 @@
|
|
|
1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AAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAEzC,uBAAuB;YACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE;gBAC3D,KAAK,OAAA;gBACL,OAAO,EAAE,cAAc;gBACvB,KAAK,OAAA;aACL,CAAC,CAAC;YAEH,eAAe;YACf,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;gBACvD,cAAc,gBAAA;aACd,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,4BAAO,GAAP;QACC,yBAAyB;QACzB,IAAI,CAAC,MAAM;aACT,SAAS,CAAC,UAAU,CAAC;aACrB,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;aACrB,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC;aACrB,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAEvB,0BAA0B;QAC1B,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,cAAc,CAAC,mBAAmB,CACjC,MAAM,CAAC,MAAM,CAAC,UAAU,EACxB,IAAI,CAAC,mBAAmB,CACxB,CAAC;QACF,cAAc,CAAC,mBAAmB,CACjC,MAAM,CAAC,MAAM,CAAC,aAAa,EAC3B,IAAI,CAAC,oBAAoB,CACzB,CAAC;IACH,CAAC;IACF,iBAAC;AAAD,CAAC,AAzSD,CAAgC,GAAG,GAySlC","sourcesContent":["// Internal Imports\nimport { Tools } from '../../tools';\nimport { Bar } from './bar';\nimport {\n\tRoles,\n\tEvents,\n\tCartesianOrientations,\n\tColorClassNameTypes,\n\tRenderTypes,\n} from '../../interfaces';\n\n// D3 Imports\nimport { select } from 'd3-selection';\n\nexport class StackedBar extends Bar {\n\ttype = 'stacked-bar';\n\trenderType = RenderTypes.SVG;\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.Legend.ITEM_HOVER,\n\t\t\tthis.handleLegendOnHover\n\t\t);\n\n\t\t// Un-highlight circles on legend item mouseouts\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Legend.ITEM_MOUSEOUT,\n\t\t\tthis.handleLegendMouseOut\n\t\t);\n\t}\n\n\trender(animate: boolean) {\n\t\t// Grab container SVG\n\t\tconst svg = this.getComponentContainer({ withinChartClip: true });\n\n\t\t// Chart options mixed with the internal configurations\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\t// Create the data and keys that'll be used by the stack layout\n\t\tconst stackData = this.model.getStackedData({\n\t\t\tgroups: this.configs.groups,\n\t\t\tdivergent: true\n\t\t});\n\n\t\tconst activeDataGroupNames = this.model.getActiveDataGroupNames();\n\n\t\t// Update data on all bar groups\n\t\tconst barGroups = svg\n\t\t\t.selectAll('g.bars')\n\t\t\t.data(stackData, (d) => Tools.getProperty(d, 0, groupMapsTo));\n\n\t\t// Remove elements that need to be exited\n\t\t// We need exit at the top here to make sure that\n\t\t// Data filters are processed before entering new elements\n\t\t// Or updating existing ones\n\t\tbarGroups.exit().attr('opacity', 0).remove();\n\n\t\t// Add bar groups that need to be introduced\n\t\tbarGroups\n\t\t\t.enter()\n\t\t\t.append('g')\n\t\t\t.classed('bars', true)\n\t\t\t.attr('role', Roles.GROUP)\n\t\t\t.attr('data-name', 'bars');\n\n\t\t// Update data on all bars\n\t\tconst bars = svg\n\t\t\t.selectAll('g.bars')\n\t\t\t.selectAll('path.bar')\n\t\t\t.data(\n\t\t\t\t(d) => d,\n\t\t\t\t(d) => d.data.sharedStackKey\n\t\t\t);\n\n\t\t// Remove bars that need to be removed\n\t\tbars.exit().remove();\n\n\t\tbars.enter()\n\t\t\t.append('path')\n\t\t\t.merge(bars)\n\t\t\t.classed('bar', true)\n\t\t\t.transition()\n\t\t\t.call((t) =>\n\t\t\t\tthis.services.transitions.setupTransition({\n\t\t\t\t\ttransition: t,\n\t\t\t\t\tname: 'bar-update-enter',\n\t\t\t\t\tanimate,\n\t\t\t\t})\n\t\t\t)\n\t\t\t.attr('class', (d) =>\n\t\t\t\tthis.model.getColorClassName({\n\t\t\t\t\tclassNameTypes: [ColorClassNameTypes.FILL],\n\t\t\t\t\tdataGroupName: d[groupMapsTo],\n\t\t\t\t\toriginalClassName: 'bar',\n\t\t\t\t})\n\t\t\t)\n\t\t\t.style('fill', (d) => this.model.getFillColor(d[groupMapsTo]))\n\t\t\t.attr('d', (d, i) => {\n\t\t\t\tconst key = d.data.sharedStackKey;\n\n\t\t\t\t/*\n\t\t\t\t * Orientation support for horizontal/vertical bar charts\n\t\t\t\t * Determine coordinates needed for a vertical set of paths\n\t\t\t\t * to draw the bars needed, and pass those coordinates down to\n\t\t\t\t * generateSVGPathString() to decide whether it needs to flip them\n\t\t\t\t */\n\t\t\t\tconst barWidth = this.getBarWidth();\n\t\t\t\tconst x0 =\n\t\t\t\t\tthis.services.cartesianScales.getDomainValue(key, i) -\n\t\t\t\t\tbarWidth / 2;\n\t\t\t\tconst x1 = x0 + barWidth;\n\t\t\t\tlet y0 = this.services.cartesianScales.getRangeValue(d[0], i);\n\t\t\t\tlet y1 = this.services.cartesianScales.getRangeValue(d[1], i);\n\n\t\t\t\t// don't show if part of bar is out of zoom domain\n\t\t\t\tif (this.isOutsideZoomedDomain(x0, x1)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Add the divider gap\n\t\t\t\tif (\n\t\t\t\t\tMath.abs(y1 - y0) > 0 &&\n\t\t\t\t\tMath.abs(y1 - y0) > options.bars.dividerSize\n\t\t\t\t) {\n\t\t\t\t\tconst barIsNegative = d[0] < 0 && d[1] <= 0;\n\t\t\t\t\tif (barIsNegative && activeDataGroupNames.length > 1) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.services.cartesianScales.getOrientation() ===\n\t\t\t\t\t\t\tCartesianOrientations.VERTICAL\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ty1 += d[1] === 0 ? 2 : 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ty1 -= d[1] === 0 ? 1 : 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!barIsNegative) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.services.cartesianScales.getOrientation() ===\n\t\t\t\t\t\t\tCartesianOrientations.VERTICAL\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ty1 += 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ty1 -= 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn Tools.generateSVGPathString(\n\t\t\t\t\t{ x0, x1, y0, y1 },\n\t\t\t\t\tthis.services.cartesianScales.getOrientation()\n\t\t\t\t);\n\t\t\t})\n\t\t\t.attr('opacity', 1)\n\t\t\t// a11y\n\t\t\t.attr('role', Roles.GRAPHICS_SYMBOL)\n\t\t\t.attr('aria-roledescription', 'bar')\n\t\t\t.attr('aria-label', (d) => d[1] - d[0]);\n\n\t\t// Add event listeners for the above elements\n\t\tthis.addEventListeners();\n\t}\n\n\t// Highlight elements that match the hovered legend item\n\thandleLegendOnHover = (event: CustomEvent) => {\n\t\tconst { hoveredElement } = event.detail;\n\n\t\tconst { groupMapsTo } = this.model.getOptions().data;\n\n\t\tthis.parent\n\t\t\t.selectAll('path.bar')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition('legend-hover-bar')\n\t\t\t)\n\t\t\t.attr('opacity', (d) =>\n\t\t\t\td[groupMapsTo] !== hoveredElement.datum()['name'] ? 0.3 : 1\n\t\t\t);\n\t};\n\n\t// Un-highlight all elements\n\thandleLegendMouseOut = (event: CustomEvent) => {\n\t\tthis.parent\n\t\t\t.selectAll('path.bar')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition('legend-mouseout-bar')\n\t\t\t)\n\t\t\t.attr('opacity', 1);\n\t};\n\n\taddEventListeners() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst self = this;\n\t\tthis.parent\n\t\t\t.selectAll('path.bar')\n\t\t\t.on('mouseover', function (event, datum) {\n\t\t\t\tconst hoveredElement = select(this);\n\t\t\t\thoveredElement.classed('hovered', true);\n\n\t\t\t\thoveredElement.transition(\n\t\t\t\t\tself.services.transitions.getTransition(\n\t\t\t\t\t\t'graph_element_mouseover_fill_update'\n\t\t\t\t\t)\n\t\t\t\t);\n\n\t\t\t\t// Dispatch mouse event\n\t\t\t\tself.services.events.dispatchEvent(Events.Bar.BAR_MOUSEOVER, {\n\t\t\t\t\tevent,\n\t\t\t\t\telement: hoveredElement,\n\t\t\t\t\tdatum,\n\t\t\t\t});\n\n\t\t\t\tconst displayData = self.model.getDisplayData(\n\t\t\t\t\tself.configs.groups\n\t\t\t\t);\n\n\t\t\t\tlet matchingDataPoint = displayData.find((d) => {\n\t\t\t\t\tconst domainIdentifier = self.services.cartesianScales.getDomainIdentifier(\n\t\t\t\t\t\td\n\t\t\t\t\t);\n\t\t\t\t\tconst rangeIdentifier = self.services.cartesianScales.getRangeIdentifier(\n\t\t\t\t\t\td\n\t\t\t\t\t);\n\t\t\t\t\treturn (\n\t\t\t\t\t\td[rangeIdentifier] === datum.data[datum.group] &&\n\t\t\t\t\t\td[domainIdentifier].toString() ===\n\t\t\t\t\t\t\tdatum.data.sharedStackKey &&\n\t\t\t\t\t\td[groupMapsTo] === datum.group\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tif (matchingDataPoint === undefined) {\n\t\t\t\t\t// use the primary range and domain ids\n\t\t\t\t\tconst domainIdentifier = self.services.cartesianScales.getDomainIdentifier();\n\t\t\t\t\tconst rangeIdentifier = self.services.cartesianScales.getRangeIdentifier();\n\t\t\t\t\tmatchingDataPoint = {\n\t\t\t\t\t\t[domainIdentifier]: datum.data.sharedStackKey,\n\t\t\t\t\t\t[rangeIdentifier]: datum.data[datum.group],\n\t\t\t\t\t\t[groupMapsTo]: datum.group,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Show tooltip\n\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\t\tevent,\n\t\t\t\t\thoveredElement,\n\t\t\t\t\tdata: [matchingDataPoint],\n\t\t\t\t});\n\t\t\t})\n\t\t\t.on('mousemove', function (event, datum) {\n\t\t\t\tconst hoveredElement = select(this);\n\n\t\t\t\t// Dispatch mouse event\n\t\t\t\tself.services.events.dispatchEvent(Events.Bar.BAR_MOUSEMOVE, {\n\t\t\t\t\tevent,\n\t\t\t\t\telement: hoveredElement,\n\t\t\t\t\tdatum,\n\t\t\t\t});\n\n\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.MOVE, {\n\t\t\t\t\tevent,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.on('click', function (event, datum) {\n\t\t\t\t// Dispatch mouse event\n\t\t\t\tself.services.events.dispatchEvent(Events.Bar.BAR_CLICK, {\n\t\t\t\t\tevent,\n\t\t\t\t\telement: select(this),\n\t\t\t\t\tdatum,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.on('mouseout', function (event, datum) {\n\t\t\t\tconst hoveredElement = select(this);\n\t\t\t\thoveredElement.classed('hovered', false);\n\n\t\t\t\t// Dispatch mouse event\n\t\t\t\tself.services.events.dispatchEvent(Events.Bar.BAR_MOUSEOUT, {\n\t\t\t\t\tevent,\n\t\t\t\t\telement: hoveredElement,\n\t\t\t\t\tdatum,\n\t\t\t\t});\n\n\t\t\t\t// Hide tooltip\n\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.HIDE, {\n\t\t\t\t\thoveredElement,\n\t\t\t\t});\n\t\t\t});\n\t}\n\n\tdestroy() {\n\t\t// Remove event listeners\n\t\tthis.parent\n\t\t\t.selectAll('path.bar')\n\t\t\t.on('mouseover', null)\n\t\t\t.on('mousemove', null)\n\t\t\t.on('mouseout', null);\n\n\t\t// Remove legend listeners\n\t\tconst eventsFragment = this.services.events;\n\t\teventsFragment.removeEventListener(\n\t\t\tEvents.Legend.ITEM_HOVER,\n\t\t\tthis.handleLegendOnHover\n\t\t);\n\t\teventsFragment.removeEventListener(\n\t\t\tEvents.Legend.ITEM_MOUSEOUT,\n\t\t\tthis.handleLegendMouseOut\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bar-stacked.js","sourceRoot":"","sources":["bar-stacked.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EACN,KAAK,EACL,MAAM,EACN,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,GACX,MAAM,kBAAkB,CAAC;AAE1B,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;IAAgC,8BAAG;IAAnC;QAAA,qEAySC;QAxSA,UAAI,GAAG,aAAa,CAAC;QACrB,gBAAU,GAAG,WAAW,CAAC,GAAG,CAAC;QAqJ7B,wDAAwD;QACxD,yBAAmB,GAAG,UAAC,KAAkB;YAChC,IAAA,4CAAc,CAAkB;YAEhC,IAAA,uDAAW,CAAkC;YAErD,KAAI,CAAC,MAAM;iBACT,SAAS,CAAC,UAAU,CAAC;iBACrB,UAAU,CACV,KAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAC3D;iBACA,IAAI,CAAC,SAAS,EAAE,UAAC,CAAC;gBAClB,OAAA,CAAC,CAAC,WAAW,CAAC,KAAK,cAAc,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAA3D,CAA2D,CAC3D,CAAC;QACJ,CAAC,CAAC;QAEF,4BAA4B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GAAG,GAySlC","sourcesContent":["// Internal Imports\nimport { Tools } from '../../tools';\nimport { Bar } from './bar';\nimport {\n\tRoles,\n\tEvents,\n\tCartesianOrientations,\n\tColorClassNameTypes,\n\tRenderTypes,\n} from '../../interfaces';\n\n// D3 Imports\nimport { select } from 'd3-selection';\n\nexport class StackedBar extends Bar {\n\ttype = 'stacked-bar';\n\trenderType = RenderTypes.SVG;\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.Legend.ITEM_HOVER,\n\t\t\tthis.handleLegendOnHover\n\t\t);\n\n\t\t// Un-highlight circles on legend item mouseouts\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Legend.ITEM_MOUSEOUT,\n\t\t\tthis.handleLegendMouseOut\n\t\t);\n\t}\n\n\trender(animate: boolean) {\n\t\t// Grab container SVG\n\t\tconst svg = this.getComponentContainer({ withinChartClip: true });\n\n\t\t// Chart options mixed with the internal configurations\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\t// Create the data and keys that'll be used by the stack layout\n\t\tconst stackData = this.model.getStackedData({\n\t\t\tgroups: this.configs.groups,\n\t\t\tdivergent: true,\n\t\t});\n\n\t\tconst activeDataGroupNames = this.model.getActiveDataGroupNames();\n\n\t\t// Update data on all bar groups\n\t\tconst barGroups = svg\n\t\t\t.selectAll('g.bars')\n\t\t\t.data(stackData, (d) => Tools.getProperty(d, 0, groupMapsTo));\n\n\t\t// Remove elements that need to be exited\n\t\t// We need exit at the top here to make sure that\n\t\t// Data filters are processed before entering new elements\n\t\t// Or updating existing ones\n\t\tbarGroups.exit().attr('opacity', 0).remove();\n\n\t\t// Add bar groups that need to be introduced\n\t\tbarGroups\n\t\t\t.enter()\n\t\t\t.append('g')\n\t\t\t.classed('bars', true)\n\t\t\t.attr('role', Roles.GROUP)\n\t\t\t.attr('data-name', 'bars');\n\n\t\t// Update data on all bars\n\t\tconst bars = svg\n\t\t\t.selectAll('g.bars')\n\t\t\t.selectAll('path.bar')\n\t\t\t.data(\n\t\t\t\t(d) => d,\n\t\t\t\t(d) => d.data.sharedStackKey\n\t\t\t);\n\n\t\t// Remove bars that need to be removed\n\t\tbars.exit().remove();\n\n\t\tbars.enter()\n\t\t\t.append('path')\n\t\t\t.merge(bars)\n\t\t\t.classed('bar', true)\n\t\t\t.transition()\n\t\t\t.call((t) =>\n\t\t\t\tthis.services.transitions.setupTransition({\n\t\t\t\t\ttransition: t,\n\t\t\t\t\tname: 'bar-update-enter',\n\t\t\t\t\tanimate,\n\t\t\t\t})\n\t\t\t)\n\t\t\t.attr('class', (d) =>\n\t\t\t\tthis.model.getColorClassName({\n\t\t\t\t\tclassNameTypes: [ColorClassNameTypes.FILL],\n\t\t\t\t\tdataGroupName: d[groupMapsTo],\n\t\t\t\t\toriginalClassName: 'bar',\n\t\t\t\t})\n\t\t\t)\n\t\t\t.style('fill', (d) => this.model.getFillColor(d[groupMapsTo]))\n\t\t\t.attr('d', (d, i) => {\n\t\t\t\tconst key = d.data.sharedStackKey;\n\n\t\t\t\t/*\n\t\t\t\t * Orientation support for horizontal/vertical bar charts\n\t\t\t\t * Determine coordinates needed for a vertical set of paths\n\t\t\t\t * to draw the bars needed, and pass those coordinates down to\n\t\t\t\t * generateSVGPathString() to decide whether it needs to flip them\n\t\t\t\t */\n\t\t\t\tconst barWidth = this.getBarWidth();\n\t\t\t\tconst x0 =\n\t\t\t\t\tthis.services.cartesianScales.getDomainValue(key, i) -\n\t\t\t\t\tbarWidth / 2;\n\t\t\t\tconst x1 = x0 + barWidth;\n\t\t\t\tlet y0 = this.services.cartesianScales.getRangeValue(d[0], i);\n\t\t\t\tlet y1 = this.services.cartesianScales.getRangeValue(d[1], i);\n\n\t\t\t\t// don't show if part of bar is out of zoom domain\n\t\t\t\tif (this.isOutsideZoomedDomain(x0, x1)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Add the divider gap\n\t\t\t\tif (\n\t\t\t\t\tMath.abs(y1 - y0) > 0 &&\n\t\t\t\t\tMath.abs(y1 - y0) > options.bars.dividerSize\n\t\t\t\t) {\n\t\t\t\t\tconst barIsNegative = d[0] < 0 && d[1] <= 0;\n\t\t\t\t\tif (barIsNegative && activeDataGroupNames.length > 1) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.services.cartesianScales.getOrientation() ===\n\t\t\t\t\t\t\tCartesianOrientations.VERTICAL\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ty1 += d[1] === 0 ? 2 : 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ty1 -= d[1] === 0 ? 1 : 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!barIsNegative) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.services.cartesianScales.getOrientation() ===\n\t\t\t\t\t\t\tCartesianOrientations.VERTICAL\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\ty1 += 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ty1 -= 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn Tools.generateSVGPathString(\n\t\t\t\t\t{ x0, x1, y0, y1 },\n\t\t\t\t\tthis.services.cartesianScales.getOrientation()\n\t\t\t\t);\n\t\t\t})\n\t\t\t.attr('opacity', 1)\n\t\t\t// a11y\n\t\t\t.attr('role', Roles.GRAPHICS_SYMBOL)\n\t\t\t.attr('aria-roledescription', 'bar')\n\t\t\t.attr('aria-label', (d) => d[1] - d[0]);\n\n\t\t// Add event listeners for the above elements\n\t\tthis.addEventListeners();\n\t}\n\n\t// Highlight elements that match the hovered legend item\n\thandleLegendOnHover = (event: CustomEvent) => {\n\t\tconst { hoveredElement } = event.detail;\n\n\t\tconst { groupMapsTo } = this.model.getOptions().data;\n\n\t\tthis.parent\n\t\t\t.selectAll('path.bar')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition('legend-hover-bar')\n\t\t\t)\n\t\t\t.attr('opacity', (d) =>\n\t\t\t\td[groupMapsTo] !== hoveredElement.datum()['name'] ? 0.3 : 1\n\t\t\t);\n\t};\n\n\t// Un-highlight all elements\n\thandleLegendMouseOut = (event: CustomEvent) => {\n\t\tthis.parent\n\t\t\t.selectAll('path.bar')\n\t\t\t.transition(\n\t\t\t\tthis.services.transitions.getTransition('legend-mouseout-bar')\n\t\t\t)\n\t\t\t.attr('opacity', 1);\n\t};\n\n\taddEventListeners() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst self = this;\n\t\tthis.parent\n\t\t\t.selectAll('path.bar')\n\t\t\t.on('mouseover', function (event, datum) {\n\t\t\t\tconst hoveredElement = select(this);\n\t\t\t\thoveredElement.classed('hovered', true);\n\n\t\t\t\thoveredElement.transition(\n\t\t\t\t\tself.services.transitions.getTransition(\n\t\t\t\t\t\t'graph_element_mouseover_fill_update'\n\t\t\t\t\t)\n\t\t\t\t);\n\n\t\t\t\t// Dispatch mouse event\n\t\t\t\tself.services.events.dispatchEvent(Events.Bar.BAR_MOUSEOVER, {\n\t\t\t\t\tevent,\n\t\t\t\t\telement: hoveredElement,\n\t\t\t\t\tdatum,\n\t\t\t\t});\n\n\t\t\t\tconst displayData = self.model.getDisplayData(\n\t\t\t\t\tself.configs.groups\n\t\t\t\t);\n\n\t\t\t\tlet matchingDataPoint = displayData.find((d) => {\n\t\t\t\t\tconst domainIdentifier = self.services.cartesianScales.getDomainIdentifier(\n\t\t\t\t\t\td\n\t\t\t\t\t);\n\t\t\t\t\tconst rangeIdentifier = self.services.cartesianScales.getRangeIdentifier(\n\t\t\t\t\t\td\n\t\t\t\t\t);\n\t\t\t\t\treturn (\n\t\t\t\t\t\td[rangeIdentifier] === datum.data[datum.group] &&\n\t\t\t\t\t\td[domainIdentifier].toString() ===\n\t\t\t\t\t\t\tdatum.data.sharedStackKey &&\n\t\t\t\t\t\td[groupMapsTo] === datum.group\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tif (matchingDataPoint === undefined) {\n\t\t\t\t\t// use the primary range and domain ids\n\t\t\t\t\tconst domainIdentifier = self.services.cartesianScales.getDomainIdentifier();\n\t\t\t\t\tconst rangeIdentifier = self.services.cartesianScales.getRangeIdentifier();\n\t\t\t\t\tmatchingDataPoint = {\n\t\t\t\t\t\t[domainIdentifier]: datum.data.sharedStackKey,\n\t\t\t\t\t\t[rangeIdentifier]: datum.data[datum.group],\n\t\t\t\t\t\t[groupMapsTo]: datum.group,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Show tooltip\n\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\t\tevent,\n\t\t\t\t\thoveredElement,\n\t\t\t\t\tdata: [matchingDataPoint],\n\t\t\t\t});\n\t\t\t})\n\t\t\t.on('mousemove', function (event, datum) {\n\t\t\t\tconst hoveredElement = select(this);\n\n\t\t\t\t// Dispatch mouse event\n\t\t\t\tself.services.events.dispatchEvent(Events.Bar.BAR_MOUSEMOVE, {\n\t\t\t\t\tevent,\n\t\t\t\t\telement: hoveredElement,\n\t\t\t\t\tdatum,\n\t\t\t\t});\n\n\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.MOVE, {\n\t\t\t\t\tevent,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.on('click', function (event, datum) {\n\t\t\t\t// Dispatch mouse event\n\t\t\t\tself.services.events.dispatchEvent(Events.Bar.BAR_CLICK, {\n\t\t\t\t\tevent,\n\t\t\t\t\telement: select(this),\n\t\t\t\t\tdatum,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.on('mouseout', function (event, datum) {\n\t\t\t\tconst hoveredElement = select(this);\n\t\t\t\thoveredElement.classed('hovered', false);\n\n\t\t\t\t// Dispatch mouse event\n\t\t\t\tself.services.events.dispatchEvent(Events.Bar.BAR_MOUSEOUT, {\n\t\t\t\t\tevent,\n\t\t\t\t\telement: hoveredElement,\n\t\t\t\t\tdatum,\n\t\t\t\t});\n\n\t\t\t\t// Hide tooltip\n\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.HIDE, {\n\t\t\t\t\thoveredElement,\n\t\t\t\t});\n\t\t\t});\n\t}\n\n\tdestroy() {\n\t\t// Remove event listeners\n\t\tthis.parent\n\t\t\t.selectAll('path.bar')\n\t\t\t.on('mouseover', null)\n\t\t\t.on('mousemove', null)\n\t\t\t.on('mouseout', null);\n\n\t\t// Remove legend listeners\n\t\tconst eventsFragment = this.services.events;\n\t\teventsFragment.removeEventListener(\n\t\t\tEvents.Legend.ITEM_HOVER,\n\t\t\tthis.handleLegendOnHover\n\t\t);\n\t\teventsFragment.removeEventListener(\n\t\t\tEvents.Legend.ITEM_MOUSEOUT,\n\t\t\tthis.handleLegendMouseOut\n\t\t);\n\t}\n}\n"]}
|
|
@@ -81,7 +81,7 @@ var Donut = /** @class */ (function (_super) {
|
|
|
81
81
|
donutCenterFigure = this.model
|
|
82
82
|
.getDisplayData()
|
|
83
83
|
.reduce(function (accumulator, d) {
|
|
84
|
-
return accumulator + d.
|
|
84
|
+
return accumulator + d[options.pie.valueMapsTo];
|
|
85
85
|
}, 0);
|
|
86
86
|
}
|
|
87
87
|
// Remove commas from the current value string, and convert to an int
|