@carbon/charts 1.7.6 → 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 (96) hide show
  1. package/CHANGELOG.md +13 -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/essentials/color-scale-legend.d.ts +3 -0
  31. package/components/essentials/color-scale-legend.js +18 -11
  32. package/components/essentials/color-scale-legend.js.map +1 -1
  33. package/components/essentials/geo-projection.d.ts +16 -0
  34. package/components/essentials/geo-projection.js +160 -0
  35. package/components/essentials/geo-projection.js.map +1 -0
  36. package/components/graphs/choropleth.d.ts +6 -0
  37. package/components/graphs/choropleth.js +106 -0
  38. package/components/graphs/choropleth.js.map +1 -0
  39. package/components/index.d.ts +2 -0
  40. package/components/index.js +2 -0
  41. package/components/index.js.map +1 -1
  42. package/configuration.d.ts +3 -1
  43. package/configuration.js +18 -1
  44. package/configuration.js.map +1 -1
  45. package/demo/create-codesandbox.js +20 -2
  46. package/demo/create-codesandbox.js.map +1 -1
  47. package/demo/data/CHART_TYPES.d.ts +5 -0
  48. package/demo/data/CHART_TYPES.js +5 -0
  49. package/demo/data/CHART_TYPES.js.map +1 -1
  50. package/demo/data/bundle.js +1 -1
  51. package/demo/data/choropleth.d.ts +738 -0
  52. package/demo/data/choropleth.js +1684 -0
  53. package/demo/data/choropleth.js.map +1 -0
  54. package/demo/data/index.d.ts +1 -0
  55. package/demo/data/index.js +45 -5
  56. package/demo/data/index.js.map +1 -1
  57. package/demo/data/topojson-110.d.ts +360 -0
  58. package/demo/data/topojson-110.js +40724 -0
  59. package/demo/data/topojson-110.js.map +1 -0
  60. package/demo/styles.css +410 -185
  61. package/demo/styles.css.map +1 -1
  62. package/demo/styles.min.css +1 -1
  63. package/demo/styles.min.css.map +1 -1
  64. package/demo/tsconfig.tsbuildinfo +25 -6
  65. package/demo/utils.js +29 -1
  66. package/demo/utils.js.map +1 -1
  67. package/interfaces/charts.d.ts +28 -1
  68. package/interfaces/charts.js.map +1 -1
  69. package/interfaces/enums.d.ts +12 -0
  70. package/interfaces/enums.js +16 -0
  71. package/interfaces/enums.js.map +1 -1
  72. package/interfaces/events.d.ts +9 -0
  73. package/interfaces/events.js +10 -0
  74. package/interfaces/events.js.map +1 -1
  75. package/model/choropleth.d.ts +29 -0
  76. package/model/choropleth.js +105 -0
  77. package/model/choropleth.js.map +1 -0
  78. package/model/heatmap.d.ts +0 -5
  79. package/model/heatmap.js +3 -64
  80. package/model/heatmap.js.map +1 -1
  81. package/package.json +4 -3
  82. package/services/color-scale-utils.d.ts +2 -0
  83. package/services/color-scale-utils.js +64 -0
  84. package/services/color-scale-utils.js.map +1 -0
  85. package/services/index.d.ts +1 -0
  86. package/services/index.js +1 -0
  87. package/services/index.js.map +1 -1
  88. package/styles/color-palatte.scss +96 -0
  89. package/styles/colors.scss +23 -8
  90. package/styles/graphs/_choropleth.scss +18 -0
  91. package/styles/graphs/index.scss +1 -0
  92. package/styles.css +156 -144
  93. package/styles.css.map +1 -1
  94. package/styles.min.css +1 -1
  95. package/styles.min.css.map +1 -1
  96. package/tsconfig.tsbuildinfo +415 -43
