-
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.
* When writing Latex in LegendBox, only the expression with inserted values appears Related to #86 * Add a bit space between LegendBox and the top/left * Add props to Point which give the ability to: - show/hide name from Points in the grid (showName) - give Points custom names (customName) - display only x or only y coordinates for points in LegendBox (legendCoordinates) Related to #86 * Make it possible to use States without them being displayed in LegendBox Related to #86 * States can now be added both before and after Latex-strings in constructor and with addElement met * Make sure it is not possible to add the same element twice to the LegendBox * Remove parenthesis from when only showing x or y coordinates on point * Create LegendText object - 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 * Lint fix and make spacing between LegendBox and top&left a bit smaller * Export LegendText in index.ts
- Loading branch information
1 parent
47c1d2d
commit 2e681ae
Showing
6 changed files
with
188 additions
and
48 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,59 @@ | ||
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
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
Oops, something went wrong.