@centreon/ui 24.8.2 → 24.8.3
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 +14 -17
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +38 -79
- package/src/Graph/BarChart/BarChart.tsx +4 -4
- package/src/Graph/BarChart/BarGroup.tsx +81 -92
- package/src/Graph/BarChart/BarStack.tsx +21 -13
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +26 -50
- package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +1 -1
- package/src/Graph/BarChart/useBarStack.ts +1 -1
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Point.tsx +1 -1
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +67 -0
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +4 -7
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/index.tsx +6 -9
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/models.ts +1 -2
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useScaleThreshold.ts +8 -20
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/index.tsx +64 -43
- package/src/Graph/{LineChart/LineChart.cypress.spec.tsx → Chart/Chart.cypress.spec.tsx} +272 -23
- package/src/Graph/{LineChart/index.stories.tsx → Chart/Chart.stories.tsx} +217 -24
- package/src/Graph/{LineChart/LineChart.styles.ts → Chart/Chart.styles.ts} +1 -1
- package/src/Graph/{LineChart/LineChart.tsx → Chart/Chart.tsx} +84 -100
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +5 -1
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +6 -1
- package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +61 -0
- package/src/Graph/{LineChart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx → Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltipContent.tsx} +2 -2
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/index.tsx +11 -15
- package/src/Graph/{LineChart → Chart}/Legend/Legend.styles.ts +1 -7
- package/src/Graph/{LineChart → Chart}/Legend/LegendHeader.tsx +9 -5
- package/src/Graph/{LineChart → Chart}/Legend/index.tsx +2 -1
- package/src/Graph/Chart/graphAtoms.ts +6 -0
- package/src/Graph/{LineChart → Chart}/index.tsx +10 -7
- package/src/Graph/{LineChart → Chart}/models.ts +8 -3
- package/src/Graph/common/Axes/AxisStyles.ts +11 -0
- package/src/Graph/common/Axes/UnitLabel.tsx +41 -10
- package/src/Graph/common/Axes/index.tsx +18 -12
- package/src/Graph/common/Axes/models.ts +4 -2
- package/src/Graph/common/Axes/useAxisY.ts +22 -12
- package/src/Graph/common/BaseChart/BaseChart.tsx +2 -2
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +8 -5
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +1 -1
- package/src/Graph/common/Grids/index.tsx +2 -2
- package/src/Graph/common/Thresholds/ThresholdLine.tsx +1 -1
- package/src/Graph/common/Thresholds/Thresholds.tsx +10 -15
- package/src/Graph/common/timeSeries/index.ts +109 -131
- package/src/Graph/common/timeSeries/models.ts +4 -5
- package/src/Graph/index.ts +4 -4
- package/src/Graph/mockedData/lastDayWithLotOfUnits.json +1668 -0
- package/src/Graph/mockedData/pingService.json +46 -1
- package/src/Graph/mockedData/pingServiceLinesBars.json +253 -0
- package/src/Graph/mockedData/pingServiceLinesBarsMixed.json +253 -0
- package/src/Graph/mockedData/pingServiceLinesBarsStacked.json +253 -0
- package/src/Graph/mockedData/pingServiceMixedStacked.json +46 -1
- package/src/Graph/mockedData/pingServiceStacked.json +46 -1
- package/src/Typography/EllipsisTypography.tsx +5 -2
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +16 -24
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +5 -5
- package/src/components/Form/AccessRights/AccessRights.tsx +3 -3
- package/src/components/Form/index.ts +2 -2
- package/src/utils/index.ts +2 -2
- package/src/Graph/BarChart/SingleBar.tsx +0 -62
- package/src/Graph/BarChart/useSingleBar.ts +0 -199
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/useStackedLines.ts +0 -39
- package/src/Graph/LineChart/graphAtoms.ts +0 -3
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/useRegularLines.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/StackedLines/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/BasicThreshold.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/Circle.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/helpers/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useCoordinateCircle.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/GuidingLines.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/useTickGraph.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Area.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Line.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Area/Downtime.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/EventAnnotations.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Acknowledgement.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Comments.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/annotationsAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/useAnnotation.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Bar.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltipStyles.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftIcon.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/useGraphTooltip.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/useZoomPreview.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/zoomPreviewAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/interactionWithGraphAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/LegendContent.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/useLegend.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/LoadingSkeleton.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/common/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/helpers/doc.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/helpers/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/translatedLabels.ts +0 -0
- /package/src/Graph/{LineChart/useLineChartData.ts → Chart/useChartData.ts} +0 -0
- /package/src/Graph/{LineChart/useLineChartIntersection.ts → Chart/useChartIntersection.ts} +0 -0
|
@@ -22,6 +22,10 @@ import dataLastWeek from '../mockedData/lastWeek.json';
|
|
|
22
22
|
import dataZoomPreview from '../mockedData/zoomPreview.json';
|
|
23
23
|
import dataLastDay from '../mockedData/lastDay.json';
|
|
24
24
|
import dataCurvesSameColor from '../mockedData/curvesWithSameColor.json';
|
|
25
|
+
import dataLastDayWithLotOfUnits from '../mockedData/lastDayWithLotOfUnits.json';
|
|
26
|
+
import dataPingServiceLinesBars from '../mockedData/pingServiceLinesBars.json';
|
|
27
|
+
import dataPingServiceLinesBarsStacked from '../mockedData/pingServiceLinesBarsStacked.json';
|
|
28
|
+
import dataPingServiceLinesBarsMixed from '../mockedData/pingServiceLinesBarsMixed.json';
|
|
25
29
|
|
|
26
30
|
import {
|
|
27
31
|
argTypes,
|
|
@@ -36,14 +40,14 @@ import {
|
|
|
36
40
|
import { dateTimeFormat } from './common';
|
|
37
41
|
import { Interval, ThresholdType, TooltipData } from './models';
|
|
38
42
|
|
|
39
|
-
import
|
|
43
|
+
import WrapperChart from '.';
|
|
40
44
|
|
|
41
|
-
const meta: Meta<typeof
|
|
42
|
-
component:
|
|
45
|
+
const meta: Meta<typeof WrapperChart> = {
|
|
46
|
+
component: WrapperChart
|
|
43
47
|
};
|
|
44
48
|
export default meta;
|
|
45
49
|
|
|
46
|
-
type Story = StoryObj<typeof
|
|
50
|
+
type Story = StoryObj<typeof WrapperChart>;
|
|
47
51
|
|
|
48
52
|
interface Random {
|
|
49
53
|
max: number;
|
|
@@ -73,7 +77,7 @@ const Threshold = (args): JSX.Element => {
|
|
|
73
77
|
<Button onClick={handleClick}>change envelope size randomly</Button>
|
|
74
78
|
</Tooltip>
|
|
75
79
|
|
|
76
|
-
<
|
|
80
|
+
<WrapperChart
|
|
77
81
|
{...args}
|
|
78
82
|
data={dataLastDayThreshold}
|
|
79
83
|
shapeLines={{
|
|
@@ -128,7 +132,7 @@ const LineChartAndCLS = (args): JSX.Element => {
|
|
|
128
132
|
}, []);
|
|
129
133
|
|
|
130
134
|
return (
|
|
131
|
-
<
|
|
135
|
+
<WrapperChart
|
|
132
136
|
{...args}
|
|
133
137
|
data={data}
|
|
134
138
|
loading={loading}
|
|
@@ -227,7 +231,7 @@ const LineChartAndTimePeriod = (args): JSX.Element => {
|
|
|
227
231
|
<TimePeriodSwitch getDataSwitch={getDataSwitch} />
|
|
228
232
|
}
|
|
229
233
|
/>
|
|
230
|
-
<
|
|
234
|
+
<WrapperChart
|
|
231
235
|
data={currentData}
|
|
232
236
|
{...args}
|
|
233
237
|
annotationEvent={annotationEventData}
|
|
@@ -279,7 +283,7 @@ const LineChartAndExclusionPeriod = (args): JSX.Element => {
|
|
|
279
283
|
second
|
|
280
284
|
</Button>
|
|
281
285
|
</ButtonGroup>
|
|
282
|
-
<
|
|
286
|
+
<WrapperChart
|
|
283
287
|
{...args}
|
|
284
288
|
data={dataLastDayThreshold as unknown as LineChartData}
|
|
285
289
|
shapeLines={{
|
|
@@ -301,7 +305,7 @@ const LineChartAndExclusionPeriod = (args): JSX.Element => {
|
|
|
301
305
|
|
|
302
306
|
const Template: Story = {
|
|
303
307
|
render: (args) => (
|
|
304
|
-
<
|
|
308
|
+
<WrapperChart
|
|
305
309
|
{...args}
|
|
306
310
|
data={dataLastDayThreshold as unknown as LineChartData}
|
|
307
311
|
shapeLines={{
|
|
@@ -408,10 +412,7 @@ export const withThresholds: Story = {
|
|
|
408
412
|
}
|
|
409
413
|
},
|
|
410
414
|
render: (args) => (
|
|
411
|
-
<
|
|
412
|
-
{...args}
|
|
413
|
-
data={dataLastDay as unknown as LineChartData}
|
|
414
|
-
/>
|
|
415
|
+
<WrapperChart {...args} data={dataLastDay as unknown as LineChartData} />
|
|
415
416
|
)
|
|
416
417
|
};
|
|
417
418
|
|
|
@@ -437,10 +438,7 @@ export const withThresholdsAndUnit: Story = {
|
|
|
437
438
|
}
|
|
438
439
|
},
|
|
439
440
|
render: (args) => (
|
|
440
|
-
<
|
|
441
|
-
{...args}
|
|
442
|
-
data={dataLastDay as unknown as LineChartData}
|
|
443
|
-
/>
|
|
441
|
+
<WrapperChart {...args} data={dataLastDay as unknown as LineChartData} />
|
|
444
442
|
)
|
|
445
443
|
};
|
|
446
444
|
|
|
@@ -474,15 +472,36 @@ export const thresholdsRange: Story = {
|
|
|
474
472
|
}
|
|
475
473
|
},
|
|
476
474
|
render: (args) => (
|
|
477
|
-
<
|
|
478
|
-
{...args}
|
|
479
|
-
data={dataLastDay as unknown as LineChartData}
|
|
480
|
-
/>
|
|
475
|
+
<WrapperChart {...args} data={dataLastDay as unknown as LineChartData} />
|
|
481
476
|
)
|
|
482
477
|
};
|
|
483
478
|
|
|
484
479
|
export const LineChartWithSameColorCurves: Story = {
|
|
485
480
|
...Template,
|
|
481
|
+
argTypes,
|
|
482
|
+
args: argumentsData,
|
|
483
|
+
render: (args) => (
|
|
484
|
+
<WrapperChart
|
|
485
|
+
{...args}
|
|
486
|
+
data={dataCurvesSameColor as unknown as LineChartData}
|
|
487
|
+
/>
|
|
488
|
+
)
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
export const zeroCentered: Story = {
|
|
492
|
+
argTypes,
|
|
493
|
+
args: {
|
|
494
|
+
...argumentsData,
|
|
495
|
+
axis: {
|
|
496
|
+
isCenteredZero: true
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
render: (args) => (
|
|
500
|
+
<WrapperChart {...args} data={dataLastDay as unknown as LineChartData} />
|
|
501
|
+
)
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
export const customLines: Story = {
|
|
486
505
|
argTypes,
|
|
487
506
|
args: {
|
|
488
507
|
...argumentsData,
|
|
@@ -490,15 +509,189 @@ export const LineChartWithSameColorCurves: Story = {
|
|
|
490
509
|
areaTransparency: 10,
|
|
491
510
|
dashLength: 10,
|
|
492
511
|
dashOffset: 10,
|
|
493
|
-
lineWidth:
|
|
512
|
+
lineWidth: 3,
|
|
494
513
|
showArea: true,
|
|
495
514
|
showPoints: true
|
|
496
515
|
}
|
|
497
516
|
},
|
|
498
517
|
render: (args) => (
|
|
499
|
-
<
|
|
518
|
+
<WrapperChart {...args} data={dataLastDay as unknown as LineChartData} />
|
|
519
|
+
)
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
export const customLinesAndBars: Story = {
|
|
523
|
+
argTypes,
|
|
524
|
+
args: {
|
|
525
|
+
...argumentsData,
|
|
526
|
+
barStyle: {
|
|
527
|
+
opacity: 0.5,
|
|
528
|
+
radius: 0.5
|
|
529
|
+
},
|
|
530
|
+
lineStyle: {
|
|
531
|
+
curve: 'natural',
|
|
532
|
+
lineWidth: 2,
|
|
533
|
+
showPoints: true
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
render: (args) => (
|
|
537
|
+
<WrapperChart
|
|
500
538
|
{...args}
|
|
501
|
-
data={
|
|
539
|
+
data={dataPingServiceLinesBars as unknown as LineChartData}
|
|
540
|
+
/>
|
|
541
|
+
)
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
export const multipleUnits: Story = {
|
|
545
|
+
argTypes,
|
|
546
|
+
args: argumentsData,
|
|
547
|
+
render: (args) => (
|
|
548
|
+
<WrapperChart
|
|
549
|
+
{...args}
|
|
550
|
+
data={dataLastDayWithLotOfUnits as unknown as LineChartData}
|
|
551
|
+
/>
|
|
552
|
+
)
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
export const linesAndBars: Story = {
|
|
556
|
+
argTypes,
|
|
557
|
+
args: {
|
|
558
|
+
...argumentsData,
|
|
559
|
+
lineStyle: {
|
|
560
|
+
curve: 'natural',
|
|
561
|
+
lineWidth: 2,
|
|
562
|
+
showPoints: true
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
render: (args) => (
|
|
566
|
+
<WrapperChart
|
|
567
|
+
{...args}
|
|
568
|
+
data={dataPingServiceLinesBars as unknown as LineChartData}
|
|
502
569
|
/>
|
|
503
570
|
)
|
|
504
571
|
};
|
|
572
|
+
|
|
573
|
+
export const linesAndBarsStacked: Story = {
|
|
574
|
+
argTypes,
|
|
575
|
+
args: {
|
|
576
|
+
...argumentsData,
|
|
577
|
+
lineStyle: {
|
|
578
|
+
curve: 'natural',
|
|
579
|
+
lineWidth: 2,
|
|
580
|
+
showPoints: false
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
render: (args) => (
|
|
584
|
+
<WrapperChart
|
|
585
|
+
{...args}
|
|
586
|
+
data={dataPingServiceLinesBarsStacked as unknown as LineChartData}
|
|
587
|
+
/>
|
|
588
|
+
)
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
export const linesAndBarsMixed: Story = {
|
|
592
|
+
argTypes,
|
|
593
|
+
args: {
|
|
594
|
+
...argumentsData,
|
|
595
|
+
lineStyle: {
|
|
596
|
+
curve: 'natural',
|
|
597
|
+
lineWidth: 2,
|
|
598
|
+
showPoints: false
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
render: (args) => (
|
|
602
|
+
<WrapperChart
|
|
603
|
+
{...args}
|
|
604
|
+
data={dataPingServiceLinesBarsMixed as unknown as LineChartData}
|
|
605
|
+
/>
|
|
606
|
+
)
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
export const linesAndBarsCenteredZero: Story = {
|
|
610
|
+
argTypes,
|
|
611
|
+
args: {
|
|
612
|
+
...argumentsData,
|
|
613
|
+
axis: {
|
|
614
|
+
isCenteredZero: true
|
|
615
|
+
},
|
|
616
|
+
lineStyle: {
|
|
617
|
+
curve: 'natural',
|
|
618
|
+
lineWidth: 2,
|
|
619
|
+
showPoints: true
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
render: (args) => (
|
|
623
|
+
<WrapperChart
|
|
624
|
+
{...args}
|
|
625
|
+
data={dataPingServiceLinesBars as unknown as LineChartData}
|
|
626
|
+
/>
|
|
627
|
+
)
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
export const linesAndBarsStackedCenteredZero: Story = {
|
|
631
|
+
argTypes,
|
|
632
|
+
args: {
|
|
633
|
+
...argumentsData,
|
|
634
|
+
axis: {
|
|
635
|
+
isCenteredZero: true
|
|
636
|
+
},
|
|
637
|
+
lineStyle: {
|
|
638
|
+
curve: 'natural',
|
|
639
|
+
lineWidth: 2,
|
|
640
|
+
showPoints: false
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
render: (args) => (
|
|
644
|
+
<WrapperChart
|
|
645
|
+
{...args}
|
|
646
|
+
data={dataPingServiceLinesBarsStacked as unknown as LineChartData}
|
|
647
|
+
/>
|
|
648
|
+
)
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
export const linesAndBarsMixedCenteredZero: Story = {
|
|
652
|
+
argTypes,
|
|
653
|
+
args: {
|
|
654
|
+
...argumentsData,
|
|
655
|
+
axis: {
|
|
656
|
+
isCenteredZero: true
|
|
657
|
+
},
|
|
658
|
+
lineStyle: {
|
|
659
|
+
curve: 'natural',
|
|
660
|
+
lineWidth: 2,
|
|
661
|
+
showPoints: false
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
render: (args) => (
|
|
665
|
+
<WrapperChart
|
|
666
|
+
{...args}
|
|
667
|
+
data={dataPingServiceLinesBarsMixed as unknown as LineChartData}
|
|
668
|
+
/>
|
|
669
|
+
)
|
|
670
|
+
};
|
|
671
|
+
const CustomYUnits = (props): JSX.Element => {
|
|
672
|
+
const [leftUnit, setLeftUnit] = useState('b');
|
|
673
|
+
const [rightUnit, setRightUnit] = useState('ms');
|
|
674
|
+
|
|
675
|
+
return (
|
|
676
|
+
<WrapperChart
|
|
677
|
+
{...props}
|
|
678
|
+
axis={{
|
|
679
|
+
axisYLeft: {
|
|
680
|
+
onUnitChange: setLeftUnit,
|
|
681
|
+
unit: leftUnit
|
|
682
|
+
},
|
|
683
|
+
axisYRight: {
|
|
684
|
+
onUnitChange: setRightUnit,
|
|
685
|
+
unit: rightUnit
|
|
686
|
+
}
|
|
687
|
+
}}
|
|
688
|
+
data={dataPingServiceLinesBars}
|
|
689
|
+
/>
|
|
690
|
+
);
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
export const customYUnits: Story = {
|
|
694
|
+
argTypes,
|
|
695
|
+
args: argumentsData,
|
|
696
|
+
render: (args) => <CustomYUnits {...args} />
|
|
697
|
+
};
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { MutableRefObject, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Tooltip } from '@visx/visx';
|
|
4
3
|
import { equals, flatten, isNil, pluck, reject } from 'ramda';
|
|
4
|
+
import { useAtom } from 'jotai';
|
|
5
5
|
|
|
6
|
-
import { ClickAwayListener,
|
|
6
|
+
import { ClickAwayListener, Skeleton } from '@mui/material';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
getLeftScale,
|
|
10
|
-
getRightScale,
|
|
11
9
|
getUnits,
|
|
12
|
-
getXScale
|
|
10
|
+
getXScale,
|
|
11
|
+
getXScaleBand,
|
|
12
|
+
getYScalePerUnit
|
|
13
13
|
} from '../common/timeSeries';
|
|
14
14
|
import { Line } from '../common/timeSeries/models';
|
|
15
15
|
import { Thresholds as ThresholdsModel } from '../common/models';
|
|
16
|
-
import { Tooltip as MuiTooltip } from '../../components/Tooltip';
|
|
17
|
-
import { useTooltipStyles } from '../common/useTooltipStyles';
|
|
18
16
|
import BaseChart from '../common/BaseChart/BaseChart';
|
|
19
17
|
import { useComputeBaseChartDimensions } from '../common/BaseChart/useComputeBaseChartDimensions';
|
|
20
18
|
import ChartSvgWrapper from '../common/BaseChart/ChartSvgWrapper';
|
|
21
19
|
import Thresholds from '../common/Thresholds/Thresholds';
|
|
22
20
|
import { useDeepCompare } from '../../utils';
|
|
21
|
+
import BarGroup from '../BarChart/BarGroup';
|
|
23
22
|
|
|
24
23
|
import Lines from './BasicComponents/Lines';
|
|
25
24
|
import {
|
|
@@ -33,9 +32,10 @@ import GraphTooltip from './InteractiveComponents/Tooltip';
|
|
|
33
32
|
import useGraphTooltip from './InteractiveComponents/Tooltip/useGraphTooltip';
|
|
34
33
|
import { margin } from './common';
|
|
35
34
|
import { Data, GlobalAreaLines, GraphInterval, LineChartProps } from './models';
|
|
36
|
-
import { useIntersection } from './
|
|
35
|
+
import { useIntersection } from './useChartIntersection';
|
|
36
|
+
import { useChartStyles } from './Chart.styles';
|
|
37
37
|
import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphValueTooltip';
|
|
38
|
-
import {
|
|
38
|
+
import { thresholdTooltipAtom } from './graphAtoms';
|
|
39
39
|
|
|
40
40
|
interface Props extends LineChartProps {
|
|
41
41
|
graphData: Data;
|
|
@@ -47,11 +47,6 @@ interface Props extends LineChartProps {
|
|
|
47
47
|
thresholds?: ThresholdsModel;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const baseStyles = {
|
|
51
|
-
...Tooltip.defaultStyles,
|
|
52
|
-
textAlign: 'center'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
50
|
const filterLines = (lines: Array<Line>, displayThreshold): Array<Line> => {
|
|
56
51
|
if (!displayThreshold) {
|
|
57
52
|
return lines;
|
|
@@ -69,7 +64,7 @@ const filterLines = (lines: Array<Line>, displayThreshold): Array<Line> => {
|
|
|
69
64
|
return [...lineOriginMetric, ...linesUpperLower] as Array<Line>;
|
|
70
65
|
};
|
|
71
66
|
|
|
72
|
-
const
|
|
67
|
+
const Chart = ({
|
|
73
68
|
graphData,
|
|
74
69
|
height = 500,
|
|
75
70
|
width,
|
|
@@ -85,14 +80,15 @@ const LineChart = ({
|
|
|
85
80
|
graphRef,
|
|
86
81
|
header,
|
|
87
82
|
lineStyle,
|
|
83
|
+
barStyle = {
|
|
84
|
+
opacity: 1,
|
|
85
|
+
radius: 0.2
|
|
86
|
+
},
|
|
88
87
|
thresholds,
|
|
89
88
|
thresholdUnit,
|
|
90
89
|
limitLegend
|
|
91
90
|
}: Props): JSX.Element => {
|
|
92
|
-
const { classes } =
|
|
93
|
-
const { classes: tooltipClasses, cx } = useTooltipStyles();
|
|
94
|
-
|
|
95
|
-
const theme = useTheme();
|
|
91
|
+
const { classes } = useChartStyles();
|
|
96
92
|
|
|
97
93
|
const { title, timeSeries, baseAxis, lines } = graphData;
|
|
98
94
|
|
|
@@ -101,23 +97,23 @@ const LineChart = ({
|
|
|
101
97
|
);
|
|
102
98
|
const graphSvgRef = useRef<SVGSVGElement | null>(null);
|
|
103
99
|
|
|
104
|
-
const
|
|
100
|
+
const [thresholdTooltip, setThresholdTooltip] = useAtom(thresholdTooltipAtom);
|
|
105
101
|
|
|
106
|
-
const {
|
|
107
|
-
tooltipOpen: thresholdTooltipOpen,
|
|
108
|
-
tooltipLeft: thresholdTooltipLeft,
|
|
109
|
-
tooltipTop: thresholdTooltipTop,
|
|
110
|
-
tooltipData: thresholdTooltipData,
|
|
111
|
-
hideTooltip: hideThresholdTooltip,
|
|
112
|
-
showTooltip: showThresholdTooltip
|
|
113
|
-
} = Tooltip.useTooltip();
|
|
102
|
+
const { isInViewport } = useIntersection({ element: graphRef?.current });
|
|
114
103
|
|
|
115
104
|
const thresholdValues = flatten([
|
|
116
105
|
pluck('value', thresholds?.warning || []),
|
|
117
106
|
pluck('value', thresholds?.critical || [])
|
|
118
107
|
]);
|
|
119
108
|
|
|
120
|
-
const
|
|
109
|
+
const displayedLines = useMemo(
|
|
110
|
+
() => linesGraph.filter(({ display }) => display),
|
|
111
|
+
[linesGraph]
|
|
112
|
+
);
|
|
113
|
+
const [firstUnit, secondUnit] = useMemo(
|
|
114
|
+
() => getUnits(displayedLines),
|
|
115
|
+
[displayedLines]
|
|
116
|
+
);
|
|
121
117
|
|
|
122
118
|
const { legendRef, graphWidth, graphHeight } = useComputeBaseChartDimensions({
|
|
123
119
|
hasSecondUnit: Boolean(secondUnit),
|
|
@@ -137,56 +133,57 @@ const LineChart = ({
|
|
|
137
133
|
[timeSeries, graphWidth]
|
|
138
134
|
);
|
|
139
135
|
|
|
140
|
-
const
|
|
141
|
-
() =>
|
|
142
|
-
|
|
136
|
+
const xScaleBand = useMemo(
|
|
137
|
+
() =>
|
|
138
|
+
getXScaleBand({
|
|
139
|
+
dataTime: timeSeries,
|
|
140
|
+
valueWidth: graphWidth
|
|
141
|
+
}),
|
|
142
|
+
[timeSeries, graphWidth, graphHeight]
|
|
143
143
|
);
|
|
144
144
|
|
|
145
|
-
const
|
|
145
|
+
const yScalesPerUnit = useMemo(
|
|
146
146
|
() =>
|
|
147
|
-
|
|
148
|
-
dataLines:
|
|
147
|
+
getYScalePerUnit({
|
|
148
|
+
dataLines: linesGraph,
|
|
149
149
|
dataTimeSeries: timeSeries,
|
|
150
150
|
isCenteredZero: axis?.isCenteredZero,
|
|
151
151
|
scale: axis?.scale,
|
|
152
152
|
scaleLogarithmicBase: axis?.scaleLogarithmicBase,
|
|
153
153
|
thresholdUnit,
|
|
154
154
|
thresholds: (thresholds?.enabled && thresholdValues) || [],
|
|
155
|
-
valueGraphHeight: graphHeight -
|
|
155
|
+
valueGraphHeight: graphHeight - margin.bottom
|
|
156
156
|
}),
|
|
157
157
|
[
|
|
158
|
-
|
|
158
|
+
linesGraph,
|
|
159
159
|
timeSeries,
|
|
160
160
|
graphHeight,
|
|
161
161
|
thresholdValues,
|
|
162
|
+
thresholds?.enabled,
|
|
162
163
|
axis?.isCenteredZero,
|
|
163
164
|
axis?.scale,
|
|
164
165
|
axis?.scaleLogarithmicBase
|
|
165
166
|
]
|
|
166
167
|
);
|
|
167
168
|
|
|
168
|
-
const
|
|
169
|
+
const leftScale = yScalesPerUnit[axis?.axisYLeft?.unit ?? firstUnit];
|
|
170
|
+
const rightScale = yScalesPerUnit[axis?.axisYRight?.unit ?? secondUnit];
|
|
171
|
+
|
|
172
|
+
const linesDisplayedAsLine = useMemo(
|
|
169
173
|
() =>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}),
|
|
180
|
-
[
|
|
181
|
-
timeSeries,
|
|
182
|
-
displayedLines,
|
|
183
|
-
graphHeight,
|
|
184
|
-
axis?.isCenteredZero,
|
|
185
|
-
axis?.scale,
|
|
186
|
-
axis?.scaleLogarithmicBase
|
|
187
|
-
]
|
|
174
|
+
displayedLines.filter(
|
|
175
|
+
({ displayAs }) => isNil(displayAs) || equals(displayAs, 'line')
|
|
176
|
+
),
|
|
177
|
+
[displayedLines]
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const linesDisplayedAsBar = useMemo(
|
|
181
|
+
() => displayedLines.filter(({ displayAs }) => equals(displayAs, 'bar')),
|
|
182
|
+
[displayedLines]
|
|
188
183
|
);
|
|
189
184
|
|
|
185
|
+
const allUnits = getUnits(linesGraph);
|
|
186
|
+
|
|
190
187
|
useEffect(
|
|
191
188
|
() => {
|
|
192
189
|
setLinesGraph(
|
|
@@ -241,26 +238,14 @@ const LineChart = ({
|
|
|
241
238
|
setLines={setLinesGraph}
|
|
242
239
|
title={title}
|
|
243
240
|
>
|
|
244
|
-
<
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
tooltipClasses.tooltipDisablePadding
|
|
249
|
-
)
|
|
250
|
-
}}
|
|
251
|
-
placement="top-start"
|
|
252
|
-
title={
|
|
253
|
-
equals('hidden', tooltip?.mode) ? null : (
|
|
254
|
-
<GraphValueTooltip
|
|
255
|
-
base={baseAxis}
|
|
256
|
-
isSingleMode={equals('single', tooltip?.mode)}
|
|
257
|
-
sortOrder={tooltip?.sortOrder}
|
|
258
|
-
/>
|
|
259
|
-
)
|
|
260
|
-
}
|
|
241
|
+
<GraphValueTooltip
|
|
242
|
+
baseAxis={baseAxis}
|
|
243
|
+
thresholdTooltip={thresholdTooltip}
|
|
244
|
+
tooltip={tooltip}
|
|
261
245
|
>
|
|
262
246
|
<div className={classes.tooltipChildren}>
|
|
263
247
|
<ChartSvgWrapper
|
|
248
|
+
allUnits={allUnits}
|
|
264
249
|
axis={axis}
|
|
265
250
|
base={baseAxis}
|
|
266
251
|
displayedLines={displayedLines}
|
|
@@ -275,24 +260,35 @@ const LineChart = ({
|
|
|
275
260
|
xScale={xScale}
|
|
276
261
|
>
|
|
277
262
|
<>
|
|
263
|
+
<BarGroup
|
|
264
|
+
barStyle={barStyle}
|
|
265
|
+
isTooltipHidden={false}
|
|
266
|
+
lines={linesDisplayedAsBar}
|
|
267
|
+
orientation="horizontal"
|
|
268
|
+
size={graphHeight - margin.top - 5}
|
|
269
|
+
timeSeries={timeSeries}
|
|
270
|
+
xScale={xScaleBand}
|
|
271
|
+
yScalesPerUnit={yScalesPerUnit}
|
|
272
|
+
/>
|
|
278
273
|
<Lines
|
|
279
274
|
areaTransparency={lineStyle?.areaTransparency}
|
|
280
275
|
curve={lineStyle?.curve || 'linear'}
|
|
281
276
|
dashLength={lineStyle?.dashLength}
|
|
282
277
|
dashOffset={lineStyle?.dashOffset}
|
|
283
278
|
displayAnchor={displayAnchor}
|
|
284
|
-
displayedLines={
|
|
279
|
+
displayedLines={linesDisplayedAsLine}
|
|
285
280
|
dotOffset={lineStyle?.dotOffset}
|
|
286
281
|
graphSvgRef={graphSvgRef}
|
|
287
282
|
height={graphHeight - margin.top}
|
|
288
|
-
leftScale={leftScale}
|
|
289
283
|
lineWidth={lineStyle?.lineWidth}
|
|
290
|
-
|
|
284
|
+
scale={axis?.scale}
|
|
285
|
+
scaleLogarithmicBase={axis?.scaleLogarithmicBase}
|
|
291
286
|
showArea={lineStyle?.showArea}
|
|
292
287
|
showPoints={lineStyle?.showPoints}
|
|
293
288
|
timeSeries={timeSeries}
|
|
294
289
|
width={graphWidth}
|
|
295
290
|
xScale={xScale}
|
|
291
|
+
yScalesPerUnit={yScalesPerUnit}
|
|
296
292
|
{...shapeLines}
|
|
297
293
|
/>
|
|
298
294
|
<InteractionWithGraph
|
|
@@ -301,11 +297,10 @@ const LineChart = ({
|
|
|
301
297
|
graphHeight,
|
|
302
298
|
graphSvgRef,
|
|
303
299
|
graphWidth,
|
|
304
|
-
|
|
305
|
-
lines: linesGraph,
|
|
306
|
-
rightScale,
|
|
300
|
+
lines: displayedLines,
|
|
307
301
|
timeSeries,
|
|
308
|
-
xScale
|
|
302
|
+
xScale,
|
|
303
|
+
yScalesPerUnit
|
|
309
304
|
}}
|
|
310
305
|
timeShiftZonesData={{
|
|
311
306
|
...timeShiftZones,
|
|
@@ -316,38 +311,27 @@ const LineChart = ({
|
|
|
316
311
|
{thresholds?.enabled && (
|
|
317
312
|
<Thresholds
|
|
318
313
|
displayedLines={displayedLines}
|
|
319
|
-
hideTooltip={
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
314
|
+
hideTooltip={() => setThresholdTooltip(null)}
|
|
315
|
+
showTooltip={({ tooltipData: thresholdLabel }) =>
|
|
316
|
+
setThresholdTooltip({
|
|
317
|
+
thresholdLabel
|
|
318
|
+
})
|
|
319
|
+
}
|
|
323
320
|
thresholdUnit={thresholdUnit}
|
|
324
321
|
thresholds={thresholds as ThresholdsModel}
|
|
325
322
|
width={graphWidth}
|
|
323
|
+
yScalesPerUnit={yScalesPerUnit}
|
|
326
324
|
/>
|
|
327
325
|
)}
|
|
328
326
|
</>
|
|
329
327
|
</ChartSvgWrapper>
|
|
330
328
|
</div>
|
|
331
|
-
</
|
|
329
|
+
</GraphValueTooltip>
|
|
332
330
|
</BaseChart>
|
|
333
331
|
{displayTooltip && <GraphTooltip {...tooltip} {...graphTooltipData} />}
|
|
334
|
-
<Fade in={thresholdTooltipOpen}>
|
|
335
|
-
<Tooltip.Tooltip
|
|
336
|
-
left={thresholdTooltipLeft}
|
|
337
|
-
style={{
|
|
338
|
-
...baseStyles,
|
|
339
|
-
backgroundColor: theme.palette.background.paper,
|
|
340
|
-
color: theme.palette.text.primary,
|
|
341
|
-
transform: `translate(${graphWidth / 2}px, -10px)`
|
|
342
|
-
}}
|
|
343
|
-
top={thresholdTooltipTop}
|
|
344
|
-
>
|
|
345
|
-
{thresholdTooltipData}
|
|
346
|
-
</Tooltip.Tooltip>
|
|
347
|
-
</Fade>
|
|
348
332
|
</>
|
|
349
333
|
</ClickAwayListener>
|
|
350
334
|
);
|
|
351
335
|
};
|
|
352
336
|
|
|
353
|
-
export default
|
|
337
|
+
export default Chart;
|
package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx
RENAMED
|
@@ -22,10 +22,14 @@ export const getYAnchorPoint = ({
|
|
|
22
22
|
timeSeries,
|
|
23
23
|
yScale,
|
|
24
24
|
metric_id
|
|
25
|
-
}: GetYAnchorPoint): number => {
|
|
25
|
+
}: GetYAnchorPoint): number | null => {
|
|
26
26
|
const index = bisectDate(getDates(timeSeries), timeTick);
|
|
27
27
|
const timeValue = timeSeries[index];
|
|
28
28
|
|
|
29
|
+
if (isNil(timeValue)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
return yScale(prop(metric_id, timeValue) as number);
|
|
30
34
|
};
|
|
31
35
|
|
package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx
RENAMED
|
@@ -34,9 +34,14 @@ export const getYAnchorPoint = ({
|
|
|
34
34
|
timeTick,
|
|
35
35
|
stackValues,
|
|
36
36
|
yScale
|
|
37
|
-
}: GetYAnchorPoint): number => {
|
|
37
|
+
}: GetYAnchorPoint): number | null => {
|
|
38
38
|
const index = bisectDate(getStackedDates(stackValues), timeTick);
|
|
39
39
|
const timeValue = stackValues[index];
|
|
40
|
+
const { key } = stackValues;
|
|
41
|
+
|
|
42
|
+
if (isNil(timeValue.data[key])) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
40
45
|
|
|
41
46
|
return yScale(timeValue[1] as number);
|
|
42
47
|
};
|