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