@sybilion/uilib 1.8.0 → 1.8.1
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/esm/src/components/ui/Chart/Chart.js +4 -1
- package/dist/esm/src/components/ui/Chart/components/BaseChartWrapper.js +30 -8
- package/dist/esm/src/components/ui/Chart/components/ChartAxes.js +8 -7
- package/dist/esm/src/components/ui/Chart/components/ChartPlacedTooltip.js +65 -0
- package/dist/esm/src/components/ui/Chart/components/ChartTooltipContent.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/ChartTooltipItem.js +22 -6
- package/dist/esm/src/components/ui/Chart/components/QuantileBands.js +1 -1
- package/dist/esm/src/components/ui/ChartAreaInteractive/ChartLines.js +14 -8
- package/dist/esm/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.js +2 -3
- package/dist/esm/src/components/widgets/DriverCard/DriverPerformanceChart.js +5 -25
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/types/src/components/ui/Chart/Chart.d.ts +4 -2
- package/dist/esm/types/src/components/ui/Chart/Chart.types.d.ts +5 -0
- package/dist/esm/types/src/components/ui/Chart/chartForecastVisualization.types.d.ts +7 -0
- package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.d.ts +17 -0
- package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartAxes.d.ts +8 -1
- package/dist/esm/types/src/components/ui/Chart/components/ChartAxes.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartPlacedTooltip.d.ts +31 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartPlacedTooltip.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipContent.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipContent.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipItem.d.ts +2 -1
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartLines.d.ts +12 -1
- package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.d.ts +2 -3
- package/package.json +2 -2
- package/src/components/ui/Chart/AGENT.md +5 -0
- package/src/components/ui/Chart/Chart.tsx +7 -1
- package/src/components/ui/Chart/Chart.types.ts +5 -0
- package/src/components/ui/Chart/chartForecastVisualization.types.ts +7 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.test.tsx +344 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.tsx +78 -36
- package/src/components/ui/Chart/components/ChartAxes.test.tsx +49 -0
- package/src/components/ui/Chart/components/ChartAxes.tsx +36 -20
- package/src/components/ui/Chart/components/ChartPlacedTooltip.test.tsx +160 -0
- package/src/components/ui/Chart/components/ChartPlacedTooltip.tsx +93 -0
- package/src/components/ui/Chart/components/ChartTooltipContent.test.tsx +85 -0
- package/src/components/ui/Chart/components/ChartTooltipContent.tsx +2 -0
- package/src/components/ui/Chart/components/ChartTooltipItem.tsx +41 -10
- package/src/components/ui/Chart/components/QuantileBands.tsx +1 -1
- package/src/components/ui/ChartAreaInteractive/AGENT.md +2 -0
- package/src/components/ui/ChartAreaInteractive/ChartLines.tsx +75 -45
- package/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.tsx +2 -3
- package/src/components/widgets/DriverCard/DriverPerformanceChart.tsx +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Line } from 'recharts';
|
|
3
|
+
import { DefaultZIndexes, Line } from 'recharts';
|
|
4
4
|
|
|
5
5
|
import { ChartDataPoint } from './ChartAreaInteractive.types';
|
|
6
6
|
import {
|
|
@@ -106,6 +106,10 @@ export const ChartLines = memo(
|
|
|
106
106
|
forecastLineStyle = 'dashed',
|
|
107
107
|
disableAnimation = false,
|
|
108
108
|
disableHistoricalAnimation = false,
|
|
109
|
+
connectHistoryNulls = false,
|
|
110
|
+
connectForecastNulls = false,
|
|
111
|
+
historyOnTop = false,
|
|
112
|
+
showEndDots = true,
|
|
109
113
|
}: {
|
|
110
114
|
chartData: ChartDataPoint[];
|
|
111
115
|
forecastData?: ForecastItemData[];
|
|
@@ -119,6 +123,17 @@ export const ChartLines = memo(
|
|
|
119
123
|
forecastLineStyle?: 'dashed' | 'solid';
|
|
120
124
|
disableAnimation?: boolean;
|
|
121
125
|
disableHistoricalAnimation?: boolean;
|
|
126
|
+
/** Draw each history line across months it has no value for. */
|
|
127
|
+
connectHistoryNulls?: boolean;
|
|
128
|
+
/** Draw each forecast line across months it has no value for. */
|
|
129
|
+
connectForecastNulls?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Draw the history lines after the forecast lines, over them (for many
|
|
132
|
+
* faint forecasts that would otherwise cover the history).
|
|
133
|
+
*/
|
|
134
|
+
historyOnTop?: boolean;
|
|
135
|
+
/** Mark each line's last point with a dot (default: on). */
|
|
136
|
+
showEndDots?: boolean;
|
|
122
137
|
}) => {
|
|
123
138
|
const dotStroke = isDarkTheme ? '#000000' : '#FFFFFF';
|
|
124
139
|
|
|
@@ -216,63 +231,78 @@ export const ChartLines = memo(
|
|
|
216
231
|
const animationDuration = disableAnimation ? 0 : ANIMATION_DURATION;
|
|
217
232
|
const valueAnimationEnabled = !disableAnimation;
|
|
218
233
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
234
|
+
// recharts draws each line into its z-index layer in mount order, not in
|
|
235
|
+
// JSX order: a layer above the forecasts keeps history on top through
|
|
236
|
+
// hiding, showing and added forecasts, and leaves the tooltip's order.
|
|
237
|
+
const historyZIndex = historyOnTop ? DefaultZIndexes.line + 1 : undefined;
|
|
238
|
+
|
|
239
|
+
const historyElements = historyLines.map(({ dataKey, name, color }) => (
|
|
240
|
+
<Line
|
|
241
|
+
key={dataKey}
|
|
242
|
+
zIndex={historyZIndex}
|
|
243
|
+
type="monotone"
|
|
244
|
+
dataKey={dataKey}
|
|
245
|
+
stroke={color}
|
|
246
|
+
strokeWidth={1}
|
|
247
|
+
dot={
|
|
248
|
+
showEndDots ? props => renderHistoryDot(props, dataKey, color) : false
|
|
249
|
+
}
|
|
250
|
+
activeDot={{ ...activeDotHistorical, fill: color }}
|
|
251
|
+
name={name}
|
|
252
|
+
legendType={showLegend === false ? 'none' : undefined}
|
|
253
|
+
strokeDasharray="0"
|
|
254
|
+
connectNulls={connectHistoryNulls}
|
|
255
|
+
hide={hiddenSeries?.has(dataKey)}
|
|
256
|
+
isAnimationActive={historicalAnimationActive}
|
|
257
|
+
animationDuration={animationDuration}
|
|
258
|
+
animateNewValues={valueAnimationEnabled}
|
|
259
|
+
animationBegin={0}
|
|
260
|
+
animationEasing="ease-out"
|
|
261
|
+
/>
|
|
262
|
+
));
|
|
263
|
+
|
|
264
|
+
const forecastElements = forecastData?.map(
|
|
265
|
+
(data: ForecastItemData, index: number) => {
|
|
266
|
+
const {
|
|
267
|
+
id,
|
|
268
|
+
name,
|
|
269
|
+
color = FORECAST_LINE_COLORS[index % FORECAST_LINE_COLORS.length],
|
|
270
|
+
} = data;
|
|
271
|
+
const dataKey = `forecast_${id}`;
|
|
272
|
+
|
|
273
|
+
return (
|
|
223
274
|
<Line
|
|
224
|
-
key={
|
|
275
|
+
key={`forecast-${id}`}
|
|
225
276
|
type="monotone"
|
|
226
277
|
dataKey={dataKey}
|
|
227
278
|
stroke={color}
|
|
228
279
|
strokeWidth={1}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
280
|
+
strokeDasharray={forecastLineStyle === 'dashed' ? '4 2' : '0'}
|
|
281
|
+
dot={
|
|
282
|
+
showEndDots ? props => renderForecastDot(props, id, color) : false
|
|
283
|
+
}
|
|
284
|
+
activeDot={activeDotForecast(color)}
|
|
285
|
+
name={`${name || `${id}`}`}
|
|
232
286
|
legendType={showLegend === false ? 'none' : undefined}
|
|
233
|
-
|
|
287
|
+
connectNulls={connectForecastNulls}
|
|
234
288
|
hide={hiddenSeries?.has(dataKey)}
|
|
235
|
-
isAnimationActive={
|
|
289
|
+
isAnimationActive={forecastAnimationActive}
|
|
236
290
|
animationDuration={animationDuration}
|
|
237
291
|
animateNewValues={valueAnimationEnabled}
|
|
238
292
|
animationBegin={0}
|
|
239
293
|
animationEasing="ease-out"
|
|
294
|
+
className={
|
|
295
|
+
data.status === 'pending' ? 'chart-line-blinking' : undefined
|
|
296
|
+
}
|
|
240
297
|
/>
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
{forecastData?.map((data: ForecastItemData, index: number) => {
|
|
245
|
-
const {
|
|
246
|
-
id,
|
|
247
|
-
name,
|
|
248
|
-
color = FORECAST_LINE_COLORS[index % FORECAST_LINE_COLORS.length],
|
|
249
|
-
} = data;
|
|
250
|
-
const dataKey = `forecast_${id}`;
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
);
|
|
251
301
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
dataKey={dataKey}
|
|
257
|
-
stroke={color}
|
|
258
|
-
strokeWidth={1}
|
|
259
|
-
strokeDasharray={forecastLineStyle === 'dashed' ? '4 2' : '0'}
|
|
260
|
-
dot={props => renderForecastDot(props, id, color)}
|
|
261
|
-
activeDot={activeDotForecast(color)}
|
|
262
|
-
name={`${name || `${id}`}`}
|
|
263
|
-
legendType={showLegend === false ? 'none' : undefined}
|
|
264
|
-
hide={hiddenSeries?.has(dataKey)}
|
|
265
|
-
isAnimationActive={forecastAnimationActive}
|
|
266
|
-
animationDuration={animationDuration}
|
|
267
|
-
animateNewValues={valueAnimationEnabled}
|
|
268
|
-
animationBegin={0}
|
|
269
|
-
animationEasing="ease-out"
|
|
270
|
-
className={
|
|
271
|
-
data.status === 'pending' ? 'chart-line-blinking' : undefined
|
|
272
|
-
}
|
|
273
|
-
/>
|
|
274
|
-
);
|
|
275
|
-
})}
|
|
302
|
+
return (
|
|
303
|
+
<>
|
|
304
|
+
{historyElements}
|
|
305
|
+
{forecastElements}
|
|
276
306
|
</>
|
|
277
307
|
);
|
|
278
308
|
},
|
|
@@ -12,9 +12,8 @@ export type TooltipRow = {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Tooltip rows in series order, showing real zeros
|
|
16
|
-
*
|
|
17
|
-
* is its white stack stroke).
|
|
15
|
+
* Tooltip rows in series order, showing real zeros, and colouring each row
|
|
16
|
+
* from the chart config (an area's own colour is its white stack stroke).
|
|
18
17
|
*/
|
|
19
18
|
export function StackedTooltip({
|
|
20
19
|
active,
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
CartesianGrid,
|
|
6
6
|
Line,
|
|
7
7
|
LineChart,
|
|
8
|
-
Tooltip as RechartsTooltip,
|
|
9
8
|
type TooltipContentProps,
|
|
10
9
|
XAxis,
|
|
11
10
|
YAxis,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
type ChartConfig,
|
|
16
15
|
ChartContainer,
|
|
17
16
|
ChartEmptyState,
|
|
17
|
+
ChartTooltip,
|
|
18
18
|
} from '../../ui/Chart/Chart';
|
|
19
19
|
import type { DriverData } from '../DriverMap/driverMapGeography';
|
|
20
20
|
import S from './DriverPerformanceChart.styl';
|
|
@@ -133,7 +133,7 @@ export function DriverPerformanceChart({
|
|
|
133
133
|
width={0}
|
|
134
134
|
domain={['dataMin', 'dataMax']}
|
|
135
135
|
/>
|
|
136
|
-
<
|
|
136
|
+
<ChartTooltip cursor={false} content={renderTooltipContent} />
|
|
137
137
|
<Line dataKey="value" type="natural" stroke="var(--color-value)" />
|
|
138
138
|
</LineChart>
|
|
139
139
|
</ChartContainer>
|