@carbon/charts 1.7.5 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/build/demo/data/CHART_TYPES.d.ts +5 -0
  3. package/build/demo/data/choropleth.d.ts +738 -0
  4. package/build/demo/data/index.d.ts +1 -0
  5. package/build/demo/data/topojson-110.d.ts +360 -0
  6. package/build/src/charts/choropleth.d.ts +10 -0
  7. package/build/src/charts/index.d.ts +1 -0
  8. package/build/src/components/essentials/color-scale-legend.d.ts +3 -0
  9. package/build/src/components/essentials/geo-projection.d.ts +16 -0
  10. package/build/src/components/graphs/choropleth.d.ts +6 -0
  11. package/build/src/components/index.d.ts +2 -0
  12. package/build/src/configuration.d.ts +3 -1
  13. package/build/src/interfaces/charts.d.ts +28 -1
  14. package/build/src/interfaces/enums.d.ts +12 -0
  15. package/build/src/interfaces/events.d.ts +9 -0
  16. package/build/src/model/choropleth.d.ts +29 -0
  17. package/build/src/model/heatmap.d.ts +0 -5
  18. package/build/src/services/color-scale-utils.d.ts +10 -0
  19. package/build/src/services/index.d.ts +1 -0
  20. package/build/src/services/scales-cartesian.d.ts +1 -1
  21. package/bundle.js +2 -2
  22. package/charts/choropleth.d.ts +10 -0
  23. package/charts/choropleth.js +141 -0
  24. package/charts/choropleth.js.map +1 -0
  25. package/charts/heatmap.js +5 -1
  26. package/charts/heatmap.js.map +1 -1
  27. package/charts/index.d.ts +1 -0
  28. package/charts/index.js +1 -0
  29. package/charts/index.js.map +1 -1
  30. package/components/axes/chart-clip.js +7 -5
  31. package/components/axes/chart-clip.js.map +1 -1
  32. package/components/axes/grid-brush.js +12 -9
  33. package/components/axes/grid-brush.js.map +1 -1
  34. package/components/essentials/color-scale-legend.d.ts +3 -0
  35. package/components/essentials/color-scale-legend.js +18 -11
  36. package/components/essentials/color-scale-legend.js.map +1 -1
  37. package/components/essentials/geo-projection.d.ts +16 -0
  38. package/components/essentials/geo-projection.js +160 -0
  39. package/components/essentials/geo-projection.js.map +1 -0
  40. package/components/essentials/title-meter.js +1 -1
  41. package/components/essentials/title-meter.js.map +1 -1
  42. package/components/graphs/choropleth.d.ts +6 -0
  43. package/components/graphs/choropleth.js +106 -0
  44. package/components/graphs/choropleth.js.map +1 -0
  45. package/components/graphs/radar.js +1 -1
  46. package/components/graphs/radar.js.map +1 -1
  47. package/components/index.d.ts +2 -0
  48. package/components/index.js +2 -0
  49. package/components/index.js.map +1 -1
  50. package/configuration.d.ts +3 -1
  51. package/configuration.js +18 -1
  52. package/configuration.js.map +1 -1
  53. package/demo/create-codesandbox.js +20 -2
  54. package/demo/create-codesandbox.js.map +1 -1
  55. package/demo/data/CHART_TYPES.d.ts +5 -0
  56. package/demo/data/CHART_TYPES.js +5 -0
  57. package/demo/data/CHART_TYPES.js.map +1 -1
  58. package/demo/data/bundle.js +1 -1
  59. package/demo/data/choropleth.d.ts +738 -0
  60. package/demo/data/choropleth.js +1684 -0
  61. package/demo/data/choropleth.js.map +1 -0
  62. package/demo/data/index.d.ts +1 -0
  63. package/demo/data/index.js +45 -5
  64. package/demo/data/index.js.map +1 -1
  65. package/demo/data/topojson-110.d.ts +360 -0
  66. package/demo/data/topojson-110.js +40724 -0
  67. package/demo/data/topojson-110.js.map +1 -0
  68. package/demo/styles.css +410 -185
  69. package/demo/styles.css.map +1 -1
  70. package/demo/styles.min.css +1 -1
  71. package/demo/styles.min.css.map +1 -1
  72. package/demo/tsconfig.tsbuildinfo +25 -6
  73. package/demo/utils.js +29 -1
  74. package/demo/utils.js.map +1 -1
  75. package/interfaces/charts.d.ts +28 -1
  76. package/interfaces/charts.js.map +1 -1
  77. package/interfaces/enums.d.ts +12 -0
  78. package/interfaces/enums.js +16 -0
  79. package/interfaces/enums.js.map +1 -1
  80. package/interfaces/events.d.ts +9 -0
  81. package/interfaces/events.js +10 -0
  82. package/interfaces/events.js.map +1 -1
  83. package/model/choropleth.d.ts +29 -0
  84. package/model/choropleth.js +105 -0
  85. package/model/choropleth.js.map +1 -0
  86. package/model/heatmap.d.ts +0 -5
  87. package/model/heatmap.js +3 -64
  88. package/model/heatmap.js.map +1 -1
  89. package/package.json +4 -3
  90. package/services/color-scale-utils.d.ts +2 -0
  91. package/services/color-scale-utils.js +64 -0
  92. package/services/color-scale-utils.js.map +1 -0
  93. package/services/index.d.ts +1 -0
  94. package/services/index.js +1 -0
  95. package/services/index.js.map +1 -1
  96. package/styles/color-palatte.scss +96 -0
  97. package/styles/colors.scss +23 -8
  98. package/styles/graphs/_choropleth.scss +18 -0
  99. package/styles/graphs/index.scss +1 -0
  100. package/styles.css +156 -144
  101. package/styles.css.map +1 -1
  102. package/styles.min.css +1 -1
  103. package/styles.min.css.map +1 -1
  104. package/tsconfig.tsbuildinfo +419 -47
