-
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
Add Negative Y Value Support and Example for Vertical Bar Chart #33377
base: master
Are you sure you want to change the base?
Conversation
📊 Bundle size report✅ No changes found |
Pull request demo site: URL |
...ages/react-examples/src/react-charting/VerticalBarChart/VerticalBarChartNegative.Example.tsx
Outdated
Show resolved
Hide resolved
...ages/react-examples/src/react-charting/VerticalBarChart/VerticalBarChartNegative.Example.tsx
Outdated
Show resolved
Hide resolved
Test snapshots have changed. It should not change if the negative value prop is not used. |
Add a test for negative values. |
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Outdated
Show resolved
Hide resolved
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Outdated
Show resolved
Hide resolved
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Outdated
Show resolved
Hide resolved
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Show resolved
Hide resolved
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Outdated
Show resolved
Hide resolved
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Outdated
Show resolved
Hide resolved
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Outdated
Show resolved
Hide resolved
What is the output when all negative and yMax < 0 |
…crosoft/fluentui into usr/agupta/negativeYValue/VBC
CI build is failing |
packages/charts/react-charting/src/utilities/__snapshots__/UtilityUnitTests.test.ts.snap
Show resolved
Hide resolved
...act-charting/src/components/VerticalBarChart/__snapshots__/VerticalBarChartRTL.test.tsx.snap
Outdated
Show resolved
Hide resolved
const domainValues = prepareDatapoints(finalYmax, finalYmin, yAxisTickCount, isIntegralDataset); | ||
const yAxisScale = d3ScaleLinear() | ||
.domain([finalYmin, domainValues[domainValues.length - 1]]) | ||
.domain([domainValues[0], domainValues[domainValues.length - 1]]) |
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.
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.
domainValues[0] can be less than finalYmin ( for negative y value cases )
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Outdated
Show resolved
Hide resolved
@@ -693,25 +700,40 @@ export class VerticalBarChartBase extends React.Component<IVerticalBarChartProps | |||
const { xBarScale, yBarScale } = this._getScales(containerHeight, containerWidth); | |||
const colorScale = this._createColors(); | |||
|
|||
const baselinePoint = this._yMax < 0 ? this._yMax : 0; |
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.
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.
this._ymax is calculated as max(all y points, this.props.yMaxValue). So won't this._ymax < 0 be sufficient condition?
packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx
Outdated
Show resolved
Hide resolved
barHeight = Math.abs(barHeight); | ||
// Calculate threshold for minimum visible bar height | ||
const maxHeightFromBaseline = | ||
this._yMax < 0 ? Math.abs(this._yMin - baselinePoint) : Math.abs(this._yMax - baselinePoint); |
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.
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.
for the case this._ymax<0 , abs(ymin) will always be greater than abs(ymax). Hence we don't need max for this.
But yes, for other case, we must take that. Do you agree?
mix of positive and negative y:
All negative y:
All positive y:
All y positive and yMax/yMin set
Some y positive, some y negative, yMax/yMin set
All y negative, yMax/yMin set
Related Issue(s)