Skip to content

Commit

Permalink
dont hide graph series label in compare view #445
Browse files Browse the repository at this point in the history
  • Loading branch information
io53 committed Sep 29, 2024
1 parent a413434 commit 8aa777d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/TimeHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function getTimestamp(date) {
}

export function secondsToUserDateString(seconds) {
if (!seconds) return "-"
return new Date(seconds * 1000).toLocaleString(navigator.language || "fi-FI")
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/CompareView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function CompareView(props) {
: (
<UplotReact
options={{
plugins: [UplotTouchZoomPlugin(getXRange()), UplotLegendHider],
plugins: [UplotTouchZoomPlugin(getXRange())],
padding: [10, 10, 0, -10],
width: width,
height: 450,
Expand All @@ -185,6 +185,7 @@ function CompareView(props) {
return {
label: x.name || x.sensor,
points: { show: true, size: 2, fill: getGraphColor(i) },
class: "graphLabel",
stroke: getGraphColor(i),
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/Graph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Graph extends Component {
var plugins = [];
if (!this.props.cardView) {
plugins.push(UplotTouchZoomPlugin(this.getXRange()))
plugins.push(UplotLegendHider)
plugins.push(UplotLegendHider())
}
let colorMode = this.props.overrideColorMode ? this.props.overrideColorMode : this.props.colorMode.colorMode;
let height = this.props.height || 300;
Expand Down
24 changes: 13 additions & 11 deletions src/components/uplotPlugins/UplotLegendHider.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
export default {
hooks: {
init(u, opts) {
const legend = document.getElementsByClassName("u-legend")[0];
legend.style.visibility = 'hidden';

u.over.addEventListener("mouseleave", () => {
export default function (hideClass = "u-legend") {
return {
hooks: {
init(u, opts) {
const legend = document.getElementsByClassName(hideClass)[0];
legend.style.visibility = 'hidden';
});

u.over.addEventListener("mousemove", () => {
legend.style.visibility = '';
});
u.over.addEventListener("mouseleave", () => {
legend.style.visibility = 'hidden';
});

u.over.addEventListener("mousemove", () => {
legend.style.visibility = '';
});
}
}
}
};

0 comments on commit 8aa777d

Please sign in to comment.