@evergis/react 3.1.15 → 3.1.17

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.
@@ -1,5 +1,7 @@
1
+ import { CSSProperties } from 'react';
1
2
  export declare const ChartTooltipTable: import('styled-components').StyledComponent<"table", any, {}, never>;
2
3
  export declare const ChartTooltip: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps, never>;
4
+ export declare const ChartTooltipLabel: import('styled-components').StyledComponent<"div", any, {}, never>;
3
5
  export declare const ChartTooltipColor: import('styled-components').StyledComponent<"div", any, {
4
6
  $color: string;
5
7
  }, never>;
@@ -13,3 +15,17 @@ export declare const PieChartCenter: import('styled-components').StyledComponent
13
15
  export declare const ChartWrapperContainer: import('styled-components').StyledComponent<"div", any, {
14
16
  column: boolean;
15
17
  }, never>;
18
+ export declare const Tooltip: import('styled-components').StyledComponent<"div", any, {
19
+ transform?: CSSProperties["transform"];
20
+ }, never>;
21
+ export declare const LineChartStyles: import('styled-components').GlobalStyleComponent<{
22
+ [x: string]: any;
23
+ [x: number]: any;
24
+ [x: symbol]: any;
25
+ } & {
26
+ theme?: any;
27
+ } & {
28
+ as?: string | import('react').ComponentType<any>;
29
+ forwardedAs?: string | import('react').ComponentType<any>;
30
+ }, import('styled-components').DefaultTheme>;
31
+ export declare const StyledBarChart: import('styled-components').StyledComponent<import('react').FC<import('@evergis/charts').BarChartProps>, any, {}, never>;
@@ -1,6 +1,8 @@
1
+ export declare const ContainerIconValue: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps, never>;
1
2
  export declare const RoundedBackgroundContainerWrapper: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps & {
2
3
  $center?: boolean;
3
4
  $color?: string;
4
5
  $inlineUnits?: boolean;
6
+ $big?: boolean;
5
7
  $bigIcon?: boolean;
6
8
  }, never>;
@@ -1,6 +1,6 @@
1
1
  import { LineChartProps } from '@evergis/charts';
2
2
  import { ConfigDataSource, ConfigRelatedDataSource } from '../types';
