@devgateway/dvz-ui-react 1.9.6 → 1.9.8
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/dist/cjs/embeddable/chart/colors/ManualColors.js +1 -1
- package/dist/cjs/embeddable/chart/data/Line.js +1 -1
- package/dist/cjs/embeddable/common/MapTooltip.js +1 -1
- package/dist/cjs/embeddable/common/colors/ManualColors.js +1 -1
- package/dist/cjs/embeddable/map/MapDataFrame.js +1 -1
- package/dist/cjs/embeddable/map/index.js +2 -2
- package/dist/cjs/embeddable/map/map.js +4 -4
- package/dist/cjs/embeddable/map/mapHelpers.js +1 -0
- package/dist/esm/embeddable/chart/colors/ManualColors.js +73 -41
- package/dist/esm/embeddable/chart/data/Line.js +132 -128
- package/dist/esm/embeddable/common/MapTooltip.js +26 -22
- package/dist/esm/embeddable/common/colors/ManualColors.js +66 -35
- package/dist/esm/embeddable/map/MapDataFrame.js +152 -18
- package/dist/esm/embeddable/map/index.js +209 -198
- package/dist/esm/embeddable/map/map.js +602 -918
- package/dist/esm/embeddable/map/mapHelpers.js +243 -0
- package/dist/types/embeddable/chart/colors/ManualColors.d.ts +2 -0
- package/dist/types/embeddable/common/colors/ManualColors.d.ts +2 -0
- package/dist/types/embeddable/map/map.d.ts +2 -1
- package/dist/types/embeddable/map/mapHelpers.d.ts +55 -0
- package/package.json +1 -1
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import * as L from "topojson-client";
|
|
2
|
+
import x from "geostats";
|
|
3
|
+
import y from "../../utils/deviceType.js";
|
|
4
|
+
const w = "_Color_", M = "location", k = "showAll", A = "ifUnitHasData", j = 10, B = {
|
|
5
|
+
mobile: 4,
|
|
6
|
+
tablet: 4,
|
|
7
|
+
midTablet: 2,
|
|
8
|
+
laptop: 2,
|
|
9
|
+
desktop: 2,
|
|
10
|
+
wide: 2
|
|
11
|
+
}, I = {
|
|
12
|
+
mobile: 330,
|
|
13
|
+
tablet: 250,
|
|
14
|
+
midTablet: 250,
|
|
15
|
+
laptop: 200,
|
|
16
|
+
desktop: 100,
|
|
17
|
+
wide: 100
|
|
18
|
+
}, _ = {
|
|
19
|
+
mobile: 250,
|
|
20
|
+
tablet: 250,
|
|
21
|
+
midTablet: 250,
|
|
22
|
+
laptop: 0,
|
|
23
|
+
desktop: 0,
|
|
24
|
+
wide: 0
|
|
25
|
+
}, C = {
|
|
26
|
+
greens: [
|
|
27
|
+
"#ccffdd",
|
|
28
|
+
"#b3ffcc",
|
|
29
|
+
"#99ffbb",
|
|
30
|
+
"#80ffaa",
|
|
31
|
+
"#66ff99",
|
|
32
|
+
"#4dff88",
|
|
33
|
+
"#33ff77",
|
|
34
|
+
"#1aff66",
|
|
35
|
+
"#00ff55",
|
|
36
|
+
"#00e64d"
|
|
37
|
+
],
|
|
38
|
+
greys: [
|
|
39
|
+
"#f2f2f2",
|
|
40
|
+
"#e6e6e6",
|
|
41
|
+
"#d9d9d9",
|
|
42
|
+
"#cccccc",
|
|
43
|
+
"#bfbfbf",
|
|
44
|
+
"#b3b3b3",
|
|
45
|
+
"#a6a6a6",
|
|
46
|
+
"#999999",
|
|
47
|
+
"#8c8c8c",
|
|
48
|
+
"#808080"
|
|
49
|
+
],
|
|
50
|
+
oranges: [
|
|
51
|
+
"#fff0e6",
|
|
52
|
+
"#ffe0cc",
|
|
53
|
+
"#ffd1b3",
|
|
54
|
+
"#ffc299",
|
|
55
|
+
"#ffb380",
|
|
56
|
+
"#ffa366",
|
|
57
|
+
"#ff944d",
|
|
58
|
+
"#ff8533",
|
|
59
|
+
"#ff751a",
|
|
60
|
+
"#ff6600"
|
|
61
|
+
],
|
|
62
|
+
purples: [
|
|
63
|
+
"#ffe6ff",
|
|
64
|
+
"#ffccff",
|
|
65
|
+
"#ffb3ff",
|
|
66
|
+
"#ff99ff",
|
|
67
|
+
"#ff80ff",
|
|
68
|
+
"#ff66ff",
|
|
69
|
+
"#ff4dff",
|
|
70
|
+
"#ff33ff",
|
|
71
|
+
"#ff1aff",
|
|
72
|
+
"#ff00ff"
|
|
73
|
+
],
|
|
74
|
+
reds: [
|
|
75
|
+
"#ffe6e6",
|
|
76
|
+
"#ffcccc",
|
|
77
|
+
"#ffb3b3",
|
|
78
|
+
"#ff9999",
|
|
79
|
+
"#ff8080",
|
|
80
|
+
"#ff6666",
|
|
81
|
+
"#ff4d4d",
|
|
82
|
+
"#ff3333",
|
|
83
|
+
"#ff1a1a",
|
|
84
|
+
"#ff0000"
|
|
85
|
+
],
|
|
86
|
+
blues: [
|
|
87
|
+
"#e6eeff",
|
|
88
|
+
"#ccddff",
|
|
89
|
+
"#b3ccff",
|
|
90
|
+
"#99bbff",
|
|
91
|
+
"#80aaff",
|
|
92
|
+
"#6699ff",
|
|
93
|
+
"#4d88ff",
|
|
94
|
+
"#3377ff",
|
|
95
|
+
"#1a66ff",
|
|
96
|
+
"#0055ff"
|
|
97
|
+
]
|
|
98
|
+
};
|
|
99
|
+
function v(e, r, l) {
|
|
100
|
+
var t;
|
|
101
|
+
if (!(e != null && e.length)) return r;
|
|
102
|
+
const o = ((t = e[0]) == null ? void 0 : t.items) ?? [], n = (i) => (i == null ? void 0 : i.trim().toLowerCase()) ?? "", s = n(r), c = n(l).toUpperCase(), f = o.find((i) => n(i.value) === s || n(i.code) === s) ?? null;
|
|
103
|
+
if (!f) return r;
|
|
104
|
+
const a = c && f.labels && f.labels[c] ? f.labels[c] : f.value;
|
|
105
|
+
return (a == null ? void 0 : a.trim()) || f.value.trim();
|
|
106
|
+
}
|
|
107
|
+
function D(e) {
|
|
108
|
+
let r = e;
|
|
109
|
+
return r || (r = ["mobile", "tablet", "midTablet"].includes(y())), r ? "active zoom-enabled" : "active";
|
|
110
|
+
}
|
|
111
|
+
function E(e, r) {
|
|
112
|
+
const { autoGenerateBreaks: l, numberOfBreaks: o, colorScheme: n } = r, s = [];
|
|
113
|
+
if (l && e && e.length > 0) {
|
|
114
|
+
const c = e.filter((t) => t.properties && t.properties.value != null).map((t) => t.properties.value.toFixed(2)), f = [];
|
|
115
|
+
c.forEach((t) => {
|
|
116
|
+
if (t > 0) {
|
|
117
|
+
const i = t * 0.99, p = t * 1.01;
|
|
118
|
+
f.indexOf(i) === -1 && f.push(i), f.indexOf(p) === -1 && f.push(p);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const a = C[n];
|
|
122
|
+
if (f.length > 0) {
|
|
123
|
+
const t = new x(f);
|
|
124
|
+
t.setPrecision(2);
|
|
125
|
+
const i = f.length > 1 ? f.length - 1 : f.length;
|
|
126
|
+
return t.getJenks(Math.min(o, i)), t.ranges.forEach((p, u) => {
|
|
127
|
+
const b = {};
|
|
128
|
+
b.min = parseFloat(p.substr(0, p.indexOf("-") - 1)) + (u > 0 ? 0.01 : 0), b.max = parseFloat(p.substr(p.indexOf("-") + 2, p.length)), b.color = a[u], s.push(b);
|
|
129
|
+
}), s;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return s;
|
|
133
|
+
}
|
|
134
|
+
function H(e, r, l) {
|
|
135
|
+
const { mapNoDataColor: o, mainLayerId: n, enabledLayers: s, selectedMeasure: c } = l;
|
|
136
|
+
if (e.properties && e.properties.variables && c && e.properties.value != null) {
|
|
137
|
+
const a = w + c, t = e.properties.variables[a.trim()];
|
|
138
|
+
if (t) return t;
|
|
139
|
+
}
|
|
140
|
+
if (e.properties.value != null && (n && e.properties.layerId === n || !n)) {
|
|
141
|
+
const a = r.find((t) => t.min != null && t.max != null ? e.properties.value >= t.min && e.properties.value <= t.max : t.min != null ? e.properties.value >= t.min : t.max != null ? e.properties.value <= t.max : !1);
|
|
142
|
+
return a && a.color ? a.color : o;
|
|
143
|
+
}
|
|
144
|
+
const f = s.filter((a) => a.id === e.properties.layerId)[0];
|
|
145
|
+
return f && f.bgColor && f.bgColor != "undefined" ? f.bgColor : o;
|
|
146
|
+
}
|
|
147
|
+
function S(e, r) {
|
|
148
|
+
if (e.properties[r]) {
|
|
149
|
+
const o = e.properties[r].length;
|
|
150
|
+
return o < 10 ? 80 : o * 8;
|
|
151
|
+
}
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
function R(e) {
|
|
155
|
+
return e ? 30 : 25;
|
|
156
|
+
}
|
|
157
|
+
function O(e, r) {
|
|
158
|
+
if (e && e.objects) {
|
|
159
|
+
const l = Object.keys(e.objects);
|
|
160
|
+
for (const o in l) {
|
|
161
|
+
const n = l[o];
|
|
162
|
+
if (e.objects[n].type == "GeometryCollection")
|
|
163
|
+
return n;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return r;
|
|
167
|
+
}
|
|
168
|
+
function W(e, r) {
|
|
169
|
+
const l = O(e, r);
|
|
170
|
+
return e && e.objects && e.objects[l] ? L.feature(e, e.objects[l]).features : e && e.features ? e.features : [];
|
|
171
|
+
}
|
|
172
|
+
function U(e, r, l) {
|
|
173
|
+
if (e.properties.displayLayerLabels && e.properties.layerLocale) {
|
|
174
|
+
const o = e.properties.layerMappingField || r, n = e.properties[o];
|
|
175
|
+
return v(l, n, e.properties.layerLocale);
|
|
176
|
+
}
|
|
177
|
+
return e.properties[r];
|
|
178
|
+
}
|
|
179
|
+
function z(e, r, l, o) {
|
|
180
|
+
const {
|
|
181
|
+
mapLabelField: n,
|
|
182
|
+
mapLabelShowValue: s,
|
|
183
|
+
intl: c,
|
|
184
|
+
valueFormat: f,
|
|
185
|
+
showNoDataLabel: a,
|
|
186
|
+
showAdminUnitLabel: t,
|
|
187
|
+
noDataText: i,
|
|
188
|
+
selectedMeasure: p
|
|
189
|
+
} = r;
|
|
190
|
+
let u = "";
|
|
191
|
+
if (t == k || t == A && e.properties.hasDataRow || e.properties.displayLayerLabels) {
|
|
192
|
+
const b = e.properties.displayLayerLabels && e.properties.layerMappingField ? e.properties.layerMappingField : n, d = e.properties[b], h = e.properties.layerLocale || (c == null ? void 0 : c.locale);
|
|
193
|
+
u = v(l, d, h);
|
|
194
|
+
const g = e.properties.abbrev;
|
|
195
|
+
if (u && u.length > j && g && (u = g), s)
|
|
196
|
+
if (e.properties.value != null) {
|
|
197
|
+
const m = e.properties.variables || {};
|
|
198
|
+
u += "<br><span class='map-label-value'>" + o(
|
|
199
|
+
f,
|
|
200
|
+
{ value: e.properties.value, measure: p, ...m },
|
|
201
|
+
c
|
|
202
|
+
) + "</span>";
|
|
203
|
+
} else a == !0 && e.properties.value == null && e.properties.hasDataRow && (u += "<br><span class='map-label-value'>" + i + "</span>");
|
|
204
|
+
}
|
|
205
|
+
return u;
|
|
206
|
+
}
|
|
207
|
+
function G(e) {
|
|
208
|
+
const r = {};
|
|
209
|
+
return e && Object.keys(e).forEach((l) => {
|
|
210
|
+
const o = e[l];
|
|
211
|
+
o && (r[l] = Array.isArray(o) ? o.join(" ,") : o);
|
|
212
|
+
}), r;
|
|
213
|
+
}
|
|
214
|
+
function N(e, r, l) {
|
|
215
|
+
const o = e ? e.value : null;
|
|
216
|
+
if (o != null) {
|
|
217
|
+
const n = r.find((s) => s.min != null && s.max != null ? o >= s.min && o <= s.max : s.min != null ? o >= s.min : s.max != null ? o <= s.max : !1);
|
|
218
|
+
return n && n.color ? n.color : l;
|
|
219
|
+
}
|
|
220
|
+
return l;
|
|
221
|
+
}
|
|
222
|
+
export {
|
|
223
|
+
w as COLOR_VARIABLE,
|
|
224
|
+
M as LOCATION,
|
|
225
|
+
j as MAX_LABEL_LEN,
|
|
226
|
+
k as SHOW_ALL,
|
|
227
|
+
A as SHOW_IF_HAS_DATA,
|
|
228
|
+
D as classColor,
|
|
229
|
+
z as createLabel,
|
|
230
|
+
I as deviceMapHeight,
|
|
231
|
+
_ as deviceMapWidth,
|
|
232
|
+
B as deviceTranslateMap,
|
|
233
|
+
W as extractFeatures,
|
|
234
|
+
H as fillColor,
|
|
235
|
+
E as generateBreaks,
|
|
236
|
+
O as getCollectionField,
|
|
237
|
+
G as getFilters,
|
|
238
|
+
N as getHighlightedLocationColor,
|
|
239
|
+
R as getLabelBoxHeight,
|
|
240
|
+
S as getLabelBoxWidth,
|
|
241
|
+
v as getTranslatedItemLabel,
|
|
242
|
+
U as getTranslatedLocationName
|
|
243
|
+
};
|
|
@@ -2,7 +2,9 @@ import { default as Colors } from './Colors';
|
|
|
2
2
|
export default CustomColors;
|
|
3
3
|
declare class CustomColors extends Colors {
|
|
4
4
|
constructor(app: any, type: any, colorBy: any, scheme: any, data: any, dimensionsMetadata: any, measuresMetadata: any, keys: any, indexBy: any, manualColors: {} | undefined, locale: any, overallLabel: any, customLabels: any, options: any);
|
|
5
|
+
type: any;
|
|
5
6
|
_manualColor: any;
|
|
6
7
|
getColor(id: any, datum: any): any;
|
|
8
|
+
getColorByIndex(value: any): any;
|
|
7
9
|
getColorByKey(value: any): any;
|
|
8
10
|
}
|
|
@@ -2,7 +2,9 @@ import { default as Colors } from './Colors';
|
|
|
2
2
|
export default CustomColors;
|
|
3
3
|
declare class CustomColors extends Colors {
|
|
4
4
|
constructor(app: any, type: any, colorBy: any, scheme: any, data: any, dimensionsMetadata: any, measuresMetadata: any, keys: any, indexBy: any, manualColors: any, locale: any, overallLabel: any, customLabels: any);
|
|
5
|
+
type: any;
|
|
5
6
|
_manualColor: any;
|
|
6
7
|
getColor(id: any, datum: any): any;
|
|
8
|
+
getColorByIndex(value: any): any;
|
|
7
9
|
getColorByKey(value: any): any;
|
|
8
10
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { getTranslatedItemLabel } from './mapHelpers';
|
|
1
2
|
import { default as React } from 'react';
|
|
2
|
-
export
|
|
3
|
+
export { getTranslatedItemLabel };
|
|
3
4
|
declare const _default: React.FC<import('react-intl').WithIntlProps<any>> & {
|
|
4
5
|
WrappedComponent: React.ComponentType<any>;
|
|
5
6
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type Feature = any;
|
|
2
|
+
export type MetadataTypes = any[];
|
|
3
|
+
export interface LegendBreak {
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
measure?: string;
|
|
8
|
+
filters?: Array<{
|
|
9
|
+
field: string;
|
|
10
|
+
values: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare const COLOR_VARIABLE = "_Color_";
|
|
14
|
+
export declare const LOCATION = "location";
|
|
15
|
+
export declare const SHOW_ALL = "showAll";
|
|
16
|
+
export declare const SHOW_IF_HAS_DATA = "ifUnitHasData";
|
|
17
|
+
export declare const MAX_LABEL_LEN = 10;
|
|
18
|
+
export declare const deviceTranslateMap: Record<string, number>;
|
|
19
|
+
export declare const deviceMapHeight: Record<string, number>;
|
|
20
|
+
export declare const deviceMapWidth: Record<string, number>;
|
|
21
|
+
export declare function getTranslatedItemLabel(data: MetadataTypes | undefined, itemNameOrCode: string | undefined, locale: string | undefined): string | undefined;
|
|
22
|
+
export declare function classColor(zoomEnabledProp?: boolean): string;
|
|
23
|
+
export declare function generateBreaks(data: Feature[] | undefined, options: {
|
|
24
|
+
autoGenerateBreaks?: boolean;
|
|
25
|
+
numberOfBreaks: number;
|
|
26
|
+
colorScheme: string;
|
|
27
|
+
}): LegendBreak[];
|
|
28
|
+
export declare function fillColor(d: Feature, breaks: LegendBreak[], options: {
|
|
29
|
+
mapNoDataColor: string;
|
|
30
|
+
mainLayerId?: string | number;
|
|
31
|
+
enabledLayers: Array<{
|
|
32
|
+
id: any;
|
|
33
|
+
bgColor?: string;
|
|
34
|
+
}>;
|
|
35
|
+
selectedMeasure?: string | null;
|
|
36
|
+
}): string;
|
|
37
|
+
export declare function getLabelBoxWidth(d: Feature, mapLabelField: string): number;
|
|
38
|
+
export declare function getLabelBoxHeight(mapLabelShowValue?: boolean): number;
|
|
39
|
+
export declare function getCollectionField(mainLayer: any, topoJSONField: string): string;
|
|
40
|
+
export declare function extractFeatures(mainLayer: any, topoJSONField: string): Feature[];
|
|
41
|
+
export declare function getTranslatedLocationName(d: Feature, mappingField: string, metadataTypes: MetadataTypes): string;
|
|
42
|
+
export declare function createLabel(d: Feature, props: {
|
|
43
|
+
mapLabelField: string;
|
|
44
|
+
mapLabelShowValue?: boolean;
|
|
45
|
+
intl: any;
|
|
46
|
+
valueFormat: string;
|
|
47
|
+
showNoDataLabel?: boolean;
|
|
48
|
+
showAdminUnitLabel: string;
|
|
49
|
+
noDataText: string;
|
|
50
|
+
selectedMeasure?: string | null;
|
|
51
|
+
}, metadataTypes: MetadataTypes, formatContent: (format: string, vars: Record<string, any>, intl: any, noDataText?: string) => string): string;
|
|
52
|
+
export declare function getFilters(appliedFilters: Record<string, any> | undefined): Record<string, string>;
|
|
53
|
+
export declare function getHighlightedLocationColor(data: {
|
|
54
|
+
value?: number;
|
|
55
|
+
} | undefined, breaks: LegendBreak[], mapNoDataColor: string): string;
|