@@ -0,0 +1,160 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ // Internal Imports
15
+ import { Component } from '../component';
16
+ import { DOMUtils } from '../../services';
17
+ import * as Tools from '../../tools';
18
+ import { RenderTypes, Projection } from '../../interfaces';
19
+ // D3 imports
20
+ import { geoPath, line } from 'd3';
21
+ import { feature, merge } from 'topojson-client';
22
+ import {
23
+ // Azimuthal Projections - project the sphere directly on to the plane
24
+ geoEqualEarth,
25
+ // Conic projections - project the sphere onto a cone & unroll into the plane
26
+ geoAlbers, geoConicEqualArea, geoConicEquidistant,
27
+ // Cylindrical projections - project the sphere onto a containing cylinder & unroll onto the plane
28
+ geoEquirectangular, geoMercator, geoNaturalEarth1, } from 'd3-geo';
29
+ var GeoProjection = /** @class */ (function (_super) {
30
+ __extends(GeoProjection, _super);
31
+ function GeoProjection() {
32
+ var _this = _super !== null && _super.apply(this, arguments) || this;
33
+ _this.type = 'geo';
34
+ _this.renderType = RenderTypes.SVG;
35
+ return _this;
36
+ }
37
+ GeoProjection.prototype.render = function () {
38
+ var svg = this.getComponentContainer({ withinChartClip: true });
39
+ var _a = DOMUtils.getSVGElementSize(svg, {
40
+ useAttrs: true,
41
+ }), width = _a.width, height = _a.height;
42
+ // Because of a Firefox bug with regards to sizing & d3 packs,
43
+ // rather than checking if height or width aren't 0,
44
+ // we have to make sure they're not smaller than 1
45
+ if (width < 1 || height < 1) {
46
+ return;
47
+ }
48
+ // Get users projection
49
+ var projection = this.getProjection();
50
+ var geoData = Tools.getProperty(this.getOptions(), 'geoData');
51
+ var data = this.model.getCombinedData();
52
+ // Seperate countries that have data & countries with missing data
53
+ var withData = {};
54
+ var withoutData = {};
55
+ Object.keys(data).forEach(function (element) {
56
+ if (typeof data[element].value === 'number') {
57
+ withData[element] = data[element];
58
+ }
59
+ else {
60
+ withoutData[element] = data[element];
61
+ }
62
+ });
63
+ // Merge all without data
64
+ var withoutDataMerge = merge(geoData, Object.values(withoutData));
65
+ /**
66
+ * @todo - Currently only topojson is supported
67
+ *
68
+ * Unlike geojson, topojson does not have a standard format
69
+ * So data must be nested in the following format:
70
+ * options : {
71
+ * geoData: {
72
+ * objects: {
73
+ * ...
74
+ * }
75
+ * }
76
+ * }
77
+ */
78
+ // Convert from topojson to geojson
79
+ var json = feature(geoData, {
80
+ // We need to specify that we are converting geometry collections
81
+ type: 'GeometryCollection',
82
+ geometries: Object.values(withData),
83
+ });
84
+ // Depending on the projection selected, we will need to scale/translate accordingly
85
+ var projectionScale = projection.fitSize([width, height], json);
86
+ var geo = geoPath().projection(projectionScale);
87
+ var borders = DOMUtils.appendOrSelect(svg, 'g.geo');
88
+ borders
89
+ .selectAll('path')
90
+ .data(json.features)
91
+ .join('path')
92
+ .attr('d', geo);
93
+ var patternID = this.services.domUtils.generateElementIDString("geo-pattern-stripes");
94
+ // Create a striped pattern for missing data
95
+ var defs = DOMUtils.appendOrSelect(svg, 'defs');
96
+ DOMUtils.appendOrSelect(defs, 'pattern')
97
+ .attr('id', patternID)
98
+ .attr('width', 5)
99
+ .attr('height', 10)
100
+ .attr('patternUnits', 'userSpaceOnUse')
101
+ .attr('patternTransform', 'rotate(45)')
102
+ .append('path')
103
+ .classed('pattern-fill', true)
104
+ .attr('d', line()([
105
+ [0, 0],
106
+ [0, 10],
107
+ ]));
108
+ var missingBorders = DOMUtils.appendOrSelect(svg, 'g.missing-data');
109
+ DOMUtils.appendOrSelect(missingBorders, 'path')
110
+ .datum(withoutDataMerge)
111
+ .attr('d', geo)
112
+ .style('fill', "url(#" + patternID + ")");
113
+ };
114
+ /**
115
+ * @info
116
+ * Depending on projection, we may need to provide additional configuration
117
+ * e.g. sizing
118
+ *
119
+ * In such case, function can be refactored so that
120
+ * projection should return an object with the configuraiton & function
121
+ */
122
+ GeoProjection.prototype.getProjection = function () {
123
+ var projection = null;
124
+ var projectionSelected = Tools.getProperty(this.getOptions(), 'thematic', 'projection');
125
+ switch (projectionSelected) {
126
+ // Azimuthal Projections
127
+ case Projection.geoEqualEarth:
128
+ projection = geoEqualEarth();
129
+ break;
130
+ // Conic Projections
131
+ case Projection.geoAlbers:
132
+ projection = geoAlbers();
133
+ break;
134
+ case Projection.geoConicEqualArea:
135
+ projection = geoConicEqualArea();
136
+ break;
137
+ case Projection.geoConicEquidistant:
138
+ projection = geoConicEquidistant();
139
+ break;
140
+ // Cyndrical projections
141
+ case Projection.geoEquirectangular:
142
+ projection = geoEquirectangular();
143
+ break;
144
+ case Projection.geoMercator:
145
+ projection = geoMercator();
146
+ break;
147
+ case Projection.geoNaturalEarth1:
148
+ projection = geoNaturalEarth1();
149
+ break;
150
+ default:
151
+ // Projection is missing or an unsupported projection value is passed
152
+ throw new Error('Projection is not supported.');
153
+ break;
154
+ }
155
+ return projection;
156
+ };
157
+ return GeoProjection;
158
+ }(Component));
159
+ export { GeoProjection };
160
+ //# sourceMappingURL=../../../src/components/essentials/geo-projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo-projection.js","sourceRoot":"","sources":["geo-projection.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3D,aAAa;AACb,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO;AACN,sEAAsE;AACtE,aAAa;AACb,6EAA6E;AAC7E,SAAS,EACT,iBAAiB,EACjB,mBAAmB;AACnB,kGAAkG;AAClG,kBAAkB,EAClB,WAAW,EACX,gBAAgB,GAChB,MAAM,QAAQ,CAAC;AAEhB;IAAmC,iCAAS;IAA5C;QAAA,qEAmJC;QAlJA,UAAI,GAAG,KAAK,CAAC;QACb,gBAAU,GAAG,WAAW,CAAC,GAAG,CAAC;;IAiJ9B,CAAC;IA/IA,8BAAM,GAAN;QACC,IAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,IAAA;;UAEJ,EAFM,gBAAK,EAAE,kBAEb,CAAC;QAEH,8DAA8D;QAC9D,oDAAoD;QACpD,kDAAkD;QAClD,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE;YAC5B,OAAO;SACP;QAED,uBAAuB;QACvB,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAA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,CACZ,CAAC;QAEF,QAAQ,kBAAkB,EAAE;YAC3B,wBAAwB;YACxB,KAAK,UAAU,CAAC,aAAa;gBAC5B,UAAU,GAAG,aAAa,EAAE,CAAC;gBAC7B,MAAM;YACP,oBAAoB;YACpB,KAAK,UAAU,CAAC,SAAS;gBACxB,UAAU,GAAG,SAAS,EAAE,CAAC;gBACzB,MAAM;YACP,KAAK,UAAU,CAAC,iBAAiB;gBAChC,UAAU,GAAG,iBAAiB,EAAE,CAAC;gBACjC,MAAM;YACP,KAAK,UAAU,CAAC,mBAAmB;gBAClC,UAAU,GAAG,mBAAmB,EAAE,CAAC;gBACnC,MAAM;YACP,wBAAwB;YACxB,KAAK,UAAU,CAAC,kBAAkB;gBACjC,UAAU,GAAG,kBAAkB,EAAE,CAAC;gBAClC,MAAM;YACP,KAAK,UAAU,CAAC,WAAW;gBAC1B,UAAU,GAAG,WAAW,EAAE,CAAC;gBAC3B,MAAM;YACP,KAAK,UAAU,CAAC,gBAAgB;gBAC/B,UAAU,GAAG,gBAAgB,EAAE,CAAC;gBAChC,MAAM;YACP;gBACC,qEAAqE;gBACrE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;gBAChD,MAAM;SACP;QAED,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,oBAAC;AAAD,CAAC,AAnJD,CAAmC,SAAS,GAmJ3C","sourcesContent":["// Internal Imports\nimport { Component } from '../component';\nimport { DOMUtils } from '../../services';\nimport * as Tools from '../../tools';\nimport { RenderTypes, Projection } from '../../interfaces';\n\n// D3 imports\nimport { geoPath, line } from 'd3';\nimport { feature, merge } from 'topojson-client';\nimport {\n\t// Azimuthal Projections - project the sphere directly on to the plane\n\tgeoEqualEarth,\n\t// Conic projections - project the sphere onto a cone & unroll into the plane\n\tgeoAlbers,\n\tgeoConicEqualArea,\n\tgeoConicEquidistant,\n\t// Cylindrical projections - project the sphere onto a containing cylinder & unroll onto the plane\n\tgeoEquirectangular,\n\tgeoMercator,\n\tgeoNaturalEarth1,\n} from 'd3-geo';\n\nexport class GeoProjection extends Component {\n\ttype = 'geo';\n\trenderType = RenderTypes.SVG;\n\n\trender() {\n\t\tconst svg = this.getComponentContainer({ withinChartClip: true });\n\t\tconst { width, height } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\t// Because of a Firefox bug with regards to sizing & d3 packs,\n\t\t// rather than checking if height or width aren't 0,\n\t\t// we have to make sure they're not smaller than 1\n\t\tif (width < 1 || height < 1) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get users projection\n\t\tconst projection = this.getProjection();\n\n\t\tconst geoData = Tools.getProperty(this.getOptions(), 'geoData');\n\n\t\tconst data = this.model.getCombinedData();\n\n\t\t// Seperate countries that have data & countries with missing data\n\t\tconst withData = {};\n\t\tconst withoutData = {};\n\t\tObject.keys(data).forEach((element) => {\n\t\t\tif (typeof data[element].value === 'number') {\n\t\t\t\twithData[element] = data[element];\n\t\t\t} else {\n\t\t\t\twithoutData[element] = data[element];\n\t\t\t}\n\t\t});\n\n\t\t// Merge all without data\n\t\tconst withoutDataMerge = merge(geoData, Object.values(withoutData));\n\n\t\t/**\n\t\t * @todo - Currently only topojson is supported\n\t\t *\n\t\t * Unlike geojson, topojson does not have a standard format\n\t\t * So data must be nested in the following format:\n\t\t * options : {\n\t\t * \tgeoData: {\n\t\t * \tobjects: {\n\t\t * \t\t\t...\n\t\t * \t\t}\n\t\t * }\n\t\t * }\n\t\t */\n\t\t// Convert from topojson to geojson\n\t\tconst json = feature(geoData, {\n\t\t\t// We need to specify that we are converting geometry collections\n\t\t\ttype: 'GeometryCollection',\n\t\t\tgeometries: Object.values(withData),\n\t\t});\n\n\t\t// Depending on the projection selected, we will need to scale/translate accordingly\n\t\tconst projectionScale = projection.fitSize([width, height], json);\n\t\tconst geo = geoPath().projection(projectionScale);\n\n\t\tconst borders = DOMUtils.appendOrSelect(svg, 'g.geo');\n\t\tborders\n\t\t\t.selectAll('path')\n\t\t\t.data(json.features)\n\t\t\t.join('path')\n\t\t\t.attr('d', geo);\n\n\t\tconst patternID = this.services.domUtils.generateElementIDString(\n\t\t\t`geo-pattern-stripes`\n\t\t);\n\n\t\t// Create a striped pattern for missing data\n\t\tconst defs = DOMUtils.appendOrSelect(svg, 'defs');\n\t\tDOMUtils.appendOrSelect(defs, 'pattern')\n\t\t\t.attr('id', patternID)\n\t\t\t.attr('width', 5)\n\t\t\t.attr('height', 10)\n\t\t\t.attr('patternUnits', 'userSpaceOnUse')\n\t\t\t.attr('patternTransform', 'rotate(45)')\n\t\t\t.append('path')\n\t\t\t.classed('pattern-fill', true)\n\t\t\t.attr(\n\t\t\t\t'd',\n\t\t\t\tline()([\n\t\t\t\t\t[0, 0],\n\t\t\t\t\t[0, 10],\n\t\t\t\t])\n\t\t\t);\n\n\t\tconst missingBorders = DOMUtils.appendOrSelect(svg, 'g.missing-data');\n\t\tDOMUtils.appendOrSelect(missingBorders, 'path')\n\t\t\t.datum(withoutDataMerge)\n\t\t\t.attr('d', geo)\n\t\t\t.style('fill', `url(#${patternID})`);\n\t}\n\n\t/**\n\t * @info\n\t * Depending on projection, we may need to provide additional configuration\n\t * e.g. sizing\n\t *\n\t * In such case, function can be refactored so that\n\t * projection should return an object with the configuraiton & function\n\t */\n\tgetProjection() {\n\t\tlet projection = null;\n\t\tconst projectionSelected = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'thematic',\n\t\t\t'projection'\n\t\t);\n\n\t\tswitch (projectionSelected) {\n\t\t\t// Azimuthal Projections\n\t\t\tcase Projection.geoEqualEarth:\n\t\t\t\tprojection = geoEqualEarth();\n\t\t\t\tbreak;\n\t\t\t// Conic Projections\n\t\t\tcase Projection.geoAlbers:\n\t\t\t\tprojection = geoAlbers();\n\t\t\t\tbreak;\n\t\t\tcase Projection.geoConicEqualArea:\n\t\t\t\tprojection = geoConicEqualArea();\n\t\t\t\tbreak;\n\t\t\tcase Projection.geoConicEquidistant:\n\t\t\t\tprojection = geoConicEquidistant();\n\t\t\t\tbreak;\n\t\t\t// Cyndrical projections\n\t\t\tcase Projection.geoEquirectangular:\n\t\t\t\tprojection = geoEquirectangular();\n\t\t\t\tbreak;\n\t\t\tcase Projection.geoMercator:\n\t\t\t\tprojection = geoMercator();\n\t\t\t\tbreak;\n\t\t\tcase Projection.geoNaturalEarth1:\n\t\t\t\tprojection = geoNaturalEarth1();\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// Projection is missing or an unsupported projection value is passed\n\t\t\t\tthrow new Error('Projection is not supported.');\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn projection;\n\t}\n}\n"]}
@@ -139,7 +139,7 @@ var MeterTitle = /** @class */ (function (_super) {
139
139
  .classed('proportional-meter-total', true)
140
140
  .merge(title)
141
141
  // Position the total text -24 pixels to add spacing between text and status icon (if status exists)
142
- .attr('x', this.model.getStatus()
142
+ .attr('x', this.model.getStatus() && typeof containerWidth !== 'string'
143
143
  ? containerWidth - Configuration.meter.total.paddingRight
144
144
  : containerWidth)
145
145
  .attr('y', '1em')
@@ -1 +1 @@
1
- {"version":3,"file":"title-meter.js","sourceRoot":"","sources":["title-meter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AAErD;IAAgC,8BAAK;IAArC;QAAA,qEAmYC;QAlYA,UAAI,GAAG,aAAa,CAAC;QACrB,gBAAU,GAAG,WAAW,CAAC,GAAG,CAAC;;IAiY9B,CAAC;IA/XA,2BAAM,GAAN;QACC,IAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,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,IAAM,eAAe,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,qBAAqB,EAAE,CAAC;YAElE,IAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAC1C,IAAI,CAAC,MAAM,EACX,oBAAoB,CACpB,CAAC,IAAI,EAAE,CAAC;YACT,IAAM,WAAW,GAChB,QAAQ,CAAC,iBAAiB,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iBACxD,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;YAElD,OAAO,cAAc,GAAG,eAAe,GAAG,MAAM,GAAG,WAAW,CAAC;SAC/D;IACF,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,AAnYD,CAAgC,KAAK,GAmYpC","sourcesContent":["// Internal Imports\nimport { Title } from './title';\nimport { DOMUtils } from '../../services';\nimport * as 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\t\t}\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\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.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\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// Position the total text -24 pixels to add spacing between text and status icon (if status exists)\n\t\t\t.attr(\n\t\t\t\t'x',\n\t\t\t\tthis.model.getStatus()\n\t\t\t\t\t? containerWidth - Configuration.meter.total.paddingRight\n\t\t\t\t\t: containerWidth\n\t\t\t)\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"]}
1
+ {"version":3,"file":"title-meter.js","sourceRoot":"","sources":["title-meter.ts"],"names":[],"mappings":";;;;;;;;;;;;;A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,CAAgC,KAAK,GAmYpC","sourcesContent":["// Internal Imports\nimport { Title } from './title';\nimport { DOMUtils } from '../../services';\nimport * as 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\t\t}\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\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.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: <string | number>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// Position the total text -24 pixels to add spacing between text and status icon (if status exists)\n\t\t\t.attr(\n\t\t\t\t'x',\n\t\t\t\tthis.model.getStatus() && typeof containerWidth !== 'string'\n\t\t\t\t\t? containerWidth - Configuration.meter.total.paddingRight\n\t\t\t\t\t: containerWidth\n\t\t\t)\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"]}
@@ -0,0 +1,6 @@
1
+ import { GeoProjection } from '../essentials/geo-projection';
2
+ export declare class Choropleth extends GeoProjection {
3
+ type: string;
4
+ render(animate?: boolean): void;
5
+ addCountryAreaEventListener(): void;
6
+ }
@@ -0,0 +1,106 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ // Internal Imports
15
+ import { Events } from '../../interfaces';
16
+ import { GeoProjection } from '../essentials/geo-projection';
17
+ // D3 imports
18
+ import { select } from 'd3-selection';
19
+ var Choropleth = /** @class */ (function (_super) {
20
+ __extends(Choropleth, _super);
21
+ function Choropleth() {
22
+ var _this = _super !== null && _super.apply(this, arguments) || this;
23
+ _this.type = 'choropleth';
24
+ return _this;
25
+ }
26
+ Choropleth.prototype.render = function (animate) {
27
+ var _this = this;
28
+ if (animate === void 0) { animate = true; }
29
+ _super.prototype.render.call(this);
30
+ var data = this.model.getCombinedData();
31
+ var svg = this.getComponentContainer({ withinChartClip: true });
32
+ var geo = svg.select('g.geo');
33
+ geo.selectAll('path')
34
+ .classed('border', true)
35
+ .attr('class', function (d) {
36
+ return _this.model.getColorClassName({
37
+ value: data[d.properties.NAME].value,
38
+ originalClassName: "border",
39
+ });
40
+ });
41
+ this.addCountryAreaEventListener();
42
+ };
43
+ Choropleth.prototype.addCountryAreaEventListener = function () {
44
+ var self = this;
45
+ var data = this.model.getCombinedData();
46
+ this.parent
47
+ .selectAll('path.border')
48
+ .on('mouseover', function (event, datum) {
49
+ var hoveredElement = select(this);
50
+ // Dispatch mouse over event
51
+ self.services.events.dispatchEvent(Events.Choropleth.CHOROPLETH_MOUSEOVER, {
52
+ event: event,
53
+ element: hoveredElement,
54
+ datum: data[datum.properties.NAME],
55
+ });
56
+ // Dispatch tooltip show event
57
+ self.services.events.dispatchEvent(Events.Tooltip.SHOW, {
58
+ event: event,
59
+ hoveredElement: hoveredElement,
60
+ items: [
61
+ {
62
+ label: datum.properties.NAME,
63
+ value: data[datum.properties.NAME].value,
64
+ },
65
+ ],
66
+ });
67
+ })
68
+ .on('mousemove', function (event, datum) {
69
+ // Dispatch mouse move event
70
+ self.services.events.dispatchEvent(Events.Choropleth.CHOROPLETH_MOUSEMOVE, {
71
+ event: event,
72
+ element: select(this),
73
+ datum: data[datum.properties.NAME],
74
+ });
75
+ // Dispatch tooltip move event
76
+ self.services.events.dispatchEvent(Events.Tooltip.MOVE, {
77
+ event: event,
78
+ });
79
+ })
80
+ .on('click', function (event, datum) {
81
+ // Dispatch mouse click event
82
+ self.services.events.dispatchEvent(Events.Choropleth.CHOROPLETH_CLICK, {
83
+ event: event,
84
+ element: select(this),
85
+ datum: data[datum.properties.NAME],
86
+ });
87
+ })
88
+ .on('mouseout', function (event, datum) {
89
+ var hoveredElement = select(this);
90
+ // Dispatch mouse out event
91
+ self.services.events.dispatchEvent(Events.Choropleth.CHOROPLETH_MOUSEOUT, {
92
+ event: event,
93
+ element: hoveredElement,
94
+ datum: data[datum.properties.NAME],
95
+ });
96
+ // Dispatch hide tooltip event
97
+ self.services.events.dispatchEvent(Events.Tooltip.HIDE, {
98
+ event: event,
99
+ hoveredElement: hoveredElement,
100
+ });
101
+ });
102
+ };
103
+ return Choropleth;
104
+ }(GeoProjection));
105
+ export { Choropleth };
106
+ //# sourceMappingURL=../../../src/components/graphs/choropleth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choropleth.js","sourceRoot":"","sources":["choropleth.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;IAAgC,8BAAa;IAA7C;QAAA,qEAkGC;QAjGA,UAAI,GAAG,YAAY,CAAC;;IAiGrB,CAAC;IA/FA,2BAAM,GAAN,UAAO,OAAc;QAArB,iBAgBC;QAhBM,wBAAA,EAAA,cAAc;QACpB,iBAAM,MAAM,WAAE,CAAC;QACf,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC1C,IAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QAElE,IAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC;aACnB,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;aACvB,IAAI,CAAC,OAAO,EAAE,UAAC,CAAC;YAChB,OAAO,KAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC;gBACnC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,UAA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../essentials/geo-projection';\n\n// D3 imports\nimport { select } from 'd3-selection';\n\nexport class Choropleth extends GeoProjection {\n\ttype = 'choropleth';\n\n\trender(animate = true) {\n\t\tsuper.render();\n\t\tconst data = this.model.getCombinedData();\n\t\tconst svg = this.getComponentContainer({ withinChartClip: true });\n\n\t\tconst geo = svg.select('g.geo');\n\t\tgeo.selectAll('path')\n\t\t\t.classed('border', true)\n\t\t\t.attr('class', (d) => {\n\t\t\t\treturn this.model.getColorClassName({\n\t\t\t\t\tvalue: data[d.properties.NAME].value,\n\t\t\t\t\toriginalClassName: `border`,\n\t\t\t\t});\n\t\t\t});\n\n\t\tthis.addCountryAreaEventListener();\n\t}\n\n\taddCountryAreaEventListener() {\n\t\tconst self = this;\n\t\tconst data = this.model.getCombinedData();\n\n\t\tthis.parent\n\t\t\t.selectAll('path.border')\n\t\t\t.on('mouseover', function (event, datum) {\n\t\t\t\tconst hoveredElement = select(this);\n\n\t\t\t\t// Dispatch mouse over event\n\t\t\t\tself.services.events.dispatchEvent(\n\t\t\t\t\tEvents.Choropleth.CHOROPLETH_MOUSEOVER,\n\t\t\t\t\t{\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\telement: hoveredElement,\n\t\t\t\t\t\tdatum: data[datum.properties.NAME],\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Dispatch tooltip show event\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\titems: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: datum.properties.NAME,\n\t\t\t\t\t\t\tvalue: data[datum.properties.NAME].value,\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\t.on('mousemove', function (event, datum) {\n\t\t\t\t// Dispatch mouse move event\n\t\t\t\tself.services.events.dispatchEvent(\n\t\t\t\t\tEvents.Choropleth.CHOROPLETH_MOUSEMOVE,\n\t\t\t\t\t{\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\telement: select(this),\n\t\t\t\t\t\tdatum: data[datum.properties.NAME],\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\t// Dispatch tooltip move event\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 click event\n\t\t\t\tself.services.events.dispatchEvent(\n\t\t\t\t\tEvents.Choropleth.CHOROPLETH_CLICK,\n\t\t\t\t\t{\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\telement: select(this),\n\t\t\t\t\t\tdatum: data[datum.properties.NAME],\n\t\t\t\t\t}\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\n\t\t\t\t// Dispatch mouse out event\n\t\t\t\tself.services.events.dispatchEvent(\n\t\t\t\t\tEvents.Choropleth.CHOROPLETH_MOUSEOUT,\n\t\t\t\t\t{\n\t\t\t\t\t\tevent,\n\t\t\t\t\t\telement: hoveredElement,\n\t\t\t\t\t\tdatum: data[datum.properties.NAME],\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Dispatch hide tooltip event\n\t\t\t\tself.services.events.dispatchEvent(Events.Tooltip.HIDE, {\n\t\t\t\t\tevent,\n\t\t\t\t\thoveredElement,\n\t\t\t\t});\n\t\t\t});\n\t}\n}\n"]}
@@ -207,7 +207,7 @@ var Radar = /** @class */ (function (_super) {
207
207
  .attr('fill', 'none')
208
208
  .call(function (selection) {
209
209
  return selection
210
- .transition()
210
+ .transition() // BUG: unresolved from Issue 1555 - https://github.com/carbon-design-system/carbon-charts/issues/1555
211
211
  .call(function (t) {
212
212
  return _this.services.transitions.setupTransition({
213
213
  transition: t,