File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6262
6363 const fmtDate = uPlot . fmtDate ( "{M}/{D}/{YY} {h}:{mm}:{ss} {AA}" ) ;
6464
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+
6581 function setTooltip ( u ) {
82+ showTooltip ( ) ;
83+
6684 let top = u . valToPos ( u . data [ seriesIdx ] [ dataIdx ] , 'y' ) ;
6785 let lft = u . valToPos ( u . data [ 0 ] [ dataIdx ] , 'x' ) ;
6886
108126 u => {
109127 let c = u . cursor ;
110128
111- if ( c . idx != dataIdx ) {
129+ if ( dataIdx != c . idx ) {
112130 dataIdx = c . idx ;
113131
114132 if ( seriesIdx != null )
115- setTooltip ( u , setTooltip ) ;
133+ setTooltip ( u ) ;
116134 }
117135 }
118136 ] ,
122140 seriesIdx = sidx ;
123141
124142 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 )
128145 setTooltip ( u ) ;
129- }
130146 }
131147 }
132148 ] ,
138154 const interpolatedColorWithAlpha = "#fcb0f17a" ;
139155
140156 ctx . save ( ) ;
157+
158+ let clip = new Path2D ( ) ;
159+ clip . rect ( left , top , width , height ) ;
160+ ctx . clip ( clip ) ;
161+
141162 ctx . strokeStyle = interpolatedColorWithAlpha ;
142163 ctx . beginPath ( ) ;
143164
You can’t perform that action at this time.
0 commit comments