@@ -0,0 +1,10 @@
1
+ import { Chart } from '../chart';
2
+ import { ChoroplethModel } from '../model/choropleth';
3
+ import { ChoroplethChartOptions, ChartConfig } from '../interfaces/index';
4
+ import { Modal, LayoutComponent, Tooltip } from '../components';
5
+ export declare class EXPERIMENTAL_ChoroplethChart extends Chart {
6
+ model: ChoroplethModel;
7
+ constructor(holder: Element, chartConfigs: ChartConfig<ChoroplethChartOptions>);
8
+ protected getChartComponents(graphFrameComponents: any[], configs?: any): (Tooltip | Modal | LayoutComponent)[];
9
+ getComponents(): any[];
10
+ }
@@ -0,0 +1,141 @@
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
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
15
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
16
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
17
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
18
+ r[k] = a[j];
19
+ return r;
20
+ };
21
+ // Internal Imports
22
+ import { Chart } from '../chart';
23
+ import { ChoroplethModel } from '../model/choropleth';
24
+ import * as Configuration from '../configuration';
25
+ import * as Tools from '../tools';
26
+ import { LayoutDirection, LayoutGrowth, RenderTypes, LayoutAlignItems, } from '../interfaces/index';
27
+ // Components
28
+ import { Choropleth, Modal, LayoutComponent, ColorScaleLegend, Title, Spacer, Toolbar,
29
+ // the imports below are needed because of typescript bug (error TS4029)
30
+ Tooltip, } from '../components';
31
+ var EXPERIMENTAL_ChoroplethChart = /** @class */ (function (_super) {
32
+ __extends(EXPERIMENTAL_ChoroplethChart, _super);
33
+ function EXPERIMENTAL_ChoroplethChart(holder, chartConfigs) {
34
+ var _this = _super.call(this, holder, chartConfigs) || this;
35
+ _this.model = new ChoroplethModel(_this.services);
36
+ // Merge the default options for this chart
37
+ // With the user provided options
38
+ _this.model.setOptions(Tools.mergeDefaultChartOptions(Configuration.options.choroplethChart, chartConfigs.options));
39
+ // Initialize data, services, components etc.
40
+ _this.init(holder, chartConfigs);
41
+ return _this;
42
+ }
43
+ // Custom getChartComponents - Implements getChartComponents
44
+ // Removes zoombar support and additional `features` that are not supported in heatmap
45
+ EXPERIMENTAL_ChoroplethChart.prototype.getChartComponents = function (graphFrameComponents, configs) {
46
+ var options = this.model.getOptions();
47
+ var toolbarEnabled = Tools.getProperty(options, 'toolbar', 'enabled');
48
+ var titleAvailable = !!this.model.getOptions().title;
49
+ var titleComponent = {
50
+ id: 'title',
51
+ components: [new Title(this.model, this.services)],
52
+ growth: LayoutGrowth.STRETCH,
53
+ };
54
+ var toolbarComponent = {
55
+ id: 'toolbar',
56
+ components: [new Toolbar(this.model, this.services)],
57
+ growth: LayoutGrowth.PREFERRED,
58
+ };
59
+ var headerComponent = {
60
+ id: 'header',
61
+ components: [
62
+ new LayoutComponent(this.model, this.services, __spreadArrays([
63
+ // always add title to keep layout correct
64
+ titleComponent
65
+ ], (toolbarEnabled ? [toolbarComponent] : [])), {
66
+ direction: LayoutDirection.ROW,
67
+ alignItems: LayoutAlignItems.CENTER,
68
+ }),
69
+ ],
70
+ growth: LayoutGrowth.PREFERRED,
71
+ };
72
+ var legendComponent = {
73
+ id: 'legend',
74
+ components: [
75
+ new ColorScaleLegend(this.model, this.services, {
76
+ chartType: 'choropleth',
77
+ }),
78
+ ],
79
+ growth: LayoutGrowth.PREFERRED,
80
+ renderType: RenderTypes.SVG,
81
+ };
82
+ var graphFrameComponent = {
83
+ id: 'graph-frame',
84
+ components: graphFrameComponents,
85
+ growth: LayoutGrowth.STRETCH,
86
+ renderType: RenderTypes.SVG,
87
+ };
88
+ var isLegendEnabled = Tools.getProperty(configs, 'legend', 'enabled') !== false &&
89
+ this.model.getOptions().legend.enabled !== false;
90
+ // Decide the position of the legend in reference to the chart
91
+ var fullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE;
92
+ var legendSpacerComponent = {
93
+ id: 'spacer',
94
+ components: [new Spacer(this.model, this.services, { size: 15 })],
95
+ growth: LayoutGrowth.PREFERRED,
96
+ };
97
+ var fullFrameComponent = {
98
+ id: 'full-frame',
99
+ components: [
100
+ new LayoutComponent(this.model, this.services, __spreadArrays((isLegendEnabled ? [legendComponent] : []), (isLegendEnabled ? [legendSpacerComponent] : []), [
101
+ graphFrameComponent,
102
+ ]), {
103
+ direction: fullFrameComponentDirection,
104
+ }),
105
+ ],
106
+ growth: LayoutGrowth.STRETCH,
107
+ };
108
+ var topLevelLayoutComponents = [];
109
+ // header component is required for either title or toolbar
110
+ if (titleAvailable || toolbarEnabled) {
111
+ topLevelLayoutComponents.push(headerComponent);
112
+ var titleSpacerComponent = {
113
+ id: 'spacer',
114
+ components: [
115
+ new Spacer(this.model, this.services, toolbarEnabled ? { size: 15 } : undefined),
116
+ ],
117
+ growth: LayoutGrowth.PREFERRED,
118
+ };
119
+ topLevelLayoutComponents.push(titleSpacerComponent);
120
+ }
121
+ topLevelLayoutComponents.push(fullFrameComponent);
122
+ return [
123
+ new Tooltip(this.model, this.services),
124
+ new Modal(this.model, this.services),
125
+ new LayoutComponent(this.model, this.services, topLevelLayoutComponents, {
126
+ direction: LayoutDirection.COLUMN,
127
+ }),
128
+ ];
129
+ };
130
+ EXPERIMENTAL_ChoroplethChart.prototype.getComponents = function () {
131
+ // Specify what to render inside the graph-frame
132
+ var graphFrameComponents = [
133
+ new Choropleth(this.model, this.services),
134
+ ];
135
+ var components = this.getChartComponents(graphFrameComponents);
136
+ return components;
137
+ };
138
+ return EXPERIMENTAL_ChoroplethChart;
139
+ }(Chart));
140
+ export { EXPERIMENTAL_ChoroplethChart };
141
+ //# sourceMappingURL=../../src/charts/choropleth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choropleth.js","sourceRoot":"","sources":["choropleth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC;AAElC,OAAO,EAEN,eAAe,EACf,YAAY,EAEZ,WAAW,EACX,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAE7B,aAAa;AACb,OAAO,EACN,UAAU,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,OAAO;AACP,wEAAwE;AACxE,OAAO,GACP,MAAM,eAAe,CAAC;AAEvB;IAAkD,gDAAK;IAGtD,sCACC,MAAe,EACf,YAAiD;QAFlD,YAIC,kBAAM,MAAM,EAAE,YAAY,CAAC,SAa3B;QAnBD,WAAK,GAAG,IAAI,eAAe,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;QAQ1C,2CAA2C;QAC3C,iCAAiC;QACjC,KAAI,CAAC,KAAK,CAAC,UAAU,CACpB,KAAK,CAAC,wBAAwB,CAC7B,aAAa,CAAC,OAAO,CAAC,eAAe,EACrC,YAAY,CAAC,OAAO,CACpB,CACD,CAAC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GA2JtD","sourcesContent":["// Internal Imports\nimport { Chart } from '../chart';\nimport { ChoroplethModel } from '../model/choropleth';\nimport * as Configuration from '../configuration';\nimport * as Tools from '../tools';\n\nimport {\n\tChoroplethChartOptions,\n\tLayoutDirection,\n\tLayoutGrowth,\n\tChartConfig,\n\tRenderTypes,\n\tLayoutAlignItems,\n} from '../interfaces/index';\n\n// Components\nimport {\n\tChoropleth,\n\tModal,\n\tLayoutComponent,\n\tColorScaleLegend,\n\tTitle,\n\tSpacer,\n\tToolbar,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tTooltip,\n} from '../components';\n\nexport class EXPERIMENTAL_ChoroplethChart extends Chart {\n\tmodel = new ChoroplethModel(this.services);\n\n\tconstructor(\n\t\tholder: Element,\n\t\tchartConfigs: ChartConfig<ChoroplethChartOptions>\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.choroplethChart,\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\t}\n\n\t// Custom getChartComponents - Implements getChartComponents\n\t// Removes zoombar support and additional `features` that are not supported in heatmap\n\tprotected getChartComponents(graphFrameComponents: any[], configs?: any) {\n\t\tconst options = this.model.getOptions();\n\t\tconst toolbarEnabled = Tools.getProperty(options, 'toolbar', 'enabled');\n\n\t\tconst titleAvailable = !!this.model.getOptions().title;\n\t\tconst titleComponent = {\n\t\t\tid: 'title',\n\t\t\tcomponents: [new Title(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\tconst toolbarComponent = {\n\t\t\tid: 'toolbar',\n\t\t\tcomponents: [new Toolbar(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst headerComponent = {\n\t\t\tid: 'header',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t// always add title to keep layout correct\n\t\t\t\t\t\ttitleComponent,\n\t\t\t\t\t\t...(toolbarEnabled ? [toolbarComponent] : []),\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: LayoutDirection.ROW,\n\t\t\t\t\t\talignItems: LayoutAlignItems.CENTER,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst legendComponent = {\n\t\t\tid: 'legend',\n\t\t\tcomponents: [\n\t\t\t\tnew ColorScaleLegend(this.model, this.services, {\n\t\t\t\t\tchartType: 'choropleth',\n\t\t\t\t}),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t\trenderType: RenderTypes.SVG,\n\t\t};\n\n\t\tconst graphFrameComponent = {\n\t\t\tid: 'graph-frame',\n\t\t\tcomponents: graphFrameComponents,\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t\trenderType: RenderTypes.SVG,\n\t\t};\n\n\t\tconst isLegendEnabled =\n\t\t\tTools.getProperty(configs, 'legend', 'enabled') !== false &&\n\t\t\tthis.model.getOptions().legend.enabled !== false;\n\n\t\t// Decide the position of the legend in reference to the chart\n\t\tconst fullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE;\n\n\t\tconst legendSpacerComponent = {\n\t\t\tid: 'spacer',\n\t\t\tcomponents: [new Spacer(this.model, this.services, { size: 15 })],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst fullFrameComponent = {\n\t\t\tid: 'full-frame',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t...(isLegendEnabled ? [legendComponent] : []),\n\t\t\t\t\t\t...(isLegendEnabled ? [legendSpacerComponent] : []),\n\t\t\t\t\t\tgraphFrameComponent,\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: fullFrameComponentDirection,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\tconst topLevelLayoutComponents = [];\n\t\t// header component is required for either title or toolbar\n\t\tif (titleAvailable || toolbarEnabled) {\n\t\t\ttopLevelLayoutComponents.push(headerComponent);\n\n\t\t\tconst titleSpacerComponent = {\n\t\t\t\tid: 'spacer',\n\t\t\t\tcomponents: [\n\t\t\t\t\tnew Spacer(\n\t\t\t\t\t\tthis.model,\n\t\t\t\t\t\tthis.services,\n\t\t\t\t\t\ttoolbarEnabled ? { size: 15 } : undefined\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t\t};\n\n\t\t\ttopLevelLayoutComponents.push(titleSpacerComponent);\n\t\t}\n\t\ttopLevelLayoutComponents.push(fullFrameComponent);\n\n\t\treturn [\n\t\t\tnew Tooltip(this.model, this.services),\n\t\t\tnew Modal(this.model, this.services),\n\t\t\tnew LayoutComponent(\n\t\t\t\tthis.model,\n\t\t\t\tthis.services,\n\t\t\t\ttopLevelLayoutComponents,\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\t}\n\n\tgetComponents() {\n\t\t// Specify what to render inside the graph-frame\n\t\tconst graphFrameComponents: any = [\n\t\t\tnew Choropleth(this.model, this.services),\n\t\t];\n\n\t\tconst components: any[] = this.getChartComponents(graphFrameComponents);\n\t\treturn components;\n\t}\n}\n"]}
package/charts/heatmap.js CHANGED
@@ -71,7 +71,11 @@ var HeatmapChart = /** @class */ (function (_super) {
71
71
  };
72
72
  var legendComponent = {
73
73
  id: 'legend',
74
- components: [new ColorScaleLegend(this.model, this.services)],
74
+ components: [
75
+ new ColorScaleLegend(this.model, this.services, {
76
+ chartType: 'heatmap',
77
+ }),
78
+ ],
75
79
  growth: LayoutGrowth.PREFERRED,
76
80
  renderType: RenderTypes.SVG,
77
81
  };
@@ -1 +1 @@
1
- {"version":3,"file":"heatmap.js","sourceRoot":"","sources":["heatmap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC;AAElC,OAAO,EAEN,eAAe,EACf,YAAY,EAEZ,WAAW,EACX,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,OAAO,EACP,kBAAkB,EAClB,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,EACL,iBAAiB,EACjB,MAAM,EACN,OAAO,GAGP,MAAM,eAAe,CAAC;AAEvB;IAAkC,gCAAS;IAG1C,sBACC,MAAe,EACf,YAA8C;QAF/C,YAIC,kBAAM,MAAM,EAAE,YAAY,CAAC,SAa3B;QAnBD,WAAK,GAAG,IAAI,YAAY,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;QAQvC,2CAA2C;QAC3C,iCAAiC;QACjC,KAAI,CAAC,KAAK,CAAC,UAAU,CACpB,KAAK,CAAC,wBAAwB,CAC7B,aAAa,CAAC,OAAO,CAAC,YAAY,EAClC,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QAEF,6CAA6C;QAC7C,KAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;;IACjC,CAAC;IAED,4DAA4D;IAC5D,sFAAsF;IAC5E,6CAAsB,GAAhC,UACC,oBAA2B,EAC3B,OAAa;QAEb,IAAM,OAAO,GAAG,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B,CAAC;IACF,mBAAC;AAAD,CAAC,AAjKD,CAAkC,SAAS,GAiK1C","sourcesContent":["// Internal Imports\nimport { HeatmapModel } from '../model/heatmap';\nimport { AxisChart } from '../axis-chart';\nimport * as Configuration from '../configuration';\nimport * as Tools from '../tools';\n\nimport {\n\tHeatmapChartOptions,\n\tLayoutDirection,\n\tLayoutGrowth,\n\tChartConfig,\n\tRenderTypes,\n\tLayoutAlignItems,\n} from '../interfaces/index';\n\nimport {\n\tHeatmap,\n\tTwoDimensionalAxes,\n\tModal,\n\tLayoutComponent,\n\tColorScaleLegend,\n\tTitle,\n\tAxisChartsTooltip,\n\tSpacer,\n\tToolbar,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tTooltip,\n} from '../components';\n\nexport class HeatmapChart extends AxisChart {\n\tmodel = new HeatmapModel(this.services);\n\n\tconstructor(\n\t\tholder: Element,\n\t\tchartConfigs: ChartConfig<HeatmapChartOptions>\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.heatmapChart,\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\t}\n\n\t// Custom getChartComponents - Implements getChartComponents\n\t// Removes zoombar support and additional `features` that are not supported in heatmap\n\tprotected getAxisChartComponents(\n\t\tgraphFrameComponents: any[],\n\t\tconfigs?: any\n\t) {\n\t\tconst options = this.model.getOptions();\n\t\tconst toolbarEnabled = Tools.getProperty(options, 'toolbar', 'enabled');\n\n\t\tthis.services.cartesianScales.determineAxisDuality();\n\t\tthis.services.cartesianScales.findDomainAndRangeAxes(); // need to do this before getMainXAxisPosition()\n\t\tthis.services.cartesianScales.determineOrientation();\n\n\t\tconst titleAvailable = !!this.model.getOptions().title;\n\t\tconst titleComponent = {\n\t\t\tid: 'title',\n\t\t\tcomponents: [new Title(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\tconst toolbarComponent = {\n\t\t\tid: 'toolbar',\n\t\t\tcomponents: [new Toolbar(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst headerComponent = {\n\t\t\tid: 'header',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t// always add title to keep layout correct\n\t\t\t\t\t\ttitleComponent,\n\t\t\t\t\t\t...(toolbarEnabled ? [toolbarComponent] : []),\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: LayoutDirection.ROW,\n\t\t\t\t\t\talignItems: LayoutAlignItems.CENTER,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst legendComponent = {\n\t\t\tid: 'legend',\n\t\t\tcomponents: [new ColorScaleLegend(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t\trenderType: RenderTypes.SVG,\n\t\t};\n\n\t\tconst graphFrameComponent = {\n\t\t\tid: 'graph-frame',\n\t\t\tcomponents: graphFrameComponents,\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t\trenderType: RenderTypes.SVG,\n\t\t};\n\n\t\tconst isLegendEnabled =\n\t\t\tTools.getProperty(configs, 'legend', 'enabled') !== false &&\n\t\t\tthis.model.getOptions().legend.enabled !== false;\n\n\t\t// Decide the position of the legend in reference to the chart\n\t\tconst fullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE;\n\n\t\tconst legendSpacerComponent = {\n\t\t\tid: 'spacer',\n\t\t\tcomponents: [new Spacer(this.model, this.services, { size: 15 })],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst fullFrameComponent = {\n\t\t\tid: 'full-frame',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t...(isLegendEnabled ? [legendComponent] : []),\n\t\t\t\t\t\t...(isLegendEnabled ? [legendSpacerComponent] : []),\n\t\t\t\t\t\tgraphFrameComponent,\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: fullFrameComponentDirection,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\tconst topLevelLayoutComponents = [];\n\t\t// header component is required for either title or toolbar\n\t\tif (titleAvailable || toolbarEnabled) {\n\t\t\ttopLevelLayoutComponents.push(headerComponent);\n\n\t\t\tconst titleSpacerComponent = {\n\t\t\t\tid: 'spacer',\n\t\t\t\tcomponents: [\n\t\t\t\t\tnew Spacer(\n\t\t\t\t\t\tthis.model,\n\t\t\t\t\t\tthis.services,\n\t\t\t\t\t\ttoolbarEnabled ? { size: 15 } : undefined\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t\t};\n\n\t\t\ttopLevelLayoutComponents.push(titleSpacerComponent);\n\t\t}\n\t\ttopLevelLayoutComponents.push(fullFrameComponent);\n\n\t\treturn [\n\t\t\tnew AxisChartsTooltip(this.model, this.services),\n\t\t\tnew Modal(this.model, this.services),\n\t\t\tnew LayoutComponent(\n\t\t\t\tthis.model,\n\t\t\t\tthis.services,\n\t\t\t\ttopLevelLayoutComponents,\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\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 Heatmap(this.model, this.services),\n\t\t];\n\n\t\tconst components: any[] = this.getAxisChartComponents(\n\t\t\tgraphFrameComponents\n\t\t);\n\t\treturn components;\n\t}\n}\n"]}
1
+ {"version":3,"file":"heatmap.js","sourceRoot":"","sources":["heatmap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC;AAElC,OAAO,EAEN,eAAe,EACf,YAAY,EAEZ,WAAW,EACX,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,OAAO,EACP,kBAAkB,EAClB,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,EACL,iBAAiB,EACjB,MAAM,EACN,OAAO,GAGP,MAAM,eAAe,CAAC;AAEvB;IAAkC,gCAAS;IAG1C,sBACC,MAAe,EACf,YAA8C;QAF/C,YAIC,kBAAM,MAAM,EAAE,YAAY,CAAC,SAa3B;QAnBD,WAAK,GAAG,IAAI,YAAY,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAC;QAQvC,2CAA2C;QAC3C,iCAAiC;QACjC,KAAI,CAAC,KAAK,CAAC,UAAU,CACpB,KAAK,CAAC,wBAAwB,CAC7B,aAAa,CAAC,OAAO,CAAC,YAAY,EAClC,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QAEF,6CAA6C;QAC7C,KAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;;IACjC,CAAC;IAED,4DAA4D;IAC5D,sFAAsF;IAC5E,6CAAsB,GAAhC,UACC,oBAA2B,EAC3B,OAAa;QAEb,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACxC,IAAM,cAAc,GAAG,KAAK,C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,CAAkC,SAAS,GAqK1C","sourcesContent":["// Internal Imports\nimport { HeatmapModel } from '../model/heatmap';\nimport { AxisChart } from '../axis-chart';\nimport * as Configuration from '../configuration';\nimport * as Tools from '../tools';\n\nimport {\n\tHeatmapChartOptions,\n\tLayoutDirection,\n\tLayoutGrowth,\n\tChartConfig,\n\tRenderTypes,\n\tLayoutAlignItems,\n} from '../interfaces/index';\n\nimport {\n\tHeatmap,\n\tTwoDimensionalAxes,\n\tModal,\n\tLayoutComponent,\n\tColorScaleLegend,\n\tTitle,\n\tAxisChartsTooltip,\n\tSpacer,\n\tToolbar,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tTooltip,\n} from '../components';\n\nexport class HeatmapChart extends AxisChart {\n\tmodel = new HeatmapModel(this.services);\n\n\tconstructor(\n\t\tholder: Element,\n\t\tchartConfigs: ChartConfig<HeatmapChartOptions>\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.heatmapChart,\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\t}\n\n\t// Custom getChartComponents - Implements getChartComponents\n\t// Removes zoombar support and additional `features` that are not supported in heatmap\n\tprotected getAxisChartComponents(\n\t\tgraphFrameComponents: any[],\n\t\tconfigs?: any\n\t) {\n\t\tconst options = this.model.getOptions();\n\t\tconst toolbarEnabled = Tools.getProperty(options, 'toolbar', 'enabled');\n\n\t\tthis.services.cartesianScales.determineAxisDuality();\n\t\tthis.services.cartesianScales.findDomainAndRangeAxes(); // need to do this before getMainXAxisPosition()\n\t\tthis.services.cartesianScales.determineOrientation();\n\n\t\tconst titleAvailable = !!this.model.getOptions().title;\n\t\tconst titleComponent = {\n\t\t\tid: 'title',\n\t\t\tcomponents: [new Title(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\tconst toolbarComponent = {\n\t\t\tid: 'toolbar',\n\t\t\tcomponents: [new Toolbar(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst headerComponent = {\n\t\t\tid: 'header',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t// always add title to keep layout correct\n\t\t\t\t\t\ttitleComponent,\n\t\t\t\t\t\t...(toolbarEnabled ? [toolbarComponent] : []),\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: LayoutDirection.ROW,\n\t\t\t\t\t\talignItems: LayoutAlignItems.CENTER,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst legendComponent = {\n\t\t\tid: 'legend',\n\t\t\tcomponents: [\n\t\t\t\tnew ColorScaleLegend(this.model, this.services, {\n\t\t\t\t\tchartType: 'heatmap',\n\t\t\t\t}),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t\trenderType: RenderTypes.SVG,\n\t\t};\n\n\t\tconst graphFrameComponent = {\n\t\t\tid: 'graph-frame',\n\t\t\tcomponents: graphFrameComponents,\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t\trenderType: RenderTypes.SVG,\n\t\t};\n\n\t\tconst isLegendEnabled =\n\t\t\tTools.getProperty(configs, 'legend', 'enabled') !== false &&\n\t\t\tthis.model.getOptions().legend.enabled !== false;\n\n\t\t// Decide the position of the legend in reference to the chart\n\t\tconst fullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE;\n\n\t\tconst legendSpacerComponent = {\n\t\t\tid: 'spacer',\n\t\t\tcomponents: [new Spacer(this.model, this.services, { size: 15 })],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst fullFrameComponent = {\n\t\t\tid: 'full-frame',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t...(isLegendEnabled ? [legendComponent] : []),\n\t\t\t\t\t\t...(isLegendEnabled ? [legendSpacerComponent] : []),\n\t\t\t\t\t\tgraphFrameComponent,\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: fullFrameComponentDirection,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\tconst topLevelLayoutComponents = [];\n\t\t// header component is required for either title or toolbar\n\t\tif (titleAvailable || toolbarEnabled) {\n\t\t\ttopLevelLayoutComponents.push(headerComponent);\n\n\t\t\tconst titleSpacerComponent = {\n\t\t\t\tid: 'spacer',\n\t\t\t\tcomponents: [\n\t\t\t\t\tnew Spacer(\n\t\t\t\t\t\tthis.model,\n\t\t\t\t\t\tthis.services,\n\t\t\t\t\t\ttoolbarEnabled ? { size: 15 } : undefined\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t\t};\n\n\t\t\ttopLevelLayoutComponents.push(titleSpacerComponent);\n\t\t}\n\t\ttopLevelLayoutComponents.push(fullFrameComponent);\n\n\t\treturn [\n\t\t\tnew AxisChartsTooltip(this.model, this.services),\n\t\t\tnew Modal(this.model, this.services),\n\t\t\tnew LayoutComponent(\n\t\t\t\tthis.model,\n\t\t\t\tthis.services,\n\t\t\t\ttopLevelLayoutComponents,\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\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 Heatmap(this.model, this.services),\n\t\t];\n\n\t\tconst components: any[] = this.getAxisChartComponents(\n\t\t\tgraphFrameComponents\n\t\t);\n\t\treturn components;\n\t}\n}\n"]}
package/charts/index.d.ts CHANGED
@@ -22,3 +22,4 @@ export * from './circle-pack';
22
22
  export * from './wordcloud';
23
23
  export * from './alluvial';
24
24
  export * from './heatmap';
25
+ export * from './choropleth';
package/charts/index.js CHANGED
@@ -22,4 +22,5 @@ export * from './circle-pack';
22
22
  export * from './wordcloud';
23
23
  export * from './alluvial';
24
24
  export * from './heatmap';
25
+ export * from './choropleth';
25
26
  //# sourceMappingURL=../../src/charts/index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC","sourcesContent":["export * from './area';\nexport * from './area-stacked';\nexport * from './bar-simple';\nexport * from './bar-grouped';\nexport * from './bar-stacked';\nexport * from './boxplot';\nexport * from './bubble';\nexport * from './bullet';\nexport * from './histogram';\nexport * from './line';\nexport * from './lollipop';\nexport * from './scatter';\nexport * from './pie';\nexport * from './donut';\nexport * from './meter';\nexport * from './radar';\nexport * from './gauge';\nexport * from './combo';\nexport * from './tree';\nexport * from './treemap';\nexport * from './circle-pack';\nexport * from './wordcloud';\nexport * from './alluvial';\nexport * from './heatmap';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC","sourcesContent":["export * from './area';\nexport * from './area-stacked';\nexport * from './bar-simple';\nexport * from './bar-grouped';\nexport * from './bar-stacked';\nexport * from './boxplot';\nexport * from './bubble';\nexport * from './bullet';\nexport * from './histogram';\nexport * from './line';\nexport * from './lollipop';\nexport * from './scatter';\nexport * from './pie';\nexport * from './donut';\nexport * from './meter';\nexport * from './radar';\nexport * from './gauge';\nexport * from './combo';\nexport * from './tree';\nexport * from './treemap';\nexport * from './circle-pack';\nexport * from './wordcloud';\nexport * from './alluvial';\nexport * from './heatmap';\nexport * from './choropleth';\n"]}
@@ -1,9 +1,12 @@
1
1
  import { RenderTypes } from '../../interfaces';
2
2
  import { Legend } from './legend';
3
+ import { ChartModel } from '../../model/model';
3
4
  export declare class ColorScaleLegend extends Legend {
4
5
  type: string;
5
6
  renderType: RenderTypes;
6
7
  private gradient_id;
8
+ private chartType;
9
+ constructor(model: ChartModel, services: any, configs?: any);
7
10
  init(): void;
8
11
  handleAxisCompleteEvent: (event: CustomEvent<any>) => void;
9
12
  render(animate?: boolean): void;
@@ -16,15 +16,15 @@ import * as Tools from '../../tools';
16
16
  import { ColorLegendType, Events, RenderTypes } from '../../interfaces';
17
17
  import * as Configuration from '../../configuration';
18
18
  import { Legend } from './legend';
19
- import { DOMUtils } from '../../services';
19
+ import { DOMUtils, getDomain } from '../../services';
20
20
  // D3 imports
21
21
  import { axisBottom } from 'd3-axis';
22
22
  import { scaleBand, scaleLinear } from 'd3-scale';
23
23
  import { interpolateNumber, quantize } from 'd3-interpolate';
24
24
  var ColorScaleLegend = /** @class */ (function (_super) {
25
25
  __extends(ColorScaleLegend, _super);
26
- function ColorScaleLegend() {
27
- var _this = _super !== null && _super.apply(this, arguments) || this;
26
+ function ColorScaleLegend(model, services, configs) {
27
+ var _this = _super.call(this, model, services, configs) || this;
28
28
  _this.type = 'color-legend';
29
29
  _this.renderType = RenderTypes.SVG;
30
30
  _this.gradient_id = 'gradient-id-' + Math.floor(Math.random() * 99999999999);
@@ -66,12 +66,15 @@ var ColorScaleLegend = /** @class */ (function (_super) {
66
66
  svg.select('g.legend-title').attr('transform', "translate(0, 0)");
67
67
  }
68
68
  };
69
+ _this.chartType = configs.chartType;
69
70
  return _this;
70
71
  }
71
72
  ColorScaleLegend.prototype.init = function () {
72
- var eventsFragment = this.services.events;
73
73
  // Highlight correct circle on legend item hovers
74
- eventsFragment.addEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisCompleteEvent);
74
+ if (this.chartType === 'heatmap') {
75
+ var eventsFragment = this.services.events;
76
+ eventsFragment.addEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisCompleteEvent);
77
+ }
75
78
  };
76
79
  ColorScaleLegend.prototype.render = function (animate) {
77
80
  if (animate === void 0) { animate = false; }
@@ -81,7 +84,7 @@ var ColorScaleLegend = /** @class */ (function (_super) {
81
84
  useAttrs: true,
82
85
  }).width;
83
86
  var customColors = Tools.getProperty(options, 'color', 'gradient', 'colors');
84
- var colorScaleType = Tools.getProperty(options, 'heatmap', 'colorLegend', 'type');
87
+ var colorScaleType = Tools.getProperty(options, this.chartType, 'colorLegend', 'type');
85
88
  var colorPairingOption = Tools.getProperty(options, 'color', 'pairing', 'option');
86
89
  var title = Tools.getProperty(options, 'heatmap', 'colorLegend', 'title');
87
90
  // Clear DOM if loading
@@ -91,7 +94,7 @@ var ColorScaleLegend = /** @class */ (function (_super) {
91
94
  return;
92
95
  }
93
96
  var customColorsEnabled = !Tools.isEmpty(customColors);
94
- var domain = this.model.getValueDomain();
97
+ var domain = getDomain(this.model.getDisplayData());
95
98
  var useDefaultBarWidth = !(width <= Configuration.legend.color.barWidth);
96
99
  var barWidth = useDefaultBarWidth
97
100
  ? Configuration.legend.color.barWidth
@@ -167,7 +170,9 @@ var ColorScaleLegend = /** @class */ (function (_super) {
167
170
  .style('text-anchor', useDefaultBarWidth ? 'middle' : 'end');
168
171
  axisElement
169
172
  .select('g.tick:first-of-type text')
170
- .style('text-anchor', useDefaultBarWidth ? 'middle' : 'start');
173
+ .style('text-anchor', useDefaultBarWidth && this.chartType !== 'choropleth'
174
+ ? 'middle'
175
+ : 'start');
171
176
  };
172
177
  // Renders gradient legend
173
178
  ColorScaleLegend.prototype.drawLinear = function (colorPairing, legendGroupElement, barWidth) {
@@ -220,9 +225,11 @@ var ColorScaleLegend = /** @class */ (function (_super) {
220
225
  : 0;
221
226
  };
222
227
  ColorScaleLegend.prototype.destroy = function () {
223
- // Remove legend listeners
224
- var eventsFragment = this.services.events;
225
- eventsFragment.removeEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisCompleteEvent);
228
+ if (this.chartType === 'heatmap') {
229
+ // Remove legend listeners
230
+ var eventsFragment = this.services.events;
231
+ eventsFragment.removeEventListener(Events.Axis.RENDER_COMPLETE, this.handleAxisCompleteEvent);
232
+ }
226
233
  };
227
234
  return ColorScaleLegend;
228
235
  }(Legend));
@@ -1 +1 @@
1
- {"version":3,"file":"color-scale-legend.js","sourceRoot":"","sources":["color-scale-legend.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE7D;IAAsC,oCAAM;IAA5C;QAAA,qEA8UC;QA7UA,UAAI,GAAG,cAAc,CAAC;QACtB,gBAAU,GAAG,WAAW,CAAC,GAAG,CAAC;QAErB,iBAAW,GAClB,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC;QAY1D,2CAA2C;QAC3C,6BAAuB,GAAG,UAAC,KAAkB;YAC5C,IAAM,GAAG,GAAG,KAAI,CAAC,qBAAqB,EAAE,CAAC;YAEjC,IAAA;;oBAAK,CAEV;YAEH,IAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACtC,KAAI,CAAC,UAAU,EAAE,EACjB,MAAM,EACN,SAAS,CACT,CAAC;YAEF,IAAI,KAAK,GAAG,aAAa,C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AAE,UAAC,CAAC,IAAK,OAAA,cAAc,CAAC,CAAC,CAAC,EAAjB,CAAiB,CAAC;aACnC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;aACZ,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;aAC1D,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;aACpD,IAAI,CAAC,OAAO,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,EAAD,CAAC,CAAC;aACvB,IAAI,CAAC,MAAM,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,EAAD,CAAC,CAAC,CAAC;QAEzB,OAAO,CAAC,CAAC,mBAAmB,IAAI,WAAW,CAAC,KAAK,MAAM;YACtD,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;IAED,kCAAO,GAAP;QACC,0BAA0B;QAC1B,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,cAAc,CAAC,mBAAmB,CACjC,MAAM,CAAC,IAAI,CAAC,eAAe,EAC3B,IAAI,CAAC,uBAAuB,CAC5B,CAAC;IACH,CAAC;IACF,uBAAC;AAAD,CAAC,AA9UD,CAAsC,MAAM,GA8U3C","sourcesContent":["// Internal Imports\nimport * as Tools from '../../tools';\nimport { ColorLegendType, Events, RenderTypes } from '../../interfaces';\nimport * as Configuration from '../../configuration';\nimport { Legend } from './legend';\nimport { DOMUtils } from '../../services';\n\n// D3 imports\nimport { axisBottom } from 'd3-axis';\nimport { scaleBand, scaleLinear } from 'd3-scale';\nimport { interpolateNumber, quantize } from 'd3-interpolate';\n\nexport class ColorScaleLegend extends Legend {\n\ttype = 'color-legend';\n\trenderType = RenderTypes.SVG;\n\n\tprivate gradient_id =\n\t\t'gradient-id-' + Math.floor(Math.random() * 99999999999);\n\n\tinit() {\n\t\tconst eventsFragment = this.services.events;\n\n\t\t// Highlight correct circle on legend item hovers\n\t\teventsFragment.addEventListener(\n\t\t\tEvents.Axis.RENDER_COMPLETE,\n\t\t\tthis.handleAxisCompleteEvent\n\t\t);\n\t}\n\n\t// Position legend after axis have rendered\n\thandleAxisCompleteEvent = (event: CustomEvent) => {\n\t\tconst svg = this.getComponentContainer();\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\tif (width > Configuration.legend.color.barWidth && !isDataLoading) {\n\t\t\tconst title = Tools.getProperty(\n\t\t\t\tthis.getOptions(),\n\t\t\t\t'heatmap',\n\t\t\t\t'colorLegend',\n\t\t\t\t'title'\n\t\t\t);\n\n\t\t\tconst { cartesianScales } = this.services;\n\n\t\t\t// Get axis width & start/end positions\n\t\t\tconst mainXScale = cartesianScales.getMainXScale();\n\t\t\tconst xDimensions = mainXScale.range();\n\n\t\t\t// Align legend with the axis\n\t\t\tif (xDimensions[0] > 1) {\n\t\t\t\tsvg.select('g.legend').attr(\n\t\t\t\t\t'transform',\n\t\t\t\t\t`translate(${xDimensions[0]}, 0)`\n\t\t\t\t);\n\n\t\t\t\tif (title) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\twidth: textWidth,\n\t\t\t\t\t} = DOMUtils.getSVGElementSize(\n\t\t\t\t\t\tsvg.select('g.legend-title').select('text'),\n\t\t\t\t\t\t{ useBBox: true }\n\t\t\t\t\t);\n\n\t\t\t\t\t// D3 moves the LEFT y-axis labels by 9\n\t\t\t\t\tconst availableSpace = xDimensions[0] - textWidth - 9;\n\n\t\t\t\t\t// If space is available, align the label with the axis labels\n\t\t\t\t\tif (availableSpace > 1) {\n\t\t\t\t\t\tsvg.select('g.legend-title').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${availableSpace}, 0)`\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Move the legend down by 16 pixels to display legend text on top\n\t\t\t\t\t\tsvg.select('g.legend').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${xDimensions[0]}, 16)`\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Align legend title with start of axis\n\t\t\t\t\t\tsvg.select('g.legend-title').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${xDimensions[0]}, 0)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Default state\n\t\t\tsvg.select('g.legend-title').attr('transform', `translate(0, 0)`);\n\t\t}\n\t};\n\n\trender(animate = false) {\n\t\tconst options = this.getOptions();\n\t\tconst svg = this.getComponentContainer();\n\t\tconst { width } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tconst customColors = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'gradient',\n\t\t\t'colors'\n\t\t);\n\n\t\tconst colorScaleType = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'heatmap',\n\t\t\t'colorLegend',\n\t\t\t'type'\n\t\t);\n\n\t\tlet colorPairingOption = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'pairing',\n\t\t\t'option'\n\t\t);\n\n\t\tconst title = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'heatmap',\n\t\t\t'colorLegend',\n\t\t\t'title'\n\t\t);\n\n\t\t// Clear DOM if loading\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\tif (isDataLoading) {\n\t\t\tsvg.html('');\n\t\t\treturn;\n\t\t}\n\n\t\tconst customColorsEnabled = !Tools.isEmpty(customColors);\n\t\tconst domain = this.model.getValueDomain();\n\n\t\tconst useDefaultBarWidth = !(\n\t\t\twidth <= Configuration.legend.color.barWidth\n\t\t);\n\t\tconst barWidth = useDefaultBarWidth\n\t\t\t? Configuration.legend.color.barWidth\n\t\t\t: width;\n\n\t\tconst legendGroupElement = DOMUtils.appendOrSelect(svg, 'g.legend');\n\t\tconst axisElement = DOMUtils.appendOrSelect(\n\t\t\tlegendGroupElement,\n\t\t\t'g.legend-axis'\n\t\t);\n\n\t\t// Render title if it exists\n\t\tif (title) {\n\t\t\tconst legendTitleGroup = DOMUtils.appendOrSelect(\n\t\t\t\tsvg,\n\t\t\t\t'g.legend-title'\n\t\t\t);\n\t\t\tconst legendTitle = DOMUtils.appendOrSelect(\n\t\t\t\tlegendTitleGroup,\n\t\t\t\t'text'\n\t\t\t);\n\t\t\tlegendTitle.text(title).attr('dy', '0.7em');\n\n\t\t\t// Move the legend down by 16 pixels to display legend text on top\n\t\t\tlegendGroupElement.attr('transform', `translate(0, 16)`);\n\t\t}\n\n\t\t// If domain consists of negative and positive values, use diverging palettes\n\t\tconst colorScheme = domain[0] < 0 && domain[1] > 0 ? 'diverge' : 'mono';\n\n\t\t// Use default color pairing options if not in defined range\n\t\tif (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 4 &&\n\t\t\tcolorScheme === 'mono'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t} else if (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 2 &&\n\t\t\tcolorScheme === 'diverge'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t}\n\n\t\tlet colorPairing = [];\n\t\t// Carbon charts has 11 colors for a single monochromatic palette & 17 for a divergent palette\n\t\tlet colorGroupingLength = colorScheme === 'diverge' ? 17 : 11;\n\n\t\tif (!customColorsEnabled) {\n\t\t\t// Add class names to list and the amount based on the color scheme\n\t\t\tfor (let i = 1; i < colorGroupingLength + 1; i++) {\n\t\t\t\tcolorPairing.push(\n\t\t\t\t\tcolorScaleType === ColorLegendType.LINEAR\n\t\t\t\t\t\t? `stop-color-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t\t\t: `fill-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\t// Use custom colors\n\t\t\tcolorPairing = customColors;\n\t\t}\n\n\t\t// Generate equal chunks between range to act as ticks\n\t\tconst interpolator = interpolateNumber(domain[0], domain[1]);\n\t\tconst quant = quantize(interpolator, 3);\n\n\t\t// Create scale & ticks\n\t\tconst linearScale = scaleLinear().domain(domain).range([0, barWidth]);\n\n\t\tconst legendAxis = axisBottom(linearScale)\n\t\t\t.tickSize(0)\n\t\t\t.tickValues(quant);\n\n\t\tswitch (colorScaleType) {\n\t\t\tcase ColorLegendType.LINEAR:\n\t\t\t\tthis.drawLinear(colorPairing, legendGroupElement, barWidth);\n\t\t\t\tbreak;\n\t\t\tcase ColorLegendType.QUANTIZE:\n\t\t\t\tconst rangeStart = this.drawQuantize(\n\t\t\t\t\tcolorPairing,\n\t\t\t\t\tcolorScheme,\n\t\t\t\t\tcustomColorsEnabled,\n\t\t\t\t\tlegendGroupElement,\n\t\t\t\t\tbarWidth\n\t\t\t\t);\n\t\t\t\t// Using range provided by drawQuantize for alignment purposes\n\t\t\t\tlinearScale.range([rangeStart, barWidth]);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow Error('Entered color legend type is not supported.');\n\t\t}\n\n\t\t// Align axes at the bottom of the rectangle and delete the domain line\n\t\taxisElement\n\t\t\t.attr(\n\t\t\t\t'transform',\n\t\t\t\t`translate(0,${Configuration.legend.color.axisYTranslation})`\n\t\t\t)\n\t\t\t.call(legendAxis);\n\n\t\t// Remove auto generated axis bottom line\n\t\taxisElement.select('.domain').remove();\n\n\t\t// Translate first/last axis tick if barWidth equals chart width\n\t\t// Ensures text is not clipped when default bar width (300px) is not used\n\t\taxisElement\n\t\t\t.select('g.tick:last-of-type text')\n\t\t\t.style('text-anchor', useDefaultBarWidth ? 'middle' : 'end');\n\t\taxisElement\n\t\t\t.select('g.tick:first-of-type text')\n\t\t\t.style('text-anchor', useDefaultBarWidth ? 'middle' : 'start');\n\t}\n\n\t// Renders gradient legend\n\tdrawLinear(colorPairing, legendGroupElement, barWidth) {\n\t\tconst stopLengthPercentage = 100 / (colorPairing.length - 1);\n\n\t\t// Generate the gradient\n\t\tconst linearGradient = DOMUtils.appendOrSelect(\n\t\t\tlegendGroupElement,\n\t\t\t'linearGradient'\n\t\t);\n\t\t// Rendering gradient\n\t\tlinearGradient\n\t\t\t.attr('id', `${this.gradient_id}-legend`)\n\t\t\t.selectAll('stop')\n\t\t\t.data(colorPairing)\n\t\t\t.enter()\n\t\t\t.append('stop')\n\t\t\t.attr('offset', (_, i) => `${i * stopLengthPercentage}%`)\n\t\t\t.attr('class', (_, i) => colorPairing[i])\n\t\t\t.attr('stop-color', (d) => d);\n\n\t\t// Create the legend container\n\t\tconst rectangle = DOMUtils.appendOrSelect(legendGroupElement, 'rect');\n\t\trectangle\n\t\t\t.attr('width', barWidth)\n\t\t\t.attr('height', Configuration.legend.color.barHeight)\n\t\t\t.style('fill', `url(#${this.gradient_id}-legend)`);\n\t}\n\n\t/**\n\t * Renders quantized legend\n\t * @returns number (range start)\n\t */\n\tdrawQuantize(\n\t\tcolorPairing,\n\t\tcolorScheme,\n\t\tcustomColorsEnabled,\n\t\tlegendGroupElement,\n\t\tbarWidth\n\t) {\n\t\t// If divergent && non-custom color, remove 0/white from being displayed\n\t\tif (!customColorsEnabled && colorScheme === 'diverge') {\n\t\t\tcolorPairing.splice(colorPairing.length / 2, 1);\n\t\t}\n\n\t\tconst colorScaleBand = scaleBand()\n\t\t\t.domain(colorPairing)\n\t\t\t.range([0, barWidth]);\n\n\t\t// Render the quantized rectangles\n\t\tconst rectangle = DOMUtils.appendOrSelect(\n\t\t\tlegendGroupElement,\n\t\t\t'g.quantized-rect'\n\t\t);\n\n\t\trectangle\n\t\t\t.selectAll('rect')\n\t\t\t.data(colorScaleBand.domain())\n\t\t\t.join('rect')\n\t\t\t.attr('x', (d) => colorScaleBand(d))\n\t\t\t.attr('y', 0)\n\t\t\t.attr('width', Math.max(0, colorScaleBand.bandwidth() - 1))\n\t\t\t.attr('height', Configuration.legend.color.barHeight)\n\t\t\t.attr('class', (d) => d)\n\t\t\t.attr('fill', (d) => d);\n\n\t\treturn (!customColorsEnabled && colorScheme) === 'mono'\n\t\t\t? colorScaleBand.bandwidth() - 1\n\t\t\t: 0;\n\t}\n\n\tdestroy() {\n\t\t// Remove legend listeners\n\t\tconst eventsFragment = this.services.events;\n\t\teventsFragment.removeEventListener(\n\t\t\tEvents.Axis.RENDER_COMPLETE,\n\t\t\tthis.handleAxisCompleteEvent\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"color-scale-legend.js","sourceRoot":"","sources":["color-scale-legend.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGrD,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE7D;IAAsC,oCAAM;IAQ3C,0BAAY,KAAiB,EAAE,QAAa,EAAE,OAAa;QAA3D,YACC,kBAAM,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,SAE/B;QAVD,U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N,CAAC;IAED,kCAAO,GAAP;QACC,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE;YACjC,0BAA0B;YAC1B,IAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5C,cAAc,CAAC,mBAAmB,CACjC,MAAM,CAAC,IAAI,CAAC,eAAe,EAC3B,IAAI,CAAC,uBAAuB,CAC5B,CAAC;SACF;IACF,CAAC;IACF,uBAAC;AAAD,CAAC,AA5VD,CAAsC,MAAM,GA4V3C","sourcesContent":["// Internal Imports\nimport * as Tools from '../../tools';\nimport { ColorLegendType, Events, RenderTypes } from '../../interfaces';\nimport * as Configuration from '../../configuration';\nimport { Legend } from './legend';\nimport { DOMUtils, getDomain } from '../../services';\nimport { ChartModel } from '../../model/model';\n\n// D3 imports\nimport { axisBottom } from 'd3-axis';\nimport { scaleBand, scaleLinear } from 'd3-scale';\nimport { interpolateNumber, quantize } from 'd3-interpolate';\n\nexport class ColorScaleLegend extends Legend {\n\ttype = 'color-legend';\n\trenderType = RenderTypes.SVG;\n\n\tprivate gradient_id =\n\t\t'gradient-id-' + Math.floor(Math.random() * 99999999999);\n\tprivate chartType: string;\n\n\tconstructor(model: ChartModel, services: any, configs?: any) {\n\t\tsuper(model, services, configs);\n\t\tthis.chartType = configs.chartType;\n\t}\n\n\tinit() {\n\t\t// Highlight correct circle on legend item hovers\n\t\tif (this.chartType === 'heatmap') {\n\t\t\tconst eventsFragment = this.services.events;\n\t\t\teventsFragment.addEventListener(\n\t\t\t\tEvents.Axis.RENDER_COMPLETE,\n\t\t\t\tthis.handleAxisCompleteEvent\n\t\t\t);\n\t\t}\n\t}\n\n\t// Position legend after axis have rendered\n\thandleAxisCompleteEvent = (event: CustomEvent) => {\n\t\tconst svg = this.getComponentContainer();\n\n\t\tconst { width } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\tif (width > Configuration.legend.color.barWidth && !isDataLoading) {\n\t\t\tconst title = Tools.getProperty(\n\t\t\t\tthis.getOptions(),\n\t\t\t\t'heatmap',\n\t\t\t\t'colorLegend',\n\t\t\t\t'title'\n\t\t\t);\n\n\t\t\tconst { cartesianScales } = this.services;\n\n\t\t\t// Get axis width & start/end positions\n\t\t\tconst mainXScale = cartesianScales.getMainXScale();\n\t\t\tconst xDimensions = mainXScale.range();\n\n\t\t\t// Align legend with the axis\n\t\t\tif (xDimensions[0] > 1) {\n\t\t\t\tsvg.select('g.legend').attr(\n\t\t\t\t\t'transform',\n\t\t\t\t\t`translate(${xDimensions[0]}, 0)`\n\t\t\t\t);\n\n\t\t\t\tif (title) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\twidth: textWidth,\n\t\t\t\t\t} = DOMUtils.getSVGElementSize(\n\t\t\t\t\t\tsvg.select('g.legend-title').select('text'),\n\t\t\t\t\t\t{ useBBox: true }\n\t\t\t\t\t);\n\n\t\t\t\t\t// D3 moves the LEFT y-axis labels by 9\n\t\t\t\t\tconst availableSpace = xDimensions[0] - textWidth - 9;\n\n\t\t\t\t\t// If space is available, align the label with the axis labels\n\t\t\t\t\tif (availableSpace > 1) {\n\t\t\t\t\t\tsvg.select('g.legend-title').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${availableSpace}, 0)`\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Move the legend down by 16 pixels to display legend text on top\n\t\t\t\t\t\tsvg.select('g.legend').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${xDimensions[0]}, 16)`\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Align legend title with start of axis\n\t\t\t\t\t\tsvg.select('g.legend-title').attr(\n\t\t\t\t\t\t\t'transform',\n\t\t\t\t\t\t\t`translate(${xDimensions[0]}, 0)`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Default state\n\t\t\tsvg.select('g.legend-title').attr('transform', `translate(0, 0)`);\n\t\t}\n\t};\n\n\trender(animate = false) {\n\t\tconst options = this.getOptions();\n\t\tconst svg = this.getComponentContainer();\n\t\tconst { width } = DOMUtils.getSVGElementSize(svg, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tconst customColors = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'gradient',\n\t\t\t'colors'\n\t\t);\n\n\t\tconst colorScaleType = Tools.getProperty(\n\t\t\toptions,\n\t\t\tthis.chartType,\n\t\t\t'colorLegend',\n\t\t\t'type'\n\t\t);\n\n\t\tlet colorPairingOption = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'color',\n\t\t\t'pairing',\n\t\t\t'option'\n\t\t);\n\n\t\tconst title = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'heatmap',\n\t\t\t'colorLegend',\n\t\t\t'title'\n\t\t);\n\n\t\t// Clear DOM if loading\n\t\tconst isDataLoading = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'data',\n\t\t\t'loading'\n\t\t);\n\n\t\tif (isDataLoading) {\n\t\t\tsvg.html('');\n\t\t\treturn;\n\t\t}\n\n\t\tconst customColorsEnabled = !Tools.isEmpty(customColors);\n\t\tconst domain = getDomain(this.model.getDisplayData());\n\n\t\tconst useDefaultBarWidth = !(\n\t\t\twidth <= Configuration.legend.color.barWidth\n\t\t);\n\t\tconst barWidth = useDefaultBarWidth\n\t\t\t? Configuration.legend.color.barWidth\n\t\t\t: width;\n\n\t\tconst legendGroupElement = DOMUtils.appendOrSelect(svg, 'g.legend');\n\t\tconst axisElement = DOMUtils.appendOrSelect(\n\t\t\tlegendGroupElement,\n\t\t\t'g.legend-axis'\n\t\t);\n\n\t\t// Render title if it exists\n\t\tif (title) {\n\t\t\tconst legendTitleGroup = DOMUtils.appendOrSelect(\n\t\t\t\tsvg,\n\t\t\t\t'g.legend-title'\n\t\t\t);\n\t\t\tconst legendTitle = DOMUtils.appendOrSelect(\n\t\t\t\tlegendTitleGroup,\n\t\t\t\t'text'\n\t\t\t);\n\t\t\tlegendTitle.text(title).attr('dy', '0.7em');\n\n\t\t\t// Move the legend down by 16 pixels to display legend text on top\n\t\t\tlegendGroupElement.attr('transform', `translate(0, 16)`);\n\t\t}\n\n\t\t// If domain consists of negative and positive values, use diverging palettes\n\t\tconst colorScheme = domain[0] < 0 && domain[1] > 0 ? 'diverge' : 'mono';\n\n\t\t// Use default color pairing options if not in defined range\n\t\tif (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 4 &&\n\t\t\tcolorScheme === 'mono'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t} else if (\n\t\t\tcolorPairingOption < 1 &&\n\t\t\tcolorPairingOption > 2 &&\n\t\t\tcolorScheme === 'diverge'\n\t\t) {\n\t\t\tcolorPairingOption = 1;\n\t\t}\n\n\t\tlet colorPairing = [];\n\t\t// Carbon charts has 11 colors for a single monochromatic palette & 17 for a divergent palette\n\t\tlet colorGroupingLength = colorScheme === 'diverge' ? 17 : 11;\n\n\t\tif (!customColorsEnabled) {\n\t\t\t// Add class names to list and the amount based on the color scheme\n\t\t\tfor (let i = 1; i < colorGroupingLength + 1; i++) {\n\t\t\t\tcolorPairing.push(\n\t\t\t\t\tcolorScaleType === ColorLegendType.LINEAR\n\t\t\t\t\t\t? `stop-color-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t\t\t: `fill-${colorScheme}-${colorPairingOption}-${i}`\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\t// Use custom colors\n\t\t\tcolorPairing = customColors;\n\t\t}\n\n\t\t// Generate equal chunks between range to act as ticks\n\t\tconst interpolator = interpolateNumber(domain[0], domain[1]);\n\t\tconst quant = quantize(interpolator, 3);\n\n\t\t// Create scale & ticks\n\t\tconst linearScale = scaleLinear().domain(domain).range([0, barWidth]);\n\n\t\tconst legendAxis = axisBottom(linearScale)\n\t\t\t.tickSize(0)\n\t\t\t.tickValues(quant);\n\n\t\tswitch (colorScaleType) {\n\t\t\tcase ColorLegendType.LINEAR:\n\t\t\t\tthis.drawLinear(colorPairing, legendGroupElement, barWidth);\n\t\t\t\tbreak;\n\t\t\tcase ColorLegendType.QUANTIZE:\n\t\t\t\tconst rangeStart = this.drawQuantize(\n\t\t\t\t\tcolorPairing,\n\t\t\t\t\tcolorScheme,\n\t\t\t\t\tcustomColorsEnabled,\n\t\t\t\t\tlegendGroupElement,\n\t\t\t\t\tbarWidth\n\t\t\t\t);\n\t\t\t\t// Using range provided by drawQuantize for alignment purposes\n\t\t\t\tlinearScale.range([rangeStart, barWidth]);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow Error('Entered color legend type is not supported.');\n\t\t}\n\n\t\t// Align axes at the bottom of the rectangle and delete the domain line\n\t\taxisElement\n\t\t\t.attr(\n\t\t\t\t'transform',\n\t\t\t\t`translate(0,${Configuration.legend.color.axisYTranslation})`\n\t\t\t)\n\t\t\t.call(legendAxis);\n\n\t\t// Remove auto generated axis bottom line\n\t\taxisElement.select('.domain').remove();\n\n\t\t// Translate first/last axis tick if barWidth equals chart width\n\t\t// Ensures text is not clipped when default bar width (300px) is not used\n\t\taxisElement\n\t\t\t.select('g.tick:last-of-type text')\n\t\t\t.style('text-anchor', useDefaultBarWidth ? 'middle' : 'end');\n\t\taxisElement\n\t\t\t.select('g.tick:first-of-type text')\n\t\t\t.style(\n\t\t\t\t'text-anchor',\n\t\t\t\tuseDefaultBarWidth && this.chartType !== 'choropleth'\n\t\t\t\t\t? 'middle'\n\t\t\t\t\t: 'start'\n\t\t\t);\n\t}\n\n\t// Renders gradient legend\n\tdrawLinear(colorPairing, legendGroupElement, barWidth) {\n\t\tconst stopLengthPercentage = 100 / (colorPairing.length - 1);\n\n\t\t// Generate the gradient\n\t\tconst linearGradient = DOMUtils.appendOrSelect(\n\t\t\tlegendGroupElement,\n\t\t\t'linearGradient'\n\t\t);\n\t\t// Rendering gradient\n\t\tlinearGradient\n\t\t\t.attr('id', `${this.gradient_id}-legend`)\n\t\t\t.selectAll('stop')\n\t\t\t.data(colorPairing)\n\t\t\t.enter()\n\t\t\t.append('stop')\n\t\t\t.attr('offset', (_, i) => `${i * stopLengthPercentage}%`)\n\t\t\t.attr('class', (_, i) => colorPairing[i])\n\t\t\t.attr('stop-color', (d) => d);\n\n\t\t// Create the legend container\n\t\tconst rectangle = DOMUtils.appendOrSelect(legendGroupElement, 'rect');\n\t\trectangle\n\t\t\t.attr('width', barWidth)\n\t\t\t.attr('height', Configuration.legend.color.barHeight)\n\t\t\t.style('fill', `url(#${this.gradient_id}-legend)`);\n\t}\n\n\t/**\n\t * Renders quantized legend\n\t * @returns number (range start)\n\t */\n\tdrawQuantize(\n\t\tcolorPairing,\n\t\tcolorScheme,\n\t\tcustomColorsEnabled,\n\t\tlegendGroupElement,\n\t\tbarWidth\n\t) {\n\t\t// If divergent && non-custom color, remove 0/white from being displayed\n\t\tif (!customColorsEnabled && colorScheme === 'diverge') {\n\t\t\tcolorPairing.splice(colorPairing.length / 2, 1);\n\t\t}\n\n\t\tconst colorScaleBand = scaleBand()\n\t\t\t.domain(colorPairing)\n\t\t\t.range([0, barWidth]);\n\n\t\t// Render the quantized rectangles\n\t\tconst rectangle = DOMUtils.appendOrSelect(\n\t\t\tlegendGroupElement,\n\t\t\t'g.quantized-rect'\n\t\t);\n\n\t\trectangle\n\t\t\t.selectAll('rect')\n\t\t\t.data(colorScaleBand.domain())\n\t\t\t.join('rect')\n\t\t\t.attr('x', (d) => colorScaleBand(d))\n\t\t\t.attr('y', 0)\n\t\t\t.attr('width', Math.max(0, colorScaleBand.bandwidth() - 1))\n\t\t\t.attr('height', Configuration.legend.color.barHeight)\n\t\t\t.attr('class', (d) => d)\n\t\t\t.attr('fill', (d) => d);\n\n\t\treturn (!customColorsEnabled && colorScheme) === 'mono'\n\t\t\t? colorScaleBand.bandwidth() - 1\n\t\t\t: 0;\n\t}\n\n\tdestroy() {\n\t\tif (this.chartType === 'heatmap') {\n\t\t\t// Remove legend listeners\n\t\t\tconst eventsFragment = this.services.events;\n\t\t\teventsFragment.removeEventListener(\n\t\t\t\tEvents.Axis.RENDER_COMPLETE,\n\t\t\t\tthis.handleAxisCompleteEvent\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { Component } from '../component';
2
+ import { RenderTypes } from '../../interfaces';
3
+ export declare class GeoProjection extends Component {
4
+ type: string;
5
+ renderType: RenderTypes;
6
+ render(): void;
7
+ /**
8
+ * @info
9
+ * Depending on projection, we may need to provide additional configuration
10
+ * e.g. sizing
11
+ *
12
+ * In such case, function can be refactored so that
13
+ * projection should return an object with the configuraiton & function
14
+ */
15
+ getProjection(): any;
16
+ }
@@ -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