3
- export declare const useChartChange: ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, }: {
3
+ export declare const useChartChange: ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, showMarkers, }: {
4
4
  dataSources: ConfigDataSource[];
5
5
  chartId: string;
6
6
  width: string | number;
@@ -8,4 +8,5 @@ export declare const useChartChange: ({ dataSources, chartId, width, height, rel
8
8
  relatedAttributes: ConfigRelatedDataSource[];
9
9
  defaultColor: string;
10
10
  fontColor: string;
11
+ showMarkers: number;
11
12
  }) => [LineChartProps["customize"], (range: [number, number]) => void];
@@ -75,7 +75,9 @@ export interface ConfigOptions {
75
75
  height?: number;
76
76
  barWidth?: number;
77
77
  barHeight?: number;
78
- markers?: BarChartMarker[];
78
+ showLabels?: boolean;
79
+ showMarkers?: number;
80
+ markers?: BarChartMarker[] | string;
79
81
  drawMinMax?: boolean;
80
82
  attributes?: string[];
81
83
  colors?: string[];
@@ -98,6 +100,7 @@ export interface ConfigOptions {
98
100
  wrap?: boolean;
99
101
  icon?: string;
100
102
  iconUrl?: string;
103
+ big?: boolean;
101
104
  bigIcon?: boolean;
102
105
  onlyIcon?: boolean;
103
106
  hideEmpty?: boolean;
@@ -1,3 +1,3 @@
1
1
  import { BarChartMarker } from '@evergis/charts';
2
- import { FilterItem } from '../types';
3
- export declare const getChartMarkers: (items: FilterItem[], markers: BarChartMarker[]) => BarChartMarker[];
2
+ import { FetchedDataSource, FilterItem } from '../types';
3
+ export declare const getChartMarkers: (items: FilterItem[], markers: BarChartMarker[] | string, dataSources: FetchedDataSource[]) => BarChartMarker[];
package/dist/index.js CHANGED
@@ -37,14 +37,18 @@ const ChartTooltipTable = styled.table `
37
37
  }
38
38
  `;
39
39
  const ChartTooltip = styled(uilibGl.Flex) `
40
- flex-direction: row;
41
- align-items: center;
42
40
  flex-wrap: nowrap;
41
+ background: rgb(48, 69, 79);
42
+ border-radius: 0.25rem;
43
+ color: white;
43
44
 
44
45
  :not(:last-child) {
45
46
  margin-bottom: 0.25rem;
46
47
  }
47
48
  `;
49
+ const ChartTooltipLabel = styled.div `
50
+ margin-right: 0.25rem;
51
+ `;
48
52
  const ChartTooltipColor = styled.div `
49
53
  width: 0.625rem;
50
54
  height: 0.625rem;
@@ -90,6 +94,115 @@ const ChartWrapperContainer = styled.div `
90
94
  position: relative;
91
95
  width: 100%;
92
96
  `;
97
+ const Tooltip = styled.div `
98
+ position: relative;
99
+ border-radius: 0.25rem;
100
+ background-color: rgba(28, 33, 48);
101
+ padding: 0.5rem;
102
+ box-shadow: 0 0.125rem 0.25rem 0 rgba(0, 0, 0, 0.15);
103
+ font-size: 0.75rem;
104
+ transform: ${({ transform }) => transform};
105
+ color: white;
106
+
107
+ :before {
108
+ position: absolute;
109
+ display: block;
110
+ content: "";
111
+ width: 0;
112
+ height: 0;
113
+ }
114
+ `;
115
+ const LineChartStyles = styled.createGlobalStyle `
116
+ .dashboardLineChartTooltip.${charts.lineChartClassNames.lineChartMouseLabel} {
117
+ .${charts.lineChartClassNames.lineChartLabelFlex} {
118
+ justify-content: center;
119
+ align-items: flex-end;
120
+
121
+ ${Tooltip} {
122
+ margin: 0 0 12px 0;
123
+
124
+ :before {
125
+ top: auto;
126
+ bottom: 0;
127
+ left: 50%;
128
+ transform: translate(-50%, 100%);
129
+ border-left: 4px solid transparent;
130
+ border-right: 4px solid transparent;
131
+ border-top: 4px solid rgba(28, 33, 48, 0.9);
132
+ }
133
+ }
134
+ }
135
+ }
136
+
137
+ .${charts.lineChartClassNames.lineChartYScaleGlobal}, .${charts.lineChartClassNames.lineChartXScaleGlobal} {
138
+ .domain {
139
+ visibility: hidden;
140
+ }
141
+
142
+ .tick {
143
+ text {
144
+ fill: ${({ theme: { palette } }) => palette.textDisabled};
145
+ }
146
+
147
+ line {
148
+ visibility: hidden;
149
+ }
150
+ }
151
+ }
152
+
153
+ .${charts.lineChartClassNames.lineChartXScaleGlobal} {
154
+ .tick {
155
+ :first-of-type {
156
+ text {
157
+ text-anchor: start;
158
+ }
159
+ }
160
+
161
+ :last-of-type {
162
+ text {
163
+ text-anchor: end;
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+ .${charts.lineChartClassNames.lineChartLine} {
170
+ stroke-width: 2px;
171
+ }
172
+
173
+ .${charts.lineChartClassNames.lineChartLabel} {
174
+ color: ${({ theme: { palette } }) => palette.textPrimary};
175
+ }
176
+
177
+ .${charts.lineChartClassNames.lineChartMouseCircle} {
178
+ stroke: #ffffff;
179
+ stroke-width: 2px;
180
+ }
181
+
182
+ .${charts.lineChartClassNames.lineChartGridLineX} {
183
+ stroke: ${({ theme: { palette } }) => palette.element};
184
+ }
185
+
186
+ text {
187
+ fill: ${({ theme: { palette } }) => palette.textDisabled};
188
+ }
189
+ `;
190
+ const StyledBarChart = styled(charts.BarChart) `
191
+ .domain,
192
+ line {
193
+ display: none;
194
+ }
195
+
196
+ .tick {
197
+ text {
198
+ fill: ${({ theme: { palette } }) => palette.textDisabled};
199
+ }
200
+
201
+ line {
202
+ visibility: hidden;
203
+ }
204
+ }
205
+ `;
93
206
 
94
207
  function range(start, stop, step) {
95
208
  start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
@@ -3884,41 +3997,7 @@ function wrap() {
3884
3997
  textLength = self.node().getComputedTextLength();
3885
3998
  }
3886
3999
  }
3887
- // https://jr.everpoint.ru/browse/PUB-5221
3888
- /* function wrap2(text, width, content) {
3889
- text.each(() => {
3890
- const textElem = d3.select(this);
3891
- const words = content.split(/\s+/).reverse();
3892
- let word;
3893
- let line = [];
3894
- let lineNumber = 0;
3895
- const lineHeight = 1.1; // ems
3896
- const x = 0; // textElem.attr("x");
3897
- const y = 0; // textElem.attr("y");
3898
- const dy = 0; // parseFloat(text.attr("dy")),
3899
- // eslint-disable-next-line newline-per-chained-call
3900
- let tspan = textElem.text(null).append("tspan").attr("x", x).attr("y", y).attr("dy", `${dy}em`);
3901
-
3902
- // eslint-disable-next-line no-cond-assign
3903
- while ((word = words.pop())) {
3904
- line.push(word);
3905
- tspan.text(line.join(" "));
3906
- if (tspan.node().getComputedTextLength() > width) {
3907
- line.pop();
3908
- tspan.text(line.join(" "));
3909
- line = [word];
3910
- tspan = textElem
3911
- .append("tspan")
3912
- .attr("x", x)
3913
- .attr("y", y)
3914
- // eslint-disable-next-line no-plusplus
3915
- .attr("dy", `${++lineNumber * lineHeight + dy}em`)
3916
- .text(word);
3917
- }
3918
- }
3919
- });
3920
- }*/
3921
- const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, }) => {
4000
+ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes, defaultColor, fontColor, showMarkers, }) => {
3922
4001
  const { t } = useGlobalContext();
3923
4002
  const { layerInfos } = useWidgetContext();
3924
4003
  const strokeColors = relatedAttributes.filter(({ chartAxis }) => chartAxis === "y").map(({ axisColor }) => axisColor);
@@ -3955,11 +4034,17 @@ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes
3955
4034
  if (index === nodes.length - 1) {
3956
4035
  nodes[index].style.textAnchor = "end";
3957
4036
  }
3958
- if (index && index < nodes.length - 1) {
3959
- nodes[index].remove();
4037
+ if (showMarkers) {
4038
+ if (index % (showMarkers || 1) !== 0) {
4039
+ nodes[index].remove();
4040
+ }
4041
+ }
4042
+ else {
4043
+ if (index && index < nodes.length - 1) {
4044
+ nodes[index].remove();
4045
+ }
3960
4046
  }
3961
4047
  });
3962
- // svg.selectAll(`.${lineChartClassNames.lineChartXScaleGlobal} .tick text`).call(wrap2, 5, "!!!");
3963
4048
  svg.selectAll(`.${charts.lineChartClassNames.lineChartXScaleGlobal} .tick text`).attr("y", 16);
3964
4049
  svg
3965
4050
  .selectAll(`.${charts.lineChartClassNames.lineChartYScaleGlobal} .tick text`)
@@ -4005,7 +4090,7 @@ const useChartChange = ({ dataSources, chartId, width, height, relatedAttributes
4005
4090
  onChange();
4006
4091
  });
4007
4092
  svg.append("defs").html(() => defs.join(""));
4008
- }, [fontColor, dataSources, layerInfos, relatedAttributes, chartId, strokeColors, defaultColor, width, onChange]);
4093
+ }, [fontColor, dataSources, layerInfos, relatedAttributes, chartId, strokeColors, defaultColor, width, onChange, showMarkers]);
4009
4094
  return [customize, onChange];
4010
4095
  };
4011
4096
 
@@ -5294,7 +5379,11 @@ const getChartFilterName = (relatedDataSources) => {
5294
5379
  return axes?.[0]?.filterName;
5295
5380
  };
5296
5381
 
5297
- const getChartMarkers = (items, markers) => {
5382
+ const getChartMarkers = (items, markers, dataSources) => {
5383
+ if (typeof markers === "string") {
5384
+ const dataSource = getDataSource(markers, dataSources);
5385
+ return dataSource?.features?.map(({ attributes }) => attributes) || [];
5386
+ }
5298
5387
  return (markers?.map(marker => ({
5299
5388
  ...marker,
5300
5389
  value: items?.findIndex(({ name }) => name.toString() === marker.value?.toString()),
@@ -5716,7 +5805,6 @@ const AnyChartWrapper = styled.div `
5716
5805
  `;
5717
5806
  const BarChartWrapper = styled(AnyChartWrapper) `
5718
5807
  width: 100%;
5719
- max-width: ${MAX_CHART_WIDTH}px;
5720
5808
  margin: 0 auto ${BAR_CHART_FOOTER_MARGIN}px;
5721
5809
 
5722
5810
  :hover {
@@ -5846,7 +5934,7 @@ const PagesContainer = React.memo(({ type }) => {
5846
5934
  const { pageIndex, currentPage } = useWidgetPage(type);
5847
5935
  const { selectedTabId, setSelectedTabId, expandedContainers, attributes } = useWidgetContext(type);
5848
5936
  const { options } = config || {};
5849
- const { column } = options || {};
5937
+ const { column, width } = options || {};
5850
5938
  const isColumn = column === undefined || column;
5851
5939
  const filteredChildren = React.useMemo(() => !selectedTabId
5852
5940
  ? currentPage.children
@@ -5871,7 +5959,7 @@ const PagesContainer = React.memo(({ type }) => {
5871
5959
  setSelectedTabId,
5872
5960
  type,
5873
5961
  ]);
5874
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: config, type: type, renderElement: renderElement }), jsxRuntime.jsx(Container, { isColumn: isColumn, isMain: true, children: jsxRuntime.jsx(ContainerChildren, { items: filteredChildren, isMain: true, renderElement: renderElement }) })] }));
5962
+ return (jsxRuntime.jsxs("div", { style: { width }, children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: config, type: type, renderElement: renderElement }), jsxRuntime.jsx(Container, { isColumn: isColumn, isMain: true, children: jsxRuntime.jsx(ContainerChildren, { items: filteredChildren, isMain: true, renderElement: renderElement }) })] }));
5875
5963
  });
