1
1
//@ts -nocheck
2
2
import { sortBy , reverse } from "ramda"
3
- import React , {
4
- useLayoutEffect , useRef , useCallback , useState ,
5
- } from "react"
3
+ import React , { useLayoutEffect , useRef , useCallback } from "react"
6
4
import classNames from "classnames"
7
5
import { useUpdateEffect , useUnmount , useMount } from "react-use"
8
6
// this version is needed because it contains a fix for handling constant value in the chart
@@ -28,11 +26,14 @@ import {
28
26
selectSyncPanAndZoom ,
29
27
selectSpacePanelTransitionEndIsActive ,
30
28
selectAlarm ,
31
- selectTimezoneSetting
29
+ selectTimezoneSetting ,
32
30
} from "domains/global/selectors"
33
31
import {
34
- resetGlobalPanAndZoomAction , setCommonMaxAction , setCommonMinAction ,
35
- setGlobalPauseAction , resetGlobalPauseAction
32
+ resetGlobalPanAndZoomAction ,
33
+ setCommonMaxAction ,
34
+ setCommonMinAction ,
35
+ setGlobalPauseAction ,
36
+ resetGlobalPauseAction ,
36
37
} from "domains/global/actions"
37
38
38
39
import { resetChartPanAndZoomAction } from "domains/chart/actions"
@@ -47,7 +48,10 @@ import { ChartMetadata, DygraphData } from "../../chart-types"
47
48
import { selectResizeHeight } from "../../selectors"
48
49
49
50
import {
50
- getDygraphChartType , getDataForFakeStacked , transformColors , getDygraphFillAlpha ,
51
+ getDygraphChartType ,
52
+ getDataForFakeStacked ,
53
+ transformColors ,
54
+ getDygraphFillAlpha ,
51
55
hackDygraphIFrameTarps ,
52
56
} from "./dygraph/utils"
53
57
import "./dygraph-chart.css"
@@ -56,7 +60,6 @@ import useProceededChart from "../../hooks/use-proceeded-chart"
56
60
import useDygraphBadge from "../../hooks/useDygraphBadge"
57
61
import ProceededChartDisclaimer from "./proceeded-chart-disclaimer"
58
62
import AlarmBadge , { getBorderColor } from "./alarmBadge"
59
- import NeutralPill from "./neutralPill"
60
63
61
64
// This is the threshold above which we assume chart shown duration has changed
62
65
const timeframeThreshold = 5000
@@ -413,7 +416,6 @@ export const DygraphChart = ({
413
416
} , [ chartUuid , dispatch , isSyncPanAndZoom ] )
414
417
415
418
const [ isAlarmBadgeVisible , alarmBadgeRef , updateAlarmBadge ] = useDygraphBadge ( ) as any
416
- const [ isHighlightBadgeVisible , highlightBadgeRef , updateHighlightBadge ] = useDygraphBadge ( ) as any
417
419
418
420
// setGlobalChartUnderlay is using state from closure (chartData.after), so we need to have always
419
421
// the newest callback. Unfortunately we cannot use Dygraph.updateOptions() (library restriction)
@@ -428,7 +430,6 @@ export const DygraphChart = ({
428
430
resetGlobalPanAndZoom,
429
431
setGlobalChartUnderlay,
430
432
updateAlarmBadge,
431
- updateHighlightBadge,
432
433
updateChartPanOrZoom,
433
434
viewAfter,
434
435
viewBefore,
@@ -447,14 +448,22 @@ export const DygraphChart = ({
447
448
propsRef . current . resetGlobalPanAndZoom = resetGlobalPanAndZoom
448
449
propsRef . current . setGlobalChartUnderlay = setGlobalChartUnderlay
449
450
propsRef . current . updateAlarmBadge = updateAlarmBadge
450
- propsRef . current . updateHighlightBadge = updateHighlightBadge
451
451
propsRef . current . updateChartPanOrZoom = updateChartPanOrZoom
452
452
propsRef . current . viewAfter = viewAfter
453
453
propsRef . current . viewBefore = viewBefore
454
- } , [ alarm , chartData , globalChartUnderlay , hoveredX , immediatelyDispatchPanAndZoom ,
455
- resetGlobalPanAndZoom , setGlobalChartUnderlay , updateAlarmBadge , updateHighlightBadge , updateChartPanOrZoom , viewAfter , viewBefore ] )
456
-
457
- const [ localHighlight , setLocalHighlight ] = useState < { before ?: number , after ?: number } | null > ( null )
454
+ } , [
455
+ alarm ,
456
+ chartData ,
457
+ globalChartUnderlay ,
458
+ hoveredX ,
459
+ immediatelyDispatchPanAndZoom ,
460
+ resetGlobalPanAndZoom ,
461
+ setGlobalChartUnderlay ,
462
+ updateAlarmBadge ,
463
+ updateChartPanOrZoom ,
464
+ viewAfter ,
465
+ viewBefore ,
466
+ ] )
458
467
459
468
const shouldSmoothPlot = useSelector ( selectSmoothPlot )
460
469
useLayoutEffect ( ( ) => {
@@ -561,29 +570,6 @@ export const DygraphChart = ({
561
570
)
562
571
}
563
572
564
- const onMetricsCorralation = hasHashParam ( "metrics_correlation" )
565
- if ( onMetricsCorralation && propsRef . current . globalChartUnderlay ) {
566
- const { before, masterID } = propsRef . current . globalChartUnderlay
567
-
568
- if ( masterID && masterID !== propsRef . current . chartData . id ) {
569
- propsRef . current . updateHighlightBadge ( false )
570
- } else {
571
- const horizontalPadding = 3
572
-
573
- propsRef . current . updateHighlightBadge (
574
- true ,
575
- g ,
576
- g . toDomXCoord ( before ) ,
577
- ( pillRef , pillX , pillPosition , topMargin ) => {
578
- pillRef . current . style . left = `${ pillPosition + horizontalPadding } px`
579
- pillRef . current . style . top = topMargin
580
- }
581
- )
582
- }
583
- } else {
584
- propsRef . current . updateHighlightBadge ( false )
585
- }
586
-
587
573
// the chart is about to be drawn
588
574
// this function renders global highlighted time-frame
589
575
@@ -669,28 +655,6 @@ export const DygraphChart = ({
669
655
latestIsUserAction . current = true
670
656
// @ts -ignore
671
657
Dygraph . moveZoom ( event , dygraph , context )
672
-
673
- const onMetricsCorralation = hasHashParam ( "metrics_correlation" )
674
- if ( onMetricsCorralation ) {
675
- const before = dygraph . toDataXCoord ( event . offsetX )
676
- const after = dygraphHighlightAfter . current
677
- if ( before - after > 1000 ) { // more than a sec
678
- setLocalHighlight ( {
679
- after,
680
- before,
681
- } )
682
- propsRef . current . updateHighlightBadge (
683
- true ,
684
- dygraph ,
685
- dygraph . toDomXCoord ( before ) ,
686
- ( pillRef , pillX , pillPosition , topMargin ) => {
687
- pillRef . current . style . left = `${ pillPosition } px`
688
- pillRef . current . style . top = topMargin
689
- }
690
- )
691
- }
692
- }
693
-
694
658
event . preventDefault ( )
695
659
} else if ( context . isPanning ) {
696
660
latestIsUserAction . current = true
@@ -718,7 +682,6 @@ export const DygraphChart = ({
718
682
masterID : chartData . id ,
719
683
} )
720
684
dygraphHighlightAfter . current = null
721
- setLocalHighlight ( null )
722
685
// eslint-disable-next-line no-param-reassign
723
686
context . isZooming = false
724
687
@@ -732,13 +695,11 @@ export const DygraphChart = ({
732
695
// eslint-disable-next-line no-underscore-dangle
733
696
dygraph . drawGraph_ ( false )
734
697
} else if ( context . isPanning ) {
735
-
736
698
latestIsUserAction . current = true
737
699
// @ts -ignore
738
700
Dygraph . endPan ( event , dygraph , context )
739
701
propsRef . current . immediatelyDispatchPanAndZoom ( )
740
702
} else if ( context . isZooming ) {
741
-
742
703
latestIsUserAction . current = true
743
704
// @ts -ignore
744
705
Dygraph . endZoom ( event , dygraph , context )
@@ -1205,11 +1166,12 @@ export const DygraphChart = ({
1205
1166
) }
1206
1167
{ alarm ?. value && hasLegend && (
1207
1168
// @ts -ignore
1208
- < AlarmBadge isVisible = { isAlarmBadgeVisible } ref = { alarmBadgeRef } status = { alarm . status } label = { alarm . value } />
1209
- ) }
1210
- { hasLegend && (
1211
- // @ts -ignore
1212
- < NeutralPill isVisible = { isHighlightBadgeVisible } ref = { highlightBadgeRef } { ...globalChartUnderlay } { ...localHighlight } />
1169
+ < AlarmBadge
1170
+ isVisible = { isAlarmBadgeVisible }
1171
+ ref = { alarmBadgeRef }
1172
+ status = { alarm . status }
1173
+ label = { alarm . value }
1174
+ />
1213
1175
) }
1214
1176
< div className = "dygraph-chart__labels-hidden" id = { hiddenLabelsElementId } />
1215
1177
</ >
0 commit comments