Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5078a60

Browse files
committed
enable tooltips when board is disconnected
1 parent b144664 commit 5078a60

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

‎src/ChartPlotter.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import React, { useState, useRef, useImperativeHandle, useEffect } from "react";
1+
import React, {
2+
useState,
3+
useRef,
4+
useImperativeHandle,
5+
useEffect,
6+
useCallback,
7+
} from "react";
28

39
import { Line } from "react-chartjs-2";
410

@@ -124,9 +130,21 @@ function _Chart(
124130
},
125131
});
126132

133+
const enableTooltips = useCallback(
134+
(newState: boolean) => {
135+
(opts.plugins as any).tooltip.enabled = newState;
136+
opts.datasets!.line!.pointHoverRadius = newState ? 3 : 0;
137+
setOpts(opts);
138+
chartRef.current?.update();
139+
},
140+
[opts]
141+
);
142+
127143
useEffect(() => {
128144
if (!config.connected) {
129145
setConnected(false);
146+
// when disconnected, force tooltips to be enabled
147+
enableTooltips(true);
130148
return;
131149
}
132150

@@ -135,8 +153,11 @@ function _Chart(
135153
// cleanup buffer state
136154
worker.postMessage({ command: "cleanup" });
137155
setConnected(true);
156+
157+
// restore the tooltips state (which match the pause state when connected)
158+
enableTooltips(pause);
138159
}
139-
}, [config.connected, connected]);
160+
}, [config.connected, connected,pause,enableTooltips]);
140161

141162
const togglePause = (newState: boolean) => {
142163
if (newState === pause) {
@@ -148,9 +169,6 @@ function _Chart(
148169
setPause(newState);
149170
worker.postMessage({ command: "cleanup" });
150171
enableTooltips(newState);
151-
(opts.plugins as any).tooltip.enabled = newState;
152-
opts.datasets!.line!.pointHoverRadius = newState ? 3 : 0;
153-
setOpts(opts);
154172
};
155173

156174
const setInterpolate = (interpolate: boolean) => {

‎src/index.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ body {
216216
}
217217
}
218218

219+
.pause-button {
220+
width: 47px;
221+
text-align: center;
222+
}
223+
219224
.clear-button {
220225
border: none;
221226
background: none;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /