correct zoom when click on map
Gitea Actions Demo / build_and_push (push) Successful in 3m23s Details

This commit is contained in:
artem 2025-01-24 16:16:11 +03:00
parent c9b0168d14
commit 81a3b3db88
2 changed files with 10 additions and 5 deletions

View File

@ -17,6 +17,9 @@ class LineWithLineController extends LineController {
if (!this.chart.config.plugins) { if (!this.chart.config.plugins) {
return []; return [];
} }
if (this.chart.isZoomedOrPanned()) {
return [];
}
for (let i in this.chart.config.plugins) { for (let i in this.chart.config.plugins) {
if (this.chart.config.plugins[i].id != "yandexMapLine") { if (this.chart.config.plugins[i].id != "yandexMapLine") {
continue continue
@ -33,13 +36,16 @@ class LineWithLineController extends LineController {
const ctx = this.chart.ctx; const ctx = this.chart.ctx;
const topY = this.chart.scales.y.top; const topY = this.chart.scales.y.top;
const bottomY = this.chart.scales.y.bottom; const bottomY = this.chart.scales.y.bottom;
// @ts-ignore
let zoom = (this.chart.chartArea.right - this.chart.chartArea.left) / this.chart.config.data.labels.length;
const xVertical = this.getMapX(); const xVertical = this.getMapX();
for (let i in xVertical) { for (let i in xVertical) {
// console.log("xVertical", xVertical)
// console.log("ctx", this.chart)
ctx.save(); ctx.save();
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(xVertical[i], topY); ctx.moveTo(xVertical[i] * zoom, topY);
ctx.lineTo(xVertical[i], bottomY); ctx.lineTo(xVertical[i] * zoom, bottomY);
ctx.lineWidth = 3; ctx.lineWidth = 3;
ctx.strokeStyle = '#666'; ctx.strokeStyle = '#666';
ctx.stroke(); ctx.stroke();

View File

@ -198,7 +198,7 @@ type afterEventEvent = {
type afterEventArgs = { type afterEventArgs = {
"event": afterEventEvent, "event": afterEventEvent,
} }
let zoomLine = 1.0;
const chartPlugins = [ const chartPlugins = [
{ {
id: 'eventPlugin', id: 'eventPlugin',
@ -221,7 +221,6 @@ const chartPlugins = [
isEq = false; isEq = false;
break; break;
} }
console.log(isEq, mapX.value, mapXPrev.value);
if (isEq) { if (isEq) {
return; return;
} }