5876
5964
 
5877
5965
  const TwoColumnsInnerContainer = React.memo(({ renderElement }) => {
@@ -6270,6 +6358,7 @@ const TabsContainer = React.memo(({ elementConfig, type }) => {
6270
6358
  return (jsxRuntime.jsx(SwiperContainer, { style: style, children: jsxRuntime.jsx(react.Swiper, { spaceBetween: 0, slidesPerView: shownItems || 2, children: tabs.map(({ id, value, options: tabOptions }) => (jsxRuntime.jsxs(react.SwiperSlide, { children: [jsxRuntime.jsxs(TabContainer, { href: `#${id}`, active: selectedTabId === id, column: column, bgColor: bgColor, noBg: noBg, radius: radius, onlyIcon: onlyIcon, hasIcon: !!tabOptions?.icon, onClick: () => onClick(id), children: [renderIcon(tabOptions?.icon, selectedTabId === id), !onlyIcon && (jsxRuntime.jsx(TabValue, { children: jsxRuntime.jsx(TextTrim, { maxLength: maxLength, children: value }) }))] }), jsxRuntime.jsx(TabAnchor, { id: id })] }, id))) }) }));
6271
6359
  });
6272
6360
 
6361
+ const ContainerIconValue = styled(uilibGl.Flex) ``;
6273
6362
  const RoundedBackgroundContainerWrapper = styled(uilibGl.Flex) `
6274
6363
  position: relative;
6275
6364
  flex-direction: ${({ $bigIcon }) => ($bigIcon ? "row" : "column")};
@@ -6287,13 +6376,10 @@ const RoundedBackgroundContainerWrapper = styled(uilibGl.Flex) `
6287
6376
  styled.css `
6288
6377
  align-items: center;
6289
6378
 
6290
- * {
6379
+ > * {
6291
6380
  display: flex;
6292
6381
  justify-content: center;
6293
6382
  text-align: center;
6294
- }
6295
-
6296
- > * {
6297
6383
  width: 100%;
6298
6384
  }
6299
6385
  `};
@@ -6326,8 +6412,32 @@ const RoundedBackgroundContainerWrapper = styled(uilibGl.Flex) `
6326
6412
  }
6327
6413
  `};
