@evergis/react 3.1.40 → 3.1.41
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/react.esm.js
CHANGED
|
@@ -8833,7 +8833,7 @@ const useChartData = ({ element, type }) => {
|
|
|
8833
8833
|
return [];
|
|
8834
8834
|
return filteredAttributes
|
|
8835
8835
|
.map(relatedAxis => {
|
|
8836
|
-
const { dataSourceName, axisColor, attributeName } = relatedAxis;
|
|
8836
|
+
const { dataSourceName, axisColor, attributeName, attributeUnits } = relatedAxis;
|
|
8837
8837
|
const dataSource = configDataSources.find(({ name }) => name === dataSourceName);
|
|
8838
8838
|
const layerInfo = layerInfos?.find(item => item?.name === dataSource?.layerName);
|
|
8839
8839
|
const featureDataSource = getDataSource(dataSourceName, dataSources);
|
|
@@ -8851,8 +8851,10 @@ const useChartData = ({ element, type }) => {
|
|
|
8851
8851
|
})
|
|
8852
8852
|
: null,
|
|
8853
8853
|
color: axisColor,
|
|
8854
|
+
attributeName,
|
|
8855
|
+
attributeUnits,
|
|
8856
|
+
dataSourceName,
|
|
8854
8857
|
layerInfo,
|
|
8855
|
-
attributeName
|
|
8856
8858
|
};
|
|
8857
8859
|
})
|
|
8858
8860
|
.filter(({ items }) => items === null || (items?.length && !items.every(({ value }) => value === null)));
|
|
@@ -8862,6 +8864,8 @@ const useChartData = ({ element, type }) => {
|
|
|
8862
8864
|
items: getDataFromAttributes(t, element, attributes),
|
|
8863
8865
|
layerInfo: null,
|
|
8864
8866
|
attributeName: null,
|
|
8867
|
+
attributeUnits: null,
|
|
8868
|
+
dataSourceName: null,
|
|
8865
8869
|
color: null
|
|
8866
8870
|
}
|
|
8867
8871
|
];
|
|
@@ -9393,7 +9397,7 @@ const Chart = memo(({ config, element, elementConfig, type, renderElement }) =>
|
|
|
9393
9397
|
const { t } = useGlobalContext();
|
|
9394
9398
|
const { expandedContainers, layerInfos, attributes, dataSources } = useWidgetContext(type);
|
|
9395
9399
|
const { id, options, children } = element || {};
|
|
9396
|
-
const { column, markers: configMarkers, showLabels, showMarkers, showTotal, totalWord: configTotalWord, totalAttribute, expandable, expanded, chartType, relatedDataSources, defaultColor } = options || {};
|
|
9400
|
+
const { column, markers: configMarkers, showLabels, showMarkers, showTotal, totalWord: configTotalWord, totalAttribute, expandable, expanded, chartType, relatedDataSources, defaultColor, dotSnapping, } = options || {};
|
|
9397
9401
|
const isLineChart = chartType === "line";
|
|
9398
9402
|
const isPieChart = chartType === "pie";
|
|
9399
9403
|
const isStackBar = chartType === "stack";
|
|
@@ -9448,14 +9452,23 @@ const Chart = memo(({ config, element, elementConfig, type, renderElement }) =>
|
|
|
9448
9452
|
const renderLineChartTooltip = useCallback((items, { indexX }) => {
|
|
9449
9453
|
return (jsxs(Tooltip, { children: [jsx(ChartTooltipLabel, { children: labels[indexX] }), items
|
|
9450
9454
|
.filter(({ value }) => !isEmptyValue(value))
|
|
9451
|
-
?.map(({ layerName, attributeName, value, stroke }, index) => {
|
|
9452
|
-
const layerInfo =
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9455
|
+
?.map(({ layerName, attributeName, attributeUnits, dataSourceName, value, stroke }, index) => {
|
|
9456
|
+
const layerInfo = !attributeUnits
|
|
9457
|
+
? layerInfos?.find(({ name }) => name === layerName)
|
|
9458
|
+
: null;
|
|
9459
|
+
const attribute = !attributeUnits
|
|
9460
|
+
? layerInfo?.layerDefinition.attributes[attributeName]
|
|
9461
|
+
: null;
|
|
9462
|
+
const dataSource = dataSourceName ? getDataSource(dataSourceName, dataSources) : null;
|
|
9463
|
+
const dataSourceUnits = !dataSource || !attributeUnits
|
|
9464
|
+
? null
|
|
9465
|
+
: dataSource.features?.[0]?.attributes?.[attributeUnits];
|
|
9466
|
+
const legendValue = attribute
|
|
9467
|
+
? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat })
|
|
9468
|
+
: [value, dataSourceUnits].filter(Boolean).join(" ");
|
|
9469
|
+
return (jsxs(ChartTooltipRow, { children: [jsx(ChartLegendColor$1, { "$color": stroke }), jsx(ChartLegendValue, { children: legendValue })] }, index));
|
|
9457
9470
|
})] }));
|
|
9458
|
-
}, [labels, layerInfos]);
|
|
9471
|
+
}, [labels, layerInfos, dataSources, dotSnapping]);
|
|
9459
9472
|
const markers = useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
|
|
9460
9473
|
const margin = useMemo(() => {
|
|
9461
9474
|
const markersMargin = showMarkers ? 10 : 0;
|
|
@@ -9489,6 +9502,8 @@ const Chart = memo(({ config, element, elementConfig, type, renderElement }) =>
|
|
|
9489
9502
|
const lineChartData = data.map(item => ({
|
|
9490
9503
|
layerName: item.layerInfo?.name,
|
|
9491
9504
|
attributeName: item.attributeName,
|
|
9505
|
+
attributeUnits: item.attributeUnits,
|
|
9506
|
+
dataSourceName: item.dataSourceName,
|
|
9492
9507
|
stroke: item.color || primaryColor,
|
|
9493
9508
|
values: item.items
|
|
9494
9509
|
?.filter(({ value }) => !isEmptyValue(value))
|
|
@@ -9503,7 +9518,7 @@ const Chart = memo(({ config, element, elementConfig, type, renderElement }) =>
|
|
|
9503
9518
|
if (isHidedY) {
|
|
9504
9519
|
yAxis.remove();
|
|
9505
9520
|
}
|
|
9506
|
-
}, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: margin })] }));
|
|
9521
|
+
}, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dotSnapping: dotSnapping, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: margin })] }));
|
|
9507
9522
|
}
|
|
9508
9523
|
if (isStackBar) {
|
|
9509
9524
|
return (jsx(AnyChartWrapper, { height: height, children: jsx(StackBar, { data: data, filterName: filterName, type: type, alias: elementConfig?.children?.find(child => child.id === "alias"), options: options, renderTooltip: renderPieChartTooltip, renderElement: renderElement }) }));
|