@centreon/ui 26.3.2 → 26.3.4
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/package.json +1 -1
- package/src/Graph/BarChart/BarStack.tsx +16 -16
- package/src/Graph/BarChart/MemoizedGroup.tsx +12 -7
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +4 -4
- package/src/Graph/Chart/BasicComponents/Lines/index.tsx +100 -92
- package/src/Graph/Chart/Legend/index.tsx +11 -11
- package/src/Graph/Chart/index.tsx +42 -34
- package/src/Graph/common/BaseChart/BaseChart.tsx +4 -4
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +1 -1
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +5 -5
- package/src/Graph/common/timeSeries/index.ts +38 -38
- package/src/RichTextEditor/RichTextEditor.tsx +3 -7
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +5 -15
- package/src/components/ItemComposition/ItemComposition.tsx +9 -3
- package/src/components/Modal/Modal.styles.ts +14 -19
- package/src/components/Modal/Modal.tsx +1 -1
- package/src/components/Modal/modal.module.css +0 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement, memo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { ScaleType, scaleBand } from '@visx/scale';
|
|
4
4
|
import { BarRounded } from '@visx/shape';
|
|
@@ -123,10 +123,10 @@ const BarStack = ({
|
|
|
123
123
|
const barY =
|
|
124
124
|
isNegativeValue && isStacked && !shouldApplyRadiusOnBottom
|
|
125
125
|
? getPadding({
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
isNegativeValue,
|
|
127
|
+
padding: bar.y,
|
|
128
|
+
size: bar.height
|
|
129
|
+
})
|
|
130
130
|
: bar.y;
|
|
131
131
|
|
|
132
132
|
return (
|
|
@@ -139,10 +139,10 @@ const BarStack = ({
|
|
|
139
139
|
barWidth,
|
|
140
140
|
y: isHorizontal
|
|
141
141
|
? getPadding({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
isNegativeValue,
|
|
143
|
+
padding: bar.y,
|
|
144
|
+
size: bar.height
|
|
145
|
+
})
|
|
146
146
|
: barPadding,
|
|
147
147
|
isFirstBar: shouldApplyRadiusOnBottom,
|
|
148
148
|
isHorizontal,
|
|
@@ -157,19 +157,19 @@ const BarStack = ({
|
|
|
157
157
|
isHorizontal
|
|
158
158
|
? barPadding
|
|
159
159
|
: getPadding({
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
isNegativeValue,
|
|
161
|
+
padding: bar.x,
|
|
162
|
+
size: bar.width
|
|
163
|
+
})
|
|
164
164
|
}
|
|
165
165
|
y={isHorizontal ? barY : barPadding}
|
|
166
166
|
onMouseEnter={
|
|
167
167
|
isTooltipHidden
|
|
168
168
|
? undefined
|
|
169
169
|
: hoverBar({
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
barIndex,
|
|
171
|
+
highlightedMetric: Number(bar.key)
|
|
172
|
+
})
|
|
173
173
|
}
|
|
174
174
|
onMouseLeave={isTooltipHidden ? undefined : exitBar}
|
|
175
175
|
/>
|
|
@@ -59,17 +59,22 @@ const MemoizedGroup = ({
|
|
|
59
59
|
const linesBar = isStackedBar
|
|
60
60
|
? stackedLinesTimeSeriesPerStackKeyAndUnit[bar.key].lines
|
|
61
61
|
: (notStackedLines.find(({ metric_id }) =>
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
equals(metric_id, Number(bar.key))
|
|
63
|
+
) as Line);
|
|
64
64
|
const timeSeriesBar = isStackedBar
|
|
65
65
|
? stackedLinesTimeSeriesPerStackKeyAndUnit[bar.key].timeSeries
|
|
66
66
|
: notStackedTimeSeries.map((timeSerie) => ({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
timeTick: timeSerie.timeTick,
|
|
68
|
+
[bar.key]: timeSerie[Number(bar.key)]
|
|
69
|
+
}));
|
|
70
70
|
|
|
71
|
-
const unit = isStackedBar
|
|
72
|
-
|
|
71
|
+
const unit = isStackedBar
|
|
72
|
+
? bar.key.split('-')[1]
|
|
73
|
+
: (linesBar as Line).unit;
|
|
74
|
+
const yScale =
|
|
75
|
+
unit === '' && yScalesPerUnit[unit] === undefined
|
|
76
|
+
? yScalesPerUnit[undefined]
|
|
77
|
+
: yScalesPerUnit[unit];
|
|
73
78
|
|
|
74
79
|
return isStackedBar ? (
|
|
75
80
|
<BarStack
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type
|
|
14
14
|
} from 'ramda';
|
|
15
15
|
|
|
16
|
+
import { ReactElement } from 'react';
|
|
16
17
|
import { getDates, getTime } from '../../../../common/timeSeries';
|
|
17
18
|
import { Line, TimeValue } from '../../../../common/timeSeries/models';
|
|
18
19
|
import {
|
|
@@ -27,7 +28,6 @@ import { StackValue } from '../../../InteractiveComponents/AnchorPoint/models';
|
|
|
27
28
|
import { getCurveFactory, getFillColor } from '../../../common';
|
|
28
29
|
import { LineStyle } from '../../../models';
|
|
29
30
|
import Point from '../Point';
|
|
30
|
-
import { ReactElement } from 'react';
|
|
31
31
|
|
|
32
32
|
interface Props {
|
|
33
33
|
areaTransparency?: number;
|
|
@@ -135,9 +135,9 @@ const StackLines = ({
|
|
|
135
135
|
equals(style?.showArea, false)
|
|
136
136
|
? 'transparent'
|
|
137
137
|
: getFillColor({
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
areaColor: areaColor || lineColor,
|
|
139
|
+
transparency: formattedTransparency
|
|
140
|
+
})
|
|
141
141
|
}
|
|
142
142
|
opacity={highlight === false ? 0.3 : 1}
|
|
143
143
|
stroke={lineColor}
|
|
@@ -103,13 +103,18 @@ const Lines = ({
|
|
|
103
103
|
{Object.entries(stackedLinesData).map(
|
|
104
104
|
([stackedKey, { lines, timeSeries: stackedTimeSeries }]) => {
|
|
105
105
|
const [, unit] = stackedKey.split('-');
|
|
106
|
+
const yScale =
|
|
107
|
+
unit === '' && yScalesPerUnit[unit] === undefined
|
|
108
|
+
? yScalesPerUnit[undefined]
|
|
109
|
+
: yScalesPerUnit[unit];
|
|
110
|
+
|
|
106
111
|
return (
|
|
107
112
|
<StackedLines
|
|
108
113
|
lineStyle={lineStyle}
|
|
109
114
|
key={`stacked-${unit}`}
|
|
110
115
|
lines={lines}
|
|
111
116
|
timeSeries={stackedTimeSeries}
|
|
112
|
-
yScale={
|
|
117
|
+
yScale={yScale}
|
|
113
118
|
{...commonStackedLinesProps}
|
|
114
119
|
/>
|
|
115
120
|
);
|
|
@@ -128,7 +133,10 @@ const Lines = ({
|
|
|
128
133
|
invert: '1',
|
|
129
134
|
scale,
|
|
130
135
|
scaleLogarithmicBase,
|
|
131
|
-
unit:
|
|
136
|
+
unit:
|
|
137
|
+
unit === '' && yScalesPerUnit[unit] === undefined
|
|
138
|
+
? undefined
|
|
139
|
+
: unit,
|
|
132
140
|
yScalesPerUnit
|
|
133
141
|
})}
|
|
134
142
|
{...commonStackedLinesProps}
|
|
@@ -152,107 +160,107 @@ const Lines = ({
|
|
|
152
160
|
|
|
153
161
|
{displayAreaRegularLines
|
|
154
162
|
? regularLines.map(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
unit,
|
|
161
|
-
highlight,
|
|
162
|
-
invert,
|
|
163
|
-
metric_id,
|
|
164
|
-
...rest
|
|
165
|
-
}) => {
|
|
166
|
-
const yScale = getYScale({
|
|
167
|
-
invert,
|
|
168
|
-
scale,
|
|
169
|
-
scaleLogarithmicBase,
|
|
163
|
+
({
|
|
164
|
+
areaColor,
|
|
165
|
+
transparency,
|
|
166
|
+
lineColor,
|
|
167
|
+
filled,
|
|
170
168
|
unit,
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
const relatedTimeSeries = getTimeSeriesForLines({
|
|
169
|
+
highlight,
|
|
174
170
|
invert,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
171
|
+
metric_id,
|
|
172
|
+
...rest
|
|
173
|
+
}) => {
|
|
174
|
+
const yScale = getYScale({
|
|
175
|
+
invert,
|
|
176
|
+
scale,
|
|
177
|
+
scaleLogarithmicBase,
|
|
178
|
+
unit,
|
|
179
|
+
yScalesPerUnit
|
|
180
|
+
});
|
|
181
|
+
const relatedTimeSeries = getTimeSeriesForLines({
|
|
182
|
+
invert,
|
|
183
|
+
lines: [
|
|
184
|
+
{
|
|
185
|
+
areaColor,
|
|
186
|
+
filled,
|
|
187
|
+
highlight,
|
|
188
|
+
invert,
|
|
189
|
+
lineColor,
|
|
190
|
+
metric_id,
|
|
191
|
+
transparency,
|
|
192
|
+
unit,
|
|
193
|
+
...rest
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
timeSeries
|
|
197
|
+
});
|
|
190
198
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
199
|
+
const style = getStyle({
|
|
200
|
+
style: lineStyle,
|
|
201
|
+
metricId: metric_id
|
|
202
|
+
}) as LineStyle;
|
|
195
203
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
204
|
+
return (
|
|
205
|
+
<g key={metric_id}>
|
|
206
|
+
{displayGuidingLines && (
|
|
207
|
+
<RegularAnchorPoint
|
|
208
|
+
areaColor={areaColor || lineColor}
|
|
209
|
+
lineColor={lineColor}
|
|
210
|
+
metric_id={metric_id}
|
|
211
|
+
timeSeries={relatedTimeSeries}
|
|
212
|
+
transparency={transparency}
|
|
213
|
+
xScale={xScale}
|
|
214
|
+
yScale={yScale}
|
|
215
|
+
maxLeftAxisCharacters={maxLeftAxisCharacters}
|
|
216
|
+
hasSecondUnit={hasSecondUnit}
|
|
217
|
+
/>
|
|
218
|
+
)}
|
|
219
|
+
{style?.showPoints &&
|
|
220
|
+
getDates(relatedTimeSeries).map((timeTick) => (
|
|
221
|
+
<Point
|
|
222
|
+
key={timeTick.toString()}
|
|
223
|
+
lineColor={lineColor}
|
|
224
|
+
metric_id={metric_id}
|
|
225
|
+
radius={getPointRadius(style?.lineWidth)}
|
|
226
|
+
timeSeries={relatedTimeSeries}
|
|
227
|
+
timeTick={timeTick}
|
|
228
|
+
xScale={xScale}
|
|
229
|
+
yPoint={getYAnchorPoint({
|
|
230
|
+
metric_id,
|
|
231
|
+
timeSeries: relatedTimeSeries,
|
|
232
|
+
timeTick,
|
|
233
|
+
yScale
|
|
234
|
+
})}
|
|
235
|
+
yScale={yScale}
|
|
236
|
+
/>
|
|
237
|
+
))}
|
|
238
|
+
<RegularLine
|
|
200
239
|
areaColor={areaColor || lineColor}
|
|
240
|
+
curve={style?.curve || 'linear'}
|
|
241
|
+
dashLength={style?.dashLength}
|
|
242
|
+
dashOffset={style?.dashOffset}
|
|
243
|
+
dotOffset={style?.dotOffset}
|
|
244
|
+
filled={isNil(style?.showArea) ? filled : style.showArea}
|
|
245
|
+
graphHeight={height}
|
|
246
|
+
highlight={highlight}
|
|
201
247
|
lineColor={lineColor}
|
|
248
|
+
lineWidth={style?.lineWidth || 2}
|
|
202
249
|
metric_id={metric_id}
|
|
203
250
|
timeSeries={relatedTimeSeries}
|
|
204
|
-
transparency={
|
|
251
|
+
transparency={
|
|
252
|
+
isNil(style?.areaTransparency)
|
|
253
|
+
? transparency || 80
|
|
254
|
+
: style.areaTransparency
|
|
255
|
+
}
|
|
256
|
+
unit={unit}
|
|
205
257
|
xScale={xScale}
|
|
206
258
|
yScale={yScale}
|
|
207
|
-
maxLeftAxisCharacters={maxLeftAxisCharacters}
|
|
208
|
-
hasSecondUnit={hasSecondUnit}
|
|
209
259
|
/>
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
key={timeTick.toString()}
|
|
215
|
-
lineColor={lineColor}
|
|
216
|
-
metric_id={metric_id}
|
|
217
|
-
radius={getPointRadius(style?.lineWidth)}
|
|
218
|
-
timeSeries={relatedTimeSeries}
|
|
219
|
-
timeTick={timeTick}
|
|
220
|
-
xScale={xScale}
|
|
221
|
-
yPoint={getYAnchorPoint({
|
|
222
|
-
metric_id,
|
|
223
|
-
timeSeries: relatedTimeSeries,
|
|
224
|
-
timeTick,
|
|
225
|
-
yScale
|
|
226
|
-
})}
|
|
227
|
-
yScale={yScale}
|
|
228
|
-
/>
|
|
229
|
-
))}
|
|
230
|
-
<RegularLine
|
|
231
|
-
areaColor={areaColor || lineColor}
|
|
232
|
-
curve={style?.curve || 'linear'}
|
|
233
|
-
dashLength={style?.dashLength}
|
|
234
|
-
dashOffset={style?.dashOffset}
|
|
235
|
-
dotOffset={style?.dotOffset}
|
|
236
|
-
filled={isNil(style?.showArea) ? filled : style.showArea}
|
|
237
|
-
graphHeight={height}
|
|
238
|
-
highlight={highlight}
|
|
239
|
-
lineColor={lineColor}
|
|
240
|
-
lineWidth={style?.lineWidth || 2}
|
|
241
|
-
metric_id={metric_id}
|
|
242
|
-
timeSeries={relatedTimeSeries}
|
|
243
|
-
transparency={
|
|
244
|
-
isNil(style?.areaTransparency)
|
|
245
|
-
? transparency || 80
|
|
246
|
-
: style.areaTransparency
|
|
247
|
-
}
|
|
248
|
-
unit={unit}
|
|
249
|
-
xScale={xScale}
|
|
250
|
-
yScale={yScale}
|
|
251
|
-
/>
|
|
252
|
-
</g>
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
)
|
|
260
|
+
</g>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
)
|
|
256
264
|
: null}
|
|
257
265
|
</g>
|
|
258
266
|
);
|
|
@@ -81,17 +81,17 @@ const MainLegend = ({
|
|
|
81
81
|
|
|
82
82
|
const contextMenuClick =
|
|
83
83
|
(metricId: number) =>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
(event: MouseEvent): void => {
|
|
85
|
+
if (!secondaryClick) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
secondaryClick({
|
|
90
|
+
element: event.target,
|
|
91
|
+
metricId,
|
|
92
|
+
position: [event.pageX, event.pageY]
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
95
|
|
|
96
96
|
const selectMetric = ({
|
|
97
97
|
event,
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import dayjs
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import Loading from
|
|
12
|
-
import type { LineChartData, Thresholds } from
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import type { GlobalAreaLines, LineChartProps } from './models';
|
|
19
|
-
import useChartData from './useChartData';
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { memo, useRef } from "react";
|
|
3
|
+
import "dayjs/locale/en";
|
|
4
|
+
import "dayjs/locale/es";
|
|
5
|
+
import "dayjs/locale/fr";
|
|
6
|
+
import "dayjs/locale/pt";
|
|
7
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
8
|
+
import timezonePlugin from "dayjs/plugin/timezone";
|
|
9
|
+
import utcPlugin from "dayjs/plugin/utc";
|
|
10
|
+
import useResizeObserver from "use-resize-observer";
|
|
11
|
+
import Loading from "../../LoadingSkeleton";
|
|
12
|
+
import type { LineChartData, Thresholds } from "../common/models";
|
|
13
|
+
import Chart from "./Chart";
|
|
14
|
+
import { useChartStyles } from "./Chart.styles";
|
|
15
|
+
import LoadingSkeleton from "./LoadingSkeleton";
|
|
16
|
+
import type { GlobalAreaLines, LineChartProps } from "./models";
|
|
17
|
+
import useChartData from "./useChartData";
|
|
20
18
|
|
|
21
19
|
dayjs.extend(localizedFormat);
|
|
22
20
|
dayjs.extend(utcPlugin);
|
|
@@ -31,7 +29,7 @@ interface Props extends Partial<LineChartProps> {
|
|
|
31
29
|
start: string;
|
|
32
30
|
thresholdUnit?: string;
|
|
33
31
|
thresholds?: Thresholds;
|
|
34
|
-
getRef?: (ref:
|
|
32
|
+
getRef?: (ref: React.RefObject<HTMLDivElement | null>) => void;
|
|
35
33
|
containerStyle?: string;
|
|
36
34
|
transformMatrix?: {
|
|
37
35
|
fx?: (pointX: number) => number;
|
|
@@ -52,19 +50,19 @@ const WrapperChart = ({
|
|
|
52
50
|
loading,
|
|
53
51
|
timeShiftZones,
|
|
54
52
|
tooltip = {
|
|
55
|
-
mode:
|
|
56
|
-
sortOrder:
|
|
53
|
+
mode: "all",
|
|
54
|
+
sortOrder: "name",
|
|
57
55
|
},
|
|
58
56
|
annotationEvent,
|
|
59
57
|
legend = {
|
|
60
58
|
display: true,
|
|
61
|
-
mode:
|
|
62
|
-
placement:
|
|
59
|
+
mode: "grid",
|
|
60
|
+
placement: "bottom",
|
|
63
61
|
showCalculations: {
|
|
64
62
|
min: true,
|
|
65
63
|
max: true,
|
|
66
|
-
avg: true
|
|
67
|
-
}
|
|
64
|
+
avg: true,
|
|
65
|
+
},
|
|
68
66
|
},
|
|
69
67
|
header,
|
|
70
68
|
lineStyle,
|
|
@@ -83,15 +81,25 @@ const WrapperChart = ({
|
|
|
83
81
|
const { classes, cx } = useChartStyles();
|
|
84
82
|
|
|
85
83
|
const { adjustedData } = useChartData({ data, end, start });
|
|
84
|
+
|
|
85
|
+
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
86
|
+
|
|
86
87
|
const {
|
|
87
|
-
ref,
|
|
88
|
+
ref: resizeObserverRef,
|
|
88
89
|
width: responsiveWidth,
|
|
89
|
-
height: responsiveHeight
|
|
90
|
+
height: responsiveHeight,
|
|
90
91
|
} = useResizeObserver();
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
const combinedRef = (element: HTMLDivElement | null) => {
|
|
94
|
+
if (containerRef.current !== element) {
|
|
95
|
+
containerRef.current = element;
|
|
96
|
+
if (element) {
|
|
97
|
+
getRef?.(containerRef);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
resizeObserverRef(element);
|
|
101
|
+
};
|
|
102
|
+
|
|
95
103
|
|
|
96
104
|
if (loading && !adjustedData) {
|
|
97
105
|
return (
|
|
@@ -108,11 +116,11 @@ const WrapperChart = ({
|
|
|
108
116
|
|
|
109
117
|
return (
|
|
110
118
|
<div
|
|
111
|
-
ref={
|
|
119
|
+
ref={combinedRef}
|
|
112
120
|
className={cx(classes.wrapperContainer, rest?.containerStyle)}
|
|
113
121
|
>
|
|
114
122
|
{!responsiveHeight ? (
|
|
115
|
-
<Loading height={height ||
|
|
123
|
+
<Loading height={height || "100%"} width={width} />
|
|
116
124
|
) : (
|
|
117
125
|
<Chart
|
|
118
126
|
annotationEvent={annotationEvent}
|
|
@@ -121,7 +129,7 @@ const WrapperChart = ({
|
|
|
121
129
|
displayAnchor={displayAnchor}
|
|
122
130
|
graphData={adjustedData}
|
|
123
131
|
graphInterval={{ end, start }}
|
|
124
|
-
graphRef={
|
|
132
|
+
graphRef={containerRef}
|
|
125
133
|
header={header}
|
|
126
134
|
height={height || responsiveHeight || 0}
|
|
127
135
|
legend={legend}
|
|
@@ -35,8 +35,8 @@ interface Props {
|
|
|
35
35
|
limitLegend?: number | false;
|
|
36
36
|
lines: Array<Line>;
|
|
37
37
|
setLines:
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
| Dispatch<SetStateAction<Array<Line> | null>>
|
|
39
|
+
| Dispatch<SetStateAction<Array<Line>>>;
|
|
40
40
|
title: string;
|
|
41
41
|
graphHeight: number;
|
|
42
42
|
}
|
|
@@ -93,8 +93,8 @@ const BaseChart = ({
|
|
|
93
93
|
className={cx(
|
|
94
94
|
classes.legendContainer,
|
|
95
95
|
equals(legend?.placement, 'right') &&
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
!isHorizontal &&
|
|
97
|
+
classes.legendContainerVerticalSide
|
|
98
98
|
)}
|
|
99
99
|
ref={legendRef}
|
|
100
100
|
>
|
|
@@ -2,13 +2,13 @@ import { MutableRefObject, ReactElement } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { Group } from '@visx/visx';
|
|
4
4
|
import { equals } from 'ramda';
|
|
5
|
+
import { margin } from '../../Chart/common';
|
|
5
6
|
import { ChartAxis } from '../../Chart/models';
|
|
6
7
|
import Axes from '../Axes';
|
|
7
8
|
import Grids from '../Grids';
|
|
8
9
|
import { Line, TimeValue } from '../timeSeries/models';
|
|
9
10
|
import { useMarginTop } from '../useMarginTop';
|
|
10
11
|
import { computeGElementMarginLeft } from '../utils';
|
|
11
|
-
import { margin } from '../../Chart/common';
|
|
12
12
|
|
|
13
13
|
interface Props {
|
|
14
14
|
allUnits: Array<string>;
|
|
@@ -52,21 +52,21 @@ export const useComputeBaseChartDimensions = ({
|
|
|
52
52
|
|
|
53
53
|
const legendBoundingHeight =
|
|
54
54
|
!equals(legendDisplay, false) &&
|
|
55
|
-
|
|
55
|
+
(isNil(legendPlacement) || equals(legendPlacement, 'bottom'))
|
|
56
56
|
? currentLegendHeight
|
|
57
57
|
: 0;
|
|
58
58
|
const legendBoundingWidth =
|
|
59
59
|
!equals(legendDisplay, false) &&
|
|
60
|
-
|
|
60
|
+
(equals(legendPlacement, 'left') || equals(legendPlacement, 'right'))
|
|
61
61
|
? legendRefWidth || 0
|
|
62
62
|
: 0;
|
|
63
63
|
|
|
64
64
|
const graphWidth =
|
|
65
65
|
width > 0
|
|
66
66
|
? width -
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
(hasSecondUnit ? maxAxisCharacters * 2 : maxAxisCharacters) * 6 -
|
|
68
|
+
(hasSecondUnit ? margins.left * 0.8 : margin.left) -
|
|
69
|
+
legendBoundingWidth
|
|
70
70
|
: 0;
|
|
71
71
|
const graphHeight =
|
|
72
72
|
(height || 0) > 0
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
includes,
|
|
21
21
|
isEmpty,
|
|
22
22
|
isNil,
|
|
23
|
+
isNotNil,
|
|
23
24
|
keys,
|
|
24
25
|
last,
|
|
25
26
|
lt,
|
|
@@ -33,8 +34,7 @@ import {
|
|
|
33
34
|
reject,
|
|
34
35
|
sortBy,
|
|
35
36
|
split,
|
|
36
|
-
uniq
|
|
37
|
-
isNotNil
|
|
37
|
+
uniq
|
|
38
38
|
} from 'ramda';
|
|
39
39
|
|
|
40
40
|
import { margin } from '../../Chart/common';
|
|
@@ -161,8 +161,8 @@ const getMetrics = (timeValue: TimeValue): Array<string> =>
|
|
|
161
161
|
|
|
162
162
|
const getValueForMetric =
|
|
163
163
|
(timeValue: TimeValue) =>
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
(metric_id: number): number =>
|
|
165
|
+
prop(metric_id, timeValue) as number;
|
|
166
166
|
|
|
167
167
|
const getUnits = (lines: Array<Line>): Array<string> =>
|
|
168
168
|
pipe(map(prop('unit')), uniq)(lines);
|
|
@@ -309,8 +309,8 @@ const getTimeSeriesForLines = ({
|
|
|
309
309
|
...acc,
|
|
310
310
|
[metric_id]:
|
|
311
311
|
invert &&
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
metricsValue[metric_id] &&
|
|
313
|
+
gt(metricsValue[metric_id], 0)
|
|
314
314
|
? negate(metricsValue[metric_id])
|
|
315
315
|
: metricsValue[metric_id]
|
|
316
316
|
};
|
|
@@ -343,10 +343,10 @@ const getYScale = ({
|
|
|
343
343
|
|
|
344
344
|
return invert
|
|
345
345
|
? getScaleType(scale)({
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
346
|
+
base: scaleLogarithmicBase,
|
|
347
|
+
domain: yScale.domain().reverse(),
|
|
348
|
+
range: yScale.range().reverse()
|
|
349
|
+
})
|
|
350
350
|
: yScale;
|
|
351
351
|
};
|
|
352
352
|
|
|
@@ -391,40 +391,40 @@ const getScale = ({
|
|
|
391
391
|
const sanitizedValuesForMinimum = min
|
|
392
392
|
? [min]
|
|
393
393
|
: getSanitizedValues([
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
394
|
+
invert && graphValues.every(lt(0))
|
|
395
|
+
? negate(getMax(graphValues))
|
|
396
|
+
: getMin(graphValues),
|
|
397
|
+
!isEmpty(stackedValues) &&
|
|
398
|
+
!equals(stackedValues, [0]) &&
|
|
399
|
+
getMin(stackedValues),
|
|
400
|
+
Math.min(...thresholds)
|
|
401
|
+
]);
|
|
402
402
|
const minValue = Math.min(...sanitizedValuesForMinimum.filter(isNotNil));
|
|
403
403
|
|
|
404
404
|
const sanitizedValuesForMaximum = max
|
|
405
405
|
? [max]
|
|
406
406
|
: getSanitizedValues([
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
407
|
+
getMax(graphValues),
|
|
408
|
+
getMax(stackedValues),
|
|
409
|
+
hasOnlyZeroesHasValue(graphValues) ? 1 : null,
|
|
410
|
+
Math.max(...thresholds)
|
|
411
|
+
]);
|
|
412
412
|
const maxValue = Math.max(...sanitizedValuesForMaximum.filter(isNotNil));
|
|
413
413
|
|
|
414
414
|
const minValueWithMargin =
|
|
415
415
|
(hasDisplayAsBar && minValue > 0) ||
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
416
|
+
(hasLineFilled &&
|
|
417
|
+
Math.max(maxValue, minValue) > minValue &&
|
|
418
|
+
minValue > 0) ||
|
|
419
|
+
(hasStackedLines && minValue > maxValue)
|
|
420
420
|
? 0
|
|
421
421
|
: minValue - Math.abs(minValue) * 0.05;
|
|
422
422
|
const maxValueWithMargin =
|
|
423
423
|
(hasDisplayAsBar && maxValue < 0) ||
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
424
|
+
(hasLineFilled &&
|
|
425
|
+
Math.min(maxValue, minValue) < maxValue &&
|
|
426
|
+
maxValue < 0) ||
|
|
427
|
+
(hasStackedLines && minValue > maxValue)
|
|
428
428
|
? 0
|
|
429
429
|
: maxValue + Math.abs(maxValue) * 0.05;
|
|
430
430
|
|
|
@@ -521,11 +521,11 @@ const getYScaleUnit = ({
|
|
|
521
521
|
|
|
522
522
|
const stackedValues = hasStackedLines
|
|
523
523
|
? getStackedMetricValues({
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
524
|
+
lines: getSortedStackedLines(dataLines).filter(
|
|
525
|
+
({ unit: stackedUnit }) => equals(unit, stackedUnit)
|
|
526
|
+
),
|
|
527
|
+
timeSeries: dataTimeSeries
|
|
528
|
+
})
|
|
529
529
|
: [];
|
|
530
530
|
|
|
531
531
|
return getScale({
|
|
@@ -538,8 +538,8 @@ const getYScaleUnit = ({
|
|
|
538
538
|
),
|
|
539
539
|
hasLineFilled: isNil(isFilled)
|
|
540
540
|
? dataLines.some(
|
|
541
|
-
|
|
542
|
-
|
|
541
|
+
({ unit: lineUnit, filled }) => equals(unit, lineUnit) && filled
|
|
542
|
+
)
|
|
543
543
|
: isFilled,
|
|
544
544
|
hasStackedLines: dataLines.some(
|
|
545
545
|
({ unit: lineUnit, stackKey, stackOrder }) =>
|
|
@@ -55,12 +55,6 @@ const useStyles = makeStyles<{ toolbarPositions: 'start' | 'end' }>()(
|
|
|
55
55
|
bold: {
|
|
56
56
|
fontWeight: theme.typography.fontWeightBold
|
|
57
57
|
},
|
|
58
|
-
container: equals(toolbarPositions, 'end')
|
|
59
|
-
? {
|
|
60
|
-
display: 'flex',
|
|
61
|
-
flexDirection: 'column-reverse'
|
|
62
|
-
}
|
|
63
|
-
: {},
|
|
64
58
|
error: {
|
|
65
59
|
color: theme.palette.error.main,
|
|
66
60
|
fontSize: theme.spacing(1.5),
|
|
@@ -190,7 +184,9 @@ const RichTextEditor = ({
|
|
|
190
184
|
|
|
191
185
|
return (
|
|
192
186
|
<LexicalComposer initialConfig={initialConfig}>
|
|
193
|
-
<div
|
|
187
|
+
<div
|
|
188
|
+
className={`flex ${toolbarPositions === 'end' ? 'flex-col-reverse' : 'flex-col'}`}
|
|
189
|
+
>
|
|
194
190
|
<div className={classes.toolbar}>
|
|
195
191
|
<ToolbarPlugin
|
|
196
192
|
className={toolbarClassName}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { makeStyles } from 'tss-react/mui';
|
|
2
|
-
|
|
3
1
|
import { Divider } from '@mui/material';
|
|
4
2
|
|
|
3
|
+
import { ReactElement } from 'react';
|
|
5
4
|
import AlignPicker from './AlignPicker';
|
|
6
5
|
import BlockButtons from './BlockButtons';
|
|
7
6
|
import FormatButtons from './FormatButtons';
|
|
@@ -18,26 +17,17 @@ interface Props {
|
|
|
18
17
|
editable: boolean;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
export const useStyles = makeStyles()((theme) => ({
|
|
22
|
-
container: {
|
|
23
|
-
alignItems: 'center',
|
|
24
|
-
columnGap: theme.spacing(1),
|
|
25
|
-
display: 'flex',
|
|
26
|
-
marginBottom: theme.spacing(1)
|
|
27
|
-
}
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
20
|
const ToolbarPlugin = ({
|
|
31
21
|
editable,
|
|
32
22
|
displayMacrosButton,
|
|
33
23
|
disabled,
|
|
34
24
|
displayBlockButtons,
|
|
35
25
|
className
|
|
36
|
-
}: Props):
|
|
37
|
-
const { cx, classes } = useStyles();
|
|
38
|
-
|
|
26
|
+
}: Props): ReactElement | null => {
|
|
39
27
|
return editable ? (
|
|
40
|
-
<div
|
|
28
|
+
<div
|
|
29
|
+
className={`flex items-center gap-2 mb-2 overflow-y-auto ${className}`}
|
|
30
|
+
>
|
|
41
31
|
<UndoRedoButtons disabled={disabled} />
|
|
42
32
|
{displayBlockButtons && (
|
|
43
33
|
<>
|
|
@@ -19,6 +19,8 @@ export type Props = {
|
|
|
19
19
|
labelAdd?: string;
|
|
20
20
|
onAddItem?: () => void;
|
|
21
21
|
secondaryLabel?: string;
|
|
22
|
+
isAddButtonSticky?: boolean;
|
|
23
|
+
addButtonClassName?: string;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export const ItemComposition = ({
|
|
@@ -29,8 +31,10 @@ export const ItemComposition = ({
|
|
|
29
31
|
addButtonHidden,
|
|
30
32
|
IconAdd,
|
|
31
33
|
displayItemsAsLinked,
|
|
32
|
-
secondaryLabel
|
|
33
|
-
|
|
34
|
+
secondaryLabel,
|
|
35
|
+
isAddButtonSticky,
|
|
36
|
+
addButtonClassName
|
|
37
|
+
}: Props): ReactElement => {
|
|
34
38
|
const { classes } = useItemCompositionStyles();
|
|
35
39
|
|
|
36
40
|
const hasMoreThanOneChildren = gt(children.length, 1);
|
|
@@ -45,7 +49,9 @@ export const ItemComposition = ({
|
|
|
45
49
|
</div>
|
|
46
50
|
)}
|
|
47
51
|
</div>
|
|
48
|
-
<div
|
|
52
|
+
<div
|
|
53
|
+
className={`flex justify-between items-center w-full ${isAddButtonSticky && 'bg-background-paper sticky bottom-0 z-2'} ${addButtonClassName}`}
|
|
54
|
+
>
|
|
49
55
|
{!addButtonHidden && (
|
|
50
56
|
<Button
|
|
51
57
|
aria-label={labelAdd}
|
|
@@ -12,7 +12,12 @@ const useStyles = makeStyles<{
|
|
|
12
12
|
padding: theme.spacing(2.5)
|
|
13
13
|
},
|
|
14
14
|
'&[data-size="fullscreen"]': {
|
|
15
|
-
zIndex: 0
|
|
15
|
+
zIndex: 0,
|
|
16
|
+
margin: 0,
|
|
17
|
+
marginLeft: props?.left ?? 0,
|
|
18
|
+
marginRight: props?.right ?? 0,
|
|
19
|
+
marginTop: props?.top ?? 0,
|
|
20
|
+
marginBottom: props?.bottom ?? 0
|
|
16
21
|
},
|
|
17
22
|
'&[data-size="fullscreen"] .MuiBackdrop-root': {
|
|
18
23
|
display: 'none'
|
|
@@ -20,18 +25,18 @@ const useStyles = makeStyles<{
|
|
|
20
25
|
'&[data-size="fullscreen"] .MuiDialog-container': {
|
|
21
26
|
alignItems: 'flex-end',
|
|
22
27
|
height: '100vh',
|
|
23
|
-
justifyContent: 'flex-end'
|
|
28
|
+
justifyContent: 'flex-end',
|
|
29
|
+
position: 'relative'
|
|
24
30
|
},
|
|
25
31
|
'&[data-size="fullscreen"] .MuiDialog-paper': {
|
|
26
|
-
bottom:
|
|
27
|
-
|
|
28
|
-
left: props?.left ?? 0,
|
|
32
|
+
bottom: 0,
|
|
33
|
+
left: 0,
|
|
29
34
|
margin: 0,
|
|
30
35
|
maxWidth: 'unset',
|
|
31
36
|
paddingBottom: theme.spacing(8),
|
|
32
37
|
position: 'absolute',
|
|
33
|
-
right:
|
|
34
|
-
top:
|
|
38
|
+
right: 0,
|
|
39
|
+
top: 0,
|
|
35
40
|
transition: theme.transitions.create('left')
|
|
36
41
|
},
|
|
37
42
|
'&[data-size="large"] .MuiDialog-paper': {
|
|
@@ -46,15 +51,13 @@ const useStyles = makeStyles<{
|
|
|
46
51
|
},
|
|
47
52
|
'&[data-size="xlarge"] .MuiDialog-paper': {
|
|
48
53
|
maxWidth: '900px',
|
|
49
|
-
width: 'calc(100% -
|
|
54
|
+
width: 'calc(100% - 78px)'
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
modalActions: {
|
|
53
58
|
'&[data-fixed="true"]': {
|
|
54
|
-
background: theme.palette.background.paper,
|
|
55
59
|
padding: theme.spacing(1, 2.5, 2.5, 0),
|
|
56
|
-
position: 'fixed'
|
|
57
|
-
width: '100%'
|
|
60
|
+
position: 'fixed'
|
|
58
61
|
},
|
|
59
62
|
bottom: 0,
|
|
60
63
|
display: 'flex',
|
|
@@ -64,14 +67,6 @@ const useStyles = makeStyles<{
|
|
|
64
67
|
padding: theme.spacing(1, 0, 0, 0),
|
|
65
68
|
right: 0,
|
|
66
69
|
zIndex: theme.zIndex.modal
|
|
67
|
-
},
|
|
68
|
-
modalCloseButton: {
|
|
69
|
-
position: 'absolute',
|
|
70
|
-
right: theme.spacing(1),
|
|
71
|
-
svg: {
|
|
72
|
-
opacity: 0.6
|
|
73
|
-
},
|
|
74
|
-
top: theme.spacing(1)
|
|
75
70
|
}
|
|
76
71
|
}));
|
|
77
72
|
|