Skip to content

Commit

Permalink
Charting: Refactoring Vertical Bar Chart via implementation of Cartes…
Browse files Browse the repository at this point in the history
…ian chart (#15639)

* Charting: Refactoring Vertical Bar Chart via implementation of Cartesian chart.

* Change files
  • Loading branch information
khmakoto committed Oct 23, 2020
1 parent bed7f0a commit 562ce21
Show file tree
Hide file tree
Showing 11 changed files with 385 additions and 584 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "minor",
"comment": "Charting: Refactoring Vertical Bar Chart via implementation of Cartesian chart.",
"packageName": "@fluentui/react-charting",
"email": "humbertomakotomorimoto@gmail.com",
"dependentChangeType": "patch",
"date": "2020-10-22T02:09:10.335Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,11 @@ export class CartesianChartBase extends React.Component<IModifiedCartesianChartP
{children}
</svg>
</FocusZone>
<div ref={(e: HTMLDivElement) => (this.legendContainer = e)} className={this._classNames.legendContainer}>
{this.props.legendBars}
</div>
{!this.props.hideLegend && (
<div ref={(e: HTMLDivElement) => (this.legendContainer = e)} className={this._classNames.legendContainer}>
{this.props.legendBars}
</div>
)}
{!this.props.hideTooltip && calloutProps!.isCalloutVisible && (
<Callout {...calloutProps}>
{/** Given custom callout, then it will render */}
Expand Down Expand Up @@ -336,14 +338,17 @@ export class CartesianChartBase extends React.Component<IModifiedCartesianChartP

private _fitParentContainer(): void {
const { containerWidth, containerHeight } = this.state;

this._reqID = requestAnimationFrame(() => {
const legendContainerComputedStyles = getComputedStyle(this.legendContainer);
const legendContainerHeight =
(this.legendContainer.getBoundingClientRect().height || this.minLegendContainerHeight) +
parseFloat(legendContainerComputedStyles.marginTop || '0') +
parseFloat(legendContainerComputedStyles.marginBottom || '0');

let legendContainerHeight;
if (this.props.hideLegend) {
legendContainerHeight = 32;
} else {
const legendContainerComputedStyles = getComputedStyle(this.legendContainer);
legendContainerHeight =
(this.legendContainer.getBoundingClientRect().height || this.minLegendContainerHeight) +
parseFloat(legendContainerComputedStyles.marginTop || '0') +
parseFloat(legendContainerComputedStyles.marginBottom || '0');
}
const container = this.props.parentRef ? this.props.parentRef : this.chartContainer;
const currentContainerWidth = container.getBoundingClientRect().width;
const currentContainerHeight =
Expand Down
Loading

0 comments on commit 562ce21

Please sign in to comment.