-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(react-charting): Support marker shapes for scatter chart #34656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
srmukher
wants to merge
12
commits into
microsoft:master
Choose a base branch
from
srmukher:users/srmukher/scatter_marker_shapes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
843b776
feat(react-charting): Support marker shapes for scatter chart
srmukher 0ec3f4a
Adding change file
srmukher 4bffcec
Make shapes symmetric
srmukher dbbc124
Refactoring code
srmukher 5b8bd74
Updating checks
srmukher 81a8169
Resolving PR comments
srmukher 55d24dc
Resolving build error
srmukher 134e4fd
Updating test example
srmukher 6016492
Updating types
srmukher bca2c4f
Resolving PR comments
srmukher b717b0b
Merge branch 'master' of https://github.com/srmukher/fluentui into us…
srmukher eea8421
Add missing exports
srmukher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-charting-27a887a9-dd1e-400c-b696-da3e3c231c33.json
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "feat(react-charting): Support marker shapes for scatter chart", | ||
"packageName": "@fluentui/react-charting", | ||
"email": "120183316+srmukher@users.noreply.github.com", | ||
"dependentChangeType": "patch" | ||
} |
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
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
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
36 changes: 13 additions & 23 deletions
36
packages/charts/react-charting/src/components/Legends/shape.tsx
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 |
---|---|---|
@@ -1,44 +1,34 @@ | ||
import * as React from 'react'; | ||
import { LegendShape } from './Legends.types'; | ||
import { CustomPoints, getSecureProps, Points } from '../../utilities/utilities'; | ||
import { CustomPoints, getSecureProps, getShapePath, isOpenShape, scatterPointPaths } from '../../utilities/utilities'; | ||
|
||
export interface IShapeProps { | ||
svgProps: React.SVGAttributes<SVGElement>; | ||
pathProps: React.SVGAttributes<SVGPathElement>; | ||
shape: LegendShape; | ||
classNameForNonSvg?: string; | ||
isOpenShape?: boolean; | ||
} | ||
|
||
type PointPathType = { | ||
[key: string]: string; | ||
}; | ||
|
||
const pointPath: PointPathType = { | ||
[`${Points[Points.circle]}`]: 'M1 6 A5 5 0 1 0 12 6 M1 6 A5 5 0 0 1 12 6', | ||
[`${Points[Points.square]}`]: 'M1 1 L12 1 L12 12 L1 12 L1 1 Z', | ||
[`${Points[Points.triangle]}`]: 'M6 10L8.74228e-07 -1.04907e-06L12 0L6 10Z', | ||
[`${Points[Points.pyramid]}`]: 'M6 10L8.74228e-07 -1.04907e-06L12 0L6 10Z', | ||
[`${Points[Points.diamond]}`]: 'M2 2 L10 2 L10 10 L2 10 L2 2 Z', | ||
[`${Points[Points.hexagon]}`]: 'M9 0H3L0 5L3 10H9L12 5L9 0Z', | ||
[`${Points[Points.pentagon]}`]: 'M6.06061 0L0 4.21277L2.30303 11H9.69697L12 4.21277L6.06061 0Z', | ||
[`${Points[Points.octagon]}`]: | ||
'M7.08333 0H2.91667L0 2.91667V7.08333L2.91667 10H7.08333L10 7.08333V2.91667L7.08333 0Z', | ||
// Legacy point paths for backward compatibility | ||
const legacyPointPaths: { [key: string]: string } = { | ||
srmukher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[`${CustomPoints[CustomPoints.dottedLine]}`]: 'M0 6 H3 M5 6 H8 M10 6 H13', | ||
}; | ||
|
||
const pointPath = { ...scatterPointPaths, ...legacyPointPaths }; | ||
|
||
export const Shape: React.FC<IShapeProps> = ({ svgProps, pathProps, shape, classNameForNonSvg }) => { | ||
if (Object.keys(pointPath).indexOf(shape) === -1) { | ||
return <div className={classNameForNonSvg} />; | ||
} | ||
|
||
return ( | ||
<svg | ||
width={14} | ||
height={14} | ||
viewBox={'-1 -1 14 14'} | ||
{...getSecureProps(svgProps)} | ||
transform={`rotate(${shape === Points[Points.diamond] ? 45 : shape === Points[Points.pyramid] ? 180 : 0}, 0, 0)`} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, since we have the exact shapes this transform was changing the legend shape |
||
> | ||
<path d={pointPath[shape]} {...getSecureProps(pathProps)} /> | ||
<svg width={14} height={14} viewBox={'-1 -1 14 14'} {...getSecureProps(svgProps)}> | ||
<path | ||
d={getShapePath(shape)} | ||
{...getSecureProps(pathProps)} | ||
fill={isOpenShape(shape) ? 'none' : pathProps.fill || 'currentColor'} | ||
/> | ||
</svg> | ||
); | ||
}; |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.