FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Chart: New symbol for threshold by dlabrecq · Pull Request #2884 · patternfly/patternfly-react · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (1) .tsx  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
    • ChartPoint.tsx
    • path-helpers.ts
This file contains hidden or 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
Expand Up @@ -80,7 +80,7 @@ export interface ChartPointProps {
* the point should render
*/
symbol?: 'circle' | 'diamond' | 'plus' | 'minus' | 'square' | 'star' | 'triangleDown' | 'triangleUp' | 'dash' |
Function;
'threshold' | Function;
/**
* A transform that will be supplied to elements this component renders
*/
Expand Down Expand Up @@ -122,7 +122,8 @@ export const ChartPoint: React.FunctionComponent<ChartPointProps> = ({
plus: PathHelpers.plus,
minus: PathHelpers.minus,
star: PathHelpers.star,
dash: PathHelpers.dash
dash: PathHelpers.dash,
threshold: PathHelpers.threshold
};
const symbol = Helpers.evaluateProp(props.symbol, datum, active);
const symbolFunction = typeof pathFunctions[symbol] === 'function' ? pathFunctions[symbol] : pathFunctions.circle;
Expand Down
This file contains hidden or 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
Expand Up @@ -119,5 +119,24 @@ export const PathHelpers = {
v-${lineHeight}
h-${distance}
z`;
},

threshold(x: number, y: number, size: number) {
const baseSize = 1.1 * size;
const lineHeight = baseSize - baseSize * 0.3;
const x0 = x - baseSize;
const y1 = y + lineHeight / 2;
const distance = (x + baseSize - x0) * 0.5;
const padding = distance / 3;
return `M ${x0}, ${y1}
h${distance}
v-${lineHeight}
h-${distance}
z
M ${x0 + distance + padding}, ${y1}
h${distance}
v-${lineHeight}
h-${distance}
z`;
}
};

Back | FazBrowse Home | New Git URL