From ec7cd97d08e7df8117e9c4f6c354e1e002051f7f Mon Sep 17 00:00:00 2001 From: Jonas de Luna Skulberg <113468143+jonasdeluna@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:15:28 +0200 Subject: [PATCH] Add color to plot again (#92) --- package.json | 2 +- src/Components/Plot.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ff80e3a..a5f3585 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kateter-platform/graphica", - "version": "1.0.88", + "version": "1.0.89", "source": "./src/index.ts", "description": "A tool for advanced graphing and visualization", "repository": { diff --git a/src/Components/Plot.ts b/src/Components/Plot.ts index cf38e56..de7f612 100644 --- a/src/Components/Plot.ts +++ b/src/Components/Plot.ts @@ -11,6 +11,7 @@ type PlotOptions = { coefficients?: Coefficients; plotRange?: number; plotBetween: [number, number] | undefined; + color: number; }; const defaultPlotOptions = { @@ -19,6 +20,7 @@ const defaultPlotOptions = { lineWidth: 4, coefficients: {}, plotBetween: undefined, + color: undefined, }; type Coefficients = { @@ -50,7 +52,6 @@ class Plot extends Component { constructor(func: string, options?: PlotOptions) { super(); this.setFuncName(); - this.setColor(); const { numPoints = 1000, @@ -58,8 +59,13 @@ class Plot extends Component { lineWidth = 1, coefficients = {}, plotBetween = undefined, + color, } = { ...defaultPlotOptions, ...options }; - + if (!color) { + this.setColor(); + } else { + this.color = color; + } const minX = (-this.PLOTRANGE / 1) * 2 + 0; const maxX = (this.PLOTRANGE / 1) * 2 + 0; const initialCurve = new CatmullRomCurve3(