6328
6414
 
6415
+ ${ContainerIconValue} {
6416
+ align-items: center;
6417
+ flex-direction: column;
6418
+
6419
+ ${({ $big }) => $big &&
6420
+ styled.css `
6421
+ flex-direction: row;
6422
+ margin-bottom: 0.5rem;
6423
+
6424
+ > * {
6425
+ text-align: left;
6426
+ }
6427
+
6428
+ span[kind] {
6429
+ margin-right: 0.5rem;
6430
+ }
6431
+
6432
+ ${ContainerValue} {
6433
+ width: auto;
6434
+ }
6435
+ `};
6436
+ }
6437
+
6329
6438
  ${ContainerValue} {
6330
6439
  flex-direction: ${({ $inlineUnits }) => ($inlineUnits ? "row" : "column")};
6440
+ justify-content: ${({ $big }) => ($big ? "flex-start" : "flex-end")};
6331
6441
  align-items: ${({ $inlineUnits }) => ($inlineUnits ? "center" : "flex-start")};
6332
6442
  line-height: 1;
6333
6443
  }
@@ -6351,15 +6461,17 @@ const RoundedBackgroundContainer = React.memo(({ type, elementConfig, feature, r
6351
6461
  feature
6352
6462
  });
6353
6463
  const { options, style, children } = elementConfig || {};
6354
- const { maxLength, center, fontColor, innerTemplateStyle, inlineUnits, bigIcon, hideEmpty, colorAttribute } = options || {};
6464
+ const { maxLength, center, fontColor, innerTemplateStyle, inlineUnits, big, bigIcon, hideEmpty, colorAttribute } = options || {};
6355
6465
  const aliasElement = children?.find(({ id }) => id === "alias");
6356
6466
  const unitsElement = children?.find(({ id }) => id === "units");
6357
6467
  const valueElement = children?.find(({ id }) => id === "value");
6358
6468
  const value = renderElement({ id: "value" });
6359
6469
  const color = React.useMemo(() => attributes?.find(({ name }) => name === colorAttribute)?.value || fontColor, [attributes, colorAttribute, fontColor]);
6470
+ const renderAlias = React.useMemo(() => (jsxRuntime.jsx(ContainerAlias, { style: aliasElement?.style, children: jsxRuntime.jsx(TextTrim, { maxLength: maxLength || ALIAS_DEFAULT_MAX_LENGTH, children: renderElement({ id: "alias", wrap: false }) }) })), [aliasElement?.style, maxLength, renderElement]);
6471
+ const renderValue = React.useMemo(() => (jsxRuntime.jsxs(ContainerValue, { style: valueElement?.style, big: true, children: [value, !!unitsElement && (jsxRuntime.jsx(ContainerUnits, { style: unitsElement?.style, children: renderElement({ id: "units" }) }))] })), [valueElement?.style, value, unitsElement, renderElement]);
6360
6472
  if (!value && hideEmpty)
6361
6473
  return null;
6362
- return (jsxRuntime.jsxs(RoundedBackgroundContainerWrapper, { style: innerTemplateStyle || style, "$center": center, "$color": color, "$inlineUnits": inlineUnits, "$bigIcon": bigIcon, children: [renderElement({ id: "icon", wrap: false }), jsxRuntime.jsxs(ContainerValue, { style: valueElement?.style, big: true, children: [value, !!unitsElement && (jsxRuntime.jsx(ContainerUnits, { style: unitsElement?.style, children: renderElement({ id: "units" }) }))] }), jsxRuntime.jsx(ContainerAlias, { style: aliasElement?.style, children: jsxRuntime.jsx(TextTrim, { maxLength: maxLength || ALIAS_DEFAULT_MAX_LENGTH, children: renderElement({ id: "alias", wrap: false }) }) })] }));
6474
+ return (jsxRuntime.jsxs(RoundedBackgroundContainerWrapper, { style: innerTemplateStyle || style, "$center": center, "$color": color, "$inlineUnits": inlineUnits, "$big": big, "$bigIcon": bigIcon, children: [jsxRuntime.jsxs(ContainerIconValue, { children: [renderElement({ id: "icon", wrap: false }), big ? renderAlias : renderValue] }), big ? renderValue : renderAlias] }));
6363
6475
  });
6364
6476
 
6365
6477
  const AddFeatureContainer = React.memo(({ elementConfig }) => {
@@ -8023,7 +8135,7 @@ const useBarChartFilter = ({ type, filter, elementConfig }) => {
8023
8135
  bars.attr("rx", radius).attr("ry", radius);
8024
8136
  }, [radius]);
8025
8137
  const tooltipY = React.useMemo(() => (barHeight ? height - barHeight - DEFAULT_BAR_CHART_MARGINS.bottom : undefined), [barHeight, height]);
8026
- const markers = React.useMemo(() => getChartMarkers(filterItems, configMarkers), [configMarkers, filterItems]);
8138
+ const markers = React.useMemo(() => getChartMarkers(filterItems, configMarkers, dataSources), [configMarkers, dataSources, filterItems]);
8027
8139
  const hasDefinedColors = React.useMemo(() => configColors?.length || colorAttribute, [configColors, colorAttribute]);
8028
8140
  const marshalledMap = React.useCallback(items => {
8029
8141
  if (hasDefinedColors)
@@ -8355,7 +8467,7 @@ const getRenderElement = ({ t, config, elementConfig, attributes = [], layerInfo
8355
8467
  return formatElementValue({ t, value, elementConfig: element, attributes, wrap });
8356
8468
  };
8357
8469
 
8358
- const getResourceUrl = (url) => url ? (url.startsWith("http") ? url : `/sp/resources/${url}/download`) : "";
8470
+ const getResourceUrl = (url) => url ? (url.startsWith("http") ? url : `/sp/resources/file/${url}`) : "";
8359
8471
 
8360
8472
  const getSlideshowImages = ({ element, attribute, }) => {
8361
8473
  const { defaultValue, options } = element;
@@ -8408,7 +8520,7 @@ const pieChartTooltipFromAttributes = (t, data, attributes) => {
8408
8520
  const pieChartTooltipFromRelatedFeatures = (t, data, relatedAttributes, layerInfo) => {
8409
8521
  if (!data?.length)
8410
8522
  return "";
8411
- return (jsxRuntime.jsx(uilibGl.ThemeProvider, { children: jsxRuntime.jsxs(ChartTooltip, { children: [jsxRuntime.jsx(ChartTooltipColor, { "$color": data[0].color }), jsxRuntime.jsxs("div", { children: [data[0].name, " \u00A0 ", formatChartRelatedValue(t, data[0].value, layerInfo, relatedAttributes)] })] }) }));
8523
+ return (jsxRuntime.jsx(uilibGl.ThemeProvider, { children: jsxRuntime.jsxs(ChartTooltip, { alignItems: "center", children: [jsxRuntime.jsx(ChartTooltipColor, { "$color": data[0].color }), jsxRuntime.jsxs("div", { children: [data[0].name, " \u00A0 ", formatChartRelatedValue(t, data[0].value, layerInfo, relatedAttributes)] })] }) }));
8412
8524
  };
8413
8525
 
8414
8526
  const removeDataSource = (dashboardConfiguration, name, pageIndex) => {
@@ -8990,7 +9102,7 @@ const StackBar = ({ data, filterName, type, alias, options, renderElement, rende
8990
9102
  const units = attribute?.stringFormat?.unitsLabel;
8991
9103
  const total = React.useMemo(() => items?.reduce((result, { value }) => result + Number(value), 0) || 0, [items]);
8992
9104
  const getWidth = React.useCallback(value => ((Number(value) / total) * 100).toFixed(2), [total]);
8993
- const renderGroupTooltip = React.useMemo(() => (jsxRuntime.jsx(uilibGl.ThemeProvider, { children: jsxRuntime.jsx(ChartTooltipTable, { cellPadding: 0, cellSpacing: 0, children: items?.map(({ name, value, color }, index) => (jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx("td", { children: jsxRuntime.jsxs(ChartTooltip, { children: [jsxRuntime.jsx(ChartTooltipColor, { "$color": color }), jsxRuntime.jsx(ChartTooltipName, { children: name })] }) }), jsxRuntime.jsx("td", { children: value })] }, index))) }) })), [items]);
9105
+ const renderGroupTooltip = React.useMemo(() => (jsxRuntime.jsx(uilibGl.ThemeProvider, { children: jsxRuntime.jsx(ChartTooltipTable, { cellPadding: 0, cellSpacing: 0, children: items?.map(({ name, value, color }, index) => (jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx("td", { children: jsxRuntime.jsxs(ChartTooltip, { alignItems: "center", children: [jsxRuntime.jsx(ChartTooltipColor, { "$color": color }), jsxRuntime.jsx(ChartTooltipName, { children: name })] }) }), jsxRuntime.jsx("td", { children: value })] }, index))) }) })), [items]);
8994
9106
  const renderItem = React.useCallback(({ name, value, color }, ref) => (jsxRuntime.jsx(StackBarSection, { ref: ref, "$width": getWidth(value), "$height": height, "$color": color, cornerRadius: cornerRadius, hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: filterName ? () => onFilter(name) : undefined })), [cornerRadius, filterName, getWidth, hasAnyFilter, height, isFiltered, onFilter]);
8995
9107
  const renderItems = React.useMemo(() => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: items?.map((item, index) => (jsxRuntime.jsx(React.Fragment, { children: groupTooltip ? (renderItem(item)) : (jsxRuntime.jsx(uilibGl.ThemeProvider, { children: jsxRuntime.jsx(uilibGl.Tooltip, { placement: "top", arrow: true, content: renderTooltip([item]), children: ref => renderItem(item, ref) }) })) }, index))) })), [groupTooltip, items, renderItem, renderTooltip]);
