@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.
@@ -8,5 +8,7 @@ export type ChartDataProps = {
8
8
  items: FilterItem[] | PieChartData[] | BarChartData[];
9
9
  layerInfo: LayerInfo | null;
10
10
  attributeName: string | null;
11
+ attributeUnits: string | null;
12
+ dataSourceName: string | null;
11
13
  color: string | null;
12
14
  };
@@ -19,6 +19,7 @@ export interface ConfigRelatedDataSource {
19
19
  dataSourceName: string;
20
20
  attributeName: string;
21
21
  attributeTitle: string;
22
+ attributeUnits?: string;
22
23
  attributeColor?: string;
23
24
  alias?: string;
24
25
  chartAxis?: string;
@@ -46,6 +47,7 @@ export interface ConfigOptions {
46
47
  label?: string;
47
48
  withPadding?: boolean;
48
49
  withDivider?: boolean;
50
+ dotSnapping?: boolean;
49
51
  tagView?: boolean;
50
52
  simple?: boolean;
51
53
  separator?: string;
package/dist/index.js CHANGED
@@ -8835,7 +8835,7 @@ const useChartData = ({ element, type }) => {
8835
8835
  return [];
8836
8836
  return filteredAttributes
8837
8837
  .map(relatedAxis => {
8838
- const { dataSourceName, axisColor, attributeName } = relatedAxis;
8838
+ const { dataSourceName, axisColor, attributeName, attributeUnits } = relatedAxis;
8839
8839
  const dataSource = configDataSources.find(({ name }) => name === dataSourceName);
8840
8840
  const layerInfo = layerInfos?.find(item => item?.name === dataSource?.layerName);
8841
8841
  const featureDataSource = getDataSource(dataSourceName, dataSources);
@@ -8853,8 +8853,10 @@ const useChartData = ({ element, type }) => {
8853
8853
  })
8854
8854
  : null,
8855
8855
  color: axisColor,
8856
+ attributeName,
8857
+ attributeUnits,
8858
+ dataSourceName,
8856
8859
  layerInfo,
8857
- attributeName
8858
8860
  };
8859
8861
  })
8860
8862
  .filter(({ items }) => items === null || (items?.length && !items.every(({ value }) => value === null)));
@@ -8864,6 +8866,8 @@ const useChartData = ({ element, type }) => {
8864
8866
  items: getDataFromAttributes(t, element, attributes),
8865
8867
  layerInfo: null,
8866
8868
  attributeName: null,
8869
+ attributeUnits: null,
8870
+ dataSourceName: null,
8867
8871
  color: null
8868
8872
  }
8869
8873
  ];
@@ -9395,7 +9399,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9395
9399
  const { t } = useGlobalContext();
9396
9400
  const { expandedContainers, layerInfos, attributes, dataSources } = useWidgetContext(type);
9397
9401
  const { id, options, children } = element || {};
9398
- const { column, markers: configMarkers, showLabels, showMarkers, showTotal, totalWord: configTotalWord, totalAttribute, expandable, expanded, chartType, relatedDataSources, defaultColor } = options || {};
9402
+ const { column, markers: configMarkers, showLabels, showMarkers, showTotal, totalWord: configTotalWord, totalAttribute, expandable, expanded, chartType, relatedDataSources, defaultColor, dotSnapping, } = options || {};
9399
9403
  const isLineChart = chartType === "line";
9400
9404
  const isPieChart = chartType === "pie";
9401
9405
  const isStackBar = chartType === "stack";
@@ -9450,14 +9454,23 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9450
9454
  const renderLineChartTooltip = React.useCallback((items, { indexX }) => {
9451
9455
  return (jsxRuntime.jsxs(Tooltip, { children: [jsxRuntime.jsx(ChartTooltipLabel, { children: labels[indexX] }), items
9452
9456
  .filter(({ value }) => !isEmptyValue(value))
9453
- ?.map(({ layerName, attributeName, value, stroke }, index) => {
9454
- const layerInfo = layerInfos?.find(({ name }) => name === layerName);
9455
- const attribute = layerInfo?.layerDefinition.attributes[attributeName];
9456
- return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: attribute
9457
- ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat })
9458
- : value })] }, index));
9457
+ ?.map(({ layerName, attributeName, attributeUnits, dataSourceName, value, stroke }, index) => {
9458
+ const layerInfo = !attributeUnits
9459
+ ? layerInfos?.find(({ name }) => name === layerName)
9460
+ : null;
9461
+ const attribute = !attributeUnits
9462
+ ? layerInfo?.layerDefinition.attributes[attributeName]
9463
+ : null;
9464
+ const dataSource = dataSourceName ? getDataSource(dataSourceName, dataSources) : null;
9465
+ const dataSourceUnits = !dataSource || !attributeUnits
9466
+ ? null
9467
+ : dataSource.features?.[0]?.attributes?.[attributeUnits];
9468
+ const legendValue = attribute
9469
+ ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat })
9470
+ : [value, dataSourceUnits].filter(Boolean).join(" ");
9471
+ return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: legendValue })] }, index));
9459
9472
  })] }));
9460
- }, [labels, layerInfos]);
9473
+ }, [labels, layerInfos, dataSources, dotSnapping]);
9461
9474
  const markers = React.useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
9462
9475
  const margin = React.useMemo(() => {
9463
9476
  const markersMargin = showMarkers ? 10 : 0;
@@ -9491,6 +9504,8 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9491
9504
  const lineChartData = data.map(item => ({
9492
9505
  layerName: item.layerInfo?.name,
9493
9506
  attributeName: item.attributeName,
9507
+ attributeUnits: item.attributeUnits,
9508
+ dataSourceName: item.dataSourceName,
9494
9509
  stroke: item.color || primaryColor,
9495
9510
  values: item.items
9496
9511
  ?.filter(({ value }) => !isEmptyValue(value))
@@ -9505,7 +9520,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9505
9520
  if (isHidedY) {
9506
9521
  yAxis.remove();
9507
9522
  }
9508
- }, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: margin })] }));
9523
+ }, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dotSnapping: dotSnapping, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: margin })] }));
9509
9524
  }
9510
9525
  if (isStackBar) {
9511
9526
  return (jsxRuntime.jsx(AnyChartWrapper, { height: height, children: jsxRuntime.jsx(StackBar, { data: data, filterName: filterName, type: type, alias: elementConfig?.children?.find(child => child.id === "alias"), options: options, renderTooltip: renderPieChartTooltip, renderElement: renderElement }) }));