From 430a6b39b6835d615e2776f943b54a6c0227a14e Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Thu, 22 Aug 2024 20:35:33 +0300 Subject: [PATCH] Improve top panel elements & autofit mode (#54) * Tour changes --- src/components/Chart.svelte | 7 +- src/components/TopMenu.svelte | 127 ++++++++---------- src/components/chartUtils.ts | 7 +- src/components/dialogs/ImportAPIDialog.svelte | 4 + src/components/tree/TreeLeafNode.svelte | 7 +- src/deriveLinkDefaults.ts | 2 - src/store.ts | 3 +- src/tour.ts | 124 +++++++++-------- 8 files changed, 139 insertions(+), 142 deletions(-) diff --git a/src/components/Chart.svelte b/src/components/Chart.svelte index bf42e96..52ed214 100644 --- a/src/components/Chart.svelte +++ b/src/components/Chart.svelte @@ -134,7 +134,9 @@ setNavMode(NavMode.zoom); } } - if (navMode == NavMode.crop) { + if (navMode == NavMode.autofit) { + navMode = NavMode.pan; + } else if (navMode == NavMode.crop) { navBox = { x: m.x, y: m.y, w: 0, h: 0 }; } } @@ -268,6 +270,9 @@ dx = ((xMax - xMin) / 2) * fx; dy = ((yMax - yMin) / 2) * fy; setViewport(xMin - dx, yMin - dy, xMax - dx, yMax - dy); + if (navMode == NavMode.autofit) { + navMode = NavMode.pan; + } } function zoom(x: number, y: number): void { diff --git a/src/components/TopMenu.svelte b/src/components/TopMenu.svelte index c294cc6..878a698 100644 --- a/src/components/TopMenu.svelte +++ b/src/components/TopMenu.svelte @@ -10,12 +10,11 @@ faLink, faPaintBrush, faQuestion, - faReceipt, faSearchPlus, - faUpDown, + faShuffle, } from '@fortawesome/free-solid-svg-icons'; import Fa from 'svelte-fa'; - import { activeDatasets, isShowingPoints, navMode, randomizeColors, reset, scaleMean, autoFit } from '../store'; + import { activeDatasets, isShowingPoints, navMode, randomizeColors, reset, scaleMean } from '../store'; import type { IChart } from '../store'; import { NavMode } from './chartUtils'; import { tour } from '../tour'; @@ -55,6 +54,9 @@ chart.fitData(true); } break; + case 'a': + $navMode = NavMode.autofit; + break; case 'p': $navMode = NavMode.pan; break; @@ -70,9 +72,6 @@ case 's': $isShowingPoints = !$isShowingPoints; break; - case 'a': - $autoFit = !$autoFit; - break; case 'h': tour.cancel(); tour.start(); @@ -82,35 +81,57 @@