8996
9108
  if (!total || !attribute)
@@ -9001,10 +9113,11 @@ const StackBar = ({ data, filterName, type, alias, options, renderElement, rende
9001
9113
  const Chart = React.memo(({ config, element, elementConfig, type, renderElement }) => {
9002
9114
  const theme = styled.useTheme();
9003
9115
  const { palette } = theme;
9116
+ const primaryColor = palette.primary;
9004
9117
  const { t } = useGlobalContext();
9005
- const { expandedContainers, layerInfos, attributes } = useWidgetContext(type);
9118
+ const { expandedContainers, layerInfos, attributes, dataSources } = useWidgetContext(type);
9006
9119
  const { id, options, children } = element || {};
9007
- const { column, markers: configMarkers, showTotal, expandable, expanded, chartType, relatedDataSources, defaultColor } = options || {};
9120
+ const { column, markers: configMarkers, showLabels, showMarkers, showTotal, totalWord: configTotalWord, totalAttribute, expandable, expanded, chartType, relatedDataSources, defaultColor } = options || {};
9008
9121
  const isLineChart = chartType === "line";
9009
9122
  const isPieChart = chartType === "pie";
9010
9123
  const isStackBar = chartType === "stack";
@@ -9016,23 +9129,17 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9016
9129
  const angle = options?.angle || DEFAULT_CHART_ANGLE;
9017
9130
  const barWidth = options?.barWidth || DEFAULT_BAR_WIDTH;
9018
9131
  const cornerRadius = options?.cornerRadius || 0;
9019
- const primaryColor = theme.palette.primary;
9020
9132
  const relatedAttributes = React.useMemo(() => relatedDataSources || [], [relatedDataSources]);
9021
9133
  const axes = React.useMemo(() => relatedAttributes.filter(({ chartAxis }) => chartAxis === "y"), [relatedAttributes]);
9022
9134
  const filterName = getChartFilterName(relatedDataSources);
9023
9135
  const isRelated = !!relatedAttributes?.length;
9024
9136
  const { data, loading } = useChartData({ element, type });
9025
9137
  const totalWidthFromBarWidth = (data[0]?.items?.length || 0) * (barWidth + padding);
9026
- const width = options?.width
9027
- ? options.width > MAX_CHART_WIDTH
9028
- ? MAX_CHART_WIDTH
9029
- : options.width
9030
- : isStackBar
9138
+ const width = options?.width ? options.width :
9139
+ isStackBar
9031
9140
  ? "100%"
9032
9141
  : isBarChart
9033
- ? totalWidthFromBarWidth < MAX_CHART_WIDTH
9034
- ? MAX_CHART_WIDTH
9035
- : totalWidthFromBarWidth
9142
+ ? totalWidthFromBarWidth || MAX_CHART_WIDTH
9036
9143
  : DEFAULT_CHART_WIDTH;
9037
9144
  const [customize] = useChartChange({
9038
9145
  dataSources: config.dataSources,
@@ -9041,16 +9148,17 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9041
9148
  height,
9042
9149
  fontColor,
9043
9150
  relatedAttributes,
9044
- defaultColor: primaryColor
9151
+ defaultColor: primaryColor,
9152
+ showMarkers,
9045
9153
  });
9046
9154
  const { formatFilterColor, onFilter } = useFeatureFilters(type, filterName, data?.[0]?.items);
9047
9155
  const formattedAttributes = React.useMemo(() => getFormattedAttributes(t, (data[0]?.items || []), attributes, element), [attributes, data, element, t]);
9048
9156
  const totalSum = React.useMemo(() => isRelated
9049
9157
  ? getTotalFromRelatedFeatures((data[0]?.items || []))
9050
9158
  : getTotalFromAttributes(children, formattedAttributes), [data, children, formattedAttributes, isRelated]);
9051
- const totalWord = React.useMemo(() => options?.totalAttribute
9052
- ? attributes?.find(({ name }) => name === options.totalAttribute)?.value
9053
- : options?.totalWord, [attributes, options.totalAttribute, options?.totalWord]);
9159
+ const totalWord = React.useMemo(() => totalAttribute
9160
+ ? attributes?.find(({ name }) => name === totalAttribute)?.value
9161
+ : configTotalWord, [attributes, totalAttribute, configTotalWord]);
9054
9162
  const renderPieChartTooltip = React.useCallback(item => isRelated
9055
9163
  ? pieChartTooltipFromRelatedFeatures(t, item, relatedAttributes, data[0]?.layerInfo)
9056
9164
  : pieChartTooltipFromAttributes(t, item, formattedAttributes), [data, formattedAttributes, isRelated, relatedAttributes]);
@@ -9061,19 +9169,25 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9061
9169
  return result?.filter((name, index) => result.indexOf(name) === index);
9062
9170
  }, [data, isLineChart]);
9063
9171
  const renderLineChartTooltip = React.useCallback((items, { indexX }) => {
9064
- return (jsxRuntime.jsx(uilibGl.ThemeProvider, { children: jsxRuntime.jsxs(ChartTooltip, { children: [jsxRuntime.jsx("div", { children: labels[indexX] }), items
9065
- .filter(({ value }) => !isEmptyValue(value))
9066
- ?.map(({ layerName, attributeName, value, stroke }, index) => {
9067
- const layerInfo = layerInfos?.find(({ name }) => name === layerName);
9068
- const attribute = layerInfo?.layerDefinition.attributes[attributeName];
9069
- return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: attribute ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat }) : value })] }, index));
9070
- })] }) }));
9172
+ return (jsxRuntime.jsxs(Tooltip, { children: [jsxRuntime.jsx(ChartTooltipLabel, { children: labels[indexX] }), items
9173
+ .filter(({ value }) => !isEmptyValue(value))
9174
+ ?.map(({ layerName, attributeName, value, stroke }, index) => {
9175
+ const layerInfo = layerInfos?.find(({ name }) => name === layerName);
9176
+ const attribute = layerInfo?.layerDefinition.attributes[attributeName];
9177
+ return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: attribute ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat }) : value })] }, index));
9178
+ })] }));
9071
9179
  }, [labels, layerInfos]);
