-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shapes support for scatter chart (#380)
* Add basics for shapes support for scatter chart * Add triangleDown symbol and legend symbols support * Fix default symbol for non-linear legend * Add point size support, more readable size handling * Fix update issue * Fix unselected style * Fix appending paths * Add series index to preserve scatter symbol style * Fix index type * Fix PR issues * Fix SymbolType everywhere * Remove index from prepared series base type * Fix position issue * Fix ScatterSeries type * Fix triangle down draw function * Fix symbol size constant
- Loading branch information
1 parent
e69921b
commit d0ec520
Showing
12 changed files
with
152 additions
and
29 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
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
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
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,41 @@ | ||
import {symbolDiamond2, symbolCircle, symbolSquare, symbolTriangle2} from 'd3'; | ||
|
||
import {SymbolType} from '../../../../constants'; | ||
|
||
export const getSymbolType = (index: number) => { | ||
const scatterStyles = Object.values(SymbolType); | ||
|
||
return scatterStyles[index % scatterStyles.length]; | ||
}; | ||
|
||
// This is an inverted triangle | ||
// Based on https://github.com/d3/d3-shape/blob/main/src/symbol/triangle2.js | ||
const sqrt3 = Math.sqrt(3); | ||
const triangleDown = { | ||
draw: (context: CanvasPath, size: number) => { | ||
const s = Math.sqrt(size) * 0.6824; | ||
const t = s / 2; | ||
const u = (s * sqrt3) / 2; | ||
context.moveTo(0, s); | ||
context.lineTo(u, -t); | ||
context.lineTo(-u, -t); | ||
context.closePath(); | ||
}, | ||
}; | ||
|
||
export const getSymbol = (symbolType: SymbolType) => { | ||
switch (symbolType) { | ||
case SymbolType.Diamond: | ||
return symbolDiamond2; | ||
case SymbolType.Circle: | ||
return symbolCircle; | ||
case SymbolType.Square: | ||
return symbolSquare; | ||
case SymbolType.Triangle: | ||
return symbolTriangle2; | ||
case SymbolType.TriangleDown: | ||
return triangleDown; | ||
default: | ||
return symbolCircle; | ||
} | ||
}; |
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