-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat(charts): Update V9 Charts to use DataVizGradientPalette #33323
base: master
Are you sure you want to change the base?
Changes from all commits
e5e79fc
b362372
758f388
09b1252
eef1cf2
0c562b5
2eb7d67
942d9a3
d3cc0db
5d90039
f64134a
d9aa34d
40f628c
355faa6
18988c5
61e5ad7
fc6d1c4
e10f630
8a3d7bf
751e2e0
c58d7af
0cc5413
f75812e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Introduce gradients and rounded corners to v9 charts", | ||
"packageName": "@fluentui/react-charts-preview", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "updated to use gradient property for charts-preview", | ||
"packageName": "@fluentui/react-virtualizer", | ||
"email": "[email protected]", | ||
"dependentChangeType": "none" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { ChartDataPoint } from '../index'; | |
import { ArcProps } from './index'; | ||
import { format as d3Format } from 'd3-format'; | ||
import { formatValueWithSIPrefix, useRtl } from '../../../utilities/index'; | ||
import { useId } from '@fluentui/react-utilities'; | ||
|
||
// Create a Arc within Donut Chart variant which uses these default styles and this styled subcomponent. | ||
/** | ||
|
@@ -13,7 +14,7 @@ import { formatValueWithSIPrefix, useRtl } from '../../../utilities/index'; | |
*/ | ||
export const Arc: React.FunctionComponent<ArcProps> = React.forwardRef<HTMLDivElement, ArcProps>( | ||
(props, forwardedRef) => { | ||
const arc = d3Arc(); | ||
const arc = d3Arc().cornerRadius(5); | ||
const currentRef = React.createRef<SVGPathElement>(); | ||
const _isRTL: boolean = useRtl(); | ||
const classes = useArcStyles_unstable(props); | ||
|
@@ -90,33 +91,54 @@ export const Arc: React.FunctionComponent<ArcProps> = React.forwardRef<HTMLDivEl | |
//TO DO 'replace' is throwing error | ||
const id = props.uniqText! + props.data!.data.legend!.replace(/\s+/, '') + props.data!.data.data; | ||
const opacity: number = props.activeArc === props.data!.data.legend || props.activeArc === '' ? 1 : 0.1; | ||
|
||
const clipId = useId('Arc_clip') + `${props.gradient[0]}_${props.gradient[1]}`; | ||
const gradientFill = `conic-gradient( | ||
from ${props.data?.startAngle}rad, | ||
${props.gradient[0]}, | ||
${props.gradient[1]} ${props.data?.endAngle}rad | ||
)`; | ||
|
||
const pathData = arc({ ...props.data!, innerRadius: props.innerRadius, outerRadius: props.outerRadius })!; | ||
const focusPathData = arc({ ...props.focusData!, innerRadius: props.innerRadius, outerRadius: props.outerRadius })!; | ||
|
||
return ( | ||
<g ref={currentRef}> | ||
{!!focusedArcId && focusedArcId === id && ( | ||
// TODO innerradius and outerradius were absent | ||
<path | ||
id={id + 'focusRing'} | ||
d={arc({ ...props.focusData!, innerRadius: props.innerRadius, outerRadius: props.outerRadius })!} | ||
className={classes.focusRing} | ||
/> | ||
<path id={id + 'focusRing'} d={focusPathData} className={classes.focusRing} /> | ||
)} | ||
<path | ||
// TODO innerradius and outerradius were absent | ||
id={id} | ||
d={arc({ ...props.data!, innerRadius: props.innerRadius, outerRadius: props.outerRadius })!} | ||
className={classes.root} | ||
style={{ fill: props.color, cursor: href ? 'pointer' : 'default' }} | ||
d={pathData} | ||
style={{ fill: 'transparent', cursor: href ? 'pointer' : 'default' }} | ||
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. why removed the classname? 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. Moved the classname to the |
||
onFocus={_onFocus.bind(this, props.data!.data, id)} | ||
data-is-focusable={props.activeArc === props.data!.data.legend || props.activeArc === ''} | ||
onMouseOver={_hoverOn.bind(this, props.data!.data)} | ||
onMouseMove={_hoverOn.bind(this, props.data!.data)} | ||
onMouseLeave={_hoverOff} | ||
onBlur={_onBlur} | ||
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. why removed the opacity 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. Similar to previous comment, the element is to always be transparent, so opacity is unnecessary |
||
opacity={opacity} | ||
onClick={props.data?.data.onClick} | ||
aria-label={_getAriaLabel()} | ||
role="img" | ||
/> | ||
{/* clipping mask */} | ||
<clipPath id={clipId}> | ||
<path d={pathData} /> | ||
</clipPath> | ||
{/* div to attach conic-gradient fill to */} | ||
<foreignObject x="-50%" y="-50%" width="100%" height="100%" clipPath={`url(#${clipId})`}> | ||
<div | ||
className={classes.root} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
background: gradientFill, | ||
opacity, | ||
}} | ||
/> | ||
</foreignObject> | ||
{_renderArcLabel(classes.arcLabel)} | ||
</g> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕵🏾♀️ visual regressions to review in the fluentuiv9 Visual Regression Report
Avatar Converged 2 screenshots
Charts-DonutChart 6 screenshots
Charts-HorizontalBarChart 9 screenshots