9072
- const markers = React.useMemo(() => getChartMarkers(data[0]?.items, configMarkers), [data, configMarkers]);
9180
+ const markers = React.useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
9073
9181
  const formatTooltipName = React.useCallback((name) => (isRelated ? name : tooltipNameFromAttributes(name, formattedAttributes)), [formattedAttributes, isRelated]);
9074
9182
  const formatTooltipValue = React.useCallback((value, name) => isRelated
9075
9183
  ? tooltipValueFromRelatedFeatures(t, value, relatedAttributes, data[0]?.layerInfo)
9076
9184
  : tooltipValueFromAttributes(t, value, name, formattedAttributes), [data, formattedAttributes, isRelated, relatedAttributes]);
9185
+ const customXAxisBottom = React.useCallback((xAxisBottom, data) => {
9186
+ xAxisBottom.tickFormat((index) => (showMarkers
9187
+ ? index % (showMarkers || 1) === 0
9188
+ : index === 0 || index === data.length - 1)
9189
+ ? data[index]?.groupName || "" : "");
9190
+ }, [showMarkers]);
9077
9191
  const renderChart = React.useMemo(() => {
9078
9192
  if (!element)
9079
9193
  return null;
@@ -9091,16 +9205,16 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9091
9205
  .flat()
9092
9206
  .map(({ values }) => values)
9093
9207
  .flat();
9094
- return (jsxRuntime.jsx(AnyChartWrapper, { height: height, children: jsxRuntime.jsx(charts.LineChart, { data: lineChartData, labels: labels, width: +width, height: height, xAxisPadding: 15, yAxisPadding: 0, min: Math.min(...chartValues), customYAxisSelection: yAxis => {
9095
- if (isHidedY) {
9096
- yAxis.remove();
9097
- }
9098
- }, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dynamicTooltipEnable: true, stackedTooltip: true, drawGridX: !isHidedY, margin: {
9099
- top: 0,
9100
- right: 0,
9101
- bottom: 0,
9102
- left: 0
9103
- } }) }));
9208
+ 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 => {
9209
+ if (isHidedY) {
9210
+ yAxis.remove();
9211
+ }
9212
+ }, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: {
9213
+ top: 0,
9214
+ right: 0,
9215
+ bottom: 0,
9216
+ left: 0
9217
+ } })] }));
9104
9218
  }
9105
9219
  if (isStackBar) {
9106
9220
  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 }) }));
@@ -9113,17 +9227,20 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9113
9227
  color: formatFilterColor(item.name, item.color, defaultColor)
9114
9228
  })) || []), 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) }) }) }));
9115
9229
  }
9230
+ const barChartData = getDataFromFilterItems(data[0]?.items);
9231
+ const markersMargin = showMarkers ? 10 : 0;
9116
9232
  const margin = {
9117
- top: 0,
9118
- right: 0,
9119
- bottom: markers?.length ? 20 : 0,
9120
- left: 0
9233
+ top: markersMargin,
9234
+ right: markersMargin,
9235
+ bottom: markers?.length ? 20 : markersMargin,
9236
+ left: markersMargin
9121
9237
  };
9122
- return (jsxRuntime.jsx(BarChartWrapper, { height: height + margin.bottom, children: jsxRuntime.jsx(BarChartContainer, { children: jsxRuntime.jsx(charts.BarChart, { data: getDataFromFilterItems(data[0]?.items), colors: getColorsFromFilterItems(data[0]?.items, defaultColor, formatFilterColor), minValue: getMinValueFromFilterItems(data[0]?.items), markers: markers, width: +width, height: height, barWidth: barWidth, barPadding: padding, customXAxis: axis => axis.remove(), customYAxis: axis => axis.remove(), customBars: ({ bars }) => {
9238
+ 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, className: "dashboardBarChart", customXAxisBottom: xAxisBottom => customXAxisBottom(xAxisBottom, barChartData), customYAxis: axis => !showLabels && axis.remove(), customBars: ({ bars }) => {
9123
9239
  bars.attr("rx", radius);
9124
9240
  bars.attr("ry", radius);
9125
- }, margin: margin, xAxisPadding: 0, yAxisPadding: 0, formatTooltipValue: formatTooltipValue, formatTooltipName: formatTooltipName, onBarClick: filterName ? item => onFilter(item.name) : undefined, hideTooltipGroupName: true, dynamicTooltipEnable: true, isBarTooltip: true }) }) }));
9241
+ }, margin: margin, xAxisPadding: 0, yAxisPadding: 0, formatTooltipValue: formatTooltipValue, formatTooltipName: formatTooltipName, hideTooltipGroupName: true, dynamicTooltipEnable: true, isBarTooltip: true, onBarClick: filterName ? item => onFilter(item.name) : undefined }) }) }));
9126
9242
  }, [
9243
+ customXAxisBottom,
9127
9244
  element,
9128
9245
  isLineChart,
9129
9246
  isStackBar,
@@ -9135,6 +9252,8 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
9135
9252
  formatFilterColor,
9136
9253
  width,
9137
9254
  barWidth,
9255
+ showLabels,
9256
+ showMarkers,
9138
9257
  padding,
9139
9258
  formatTooltipValue,
9140
9259
  formatTooltipName,
@@ -9171,7 +9290,7 @@ const ChartLegend = ({ data, chartElement, type, twoColumns, loading }) => {
9171
9290
  const showMoreBtn = !!shownItems && data.length > shownItems;
9172
9291
  if (!loading && !data?.length && !!hideEmpty)
9173
9292
  return null;
9174
- return (jsxRuntime.jsxs(uilibGl.Flex, { opacity: loading ? FILTERED_VALUE_OPACITY / 100 : 1, children: [jsxRuntime.jsx(ChartLegendContainer, { twoColumns: twoColumns, children: sliceItems(data)?.map(({ name, color }, index) => (jsxRuntime.jsxs(ChartLegendItem, { hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: axes?.[0]?.filterName ? () => onFilter(name) : undefined, children: [jsxRuntime.jsx(ChartLegendColor, { color: color }), jsxRuntime.jsx(ChartLegendName, { "$fontColor": fontColor, children: name })] }, index))) }), showMoreBtn && (jsxRuntime.jsx(uilibGl.LegendToggler, { onClick: onShowMore, toggled: showMore, children: t("other", { ns: "dashboard" }) }))] }));
9293
+ return (jsxRuntime.jsxs(uilibGl.Flex, { flexDirection: "column", opacity: loading ? FILTERED_VALUE_OPACITY / 100 : 1, children: [jsxRuntime.jsx(ChartLegendContainer, { twoColumns: twoColumns, children: sliceItems(data)?.map(({ name, color }, index) => (jsxRuntime.jsxs(ChartLegendItem, { hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: axes?.[0]?.filterName ? () => onFilter(name) : undefined, children: [jsxRuntime.jsx(ChartLegendColor, { color: color }), jsxRuntime.jsx(ChartLegendName, { "$fontColor": fontColor, children: name })] }, index))) }), showMoreBtn && (jsxRuntime.jsx(uilibGl.LegendToggler, { onClick: onShowMore, toggled: showMore, children: t("other", { ns: "dashboard" }) }))] }));
9175
9294
  };
9176
9295
 
9177
9296
  const ContainerChildren = React.memo(({ items, isColumn, isMain, renderElement }) => {