File tree Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Original file line number Diff line number Diff line change 62
62
63
63
const fmtDate = uPlot . fmtDate ( "{M}/{D}/{YY} {h}:{mm}:{ss} {AA}" ) ;
64
64
65
+ let tooltipVisible = false ;
66
+
67
+ function showTooltip ( ) {
68
+ if ( ! tooltipVisible ) {
69
+ tooltip . style . display = "block" ;
70
+ tooltipVisible = true ;
71
+ }
72
+ }
73
+
74
+ function hideTooltip ( ) {
75
+ if ( tooltipVisible ) {
76
+ tooltip . style . display = "none" ;
77
+ tooltipVisible = false ;
78
+ }
79
+ }
80
+
65
81
function setTooltip ( u ) {
82
+ showTooltip ( ) ;
83
+
66
84
let top = u . valToPos ( u . data [ seriesIdx ] [ dataIdx ] , 'y' ) ;
67
85
let lft = u . valToPos ( u . data [ 0 ] [ dataIdx ] , 'x' ) ;
68
86
108
126
u => {
109
127
let c = u . cursor ;
110
128
111
- if ( c . idx != dataIdx ) {
129
+ if ( dataIdx != c . idx ) {
112
130
dataIdx = c . idx ;
113
131
114
132
if ( seriesIdx != null )
115
- setTooltip ( u , setTooltip ) ;
133
+ setTooltip ( u ) ;
116
134
}
117
135
}
118
136
] ,
122
140
seriesIdx = sidx ;
123
141
124
142
if ( sidx == null )
125
- tooltip . style . display = "none" ;
126
- else if ( dataIdx != null ) {
127
- tooltip . style . display = "block" ;
143
+ hideTooltip ( ) ;
144
+ else if ( dataIdx != null )
128
145
setTooltip ( u ) ;
129
- }
130
146
}
131
147
}
132
148
] ,
138
154
const interpolatedColorWithAlpha = "#fcb0f17a" ;
139
155
140
156
ctx . save ( ) ;
157
+
158
+ let clip = new Path2D ( ) ;
159
+ clip . rect ( left , top , width , height ) ;
160
+ ctx . clip ( clip ) ;
161
+
141
162
ctx . strokeStyle = interpolatedColorWithAlpha ;
142
163
ctx . beginPath ( ) ;
143
164
You can’t perform that action at this time.
0 commit comments