@fluentui/react-charting 5.24.6 → 5.24.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +43 -1
- package/CHANGELOG.md +22 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/CommonComponents/CartesianChart.base.d.ts +3 -2
- package/lib/components/CommonComponents/CartesianChart.base.js +118 -102
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +15 -24
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +22 -23
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +14 -12
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +13 -17
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/utilities/utilities.d.ts +3 -0
- package/lib/utilities/utilities.js +25 -38
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.d.ts +18 -0
- package/lib/utilities/vbc-utils.js +29 -0
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.d.ts +3 -2
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +117 -101
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +14 -23
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +22 -23
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +13 -11
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -16
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +3 -0
- package/lib-amd/utilities/utilities.js +26 -39
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-amd/utilities/vbc-utils.d.ts +18 -0
- package/lib-amd/utilities/vbc-utils.js +34 -1
- package/lib-amd/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.d.ts +3 -2
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +117 -101
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +14 -23
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +22 -23
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +13 -11
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -16
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +3 -0
- package/lib-commonjs/utilities/utilities.js +27 -40
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.d.ts +18 -0
- package/lib-commonjs/utilities/vbc-utils.js +34 -1
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,8 +6,6 @@ export interface ICartesianChartState {
|
|
|
6
6
|
containerHeight: number;
|
|
7
7
|
_width: number;
|
|
8
8
|
_height: number;
|
|
9
|
-
isRemoveValCalculated?: boolean;
|
|
10
|
-
_removalValueForTextTuncate?: number;
|
|
11
9
|
startFromX: number;
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
@@ -32,6 +30,7 @@ export declare class CartesianChartBase extends React.Component<IModifiedCartesi
|
|
|
32
30
|
private _tickValues;
|
|
33
31
|
private titleMargin;
|
|
34
32
|
private _isFirstRender;
|
|
33
|
+
private _removalValueForTextTuncate;
|
|
35
34
|
private _xScale;
|
|
36
35
|
private isIntegralDataset;
|
|
37
36
|
private _tooltipId;
|
|
@@ -62,4 +61,6 @@ export declare class CartesianChartBase extends React.Component<IModifiedCartesi
|
|
|
62
61
|
private _calculateChartMinWidth;
|
|
63
62
|
private _getChartDescription;
|
|
64
63
|
private _getAxisTitle;
|
|
64
|
+
private _calcMaxLabelWidthWithTransform;
|
|
65
|
+
private _transformXAxisLabels;
|
|
65
66
|
}
|
|
@@ -5,7 +5,7 @@ import { Callout } from '@fluentui/react/lib/Callout';
|
|
|
5
5
|
import { FocusZone, FocusZoneDirection } from '@fluentui/react-focus';
|
|
6
6
|
import { select as d3Select } from 'd3-selection';
|
|
7
7
|
import { formatToLocaleString } from '@fluentui/chart-utilities';
|
|
8
|
-
import { createNumericXAxis, createStringXAxis, getAccessibleDataObject, createDateXAxis, XAxisTypes, YAxisType, createWrapOfXLabels, rotateXAxisLabels, Points, pointTypes, calculateLongestLabelWidth, createYAxisLabels, ChartTypes, wrapContent, getSecureProps, truncateString, tooltipOfAxislabels, } from '../../utilities/index';
|
|
8
|
+
import { createNumericXAxis, createStringXAxis, getAccessibleDataObject, createDateXAxis, XAxisTypes, YAxisType, createWrapOfXLabels, rotateXAxisLabels, Points, pointTypes, calculateLongestLabelWidth, createYAxisLabels, ChartTypes, wrapContent, getSecureProps, truncateString, tooltipOfAxislabels, DEFAULT_WRAP_WIDTH, } from '../../utilities/index';
|
|
9
9
|
import { Shape } from '../Legends/index';
|
|
10
10
|
import { SVGTooltipText } from '../../utilities/SVGTooltipText';
|
|
11
11
|
var getClassNames = classNamesFunction();
|
|
@@ -31,6 +31,13 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
31
31
|
_this.minLegendContainerHeight = 32;
|
|
32
32
|
_this._isRtl = getRTL();
|
|
33
33
|
_this._isFirstRender = true;
|
|
34
|
+
/* Used for when WrapXAxisLabels props appeared.
|
|
35
|
+
* To display the total word (space separated words), Need to have more space than usual.
|
|
36
|
+
* This height will get total height need to disaply total word.
|
|
37
|
+
* These value need to be removed from actual svg height/graph height.
|
|
38
|
+
* Defalut value is 0. And this values calculted when 'wrapXAxisLables' or 'showXAxisLablesTooltip' is true.
|
|
39
|
+
*/
|
|
40
|
+
_this._removalValueForTextTuncate = 0;
|
|
34
41
|
_this.isIntegralDataset = true;
|
|
35
42
|
_this.calculateMaxYAxisLabelLength = function (className) {
|
|
36
43
|
var formatTickLabel = function (str) {
|
|
@@ -68,43 +75,14 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
68
75
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
76
|
_this._getData = function (xScale, yScalePrimary, yScaleSecondary) {
|
|
70
77
|
_this.props.getGraphData &&
|
|
71
|
-
_this.props.getGraphData(xScale, yScalePrimary, _this.state.containerHeight - _this.
|
|
78
|
+
_this.props.getGraphData(xScale, yScalePrimary, _this.state.containerHeight - _this._removalValueForTextTuncate, _this.state.containerWidth, _this.xAxisElement, _this.yAxisElement, yScaleSecondary);
|
|
72
79
|
};
|
|
73
80
|
_this._onChartLeave = function () {
|
|
74
81
|
_this.props.onChartMouseLeave && _this.props.onChartMouseLeave();
|
|
75
82
|
};
|
|
76
83
|
_this._calculateChartMinWidth = function () {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (!_this.props.wrapXAxisLables &&
|
|
80
|
-
_this.props.rotateXAxisLables &&
|
|
81
|
-
_this.props.xAxisType === XAxisTypes.StringAxis) {
|
|
82
|
-
var longestLabelWidth = calculateLongestLabelWidth(_this._tickValues, ".".concat(_this._classNames.xAxis, " text"));
|
|
83
|
-
labelWidth += Math.ceil(longestLabelWidth * Math.cos(Math.PI / 4));
|
|
84
|
-
}
|
|
85
|
-
// Case: truncated labels
|
|
86
|
-
else if (_this.props.showXAxisLablesTooltip) {
|
|
87
|
-
var tickValues = _this._tickValues.map(function (val) {
|
|
88
|
-
var numChars = _this.props.noOfCharsToTruncate || 4;
|
|
89
|
-
return val.toString().length > numChars ? "".concat(val.toString().slice(0, numChars), "...") : val;
|
|
90
|
-
});
|
|
91
|
-
var longestLabelWidth = calculateLongestLabelWidth(tickValues, ".".concat(_this._classNames.xAxis, " text"));
|
|
92
|
-
labelWidth += Math.ceil(longestLabelWidth);
|
|
93
|
-
}
|
|
94
|
-
// Case: wrapped labels
|
|
95
|
-
else if (_this.props.wrapXAxisLables) {
|
|
96
|
-
var words_1 = [];
|
|
97
|
-
_this._tickValues.forEach(function (val) {
|
|
98
|
-
words_1.push.apply(words_1, val.toString().split(/\s+/));
|
|
99
|
-
});
|
|
100
|
-
var longestLabelWidth = calculateLongestLabelWidth(words_1, ".".concat(_this._classNames.xAxis, " text"));
|
|
101
|
-
labelWidth += Math.max(Math.ceil(longestLabelWidth), 10);
|
|
102
|
-
}
|
|
103
|
-
// Default case
|
|
104
|
-
else {
|
|
105
|
-
var longestLabelWidth = calculateLongestLabelWidth(_this._tickValues, ".".concat(_this._classNames.xAxis, " text"));
|
|
106
|
-
labelWidth += Math.ceil(longestLabelWidth);
|
|
107
|
-
}
|
|
84
|
+
// Adding 10px for padding on both sides
|
|
85
|
+
var labelWidth = _this._calcMaxLabelWidthWithTransform(_this._tickValues) + 10;
|
|
108
86
|
var minChartWidth = _this.margins.left + _this.margins.right + labelWidth * (_this._tickValues.length - 1);
|
|
109
87
|
if ([ChartTypes.GroupedVerticalBarChart, ChartTypes.VerticalBarChart, ChartTypes.VerticalStackedBarChart].includes(_this.props.chartType)) {
|
|
110
88
|
var minDomainMargin = 8;
|
|
@@ -130,13 +108,85 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
130
108
|
: 'values')) +
|
|
131
109
|
'. ');
|
|
132
110
|
};
|
|
111
|
+
_this._calcMaxLabelWidthWithTransform = function (x) {
|
|
112
|
+
// Case: rotated labels
|
|
113
|
+
if (!_this.props.wrapXAxisLables &&
|
|
114
|
+
_this.props.rotateXAxisLables &&
|
|
115
|
+
_this.props.xAxisType === XAxisTypes.StringAxis) {
|
|
116
|
+
var longestLabelWidth_1 = calculateLongestLabelWidth(x, ".".concat(_this._classNames.xAxis, " text"));
|
|
117
|
+
return Math.ceil(longestLabelWidth_1 * Math.cos(Math.PI / 4));
|
|
118
|
+
}
|
|
119
|
+
// Case: truncated labels
|
|
120
|
+
if (_this.props.showXAxisLablesTooltip) {
|
|
121
|
+
var tickValues = x.map(function (val) {
|
|
122
|
+
var numChars = _this.props.noOfCharsToTruncate || 4;
|
|
123
|
+
return val.toString().length > numChars ? "".concat(val.toString().slice(0, numChars), "...") : val;
|
|
124
|
+
});
|
|
125
|
+
var longestLabelWidth_2 = calculateLongestLabelWidth(tickValues, ".".concat(_this._classNames.xAxis, " text"));
|
|
126
|
+
return Math.ceil(longestLabelWidth_2);
|
|
127
|
+
}
|
|
128
|
+
// Case: wrapped labels
|
|
129
|
+
if (_this.props.wrapXAxisLables) {
|
|
130
|
+
// FIXME: Calculate the max width of lines instead of words. This requires applying
|
|
131
|
+
// the wrapping transformation earlier to obtain the actual rendered lines.
|
|
132
|
+
var words_1 = [];
|
|
133
|
+
x.forEach(function (val) {
|
|
134
|
+
words_1.push.apply(words_1, val.toString().split(/\s+/));
|
|
135
|
+
});
|
|
136
|
+
// This approach works well in most cases, since overflow typically occurs only when
|
|
137
|
+
// a single word exceeds the specified width — otherwise, the text will wrap as expected.
|
|
138
|
+
var longestLabelWidth_3 = calculateLongestLabelWidth(words_1, ".".concat(_this._classNames.xAxis, " text"));
|
|
139
|
+
return Math.max(Math.ceil(longestLabelWidth_3), DEFAULT_WRAP_WIDTH);
|
|
140
|
+
}
|
|
141
|
+
// Default case
|
|
142
|
+
var longestLabelWidth = calculateLongestLabelWidth(x, ".".concat(_this._classNames.xAxis, " text"));
|
|
143
|
+
return Math.ceil(longestLabelWidth);
|
|
144
|
+
};
|
|
145
|
+
_this._transformXAxisLabels = function () {
|
|
146
|
+
var _a, _b, _c;
|
|
147
|
+
_this._removalValueForTextTuncate = 0;
|
|
148
|
+
/*
|
|
149
|
+
* To enable wrapping of x axis tick values or to display complete x axis tick values,
|
|
150
|
+
* we need to calculate how much space it needed to render the text.
|
|
151
|
+
* No need to re-calculate every time the chart renders and same time need to get an update. So using setState.
|
|
152
|
+
* Required space will be calculated first time chart rendering and if any width/height of chart updated.
|
|
153
|
+
* */
|
|
154
|
+
if (_this.props.wrapXAxisLables || _this.props.showXAxisLablesTooltip) {
|
|
155
|
+
var maxXAxisLabelWidth = void 0;
|
|
156
|
+
if (_this.props.xAxisType === XAxisTypes.StringAxis) {
|
|
157
|
+
if ((((_a = _this.props.datasetForXAxisDomain) === null || _a === void 0 ? void 0 : _a.length) || 0) > 1) {
|
|
158
|
+
maxXAxisLabelWidth = _this._xScale.step();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
maxXAxisLabelWidth = _this.state.containerWidth;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
var wrapLabelProps = {
|
|
165
|
+
node: _this.xAxisElement,
|
|
166
|
+
xAxis: _this._xScale,
|
|
167
|
+
showXAxisLablesTooltip: _this.props.showXAxisLablesTooltip || false,
|
|
168
|
+
noOfCharsToTruncate: _this.props.noOfCharsToTruncate || 4,
|
|
169
|
+
width: maxXAxisLabelWidth,
|
|
170
|
+
};
|
|
171
|
+
_this._removalValueForTextTuncate = (_b = createWrapOfXLabels(wrapLabelProps)) !== null && _b !== void 0 ? _b : 0;
|
|
172
|
+
}
|
|
173
|
+
if (!_this.props.wrapXAxisLables &&
|
|
174
|
+
_this.props.rotateXAxisLables &&
|
|
175
|
+
_this.props.xAxisType === XAxisTypes.StringAxis) {
|
|
176
|
+
var rotateLabelProps = {
|
|
177
|
+
node: _this.xAxisElement,
|
|
178
|
+
xAxis: _this._xScale,
|
|
179
|
+
};
|
|
180
|
+
var rotatedHeight = (_c = rotateXAxisLabels(rotateLabelProps)) !== null && _c !== void 0 ? _c : 0;
|
|
181
|
+
// this.margins.bottom is used as padding here
|
|
182
|
+
_this._removalValueForTextTuncate = rotatedHeight + _this.margins.bottom;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
133
185
|
_this.state = {
|
|
134
186
|
containerHeight: 0,
|
|
135
187
|
containerWidth: 0,
|
|
136
188
|
_width: _this.props.width || 600,
|
|
137
189
|
_height: _this.props.height || 350,
|
|
138
|
-
_removalValueForTextTuncate: 0,
|
|
139
|
-
isRemoveValCalculated: true,
|
|
140
190
|
startFromX: 0,
|
|
141
191
|
};
|
|
142
192
|
_this.idForGraph = getId('chart_');
|
|
@@ -224,23 +274,6 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
224
274
|
if (prevProps.height !== this.props.height || prevProps.width !== this.props.width) {
|
|
225
275
|
this._fitParentContainer();
|
|
226
276
|
}
|
|
227
|
-
if (!this.props.wrapXAxisLables &&
|
|
228
|
-
this.props.rotateXAxisLables &&
|
|
229
|
-
this.props.xAxisType === XAxisTypes.StringAxis) {
|
|
230
|
-
var rotateLabelProps = {
|
|
231
|
-
node: this.xAxisElement,
|
|
232
|
-
xAxis: this._xScale,
|
|
233
|
-
};
|
|
234
|
-
var rotatedHeight = rotateXAxisLabels(rotateLabelProps);
|
|
235
|
-
if (this.state.isRemoveValCalculated &&
|
|
236
|
-
this.state._removalValueForTextTuncate !== rotatedHeight + this.margins.bottom &&
|
|
237
|
-
rotatedHeight > 0) {
|
|
238
|
-
this.setState({
|
|
239
|
-
_removalValueForTextTuncate: rotatedHeight + this.margins.bottom,
|
|
240
|
-
isRemoveValCalculated: false,
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
277
|
if (chartTypesWithStringYAxis.includes(this.props.chartType) &&
|
|
245
278
|
this.props.showYAxisLables &&
|
|
246
279
|
this.yAxisElement &&
|
|
@@ -300,7 +333,13 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
300
333
|
domainNRangeValues: this.props.getDomainNRangeValues(points, this.props.getDomainMargins ? this.props.getDomainMargins(this.state.containerWidth) : this.margins, this.state.containerWidth, chartType, this._isRtl, this.props.xAxisType, this.props.barwidth, this.props.tickValues,
|
|
301
334
|
// This is only used for Horizontal Bar Chart with Axis for y as string axis
|
|
302
335
|
this.state.startFromX),
|
|
303
|
-
|
|
336
|
+
// FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
|
|
337
|
+
// Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
|
|
338
|
+
// However, if transformation props are enabled, the updated _removalValueForTextTuncate
|
|
339
|
+
// will only be available in the next render, as it's set after the axis is created.
|
|
340
|
+
// Solution: Delay the creation of gridlines until after the transformation has been applied,
|
|
341
|
+
// or precompute the required height for transformed labels (_removalValueForTextTuncate).
|
|
342
|
+
containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
|
|
304
343
|
margins: this.margins,
|
|
305
344
|
xAxisElement: this.xAxisElement,
|
|
306
345
|
showRoundOffXTickValues: (_e = this.props.showRoundOffXTickValues) !== null && _e !== void 0 ? _e : true,
|
|
@@ -311,27 +350,8 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
311
350
|
xAxisInnerPadding: this.props.xAxisInnerPadding,
|
|
312
351
|
xAxisOuterPadding: this.props.xAxisOuterPadding,
|
|
313
352
|
containerWidth: this.state.containerWidth,
|
|
314
|
-
hideTickOverlap: this.props.hideTickOverlap
|
|
315
|
-
|
|
316
|
-
!this.props.showXAxisLablesTooltip &&
|
|
317
|
-
!this.props.wrapXAxisLables,
|
|
318
|
-
};
|
|
319
|
-
var YAxisParams = {
|
|
320
|
-
margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
|
|
321
|
-
containerWidth: this.state.containerWidth,
|
|
322
|
-
containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
|
|
323
|
-
yAxisElement: this.yAxisElement,
|
|
324
|
-
yAxisTickFormat: this.props.yAxisTickFormat,
|
|
325
|
-
yAxisTickCount: this.props.yAxisTickCount,
|
|
326
|
-
yMinValue: this.props.yMinValue || 0,
|
|
327
|
-
yMaxValue: this.props.yMaxValue || 0,
|
|
328
|
-
tickPadding: 10,
|
|
329
|
-
maxOfYVal: this.props.maxOfYVal,
|
|
330
|
-
yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
|
|
331
|
-
// please note these padding default values must be consistent in here
|
|
332
|
-
// and the parent chart(HBWA/Vertical etc..) for more details refer example
|
|
333
|
-
// http://using-d3js.com/04_07_ordinal_scales.html
|
|
334
|
-
yAxisPadding: this.props.yAxisPadding || 0,
|
|
353
|
+
hideTickOverlap: this.props.hideTickOverlap,
|
|
354
|
+
calcMaxLabelWidth: this._calcMaxLabelWidthWithTransform,
|
|
335
355
|
};
|
|
336
356
|
/**
|
|
337
357
|
* These scales used for 2 purposes.
|
|
@@ -357,25 +377,24 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
357
377
|
}
|
|
358
378
|
this._xScale = xScale;
|
|
359
379
|
this._tickValues = tickValues;
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
//
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
380
|
+
this._transformXAxisLabels();
|
|
381
|
+
var YAxisParams = {
|
|
382
|
+
margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
|
|
383
|
+
containerWidth: this.state.containerWidth,
|
|
384
|
+
containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
|
|
385
|
+
yAxisElement: this.yAxisElement,
|
|
386
|
+
yAxisTickFormat: this.props.yAxisTickFormat,
|
|
387
|
+
yAxisTickCount: this.props.yAxisTickCount,
|
|
388
|
+
yMinValue: this.props.yMinValue || 0,
|
|
389
|
+
yMaxValue: this.props.yMaxValue || 0,
|
|
390
|
+
tickPadding: 10,
|
|
391
|
+
maxOfYVal: this.props.maxOfYVal,
|
|
392
|
+
yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
|
|
393
|
+
// please note these padding default values must be consistent in here
|
|
394
|
+
// and the parent chart(HBWA/Vertical etc..) for more details refer example
|
|
395
|
+
// http://using-d3js.com/04_07_ordinal_scales.html
|
|
396
|
+
yAxisPadding: this.props.yAxisPadding || 0,
|
|
397
|
+
};
|
|
379
398
|
/**
|
|
380
399
|
* These scales used for 2 purposes.
|
|
381
400
|
* 1. To create x and y axis
|
|
@@ -400,7 +419,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
400
419
|
var YAxisParamsSecondary = {
|
|
401
420
|
margins: this.margins,
|
|
402
421
|
containerWidth: this.state.containerWidth,
|
|
403
|
-
containerHeight: this.state.containerHeight - this.
|
|
422
|
+
containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
|
|
404
423
|
yAxisElement: this.yAxisElementSecondary,
|
|
405
424
|
yAxisTickFormat: this.props.yAxisTickFormat,
|
|
406
425
|
yAxisTickCount: this.props.yAxisTickCount,
|
|
@@ -473,7 +492,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
473
492
|
var yAxisTitleMaximumAllowedHeight = svgDimensions.height -
|
|
474
493
|
this.margins.bottom -
|
|
475
494
|
this.margins.top -
|
|
476
|
-
this.
|
|
495
|
+
this._removalValueForTextTuncate -
|
|
477
496
|
this.titleMargin;
|
|
478
497
|
var commonSvgToolTipProps = {
|
|
479
498
|
wrapContent: wrapContent,
|
|
@@ -509,7 +528,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
509
528
|
_this.xAxisElement = e;
|
|
510
529
|
}, id: "xAxisGElement".concat(this.idForGraph),
|
|
511
530
|
// To add wrap of x axis lables feature, need to remove word height from svg height.
|
|
512
|
-
transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this.
|
|
531
|
+
transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
|
|
513
532
|
this.props.xAxisTitle !== undefined && this.props.xAxisTitle !== '' && (React.createElement(SVGTooltipText, __assign({ content: this.props.xAxisTitle, textProps: {
|
|
514
533
|
x: this.margins.left + this.state.startFromX + xAxisTitleMaximumAllowedWidth / 2,
|
|
515
534
|
y: svgDimensions.height - this.titleMargin,
|
|
@@ -536,8 +555,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
536
555
|
? this.margins.left + this.state.startFromX
|
|
537
556
|
: svgDimensions.width - this.margins.right - this.state.startFromX, ", 0)"), className: this._classNames.yAxis }),
|
|
538
557
|
this.props.secondaryYAxistitle !== undefined && this.props.secondaryYAxistitle !== '' && (React.createElement(SVGTooltipText, __assign({ content: this.props.secondaryYAxistitle, textProps: {
|
|
539
|
-
x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
|
|
540
|
-
this.state._removalValueForTextTuncate,
|
|
558
|
+
x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
|
|
541
559
|
y: this._isRtl
|
|
542
560
|
? this.state.startFromX - this.titleMargin
|
|
543
561
|
: svgDimensions.width - this.margins.right,
|
|
@@ -550,8 +568,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
550
568
|
}, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))),
|
|
551
569
|
children,
|
|
552
570
|
this.props.yAxisTitle !== undefined && this.props.yAxisTitle !== '' && (React.createElement(SVGTooltipText, __assign({ content: this.props.yAxisTitle, textProps: {
|
|
553
|
-
x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
|
|
554
|
-
this.state._removalValueForTextTuncate,
|
|
571
|
+
x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
|
|
555
572
|
y: this._isRtl
|
|
556
573
|
? svgDimensions.width - this.margins.right / 2 + this.titleMargin
|
|
557
574
|
: this.margins.left / 2 - this.titleMargin,
|
|
@@ -563,8 +580,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
|
|
|
563
580
|
this.props.yAxisAnnotation !== undefined &&
|
|
564
581
|
this.props.yAxisAnnotation !== '' &&
|
|
565
582
|
(this.props.secondaryYAxistitle === undefined || this.props.secondaryYAxistitle === '') && (React.createElement(SVGTooltipText, __assign({ content: this.props.yAxisAnnotation, textProps: {
|
|
566
|
-
x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
|
|
567
|
-
this.state._removalValueForTextTuncate,
|
|
583
|
+
x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
|
|
568
584
|
y: this._isRtl
|
|
569
585
|
? this.state.startFromX - this.titleMargin
|
|
570
586
|
: svgDimensions.width - this.margins.right,
|