@evergis/react 4.0.106 → 4.0.108
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.
|
@@ -6,6 +6,7 @@ export declare const DEFAULT_BAR_PADDING = 1;
|
|
|
6
6
|
export declare const DEFAULT_BAR_CHART_HEIGHT = 100;
|
|
7
7
|
export declare const BAR_CHART_HEADER_HEIGHT = 40;
|
|
8
8
|
export declare const BAR_CHART_FOOTER_MARGIN = 16;
|
|
9
|
+
export declare const LINE_CHART_LABEL_MARGIN = 20;
|
|
9
10
|
export declare const DEFAULT_BAR_CHART_MARGINS: {
|
|
10
11
|
top: number;
|
|
11
12
|
left: number;
|
package/dist/index.js
CHANGED
|
@@ -7665,17 +7665,17 @@ const useHideIfEmptyDataSource = (type = exports.WidgetType.Dashboard) => {
|
|
|
7665
7665
|
};
|
|
7666
7666
|
|
|
7667
7667
|
const useProjectDashboardInit = () => {
|
|
7668
|
+
const { currentPage } = useWidgetPage();
|
|
7668
7669
|
const { projectInfo, updateProject } = useWidgetContext();
|
|
7669
7670
|
return React.useCallback(() => {
|
|
7670
|
-
if (!lodash.isEmpty(projectInfo
|
|
7671
|
+
if (!projectInfo || !lodash.isEmpty(projectInfo.content?.dashboardConfiguration)) {
|
|
7671
7672
|
return;
|
|
7672
7673
|
}
|
|
7673
|
-
const { alias, name
|
|
7674
|
-
const { items } = content || {};
|
|
7674
|
+
const { alias, name } = projectInfo;
|
|
7675
7675
|
const newProjectInfo = JSON.parse(JSON.stringify(projectInfo));
|
|
7676
|
-
newProjectInfo.content.dashboardConfiguration = getDefaultConfig({ title: alias || name, items });
|
|
7676
|
+
newProjectInfo.content.dashboardConfiguration = getDefaultConfig({ title: alias || name, items: currentPage?.layers });
|
|
7677
7677
|
updateProject(newProjectInfo);
|
|
7678
|
-
}, [projectInfo, updateProject]);
|
|
7678
|
+
}, [currentPage?.layers, projectInfo, updateProject]);
|
|
7679
7679
|
};
|
|
7680
7680
|
|
|
7681
7681
|
const useRelatedDataSourceAttributes = ({ type = exports.WidgetType.Dashboard, elementConfig, dataSources, feature, }) => {
|
|
@@ -8313,6 +8313,7 @@ const DEFAULT_BAR_PADDING = 1;
|
|
|
8313
8313
|
const DEFAULT_BAR_CHART_HEIGHT = 100;
|
|
8314
8314
|
const BAR_CHART_HEADER_HEIGHT = 40;
|
|
8315
8315
|
const BAR_CHART_FOOTER_MARGIN = 16;
|
|
8316
|
+
const LINE_CHART_LABEL_MARGIN = 20;
|
|
8316
8317
|
const DEFAULT_BAR_CHART_MARGINS = {
|
|
8317
8318
|
top: 0,
|
|
8318
8319
|
left: 0,
|
|
@@ -9356,7 +9357,7 @@ const useLayerGroupMenu = () => {
|
|
|
9356
9357
|
|
|
9357
9358
|
const LayerGroup = ({ group, onlyMainTools }) => {
|
|
9358
9359
|
const { projectInfo, updateProject } = useWidgetContext();
|
|
9359
|
-
const { pageIndex } = useWidgetPage();
|
|
9360
|
+
const { pageIndex, currentPage } = useWidgetPage();
|
|
9360
9361
|
const { isMenuOpen, toggleMenu, options, selectOption } = useLayerGroupMenu();
|
|
9361
9362
|
const onToggleExpand = React.useCallback((name, isExpanded) => {
|
|
9362
9363
|
if (!projectInfo) {
|
|
@@ -9364,18 +9365,18 @@ const LayerGroup = ({ group, onlyMainTools }) => {
|
|
|
9364
9365
|
}
|
|
9365
9366
|
const newProjectInfo = JSON.parse(JSON.stringify(projectInfo));
|
|
9366
9367
|
const page = getPagesFromProjectInfo(newProjectInfo)?.[pageIndex - 1];
|
|
9367
|
-
page.layers = findAnd.changeProps(
|
|
9368
|
+
page.layers = findAnd.changeProps(currentPage?.layers, { name }, { isExpanded });
|
|
9368
9369
|
updateProject(newProjectInfo);
|
|
9369
|
-
}, [pageIndex, projectInfo, updateProject]);
|
|
9370
|
+
}, [currentPage?.layers, pageIndex, projectInfo, updateProject]);
|
|
9370
9371
|
const onToggleVisibility = React.useCallback((name, isVisible) => {
|
|
9371
9372
|
if (!projectInfo) {
|
|
9372
9373
|
return;
|
|
9373
9374
|
}
|
|
9374
9375
|
const newProjectInfo = JSON.parse(JSON.stringify(projectInfo));
|
|
9375
9376
|
const page = getPagesFromProjectInfo(newProjectInfo)?.[pageIndex - 1];
|
|
9376
|
-
page.layers = findAnd.changeProps(
|
|
9377
|
+
page.layers = findAnd.changeProps(currentPage?.layers, { name }, { isVisible });
|
|
9377
9378
|
updateProject(newProjectInfo);
|
|
9378
|
-
}, [pageIndex, projectInfo, updateProject]);
|
|
9379
|
+
}, [currentPage?.layers, pageIndex, projectInfo, updateProject]);
|
|
9379
9380
|
if (!group) {
|
|
9380
9381
|
return null;
|
|
9381
9382
|
}
|
|
@@ -14378,11 +14379,17 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
14378
14379
|
.flat()
|
|
14379
14380
|
.map(({ values }) => values)
|
|
14380
14381
|
.flat();
|
|
14382
|
+
// Резервируем нижнюю полосу под подписи оси X: без неё ось прижата к нижней границе,
|
|
14383
|
+
// подписи (сдвинутые на +16px) вылезают за тело и режутся overflow: hidden у ChartFillMeasure.
|
|
14384
|
+
const lineMargin = {
|
|
14385
|
+
...margin,
|
|
14386
|
+
bottom: Math.max(margin.bottom, LINE_CHART_LABEL_MARGIN),
|
|
14387
|
+
};
|
|
14381
14388
|
return (jsxRuntime.jsxs(AnyChartWrapper, { height: chartHeight, children: [jsxRuntime.jsx(LineChartStyles, {}), jsxRuntime.jsx(charts.LineChart, { data: lineChartData, labels: labels, markers: markers, width: chartWidth, height: chartHeight, xAxisPadding: 15, yAxisPadding: 0, min: Math.min(...chartValues), customYAxisSelection: yAxis => {
|
|
14382
14389
|
if (isHidedY) {
|
|
14383
14390
|
yAxis.remove();
|
|
14384
14391
|
}
|
|
14385
|
-
}, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dotSnapping: dotSnapping, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin:
|
|
14392
|
+
}, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dotSnapping: dotSnapping, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: lineMargin })] }));
|
|
14386
14393
|
}
|
|
14387
14394
|
if (isStackBar) {
|
|
14388
14395
|
// Вне fill chartHeight — высота самой полосы, и обёртка честно становится выше на строку
|
|
@@ -14409,8 +14416,9 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
|
|
|
14409
14416
|
? chartHeight - margin.bottom - BAR_CHART_FOOTER_MARGIN
|
|
14410
14417
|
: chartHeight;
|
|
14411
14418
|
return (jsxRuntime.jsx(BarChartWrapper, { height: barBodyHeight + 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: chartWidth, height: barBodyHeight, barWidth: barWidth, barPadding: padding, customYAxisLeft: customYAxisLeft, customXAxisBottom: xAxisBottom => customXAxisBottom(xAxisBottom, barChartData), customYAxis: axis => !showLabels && axis.remove(), customBars: ({ bars }) => {
|
|
14412
|
-
|
|
14413
|
-
bars.attr("
|
|
14419
|
+
const barRadius = options?.cornerRadius ?? DEFAULT_BARCHART_RADIUS;
|
|
14420
|
+
bars.attr("rx", barRadius);
|
|
14421
|
+
bars.attr("ry", barRadius);
|
|
14414
14422
|
}, margin: margin, xAxisPadding: 0, yAxisPadding: 0, formatTooltipValue: formatTooltipValue, formatTooltipName: formatTooltipName, hideTooltipGroupName: true, dynamicTooltipEnable: true, isBarTooltip: true, onBarClick: filterName ? item => onFilter(item.name) : undefined }) }) }));
|
|
14415
14423
|
}, [
|
|
14416
14424
|
customXAxisBottom,
|