@evergis/react 4.0.14 → 4.0.20
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/components/Dashboard/elements/ElementSvg/index.d.ts +1 -2
- package/dist/components/Dashboard/elements/registry.d.ts +1 -1
- package/dist/components/Dashboard/types.d.ts +1 -1
- package/dist/index.js +91 -28
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +91 -28
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/react.esm.js
CHANGED
|
@@ -4202,7 +4202,9 @@ function getLinePoints(numPoints, svgLine) {
|
|
|
4202
4202
|
else {
|
|
4203
4203
|
interval = lineLength / (numPoints - 1);
|
|
4204
4204
|
}
|
|
4205
|
-
return range(numPoints)
|
|
4205
|
+
return range(numPoints)
|
|
4206
|
+
.filter(d => d * interval)
|
|
4207
|
+
.map(d => {
|
|
4206
4208
|
const value = d * interval;
|
|
4207
4209
|
const { x, y } = svgLine.getPointAtLength(value);
|
|
4208
4210
|
return [x, y];
|
|
@@ -4223,7 +4225,9 @@ function wrap() {
|
|
|
4223
4225
|
const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, markers, showMarkers, }) => {
|
|
4224
4226
|
const { t } = useGlobalContext();
|
|
4225
4227
|
const { layerInfos } = useWidgetContext();
|
|
4226
|
-
const strokeColors = relatedAttributes
|
|
4228
|
+
const strokeColors = relatedAttributes
|
|
4229
|
+
.filter(({ chartAxis }) => chartAxis === "y")
|
|
4230
|
+
.map(({ axisColor }) => axisColor);
|
|
4227
4231
|
const ref = useRef({
|
|
4228
4232
|
path: null,
|
|
4229
4233
|
area: null,
|
|
@@ -4244,13 +4248,15 @@ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes
|
|
|
4244
4248
|
const customize = useCallback(({ svg }) => {
|
|
4245
4249
|
svg.style("overflow", "visible");
|
|
4246
4250
|
svg
|
|
4247
|
-
.selectAll(`.${lineChartClassNames.lineChartXScaleGlobal} line,
|
|
4248
|
-
.${lineChartClassNames.lineChartYScaleGlobal} line,
|
|
4251
|
+
.selectAll(`.${lineChartClassNames.lineChartXScaleGlobal} line,
|
|
4252
|
+
.${lineChartClassNames.lineChartYScaleGlobal} line,
|
|
4249
4253
|
.domain`)
|
|
4250
4254
|
.each((_, index, nodes) => {
|
|
4251
4255
|
nodes[index].remove();
|
|
4252
4256
|
});
|
|
4253
|
-
svg
|
|
4257
|
+
svg
|
|
4258
|
+
.selectAll(`.${lineChartClassNames.lineChartXScaleGlobal} .tick`)
|
|
4259
|
+
.each((_, index, nodes) => {
|
|
4254
4260
|
if (!index) {
|
|
4255
4261
|
nodes[index].style.textAnchor = "start";
|
|
4256
4262
|
}
|
|
@@ -4271,16 +4277,28 @@ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes
|
|
|
4271
4277
|
}
|
|
4272
4278
|
}
|
|
4273
4279
|
});
|
|
4274
|
-
svg
|
|
4280
|
+
svg
|
|
4281
|
+
.selectAll(`.${lineChartClassNames.lineChartXScaleGlobal} .tick text`)
|
|
4282
|
+
.attr("y", 16);
|
|
4275
4283
|
svg
|
|
4276
4284
|
.selectAll(`.${lineChartClassNames.lineChartYScaleGlobal} .tick text`)
|
|
4277
4285
|
.text(item => {
|
|
4278
4286
|
if (!item)
|
|
4279
4287
|
return 0;
|
|
4280
4288
|
const dataSource = dataSources?.find(({ name }) => name === relatedAttributes[0].dataSourceName);
|
|
4281
|
-
const layerInfo = dataSource
|
|
4289
|
+
const layerInfo = dataSource
|
|
4290
|
+
? layerInfos.find(({ name }) => name === dataSource.layerName)
|
|
4291
|
+
: null;
|
|
4282
4292
|
const attribute = layerInfo?.layerDefinition.attributes[relatedAttributes[0].attributeName];
|
|
4283
|
-
return attribute
|
|
4293
|
+
return attribute
|
|
4294
|
+
? formatAttributeValue({
|
|
4295
|
+
t,
|
|
4296
|
+
type: attribute.type,
|
|
4297
|
+
value: item,
|
|
4298
|
+
stringFormat: attribute.stringFormat,
|
|
4299
|
+
noUnits: true,
|
|
4300
|
+
})
|
|
4301
|
+
: item;
|
|
4284
4302
|
})
|
|
4285
4303
|
.each(wrap);
|
|
4286
4304
|
svg.selectAll(".tick text").attr("style", `color: ${fontColor}`);
|
|
@@ -4302,11 +4320,11 @@ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes
|
|
|
4302
4320
|
.attr("fill", `url(#${gradientId})`)
|
|
4303
4321
|
.attr("stroke-width", "0")
|
|
4304
4322
|
.attr("fill-opacity", FILL_OPACITY);
|
|
4305
|
-
defs.push(`
|
|
4306
|
-
<linearGradient id="${gradientId}" x1="0" y1="0" x2="0" y2="1">
|
|
4307
|
-
<stop offset="0" stop-color="${color}" stop-opacity="1" />
|
|
4308
|
-
<stop offset="1" stop-color="${color}" stop-opacity="0" />
|
|
4309
|
-
</linearGradient>
|
|
4323
|
+
defs.push(`
|
|
4324
|
+
<linearGradient id="${gradientId}" x1="0" y1="0" x2="0" y2="1">
|
|
4325
|
+
<stop offset="0" stop-color="${color}" stop-opacity="1" />
|
|
4326
|
+
<stop offset="1" stop-color="${color}" stop-opacity="0" />
|
|
4327
|
+
</linearGradient>
|
|
4310
4328
|
`);
|
|
4311
4329
|
ref.current = {
|
|
4312
4330
|
path: newPath,
|
|
@@ -4316,7 +4334,19 @@ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes
|
|
|
4316
4334
|
onChange();
|
|
4317
4335
|
});
|
|
4318
4336
|
svg.append("defs").html(() => defs.join(""));
|
|
4319
|
-
}, [
|
|
4337
|
+
}, [
|
|
4338
|
+
fontColor,
|
|
4339
|
+
dataSources,
|
|
4340
|
+
layerInfos,
|
|
4341
|
+
relatedAttributes,
|
|
4342
|
+
chartId,
|
|
4343
|
+
strokeColors,
|
|
4344
|
+
defaultColor,
|
|
4345
|
+
width,
|
|
4346
|
+
onChange,
|
|
4347
|
+
showMarkers,
|
|
4348
|
+
markers,
|
|
4349
|
+
]);
|
|
4320
4350
|
return [customize, onChange];
|
|
4321
4351
|
};
|
|
4322
4352
|
|
|
@@ -8464,11 +8494,19 @@ const ElementChart = memo(({ type, elementConfig, renderElement }) => {
|
|
|
8464
8494
|
const ElementChips = memo(({ type, elementConfig }) => {
|
|
8465
8495
|
const { attributes } = useWidgetContext(type);
|
|
8466
8496
|
const { attributeName, options, style } = elementConfig || {};
|
|
8467
|
-
const { separator, bgColor, fontColor, fontSize, colorAttribute } = options || {};
|
|
8497
|
+
const { separator, bgColor, fontColor, fontSize, colorAttribute, variants, } = options || {};
|
|
8468
8498
|
const valueAttr = getAttributeByName(attributeName, attributes);
|
|
8469
8499
|
const colorAttr = getAttributeByName(colorAttribute, attributes);
|
|
8470
|
-
const tags =
|
|
8471
|
-
|
|
8500
|
+
const tags = useMemo(() => {
|
|
8501
|
+
if (variants?.length) {
|
|
8502
|
+
return variants.map(({ text, color }) => ({
|
|
8503
|
+
text,
|
|
8504
|
+
color,
|
|
8505
|
+
}));
|
|
8506
|
+
}
|
|
8507
|
+
return (valueAttr?.value?.split(separator || ",") ?? []).map(text => ({ text, color: undefined }));
|
|
8508
|
+
}, [variants, valueAttr?.value, separator]);
|
|
8509
|
+
return (jsx(DashboardChipsContainer, { style: style, children: tags.map(tag => (jsx(DashboardChip$1, { text: tag.text, "$bgColor": tag.color || colorAttr?.value || bgColor, "$fontColor": fontColor, "$fontSize": fontSize, "$isDefault": !tag.color && !colorAttr?.value }, tag.text))) }));
|
|
8472
8510
|
});
|
|
8473
8511
|
|
|
8474
8512
|
const ElementControl = ({ elementConfig }) => {
|
|
@@ -8482,6 +8520,9 @@ const ElementControl = ({ elementConfig }) => {
|
|
|
8482
8520
|
const attribute = useMemo(() => attributes?.find(({ name }) => name === control?.targetAttributeName), [attributes, control?.targetAttributeName]);
|
|
8483
8521
|
const dataSource = useMemo(() => getDataSource(relatedDataSource, dataSources), [relatedDataSource, dataSources]);
|
|
8484
8522
|
const items = useMemo(() => {
|
|
8523
|
+
if (control?.variants) {
|
|
8524
|
+
return control.variants;
|
|
8525
|
+
}
|
|
8485
8526
|
if (!dataSource?.features?.length || !attributeName) {
|
|
8486
8527
|
return [];
|
|
8487
8528
|
}
|
|
@@ -8489,14 +8530,23 @@ const ElementControl = ({ elementConfig }) => {
|
|
|
8489
8530
|
value: item.properties?.[attributeName] || "",
|
|
8490
8531
|
text: item.properties?.[control?.attributeName || attributeName] || "",
|
|
8491
8532
|
}));
|
|
8492
|
-
}, [
|
|
8533
|
+
}, [
|
|
8534
|
+
control?.variants,
|
|
8535
|
+
control?.attributeName,
|
|
8536
|
+
dataSource?.features,
|
|
8537
|
+
attributeName,
|
|
8538
|
+
]);
|
|
8493
8539
|
const isDisabled = useMemo(() => {
|
|
8494
8540
|
const attr = layerInfo?.configuration?.attributesConfiguration?.attributes?.find(item => item.attributeName === control?.targetAttributeName);
|
|
8495
8541
|
return !attr?.isEditable;
|
|
8496
8542
|
}, [
|
|
8497
8543
|
control?.targetAttributeName,
|
|
8498
|
-
layerInfo?.configuration
|
|
8544
|
+
layerInfo?.configuration
|
|
8545
|
+
?.attributesConfiguration?.attributes,
|
|
8499
8546
|
]);
|
|
8547
|
+
const currentValue = controls?.[control?.targetAttributeName] ??
|
|
8548
|
+
attribute?.value ??
|
|
8549
|
+
defaultValue;
|
|
8500
8550
|
const handleChange = useCallback(([option]) => {
|
|
8501
8551
|
if (control?.targetAttributeName && changeControls) {
|
|
8502
8552
|
changeControls({
|
|
@@ -8504,9 +8554,7 @@ const ElementControl = ({ elementConfig }) => {
|
|
|
8504
8554
|
});
|
|
8505
8555
|
}
|
|
8506
8556
|
}, [changeControls, control?.targetAttributeName]);
|
|
8507
|
-
return (jsx(Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value:
|
|
8508
|
-
attribute?.value ??
|
|
8509
|
-
defaultValue, placeholder: placeholder, disabled: isDisabled, onChange: handleChange }));
|
|
8557
|
+
return (jsx(Dropdown, { zIndex: 1000, width: `${width ?? DEFAULT_DROPDOWN_WIDTH}px`, label: label, options: items, value: currentValue, placeholder: placeholder, disabled: isDisabled, onChange: handleChange }));
|
|
8510
8558
|
};
|
|
8511
8559
|
|
|
8512
8560
|
const StyledIconFontSizeMixin = css `
|
|
@@ -8576,7 +8624,7 @@ const ElementLegend = memo(({ type, element, elementConfig }) => {
|
|
|
8576
8624
|
return axes.map(({ alias, axisColor }) => {
|
|
8577
8625
|
return {
|
|
8578
8626
|
name: alias,
|
|
8579
|
-
color: axisColor
|
|
8627
|
+
color: axisColor,
|
|
8580
8628
|
};
|
|
8581
8629
|
});
|
|
8582
8630
|
}
|
|
@@ -8588,8 +8636,16 @@ const ElementLegend = memo(({ type, element, elementConfig }) => {
|
|
|
8588
8636
|
const attribute = getAttributeByName(item.name, attributes);
|
|
8589
8637
|
return { ...item, name: attribute?.alias || item.name };
|
|
8590
8638
|
});
|
|
8591
|
-
}, [
|
|
8592
|
-
|
|
8639
|
+
}, [
|
|
8640
|
+
attributes,
|
|
8641
|
+
axes,
|
|
8642
|
+
data,
|
|
8643
|
+
options.chartType,
|
|
8644
|
+
relatedDataSources,
|
|
8645
|
+
dataSources,
|
|
8646
|
+
]);
|
|
8647
|
+
return !chartElement?.options?.expanded ||
|
|
8648
|
+
expandedContainers?.[chartElement.id] ? (jsx(ChartLegend, { data: legendData, loading: loading, chartElement: chartElement, twoColumns: twoColumns, fontSize: fontSize, type: type })) : null;
|
|
8593
8649
|
});
|
|
8594
8650
|
|
|
8595
8651
|
const ExternalLink = styled(IconButton).attrs(() => ({
|
|
@@ -10604,7 +10660,9 @@ const useChartData = ({ element, type }) => {
|
|
|
10604
10660
|
const dataSource = configDataSources.find(({ name }) => name === dataSourceName);
|
|
10605
10661
|
const layerInfo = layerInfos?.find(item => item?.name === dataSource?.layerName);
|
|
10606
10662
|
const featureDataSource = getDataSource(dataSourceName, dataSources);
|
|
10607
|
-
const hasLayerInfo = !!layerInfo ||
|
|
10663
|
+
const hasLayerInfo = !!layerInfo ||
|
|
10664
|
+
!!featureDataSource?.attributeDefinition ||
|
|
10665
|
+
!!featureDataSource?.features?.length;
|
|
10608
10666
|
return {
|
|
10609
10667
|
items: hasLayerInfo
|
|
10610
10668
|
? getDataFromRelatedFeatures({
|
|
@@ -10614,7 +10672,11 @@ const useChartData = ({ element, type }) => {
|
|
|
10614
10672
|
relatedConfig: relatedAxis,
|
|
10615
10673
|
dataSource: featureDataSource,
|
|
10616
10674
|
layerInfo: layerInfo ||
|
|
10617
|
-
{
|
|
10675
|
+
{
|
|
10676
|
+
layerDefinition: {
|
|
10677
|
+
attributes: featureDataSource.attributeDefinition,
|
|
10678
|
+
},
|
|
10679
|
+
},
|
|
10618
10680
|
})
|
|
10619
10681
|
: null,
|
|
10620
10682
|
color: axisColor,
|
|
@@ -10624,7 +10686,8 @@ const useChartData = ({ element, type }) => {
|
|
|
10624
10686
|
layerInfo,
|
|
10625
10687
|
};
|
|
10626
10688
|
})
|
|
10627
|
-
.filter(({ items }) => items === null ||
|
|
10689
|
+
.filter(({ items }) => items === null ||
|
|
10690
|
+
(items?.length && !items.every(({ value }) => value === null)));
|
|
10628
10691
|
}
|
|
10629
10692
|
return [
|
|
10630
10693
|
{
|