@evergis/react 3.1.21 → 3.1.23
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/hooks/useChartChange.d.ts +3 -2
- package/dist/components/Dashboard/hooks/useDataSources.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useAppHeight.d.ts +1 -0
- package/dist/index.js +70 -31
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +70 -32
- package/dist/react.esm.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LineChartProps } from '@evergis/charts';
|
|
1
|
+
import { BarChartMarker, LineChartProps } from '@evergis/charts';
|
|
2
2
|
import { ConfigDataSource, ConfigRelatedDataSource } from '../types';
|
|
3
|
-
export declare const useChartChange: ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, showMarkers, }: {
|
|
3
|
+
export declare const useChartChange: ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, markers, showMarkers, }: {
|
|
4
4
|
dataSources: ConfigDataSource[];
|
|
5
5
|
chartId: string;
|
|
6
6
|
width: string | number;
|
|
@@ -8,5 +8,6 @@ export declare const useChartChange: ({ dataSources, chartId, width, height, rel
|
|
|
8
8
|
relatedAttributes: ConfigRelatedDataSource[];
|
|
9
9
|
defaultColor: string;
|
|
10
10
|
fontColor: string;
|
|
11
|
+
markers: BarChartMarker[] | string;
|
|
11
12
|
showMarkers: number;
|
|
12
13
|
}) => [LineChartProps["customize"], (range: [number, number]) => void];
|
|
@@ -8,7 +8,7 @@ export declare const useDataSources: ({ type: widgetType, config, attributes, fi
|
|
|
8
8
|
layerParams?: Record<string, string>;
|
|
9
9
|
eqlParameters?: QueryLayerServiceConfigurationDc["eqlParameters"];
|
|
10
10
|
}) => {
|
|
11
|
-
getDataSourcePromises: ({ ds, query, parameters, layerName, limit, condition, url, resourceId
|
|
11
|
+
getDataSourcePromises: ({ ds, query, parameters, layerName, limit, condition, url, resourceId }: ConfigDataSource, newFilters?: SelectedFilters, offset?: number) => Promise<EqlDataSource | import('@evergis/api').PagedFeaturesListDc>;
|
|
12
12
|
getUpdatingDataSources: () => ConfigDataSource[];
|
|
13
13
|
getUpdatedDataSources: (responses: DataSourcePromise[], currentDataSources: ConfigDataSource[], otherDataSources: FetchedDataSource[]) => any;
|
|
14
14
|
zoomToLayersExtent: (layers: Array<{
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAppHeight: () => void;
|
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ const ChartTooltipRow = styled(uilibGl.Flex) `
|
|
|
70
70
|
flex-direction: row;
|
|
71
71
|
flex-wrap: nowrap;
|
|
72
72
|
align-items: center;
|
|
73
|
-
margin-top: 0.
|
|
73
|
+
margin-top: 0.5rem;
|
|
74
74
|
line-height: 0;
|
|
75
75
|
|
|
76
76
|
${ChartLegendColor$1} {
|
|
@@ -188,8 +188,7 @@ const LineChartStyles = styled.createGlobalStyle `
|
|
|
188
188
|
}
|
|
189
189
|
`;
|
|
190
190
|
const StyledBarChart = styled(charts.BarChart) `
|
|
191
|
-
.domain
|
|
192
|
-
line {
|
|
191
|
+
.domain {
|
|
193
192
|
display: none;
|
|
194
193
|
}
|
|
195
194
|
|
|
@@ -4004,7 +4003,7 @@ function wrap() {
|
|
|
4004
4003
|
textLength = self.node().getComputedTextLength();
|
|
4005
4004
|
}
|
|
4006
4005
|
}
|
|
4007
|
-
const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, showMarkers, }) => {
|
|
4006
|
+
const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, markers, showMarkers, }) => {
|
|
4008
4007
|
const { t } = useGlobalContext();
|
|
4009
4008
|
const { layerInfos } = useWidgetContext();
|
|
4010
4009
|
const strokeColors = relatedAttributes.filter(({ chartAxis }) => chartAxis === "y").map(({ axisColor }) => axisColor);
|
|
@@ -4041,8 +4040,11 @@ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes
|
|
|
4041
4040
|
if (index === nodes.length - 1) {
|
|
4042
4041
|
nodes[index].style.textAnchor = "end";
|
|
4043
4042
|
}
|
|
4043
|
+
if (markers) {
|
|
4044
|
+
nodes[index].remove();
|
|
4045
|
+
}
|
|
4044
4046
|
if (showMarkers) {
|
|
4045
|
-
if (index %
|
|
4047
|
+
if (index % showMarkers !== 0) {
|
|
4046
4048
|
nodes[index].remove();
|
|
4047
4049
|
}
|
|
4048
4050
|
}
|
|
@@ -4097,7 +4099,7 @@ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes
|
|
|
4097
4099
|
onChange();
|
|
4098
4100
|
});
|
|
4099
4101
|
svg.append("defs").html(() => defs.join(""));
|
|
4100
|
-
}, [fontColor, dataSources, layerInfos, relatedAttributes, chartId, strokeColors, defaultColor, width, onChange, showMarkers]);
|
|
4102
|
+
}, [fontColor, dataSources, layerInfos, relatedAttributes, chartId, strokeColors, defaultColor, width, onChange, showMarkers, markers]);
|
|
4101
4103
|
return [customize, onChange];
|
|
4102
4104
|
};
|
|
4103
4105
|
|
|
@@ -4944,6 +4946,19 @@ const useServerNotificationsContext = () => {
|
|
|
4944
4946
|
return React.useContext(ServerNotificationsContext);
|
|
4945
4947
|
};
|
|
4946
4948
|
|
|
4949
|
+
const useAppHeight = () => {
|
|
4950
|
+
React.useEffect(() => {
|
|
4951
|
+
const setAppHeight = () => {
|
|
4952
|
+
document.documentElement.style.setProperty("--app-height", `${window.innerHeight}px`);
|
|
4953
|
+
};
|
|
4954
|
+
window.addEventListener("resize", setAppHeight);
|
|
4955
|
+
setAppHeight();
|
|
4956
|
+
return () => {
|
|
4957
|
+
window.removeEventListener("resize", setAppHeight);
|
|
4958
|
+
};
|
|
4959
|
+
}, []);
|
|
4960
|
+
};
|
|
4961
|
+
|
|
4947
4962
|
const useDebouncedCallback = (interval) => {
|
|
4948
4963
|
return React.useMemo(() => debounce((cb) => {
|
|
4949
4964
|
cb();
|
|
@@ -5386,14 +5401,20 @@ const getChartFilterName = (relatedDataSources) => {
|
|
|
5386
5401
|
return axes?.[0]?.filterName;
|
|
5387
5402
|
};
|
|
5388
5403
|
|
|
5404
|
+
function getValueIndex(items, attributes) {
|
|
5405
|
+
return items?.findIndex(({ name }) => name.toString() === attributes.value?.toString());
|
|
5406
|
+
}
|
|
5389
5407
|
const getChartMarkers = (items, markers, dataSources) => {
|
|
5390
5408
|
if (typeof markers === "string") {
|
|
5391
5409
|
const dataSource = getDataSource(markers, dataSources);
|
|
5392
|
-
return dataSource?.features?.map(({ attributes }) =>
|
|
5410
|
+
return dataSource?.features?.map(({ attributes }) => ({
|
|
5411
|
+
...attributes,
|
|
5412
|
+
value: getValueIndex(items, attributes),
|
|
5413
|
+
})) || [];
|
|
5393
5414
|
}
|
|
5394
5415
|
return (markers?.map(marker => ({
|
|
5395
5416
|
...marker,
|
|
5396
|
-
value: items
|
|
5417
|
+
value: getValueIndex(items, marker),
|
|
5397
5418
|
})) || []);
|
|
5398
5419
|
};
|
|
5399
5420
|
|
|
@@ -8779,11 +8800,26 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
8779
8800
|
const { dataSources } = useWidgetContext(widgetType);
|
|
8780
8801
|
const { filters: configFilters, dataSources: configDataSources } = config || {};
|
|
8781
8802
|
const prevFilters = React.useRef({});
|
|
8782
|
-
const getDataSourcePromises = React.useCallback(async ({ ds, query, parameters, layerName, limit, condition, url, resourceId
|
|
8803
|
+
const getDataSourcePromises = React.useCallback(async ({ ds, query, parameters, layerName, limit, condition, url, resourceId }, newFilters, offset = 0) => {
|
|
8783
8804
|
const selectedFilters = {
|
|
8784
8805
|
...(filters || {}),
|
|
8785
8806
|
...(newFilters || {}),
|
|
8786
8807
|
};
|
|
8808
|
+
if (resourceId) {
|
|
8809
|
+
const response = await api.remoteTaskManager.post({
|
|
8810
|
+
workerType: "pythonService",
|
|
8811
|
+
methodType: "pythonrunner/run",
|
|
8812
|
+
data: {
|
|
8813
|
+
method: "get",
|
|
8814
|
+
resourceId,
|
|
8815
|
+
parameters,
|
|
8816
|
+
}
|
|
8817
|
+
});
|
|
8818
|
+
return {
|
|
8819
|
+
items: response.result.items,
|
|
8820
|
+
attributeDefinition: null,
|
|
8821
|
+
};
|
|
8822
|
+
}
|
|
8787
8823
|
const newParams = applyQueryFilters({
|
|
8788
8824
|
parameters,
|
|
8789
8825
|
dataSources,
|
|
@@ -8791,8 +8827,8 @@ const useDataSources = ({ type: widgetType, config, attributes, filters, layerPa
|
|
|
8791
8827
|
filters: configFilters,
|
|
8792
8828
|
geometry: ewktGeometry,
|
|
8793
8829
|
});
|
|
8794
|
-
if (url
|
|
8795
|
-
const response = await fetch(url
|
|
8830
|
+
if (url) {
|
|
8831
|
+
const response = await fetch(url, {
|
|
8796
8832
|
method: "POST",
|
|
8797
8833
|
headers: {
|
|
8798
8834
|
Accept: "application/json",
|
|
@@ -9162,6 +9198,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9162
9198
|
fontColor,
|
|
9163
9199
|
relatedAttributes,
|
|
9164
9200
|
defaultColor: primaryColor,
|
|
9201
|
+
markers: configMarkers,
|
|
9165
9202
|
showMarkers,
|
|
9166
9203
|
});
|
|
9167
9204
|
const { formatFilterColor, onFilter } = useFeatureFilters(type, filterName, data?.[0]?.items);
|
|
@@ -9191,6 +9228,15 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9191
9228
|
})] }));
|
|
9192
9229
|
}, [labels, layerInfos]);
|
|
9193
9230
|
const markers = React.useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
|
|
9231
|
+
const margin = React.useMemo(() => {
|
|
9232
|
+
const markersMargin = showMarkers ? 10 : 0;
|
|
9233
|
+
return {
|
|
9234
|
+
top: markersMargin,
|
|
9235
|
+
right: markersMargin,
|
|
9236
|
+
bottom: markers?.length ? 20 : markersMargin,
|
|
9237
|
+
left: markersMargin
|
|
9238
|
+
};
|
|
9239
|
+
}, [showMarkers, markers?.length]);
|
|
9194
9240
|
const formatTooltipName = React.useCallback((name) => (isRelated ? name : tooltipNameFromAttributes(name, formattedAttributes)), [formattedAttributes, isRelated]);
|
|
9195
9241
|
const formatTooltipValue = React.useCallback((value, name) => isRelated
|
|
9196
9242
|
? tooltipValueFromRelatedFeatures(t, value, relatedAttributes, data[0]?.layerInfo)
|
|
@@ -9199,11 +9245,14 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9199
9245
|
yAxisLeft.tickFormat((index) => index);
|
|
9200
9246
|
}, []);
|
|
9201
9247
|
const customXAxisBottom = React.useCallback((xAxisBottom, data) => {
|
|
9202
|
-
xAxisBottom.tickFormat((index) =>
|
|
9203
|
-
?
|
|
9204
|
-
:
|
|
9205
|
-
|
|
9206
|
-
|
|
9248
|
+
xAxisBottom.tickFormat((index) => markers
|
|
9249
|
+
? ""
|
|
9250
|
+
: (showMarkers
|
|
9251
|
+
? index % showMarkers === 0
|
|
9252
|
+
: index === 0 || index === data.length - 1)
|
|
9253
|
+
? data[index]?.groupName || ""
|
|
9254
|
+
: "");
|
|
9255
|
+
}, [markers, showMarkers]);
|
|
9207
9256
|
const renderChart = React.useMemo(() => {
|
|
9208
9257
|
if (!element)
|
|
9209
9258
|
return null;
|
|
@@ -9221,16 +9270,11 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9221
9270
|
.flat()
|
|
9222
9271
|
.map(({ values }) => values)
|
|
9223
9272
|
.flat();
|
|
9224
|
-
return (jsxRuntime.jsxs(AnyChartWrapper, { height: height, children: [jsxRuntime.jsx(LineChartStyles, {}), jsxRuntime.jsx(charts.LineChart, { data: lineChartData, labels: labels, width: +width, height: height, xAxisPadding: 15, yAxisPadding: 0, min: Math.min(...chartValues), customYAxisSelection: yAxis => {
|
|
9273
|
+
return (jsxRuntime.jsxs(AnyChartWrapper, { height: height, children: [jsxRuntime.jsx(LineChartStyles, {}), jsxRuntime.jsx(charts.LineChart, { data: lineChartData, labels: labels, markers: markers, width: +width, height: height, xAxisPadding: 15, yAxisPadding: 0, min: Math.min(...chartValues), customYAxisSelection: yAxis => {
|
|
9225
9274
|
if (isHidedY) {
|
|
9226
9275
|
yAxis.remove();
|
|
9227
9276
|
}
|
|
9228
|
-
}, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin:
|
|
9229
|
-
top: 0,
|
|
9230
|
-
right: 0,
|
|
9231
|
-
bottom: 0,
|
|
9232
|
-
left: 0
|
|
9233
|
-
} })] }));
|
|
9277
|
+
}, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: margin })] }));
|
|
9234
9278
|
}
|
|
9235
9279
|
if (isStackBar) {
|
|
9236
9280
|
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 }) }));
|
|
@@ -9244,13 +9288,6 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9244
9288
|
})) || []), width: +width, height: +width, padAngle: angle, outerRadius: radius, cornerRadius: cornerRadius, renderTooltip: renderPieChartTooltip, withTooltip: true, onClick: filterName ? item => onFilter(item.name) : undefined, children: showTotal && jsxRuntime.jsx(PieChartCenter, { children: totalWord || roundTotalSum(+totalSum) }) }) }));
|
|
9245
9289
|
}
|
|
9246
9290
|
const barChartData = getDataFromFilterItems(data[0]?.items);
|
|
9247
|
-
const markersMargin = showMarkers ? 10 : 0;
|
|
9248
|
-
const margin = {
|
|
9249
|
-
top: markersMargin,
|
|
9250
|
-
right: markersMargin,
|
|
9251
|
-
bottom: markers?.length ? 20 : markersMargin,
|
|
9252
|
-
left: markersMargin
|
|
9253
|
-
};
|
|
9254
9291
|
return (jsxRuntime.jsx(BarChartWrapper, { height: height + margin.bottom, children: jsxRuntime.jsx(BarChartContainer, { children: jsxRuntime.jsx(StyledBarChart, { data: barChartData, colors: getColorsFromFilterItems(data[0]?.items, defaultColor, formatFilterColor), minValue: getMinValueFromFilterItems(data[0]?.items), markers: markers, width: +width, height: height, barWidth: barWidth, barPadding: padding, customYAxisLeft: customYAxisLeft, customXAxisBottom: xAxisBottom => customXAxisBottom(xAxisBottom, barChartData), customYAxis: axis => !showLabels && axis.remove(), customBars: ({ bars }) => {
|
|
9255
9292
|
bars.attr("rx", radius);
|
|
9256
9293
|
bars.attr("ry", radius);
|
|
@@ -9277,6 +9314,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
9277
9314
|
filterName,
|
|
9278
9315
|
axes,
|
|
9279
9316
|
labels,
|
|
9317
|
+
margin,
|
|
9280
9318
|
renderLineChartTooltip,
|
|
9281
9319
|
customize,
|
|
9282
9320
|
primaryColor,
|
|
@@ -9763,7 +9801,7 @@ const VectorLayer = ({ layer, tileUrl, visible, beforeId, getLayerTempStyle, })
|
|
|
9763
9801
|
return (jsxRuntime.jsx(MapGL.Source, { promoteId: idAttribute, id: layer.name, type: "vector", tiles: [tileUrl], children: clientStyle?.items ? renderClientStyle() : renderLayerByGeometryType() }));
|
|
9764
9802
|
};
|
|
9765
9803
|
|
|
9766
|
-
const Layer = ({ layer, layerType, visible, beforeId, tileUrl, getLayerTempStyle, onMount = () =>
|
|
9804
|
+
const Layer = ({ layer, layerType, visible, beforeId, tileUrl, getLayerTempStyle, onMount = () => { }, }) => {
|
|
9767
9805
|
React.useEffect(onMount, []); // eslint-disable-line
|
|
9768
9806
|
if (!layer) {
|
|
9769
9807
|
return null;
|
|
@@ -10037,6 +10075,7 @@ exports.tooltipValueFromAttributes = tooltipValueFromAttributes;
|
|
|
10037
10075
|
exports.tooltipValueFromRelatedFeatures = tooltipValueFromRelatedFeatures;
|
|
10038
10076
|
exports.transparentizeColor = transparentizeColor;
|
|
10039
10077
|
exports.treeNodesToProjectItems = treeNodesToProjectItems;
|
|
10078
|
+
exports.useAppHeight = useAppHeight;
|
|
10040
10079
|
exports.useChartChange = useChartChange;
|
|
10041
10080
|
exports.useChartData = useChartData;
|
|
10042
10081
|
exports.useDashboardHeader = useDashboardHeader;
|