-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- LegendText replaces/extends the possibility of adding LaTex-strings to the LegendBox - LegendText is initialized with an expression-string and some optionals: color for icon-color, shape for icon-shape and useStates for deciding if the expression should listen to defined states This gives more freedom and flexibility in adding text, LaTeX and the use of states in LegendBox Related to #86
- Loading branch information
1 parent
a2d3f3f
commit 8a3a50e
Showing
3 changed files
with
100 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { e } from "mathjs"; | ||
|
||
type LegendTextOptions = { | ||
color?: string; | ||
shape?: string; | ||
useStates?: boolean; | ||
}; | ||
|
||
const defaultLegendTextOptions = { | ||
color: "#faa307", | ||
shape: "circle", | ||
useStates: false, | ||
}; | ||
|
||
class LegendText { | ||
private expression: string; | ||
private color: string; | ||
private shape: string; | ||
private useStates: boolean; | ||
|
||
constructor(expression: string, options?: LegendTextOptions) { | ||
const { color, shape, useStates } = { | ||
...defaultLegendTextOptions, | ||
...options, | ||
}; | ||
this.expression = expression; | ||
this.color = color; | ||
this.shape = shape; | ||
this.useStates = useStates; | ||
} | ||
|
||
getExpression(): string { | ||
return this.expression; | ||
} | ||
|
||
getColor(): string { | ||
return this.color; | ||
} | ||
|
||
getShape(): string { | ||
return this.shape; | ||
} | ||
|
||
getUseStates(): boolean { | ||
return this.useStates; | ||
} | ||
|
||
getIcon(): string { | ||
switch (this.getShape()) { | ||
case "circle": | ||
return "circle-icon"; | ||
case "rectangle": | ||
return "rectangle-icon"; | ||
case "triangle": | ||
return "triangle-icon"; | ||
default: | ||
return "circle-icon"; | ||
} | ||
} | ||
} | ||
export default LegendText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters