изменение интерфейса тренировок
Gitea Actions Demo / build_and_push (push) Successful in 44s
Details
Gitea Actions Demo / build_and_push (push) Successful in 44s
Details
This commit is contained in:
parent
b4f3a762b0
commit
17120b4852
|
|
@ -8,6 +8,10 @@ import { resetZoom } from "chartjs-plugin-zoom";
|
||||||
export class ChartGroup {
|
export class ChartGroup {
|
||||||
charts: Array<Chart>;
|
charts: Array<Chart>;
|
||||||
private broadcasting = false;
|
private broadcasting = false;
|
||||||
|
// Guards against re-entrant hover propagation: activating a tooltip on the
|
||||||
|
// source chart redraws it synchronously, which re-invokes its tooltip
|
||||||
|
// callbacks -> setHover -> infinite recursion.
|
||||||
|
private hovering = false;
|
||||||
|
|
||||||
constructor(charts: Array<Chart>) {
|
constructor(charts: Array<Chart>) {
|
||||||
this.charts = charts;
|
this.charts = charts;
|
||||||
|
|
@ -27,19 +31,51 @@ export class ChartGroup {
|
||||||
* the same point order (a common time axis), so the index is identical.
|
* the same point order (a common time axis), so the index is identical.
|
||||||
*/
|
*/
|
||||||
setHover(dataIndex: number): void {
|
setHover(dataIndex: number): void {
|
||||||
|
if (this.hovering) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.hovering = true;
|
||||||
|
try {
|
||||||
for (const chart of this.charts) {
|
for (const chart of this.charts) {
|
||||||
if (!chart.tooltip) {
|
if (!chart.tooltip) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
chart.tooltip.setActiveElements([{ datasetIndex: 0, index: dataIndex }], {
|
// Optimization: skip charts whose tooltip is already active at the
|
||||||
|
// same index so the source chart is not redrawn twice per hover move.
|
||||||
|
const active = chart.tooltip.getActiveElements();
|
||||||
|
if (
|
||||||
|
active.length === 1 &&
|
||||||
|
active[0].index === dataIndex &&
|
||||||
|
active[0].datasetIndex === 0
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
chart.tooltip.setActiveElements(
|
||||||
|
[{ datasetIndex: 0, index: dataIndex }],
|
||||||
|
{
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
chart.draw();
|
chart.draw();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.hovering = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the hover state on every chart. Idempotent; safe to call from
|
||||||
|
* mouseout at any time. Guarded by the same re-entrancy flag as setHover:
|
||||||
|
* if invoked while setHover is in progress, the caller's own setHover will
|
||||||
|
* have (re)established the correct state, so an early return loses nothing.
|
||||||
|
*/
|
||||||
clearHover(): void {
|
clearHover(): void {
|
||||||
|
if (this.hovering) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.hovering = true;
|
||||||
|
try {
|
||||||
for (const chart of this.charts) {
|
for (const chart of this.charts) {
|
||||||
if (!chart.tooltip) {
|
if (!chart.tooltip) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -47,6 +83,9 @@ export class ChartGroup {
|
||||||
chart.tooltip.setActiveElements([], { x: 0, y: 0 });
|
chart.tooltip.setActiveElements([], { x: 0, y: 0 });
|
||||||
chart.draw();
|
chart.draw();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.hovering = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Applies the same x range to every chart without re-triggering onZoomComplete. */
|
/** Applies the same x range to every chart without re-triggering onZoomComplete. */
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,7 @@
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</h4>
|
</h4>
|
||||||
|
<div class="workout-chart-canvas">
|
||||||
<LineWithLineChart
|
<LineWithLineChart
|
||||||
:ref="(el) => setChartRef(config.key, el)"
|
:ref="(el) => setChartRef(config.key, el)"
|
||||||
:options="config.options"
|
:options="config.options"
|
||||||
|
|
@ -239,6 +240,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<VaModal
|
<VaModal
|
||||||
v-if="isPrivate"
|
v-if="isPrivate"
|
||||||
v-model="showModalTitle"
|
v-model="showModalTitle"
|
||||||
|
|
@ -646,6 +648,7 @@ const buildChartOptions = (
|
||||||
duration: 0,
|
duration: 0,
|
||||||
},
|
},
|
||||||
responsive: true,
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
scales: scales,
|
scales: scales,
|
||||||
plugins: {
|
plugins: {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
|
|
@ -1132,6 +1135,11 @@ h3 {
|
||||||
.workout-chart {
|
.workout-chart {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.workout-chart-canvas {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 160px;
|
||||||
|
}
|
||||||
.workout-chart-title {
|
.workout-chart-title {
|
||||||
margin: 0 0 5px 0;
|
margin: 0 0 5px 0;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue