From b67c02f7c930ec85244924d1e9d20bfca1bb47f3 Mon Sep 17 00:00:00 2001 From: "Jameela Kowsar Shaik (Zen3 Infosolutions America Inc)" Date: Mon, 12 Oct 2020 12:44:21 +0530 Subject: [PATCH] margins default description added and minor changes to cartesian margins --- .../CommonComponents/CartesianChart.base.tsx | 15 +++++++++---- .../CommonComponents/CartesianChart.types.ts | 6 ++++++ .../VerticalStackedBarChart.base.tsx | 21 +++++++------------ packages/charting/src/utilities/utilities.ts | 12 +++++++---- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/packages/charting/src/components/CommonComponents/CartesianChart.base.tsx b/packages/charting/src/components/CommonComponents/CartesianChart.base.tsx index 6b03083a2edec..2d5b0bc57b62a 100644 --- a/packages/charting/src/components/CommonComponents/CartesianChart.base.tsx +++ b/packages/charting/src/components/CommonComponents/CartesianChart.base.tsx @@ -59,11 +59,17 @@ export class CartesianChartBase extends React.Component {children} diff --git a/packages/charting/src/components/CommonComponents/CartesianChart.types.ts b/packages/charting/src/components/CommonComponents/CartesianChart.types.ts index 1949dd0299938..2f72c5e136efd 100644 --- a/packages/charting/src/components/CommonComponents/CartesianChart.types.ts +++ b/packages/charting/src/components/CommonComponents/CartesianChart.types.ts @@ -157,6 +157,12 @@ export interface ICartesianChartProps { /** * Margins for the chart + * @default top: 20 + * @default bottom: 35 + * @default left: 40 + * @default right: 20 + * + * To avoid edge cuttings to the chart, we recommend you use default values or greater then default values */ margins?: IMargins; diff --git a/packages/charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx b/packages/charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx index 8b86d2438c97b..7017a8575db6a 100644 --- a/packages/charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx +++ b/packages/charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx @@ -374,9 +374,9 @@ export class VerticalStackedBarChartBase extends React.Component< }); }; - private _redirectToUrl(href: string): void { - href ? (window.location.href = href) : ''; - } + private _redirectToUrl = (): void => { + this.props.href ? (window.location.href = this.props.href) : ''; + }; private _getYMax(dataset: IDataPoint[]) { return Math.max(d3Max(dataset, (point: IDataPoint) => point.y)!, this.props.yMaxValue || 0); @@ -420,7 +420,7 @@ export class VerticalStackedBarChartBase extends React.Component< onMouseLeave: this._handleMouseOut, onFocus: this._onRectFocus.bind(this, point, singleChartData.xAxisPoint, color, refArrayIndexNumber), onBlur: this._handleMouseOut, - onClick: this._redirectToUrl.bind(this, this.props.href!), + onClick: this._redirectToUrl, }; return ( point.x as number)!; // barWidth / 2 - for to get tick middle of the bar const rMax = margins.left! + barWidth / 2; - const rMin = width - margins.right! - barWidth / 2 - (isRTL ? margins.right! : 0); + const rMin = width - margins.right! - barWidth / 2; return isRTL ? { dStartValue: xMax, dEndValue: xMin, rStartValue: rMax, rEndValue: rMin } : { dStartValue: xMin, dEndValue: xMax, rStartValue: rMax, rEndValue: rMin };