From 565a48b21856183c8329267d5b158c22ccb7bde5 Mon Sep 17 00:00:00 2001 From: amaliejvik Date: Fri, 28 Jun 2024 11:58:07 +0200 Subject: [PATCH] Move Plot-funcName logic out of Core.ts and into Plot.ts --- src/Components/Plot.ts | 7 +++---- src/Core.ts | 6 ------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Components/Plot.ts b/src/Components/Plot.ts index ef886d6..bea32a2 100644 --- a/src/Components/Plot.ts +++ b/src/Components/Plot.ts @@ -50,6 +50,7 @@ class Plot extends Component { constructor(func: string, options?: PlotOptions) { super(); + this.setFuncName(); this.setColor(); const { @@ -180,10 +181,8 @@ class Plot extends Component { return this.func; } - setFuncName(name: string) { - if (this.funcName === undefined) { - this.funcName = name; - } + setFuncName() { + this.funcName = String.fromCharCode("f".charCodeAt(0) + Plot.counter); } setColor() { diff --git a/src/Core.ts b/src/Core.ts index a37e3c1..f3684c8 100644 --- a/src/Core.ts +++ b/src/Core.ts @@ -232,12 +232,6 @@ class Core { this.updateComponents.push(child); } }); - - if (component instanceof Plot) { - const name = String.fromCharCode("f".charCodeAt(0) + this.plotCount); - component.setFuncName(name); - this.plotCount++; - } } remove(component: Component) {