@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.
- package/CHANGELOG.md +26 -0
- package/build/demo/data/CHART_TYPES.d.ts +5 -0
- package/build/demo/data/choropleth.d.ts +738 -0
- package/build/demo/data/index.d.ts +1 -0
- package/build/demo/data/topojson-110.d.ts +360 -0
- package/build/src/charts/choropleth.d.ts +10 -0
- package/build/src/charts/index.d.ts +1 -0
- package/build/src/components/essentials/color-scale-legend.d.ts +3 -0
- package/build/src/components/essentials/geo-projection.d.ts +16 -0
- package/build/src/components/graphs/choropleth.d.ts +6 -0
- package/build/src/components/index.d.ts +2 -0
- package/build/src/configuration.d.ts +3 -1
- package/build/src/interfaces/charts.d.ts +28 -1
- package/build/src/interfaces/enums.d.ts +12 -0
- package/build/src/interfaces/events.d.ts +9 -0
- package/build/src/model/choropleth.d.ts +29 -0
- package/build/src/model/heatmap.d.ts +0 -5
- package/build/src/services/color-scale-utils.d.ts +10 -0
- package/build/src/services/index.d.ts +1 -0
- package/build/src/services/scales-cartesian.d.ts +1 -1
- package/bundle.js +2 -2
- package/charts/choropleth.d.ts +10 -0
- package/charts/choropleth.js +141 -0
- package/charts/choropleth.js.map +1 -0
- package/charts/heatmap.js +5 -1
- package/charts/heatmap.js.map +1 -1
- package/charts/index.d.ts +1 -0
- package/charts/index.js +1 -0
- package/charts/index.js.map +1 -1
- package/components/axes/chart-clip.js +7 -5
- package/components/axes/chart-clip.js.map +1 -1
- package/components/axes/grid-brush.js +12 -9
- package/components/axes/grid-brush.js.map +1 -1
- package/components/essentials/color-scale-legend.d.ts +3 -0
- package/components/essentials/color-scale-legend.js +18 -11
- package/components/essentials/color-scale-legend.js.map +1 -1
- package/components/essentials/geo-projection.d.ts +16 -0
- package/components/essentials/geo-projection.js +160 -0
- package/components/essentials/geo-projection.js.map +1 -0
- package/components/essentials/title-meter.js +1 -1
- package/components/essentials/title-meter.js.map +1 -1
- package/components/graphs/choropleth.d.ts +6 -0
- package/components/graphs/choropleth.js +106 -0
- package/components/graphs/choropleth.js.map +1 -0
- package/components/graphs/radar.js +1 -1
- package/components/graphs/radar.js.map +1 -1
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -0
- package/components/index.js.map +1 -1
- package/configuration.d.ts +3 -1
- package/configuration.js +18 -1
- package/configuration.js.map +1 -1
- package/demo/create-codesandbox.js +20 -2
- package/demo/create-codesandbox.js.map +1 -1
- package/demo/data/CHART_TYPES.d.ts +5 -0
- package/demo/data/CHART_TYPES.js +5 -0
- package/demo/data/CHART_TYPES.js.map +1 -1
- package/demo/data/bundle.js +1 -1
- package/demo/data/choropleth.d.ts +738 -0
- package/demo/data/choropleth.js +1684 -0
- package/demo/data/choropleth.js.map +1 -0
- package/demo/data/index.d.ts +1 -0
- package/demo/data/index.js +45 -5
- package/demo/data/index.js.map +1 -1
- package/demo/data/topojson-110.d.ts +360 -0
- package/demo/data/topojson-110.js +40724 -0
- package/demo/data/topojson-110.js.map +1 -0
- package/demo/styles.css +410 -185
- package/demo/styles.css.map +1 -1
- package/demo/styles.min.css +1 -1
- package/demo/styles.min.css.map +1 -1
- package/demo/tsconfig.tsbuildinfo +25 -6
- package/demo/utils.js +29 -1
- package/demo/utils.js.map +1 -1
- package/interfaces/charts.d.ts +28 -1
- package/interfaces/charts.js.map +1 -1
- package/interfaces/enums.d.ts +12 -0
- package/interfaces/enums.js +16 -0
- package/interfaces/enums.js.map +1 -1
- package/interfaces/events.d.ts +9 -0
- package/interfaces/events.js +10 -0
- package/interfaces/events.js.map +1 -1
- package/model/choropleth.d.ts +29 -0
- package/model/choropleth.js +105 -0
- package/model/choropleth.js.map +1 -0
- package/model/heatmap.d.ts +0 -5
- package/model/heatmap.js +3 -64
- package/model/heatmap.js.map +1 -1
- package/package.json +4 -3
- package/services/color-scale-utils.d.ts +2 -0
- package/services/color-scale-utils.js +64 -0
- package/services/color-scale-utils.js.map +1 -0
- package/services/index.d.ts +1 -0
- package/services/index.js +1 -0
- package/services/index.js.map +1 -1
- package/styles/color-palatte.scss +96 -0
- package/styles/colors.scss +23 -8
- package/styles/graphs/_choropleth.scss +18 -0
- package/styles/graphs/index.scss +1 -0
- package/styles.css +156 -144
- package/styles.css.map +1 -1
- package/styles.min.css +1 -1
- package/styles.min.css.map +1 -1
- package/tsconfig.tsbuildinfo +419 -47
|
@@ -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;QAEF,6CAA6C;QAC7C,KAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;;IACjC,CAAC;IAED,4DAA4D;IAC5D,sFAAsF;IAC5E,yDAAkB,GAA5B,UAA6B,oBAA2B,EAAE,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AI,cAAc,EAAE;YACrC,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAE/C,IAAM,oBAAoB,GAAG;gBAC5B,EAAE,EAAE,QAAQ;gBACZ,UAAU,EAAE;oBACX,IAAI,MAAM,CACT,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EACb,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CACzC;iBACD;gBACD,MAAM,EAAE,YAAY,CAAC,SAAS;aAC9B,CAAC;YAEF,wBAAwB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;SACpD;QACD,wBAAwB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAElD,OAAO;YACN,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACtC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACpC,IAAI,eAAe,CAClB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EACb,wBAAwB,EACxB;gBACC,SAAS,EAAE,eAAe,CAAC,MAAM;aACjC,CACD;SACD,CAAC;IACH,CAAC;IAED,oDAAa,GAAb;QACC,gDAAgD;QAChD,IAAM,oBAAoB,GAAQ;YACjC,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;SACzC,CAAC;QAEF,IAAM,UAAU,GAAU,IAAI,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;QACxE,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,mCAAC;AAAD,CAAC,AA3JD,CAAkD,KAAK,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: [
|
|
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
|
};
|
package/charts/heatmap.js.map
CHANGED
|
@@ -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,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACxC,IAAM,cAAc,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c,IAAI,cAAc,EAAE;YACrC,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAE/C,IAAM,oBAAoB,GAAG;gBAC5B,EAAE,EAAE,QAAQ;gBACZ,UAAU,EAAE;oBACX,IAAI,MAAM,CACT,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EACb,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CACzC;iBACD;gBACD,MAAM,EAAE,YAAY,CAAC,SAAS;aAC9B,CAAC;YAEF,wBAAwB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;SACpD;QACD,wBAAwB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAElD,OAAO;YACN,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YAChD,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACpC,IAAI,eAAe,CAClB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EACb,wBAAwB,EACxB;gBACC,SAAS,EAAE,eAAe,CAAC,MAAM;aACjC,CACD;SACD,CAAC;IACH,CAAC;IAED,oCAAa,GAAb;QACC,gDAAgD;QAChD,IAAM,oBAAoB,GAAG;YAC5B,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACjD,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;SACtC,CAAC;QAEF,IAAM,UAAU,GAAU,IAAI,CAAC,sBAAsB,CACpD,oBAAoB,CACpB,CAAC;QACF,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,mBAAC;AAAD,CAAC,AArKD,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
package/charts/index.js
CHANGED
package/charts/index.js.map
CHANGED
|
@@ -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"]}
|
|
@@ -48,11 +48,13 @@ var ChartClip = /** @class */ (function (_super) {
|
|
|
48
48
|
// Get height
|
|
49
49
|
this.chartClipPath = DOMUtils.appendOrSelect(svg, "clipPath." + this.type).attr('id', this.chartClipId);
|
|
50
50
|
var clipRect = DOMUtils.appendOrSelect(this.chartClipPath, "rect." + this.type);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
if (xScaleEnd - xScaleStart > 0) {
|
|
52
|
+
clipRect
|
|
53
|
+
.attr('x', xScaleStart)
|
|
54
|
+
.attr('y', yScaleStart)
|
|
55
|
+
.attr('width', xScaleEnd - xScaleStart)
|
|
56
|
+
.attr('height', yScaleEnd - yScaleStart);
|
|
57
|
+
}
|
|
56
58
|
this.chartClipPath.merge(clipRect).lower();
|
|
57
59
|
};
|
|
58
60
|
return ChartClip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-clip.js","sourceRoot":"","sources":["chart-clip.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,yEAAyE;AACzE,0CAA0C;AAC1C;IAA+B,6BAAS;IAUvC,mBAAY,KAAiB,EAAE,QAAa,EAAE,OAAa;QAA3D,YACC,kBAAM,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,SAE/B;QAZD,UAAI,GAAG,YAAY,CAAC;QACpB,gBAAU,GAAG,WAAW,CAAC,GAAG,CAAC;QAE7B,sCAAsC;QACtC,oEAAoE;QACpE,iBAAW,GAAG,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC;QAMxE,KAAI,CAAC,IAAI,EAAE,CAAC;;IACb,CAAC;IAED,wBAAI,GAAJ;QACC,gDAAgD;QAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,0BAAM,GAAN,UAAO,OAAc;QAAd,wBAAA,EAAA,cAAc;QACpB,sBAAsB;QACtB,IAAI,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC;IA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AAK,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;IACF,gBAAC;AAAD,CAAC,AAtDD,CAA+B,SAAS,GAsDvC","sourcesContent":["// Internal Imports\nimport { Component } from '../component';\nimport { DOMUtils } from '../../services';\nimport { ChartModel } from '../../model/model';\nimport { RenderTypes } from '../../interfaces';\n\n// This class is used to create the clipPath to clip the chart components\n// It's necessary for zoom in/out behavior\nexport class ChartClip extends Component {\n\ttype = 'chart-clip';\n\trenderType = RenderTypes.SVG;\n\n\t// Give every chart-clip a distinct ID\n\t// so they don't interfere each other in a page with multiple charts\n\tchartClipId = 'chart-clip-id-' + Math.floor(Math.random() * 99999999999);\n\n\tchartClipPath: any;\n\n\tconstructor(model: ChartModel, services: any, configs?: any) {\n\t\tsuper(model, services, configs);\n\t\tthis.init();\n\t}\n\n\tinit() {\n\t\t// set unique chartClipId in this chart to model\n\t\tthis.model.set({ chartClipId: this.chartClipId }, { skipUpdate: true });\n\t}\n\n\trender(animate = true) {\n\t\t// Create the clipPath\n\t\tthis.createClipPath();\n\t}\n\n\tcreateClipPath() {\n\t\tconst svg = this.parent;\n\t\tconst { cartesianScales } = this.services;\n\t\tconst mainXScale = cartesianScales.getMainXScale();\n\t\tconst mainYScale = cartesianScales.getMainYScale();\n\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tconst [yScaleEnd, yScaleStart] = mainYScale.range();\n\n\t\t// Get height\n\t\tthis.chartClipPath = DOMUtils.appendOrSelect(\n\t\t\tsvg,\n\t\t\t`clipPath.${this.type}`\n\t\t).attr('id', this.chartClipId);\n\t\tconst clipRect = DOMUtils.appendOrSelect(\n\t\t\tthis.chartClipPath,\n\t\t\t`rect.${this.type}`\n\t\t);\n\n\t\tif (xScaleEnd - xScaleStart > 0) {\n\t\t\tclipRect\n\t\t\t\t.attr('x', xScaleStart)\n\t\t\t\t.attr('y', yScaleStart)\n\t\t\t\t.attr('width', xScaleEnd - xScaleStart)\n\t\t\t\t.attr('height', yScaleEnd - yScaleStart);\n\t\t}\n\n\t\tthis.chartClipPath.merge(clipRect).lower();\n\t}\n}\n"]}
|
|
@@ -119,6 +119,7 @@ var ChartBrush = /** @class */ (function (_super) {
|
|
|
119
119
|
_this.services.zoom.handleDomainChange(newDomain);
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
+
var brush_1;
|
|
122
123
|
var brushed = function (event) {
|
|
123
124
|
// max selection range: [0, width]
|
|
124
125
|
var selection = event.selection;
|
|
@@ -131,15 +132,17 @@ var ChartBrush = /** @class */ (function (_super) {
|
|
|
131
132
|
frontSelection.style('display', 'none');
|
|
132
133
|
}
|
|
133
134
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
if (height != 0 && width != 0) {
|
|
136
|
+
// leave some space to display selection strokes besides axis
|
|
137
|
+
brush_1 = brushX()
|
|
138
|
+
.extent([
|
|
139
|
+
[0, 0],
|
|
140
|
+
[width - 1, height],
|
|
141
|
+
])
|
|
142
|
+
.on('start brush end', brushEventHandler)
|
|
143
|
+
.on('end.brushed', brushed);
|
|
144
|
+
brushArea.call(brush_1);
|
|
145
|
+
}
|
|
143
146
|
var zoomRatio_1 = this.services.zoom.getZoomRatio();
|
|
144
147
|
backdrop.on('click', function (event) {
|
|
145
148
|
if (event.shiftKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-brush.js","sourceRoot":"","sources":["grid-brush.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAU,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,U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,CAAC,EAAE,CAAC,CAAC;gBACN,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC;aACnB,CAAC;iBACD,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;iBACxC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YAE7B,SAAS,CAAC,IAAI,CAAC,OAAK,CAAC,CAAC;YAEtB,IAAM,WAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACpD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK;gBACnC,IAAI,KAAK,CAAC,QAAQ,EAAE;oBACnB,IAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;oBAElD,6BAA6B;oBAC7B,IAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;oBAEtD,IAAI,SAAS,GAAG,QAAQ,GAAG,CAAC,KAAK,GAAG,WAAS,CAAC,GAAG,CAAC,CAAC;oBACnD,IAAI,SAAS,GAAG,CAAC,EAAE;wBAClB,SAAS,GAAG,CAAC,CAAC;qBACd;oBACD,IAAI,UAAU,GAAG,QAAQ,GAAG,CAAC,KAAK,GAAG,WAAS,CAAC,GAAG,CAAC,CAAC;oBACpD,IAAI,UAAU,GAAG,KAAK,EAAE;wBACvB,UAAU,GAAG,KAAK,CAAC;qBACnB;oBACD,mDAAmD;oBACnD,kBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;iBACxC;YACF,CAAC,CAAC,CAAC;SACH;IACF,CAAC;IA1KM,sBAAW,GAAG,CAAC,CAAC;IA2KxB,iBAAC;CAAA,AA5KD,CAAgC,SAAS,GA4KxC;SA5KY,UAAU","sourcesContent":["// Internal Imports\nimport { Component } from '../component';\nimport { Events, RenderTypes, ScaleTypes } from '../../interfaces';\nimport { DOMUtils } from '../../services';\n\n// D3 Imports\nimport { brushX } from 'd3-brush';\nimport { scaleTime } from 'd3-scale';\n// @ts-ignore\n// ts-ignore is needed because `@types/d3`\n// is missing the `pointer` function\nimport { pointer } from 'd3-selection';\n\n// This class is used for handle brush events in chart\nexport class ChartBrush extends Component {\n\tstatic DASH_LENGTH = 4;\n\n\ttype = 'grid-brush';\n\trenderType = RenderTypes.SVG;\n\n\tselectionSelector = 'rect.selection'; // needs to match the class name in d3.brush\n\n\tfrontSelectionSelector = 'rect.frontSelection'; // needs to match the class name in _grid-brush.scss\n\n\trender(animate = true) {\n\t\tconst svg = this.parent;\n\n\t\t// use this area to display selection above all graphs\n\t\tconst frontSelectionArea = this.getComponentContainer();\n\t\tconst backdrop = DOMUtils.appendOrSelect(\n\t\t\tsvg,\n\t\t\t'svg.chart-grid-backdrop'\n\t\t);\n\t\t// use this area to handle d3 brush events\n\t\tconst brushArea = DOMUtils.appendOrSelect(backdrop, `g.${this.type}`);\n\n\t\t// set an id for rect.selection to be referred\n\t\tconst d3Selection = DOMUtils.appendOrSelect(\n\t\t\tbrushArea,\n\t\t\tthis.selectionSelector\n\t\t);\n\n\t\tconst { width, height } = DOMUtils.getSVGElementSize(backdrop, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tconst { cartesianScales } = this.services;\n\t\tconst mainXScaleType = cartesianScales.getMainXScaleType();\n\t\tconst mainXScale = cartesianScales.getMainXScale();\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tfrontSelectionArea.attr('transform', `translate(${xScaleStart},0)`);\n\t\tconst frontSelection = DOMUtils.appendOrSelect(\n\t\t\tfrontSelectionArea,\n\t\t\tthis.frontSelectionSelector\n\t\t);\n\n\t\tif (mainXScale && mainXScaleType === ScaleTypes.TIME) {\n\t\t\t// get current zoomDomain\n\t\t\tlet zoomDomain = this.model.get('zoomDomain');\n\t\t\tif (zoomDomain === undefined) {\n\t\t\t\t// default to full range with extended domain\n\t\t\t\tzoomDomain = this.services.zoom.getDefaultZoomBarDomain();\n\t\t\t\tif (zoomDomain) {\n\t\t\t\t\tthis.model.set(\n\t\t\t\t\t\t{ zoomDomain: zoomDomain },\n\t\t\t\t\t\t{ animate: false }\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst updateSelectionDash = (selection) => {\n\t\t\t\t// set end drag point to dash\n\t\t\t\tconst selectionWidth = selection[1] - selection[0];\n\t\t\t\tlet dashArray = '0,' + selectionWidth.toString(); // top (invisible)\n\n\t\t\t\t// right\n\t\t\t\tconst dashCount = Math.floor(height / ChartBrush.DASH_LENGTH);\n\t\t\t\tconst totalRightDash = dashCount * ChartBrush.DASH_LENGTH;\n\t\t\t\tfor (let i = 0; i < dashCount; i++) {\n\t\t\t\t\tdashArray += ',' + ChartBrush.DASH_LENGTH; // for each full length dash\n\t\t\t\t}\n\t\t\t\tdashArray += ',' + (height - totalRightDash); // for rest of the right height\n\t\t\t\t// if dash count is even, one more \",0\" is needed to make total right dash pattern even\n\t\t\t\tif (dashCount % 2 === 1) {\n\t\t\t\t\tdashArray += ',0';\n\t\t\t\t}\n\t\t\t\tdashArray += ',' + selectionWidth.toString(); // bottom (invisible)\n\t\t\t\tdashArray += ',' + height.toString(); // left\n\t\t\t\tfrontSelection.attr('stroke-dasharray', dashArray);\n\t\t\t};\n\n\t\t\tconst brushEventHandler = (event) => {\n\t\t\t\t// selection range: [0, width]\n\t\t\t\tconst selection = event.selection;\n\t\t\t\tif (selection === null || selection[0] === selection[1]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// copy the d3 selection attrs to front selection element\n\t\t\t\tfrontSelection\n\t\t\t\t\t.attr(\n\t\t\t\t\t\t'x',\n\t\t\t\t\t\tparseFloat(d3Selection.attr('x')) +\n\t\t\t\t\t\t\tparseFloat(backdrop.attr('x'))\n\t\t\t\t\t)\n\t\t\t\t\t.attr('y', d3Selection.attr('y'))\n\t\t\t\t\t.attr('width', d3Selection.attr('width'))\n\t\t\t\t\t.attr('height', d3Selection.attr('height'))\n\t\t\t\t\t.style('cursor', 'pointer')\n\t\t\t\t\t.style('display', null);\n\n\t\t\t\tupdateSelectionDash(selection);\n\t\t\t};\n\n\t\t\t// assume max range is [0, width]\n\t\t\tconst updateZoomDomain = (startPoint, endPoint) => {\n\t\t\t\t// create xScale based on current zoomDomain\n\t\t\t\tconst xScale = scaleTime().range([0, width]).domain(zoomDomain);\n\n\t\t\t\tlet newDomain = [\n\t\t\t\t\txScale.invert(startPoint),\n\t\t\t\t\txScale.invert(endPoint),\n\t\t\t\t];\n\t\t\t\t// if selected start time and end time are the same\n\t\t\t\t// reset to default full range\n\t\t\t\tif (newDomain[0].valueOf() === newDomain[1].valueOf()) {\n\t\t\t\t\t// same as d3 behavior and zoom bar behavior: set to default full range\n\t\t\t\t\tnewDomain = this.services.zoom.getDefaultZoomBarDomain();\n\t\t\t\t}\n\n\t\t\t\t// only if zoomDomain needs update\n\t\t\t\tif (\n\t\t\t\t\tzoomDomain[0].valueOf() !== newDomain[0].valueOf() ||\n\t\t\t\t\tzoomDomain[1].valueOf() !== newDomain[1].valueOf()\n\t\t\t\t) {\n\t\t\t\t\tthis.services.zoom.handleDomainChange(newDomain);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst brushed = (event) => {\n\t\t\t\t// max selection range: [0, width]\n\t\t\t\tconst selection = event.selection;\n\n\t\t\t\tif (selection !== null) {\n\t\t\t\t\t// updateZoomDomain assumes max range is [0, width]\n\t\t\t\t\tupdateZoomDomain(selection[0], selection[1]);\n\n\t\t\t\t\t// clear brush selection\n\t\t\t\t\tbrushArea.call(brush.move, null);\n\t\t\t\t\t// hide frontSelection\n\t\t\t\t\tfrontSelection.style('display', 'none');\n\t\t\t\t}\n\t\t\t};\n\t\t\t// leave some space to display selection strokes besides axis\n\t\t\tconst brush = brushX()\n\t\t\t\t.extent([\n\t\t\t\t\t[0, 0],\n\t\t\t\t\t[width - 1, height],\n\t\t\t\t])\n\t\t\t\t.on('start brush end', brushEventHandler)\n\t\t\t\t.on('end.brushed', brushed);\n\n\t\t\tbrushArea.call(brush);\n\n\t\t\tconst zoomRatio = this.services.zoom.getZoomRatio();\n\t\t\tbackdrop.on('click', function (event) {\n\t\t\t\tif (event.shiftKey) {\n\t\t\t\t\tconst holder = this.services.domUtils.getHolder();\n\n\t\t\t\t\t// clickedX range: [0, width]\n\t\t\t\t\tconst clickedX = pointer(brushArea.node(), holder)[0];\n\n\t\t\t\t\tlet leftPoint = clickedX - (width * zoomRatio) / 2;\n\t\t\t\t\tif (leftPoint < 0) {\n\t\t\t\t\t\tleftPoint = 0;\n\t\t\t\t\t}\n\t\t\t\t\tlet rightPoint = clickedX + (width * zoomRatio) / 2;\n\t\t\t\t\tif (rightPoint > width) {\n\t\t\t\t\t\trightPoint = width;\n\t\t\t\t\t}\n\t\t\t\t\t// updateZoomDomain assumes max range is [0, width]\n\t\t\t\t\tupdateZoomDomain(leftPoint, rightPoint);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grid-brush.js","sourceRoot":"","sources":["grid-brush.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAU,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,aAAa;AACb,0CAA0C;AAC1C,oCAAoC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,sDAAsD;AACtD;IAAgC,8BAAS;IAAzC;QAAA,qEAiLC;QA9KA,UAAI,GAAG,YAAY,CAAC;QACpB,gBAAU,GAAG,WAAW,CAAC,GAAG,CA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S,CAAC,IAAI,CAAC,OAAK,CAAC,CAAC;aACtB;YAED,IAAM,WAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACpD,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK;gBACnC,IAAI,KAAK,CAAC,QAAQ,EAAE;oBACnB,IAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;oBAElD,6BAA6B;oBAC7B,IAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;oBAEtD,IAAI,SAAS,GAAG,QAAQ,GAAG,CAAC,KAAK,GAAG,WAAS,CAAC,GAAG,CAAC,CAAC;oBACnD,IAAI,SAAS,GAAG,CAAC,EAAE;wBAClB,SAAS,GAAG,CAAC,CAAC;qBACd;oBACD,IAAI,UAAU,GAAG,QAAQ,GAAG,CAAC,KAAK,GAAG,WAAS,CAAC,GAAG,CAAC,CAAC;oBACpD,IAAI,UAAU,GAAG,KAAK,EAAE;wBACvB,UAAU,GAAG,KAAK,CAAC;qBACnB;oBACD,mDAAmD;oBACnD,kBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;iBACxC;YACF,CAAC,CAAC,CAAC;SACH;IACF,CAAC;IA/KM,sBAAW,GAAG,CAAC,CAAC;IAgLxB,iBAAC;CAAA,AAjLD,CAAgC,SAAS,GAiLxC;SAjLY,UAAU","sourcesContent":["// Internal Imports\nimport { Component } from '../component';\nimport { Events, RenderTypes, ScaleTypes } from '../../interfaces';\nimport { DOMUtils } from '../../services';\n\n// D3 Imports\nimport { brushX } from 'd3-brush';\nimport { scaleTime } from 'd3-scale';\n// @ts-ignore\n// ts-ignore is needed because `@types/d3`\n// is missing the `pointer` function\nimport { pointer } from 'd3-selection';\n\n// This class is used for handle brush events in chart\nexport class ChartBrush extends Component {\n\tstatic DASH_LENGTH = 4;\n\n\ttype = 'grid-brush';\n\trenderType = RenderTypes.SVG;\n\n\tselectionSelector = 'rect.selection'; // needs to match the class name in d3.brush\n\n\tfrontSelectionSelector = 'rect.frontSelection'; // needs to match the class name in _grid-brush.scss\n\n\trender(animate = true) {\n\t\tconst svg = this.parent;\n\n\t\t// use this area to display selection above all graphs\n\t\tconst frontSelectionArea = this.getComponentContainer();\n\t\tconst backdrop = DOMUtils.appendOrSelect(\n\t\t\tsvg,\n\t\t\t'svg.chart-grid-backdrop'\n\t\t);\n\t\t// use this area to handle d3 brush events\n\t\tconst brushArea = DOMUtils.appendOrSelect(backdrop, `g.${this.type}`);\n\n\t\t// set an id for rect.selection to be referred\n\t\tconst d3Selection = DOMUtils.appendOrSelect(\n\t\t\tbrushArea,\n\t\t\tthis.selectionSelector\n\t\t);\n\n\t\tconst { width, height } = DOMUtils.getSVGElementSize(backdrop, {\n\t\t\tuseAttrs: true,\n\t\t});\n\n\t\tconst { cartesianScales } = this.services;\n\t\tconst mainXScaleType = cartesianScales.getMainXScaleType();\n\t\tconst mainXScale = cartesianScales.getMainXScale();\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tfrontSelectionArea.attr('transform', `translate(${xScaleStart},0)`);\n\t\tconst frontSelection = DOMUtils.appendOrSelect(\n\t\t\tfrontSelectionArea,\n\t\t\tthis.frontSelectionSelector\n\t\t);\n\n\t\tif (mainXScale && mainXScaleType === ScaleTypes.TIME) {\n\t\t\t// get current zoomDomain\n\t\t\tlet zoomDomain = this.model.get('zoomDomain');\n\t\t\tif (zoomDomain === undefined) {\n\t\t\t\t// default to full range with extended domain\n\t\t\t\tzoomDomain = this.services.zoom.getDefaultZoomBarDomain();\n\t\t\t\tif (zoomDomain) {\n\t\t\t\t\tthis.model.set(\n\t\t\t\t\t\t{ zoomDomain: zoomDomain },\n\t\t\t\t\t\t{ animate: false }\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst updateSelectionDash = (selection) => {\n\t\t\t\t// set end drag point to dash\n\t\t\t\tconst selectionWidth = selection[1] - selection[0];\n\t\t\t\tlet dashArray = '0,' + selectionWidth.toString(); // top (invisible)\n\n\t\t\t\t// right\n\t\t\t\tconst dashCount = Math.floor(height / ChartBrush.DASH_LENGTH);\n\t\t\t\tconst totalRightDash = dashCount * ChartBrush.DASH_LENGTH;\n\t\t\t\tfor (let i = 0; i < dashCount; i++) {\n\t\t\t\t\tdashArray += ',' + ChartBrush.DASH_LENGTH; // for each full length dash\n\t\t\t\t}\n\t\t\t\tdashArray += ',' + (height - totalRightDash); // for rest of the right height\n\t\t\t\t// if dash count is even, one more \",0\" is needed to make total right dash pattern even\n\t\t\t\tif (dashCount % 2 === 1) {\n\t\t\t\t\tdashArray += ',0';\n\t\t\t\t}\n\t\t\t\tdashArray += ',' + selectionWidth.toString(); // bottom (invisible)\n\t\t\t\tdashArray += ',' + height.toString(); // left\n\t\t\t\tfrontSelection.attr('stroke-dasharray', dashArray);\n\t\t\t};\n\n\t\t\tconst brushEventHandler = (event) => {\n\t\t\t\t// selection range: [0, width]\n\t\t\t\tconst selection = event.selection;\n\t\t\t\tif (selection === null || selection[0] === selection[1]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// copy the d3 selection attrs to front selection element\n\t\t\t\tfrontSelection\n\t\t\t\t\t.attr(\n\t\t\t\t\t\t'x',\n\t\t\t\t\t\tparseFloat(d3Selection.attr('x')) +\n\t\t\t\t\t\t\tparseFloat(backdrop.attr('x'))\n\t\t\t\t\t)\n\t\t\t\t\t.attr('y', d3Selection.attr('y'))\n\t\t\t\t\t.attr('width', d3Selection.attr('width'))\n\t\t\t\t\t.attr('height', d3Selection.attr('height'))\n\t\t\t\t\t.style('cursor', 'pointer')\n\t\t\t\t\t.style('display', null);\n\n\t\t\t\tupdateSelectionDash(selection);\n\t\t\t};\n\n\t\t\t// assume max range is [0, width]\n\t\t\tconst updateZoomDomain = (startPoint, endPoint) => {\n\t\t\t\t// create xScale based on current zoomDomain\n\t\t\t\tconst xScale = scaleTime().range([0, width]).domain(zoomDomain);\n\n\t\t\t\tlet newDomain = [\n\t\t\t\t\txScale.invert(startPoint),\n\t\t\t\t\txScale.invert(endPoint),\n\t\t\t\t];\n\t\t\t\t// if selected start time and end time are the same\n\t\t\t\t// reset to default full range\n\t\t\t\tif (newDomain[0].valueOf() === newDomain[1].valueOf()) {\n\t\t\t\t\t// same as d3 behavior and zoom bar behavior: set to default full range\n\t\t\t\t\tnewDomain = this.services.zoom.getDefaultZoomBarDomain();\n\t\t\t\t}\n\n\t\t\t\t// only if zoomDomain needs update\n\t\t\t\tif (\n\t\t\t\t\tzoomDomain[0].valueOf() !== newDomain[0].valueOf() ||\n\t\t\t\t\tzoomDomain[1].valueOf() !== newDomain[1].valueOf()\n\t\t\t\t) {\n\t\t\t\t\tthis.services.zoom.handleDomainChange(newDomain);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tlet brush;\n\n\t\t\tconst brushed = (event) => {\n\t\t\t\t// max selection range: [0, width]\n\t\t\t\tconst selection = event.selection;\n\n\t\t\t\tif (selection !== null) {\n\t\t\t\t\t// updateZoomDomain assumes max range is [0, width]\n\t\t\t\t\tupdateZoomDomain(selection[0], selection[1]);\n\n\t\t\t\t\t// clear brush selection\n\t\t\t\t\tbrushArea.call(brush.move, null);\n\t\t\t\t\t// hide frontSelection\n\t\t\t\t\tfrontSelection.style('display', 'none');\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (height != 0 && width != 0) {\n\t\t\t\t// leave some space to display selection strokes besides axis\n\t\t\t\tbrush = brushX()\n\t\t\t\t\t.extent([\n\t\t\t\t\t\t[0, 0],\n\t\t\t\t\t\t[width - 1, height],\n\t\t\t\t\t])\n\t\t\t\t\t.on('start brush end', brushEventHandler)\n\t\t\t\t\t.on('end.brushed', brushed);\n\n\t\t\t\tbrushArea.call(brush);\n\t\t\t}\n\n\t\t\tconst zoomRatio = this.services.zoom.getZoomRatio();\n\t\t\tbackdrop.on('click', function (event) {\n\t\t\t\tif (event.shiftKey) {\n\t\t\t\t\tconst holder = this.services.domUtils.getHolder();\n\n\t\t\t\t\t// clickedX range: [0, width]\n\t\t\t\t\tconst clickedX = pointer(brushArea.node(), holder)[0];\n\n\t\t\t\t\tlet leftPoint = clickedX - (width * zoomRatio) / 2;\n\t\t\t\t\tif (leftPoint < 0) {\n\t\t\t\t\t\tleftPoint = 0;\n\t\t\t\t\t}\n\t\t\t\t\tlet rightPoint = clickedX + (width * zoomRatio) / 2;\n\t\t\t\t\tif (rightPoint > width) {\n\t\t\t\t\t\trightPoint = width;\n\t\t\t\t\t}\n\t\t\t\t\t// updateZoomDomain assumes max range is [0, width]\n\t\t\t\t\tupdateZoomDomain(leftPoint, rightPoint);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\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
|
|
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
|
-
|
|
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,
|
|
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.
|
|
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
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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":";;;;;;;;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AAC,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,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;QAmB1D,2CAA2C;QAC3C,6BAAuB,GAAG,UAAC,KAAkB;YAC5C,IAAM,GAAG,GAAG,KAAI,CAAC,qBA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F,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
|
+
}
|