gifted-charts-core 0.1.30 → 0.1.32
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/dist/LineChart/index.d.ts +1 -0
- package/dist/LineChart/index.js +17 -14
- package/dist/PieChart/main.d.ts +6 -1
- package/dist/PieChart/main.js +41 -20
- package/dist/components/common/types.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/index.d.ts +7 -3
- package/dist/utils/index.js +141 -19
- package/dist/utils/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -374,6 +374,7 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
|
|
|
374
374
|
stripStrokeDashArray: number[] | undefined;
|
|
375
375
|
unFocusOnPressOut: boolean;
|
|
376
376
|
delayBeforeUnFocus: number;
|
|
377
|
+
containerHeightIncludingBelowXAxis: number;
|
|
377
378
|
lineGradient: boolean;
|
|
378
379
|
lineGradientDirection: string;
|
|
379
380
|
lineGradientStartColor: string;
|
package/dist/LineChart/index.js
CHANGED
|
@@ -425,7 +425,7 @@ export var useLineChart = function (props) {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
var xx = svgPath(pArray, (_d = set.curveType) !== null && _d !== void 0 ? _d : curveType, (_e = set.curvature) !== null && _e !== void 0 ? _e : curvature);
|
|
428
|
-
pointsArray_1.push(getCurvePathWithSegments(xx, set.lineSegments, SEGMENT_START, SEGMENT_END));
|
|
428
|
+
pointsArray_1.push(getCurvePathWithSegments(xx, set.lineSegments, SEGMENT_START, SEGMENT_END, curveType));
|
|
429
429
|
// For Arrow-
|
|
430
430
|
if (set.data.length > 1 && ((_f = set.showArrow) !== null && _f !== void 0 ? _f : props.showArrows)) {
|
|
431
431
|
var arrowTipY = pArray[pArray.length - 1][1];
|
|
@@ -474,7 +474,7 @@ export var useLineChart = function (props) {
|
|
|
474
474
|
(initialSpacing + spacing * (set.data.length - 1)) +
|
|
475
475
|
' ' +
|
|
476
476
|
heightUptoXaxis;
|
|
477
|
-
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
477
|
+
ppp += ' L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
478
478
|
fillPointsArray_1.push(ppp.replace('L', 'M'));
|
|
479
479
|
}
|
|
480
480
|
}
|
|
@@ -598,7 +598,7 @@ export var useLineChart = function (props) {
|
|
|
598
598
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
599
599
|
' ' +
|
|
600
600
|
heightUptoXaxis;
|
|
601
|
-
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
601
|
+
ppp += ' L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
602
602
|
setFillPoints(ppp.replace('L', 'M'));
|
|
603
603
|
}
|
|
604
604
|
if ((areaChart !== null && areaChart !== void 0 ? areaChart : areaChart2) && data2.length > 0) {
|
|
@@ -609,7 +609,7 @@ export var useLineChart = function (props) {
|
|
|
609
609
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
610
610
|
' ' +
|
|
611
611
|
heightUptoXaxis;
|
|
612
|
-
ppp2 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
612
|
+
ppp2 += ' L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
613
613
|
setFillPoints2(ppp2.replace('L', 'M'));
|
|
614
614
|
}
|
|
615
615
|
if ((areaChart !== null && areaChart !== void 0 ? areaChart : areaChart3) && data3.length > 0) {
|
|
@@ -620,7 +620,7 @@ export var useLineChart = function (props) {
|
|
|
620
620
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
621
621
|
' ' +
|
|
622
622
|
heightUptoXaxis;
|
|
623
|
-
ppp3 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
623
|
+
ppp3 += ' L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
624
624
|
setFillPoints3(ppp3.replace('L', 'M'));
|
|
625
625
|
}
|
|
626
626
|
if ((areaChart !== null && areaChart !== void 0 ? areaChart : areaChart4) && data4.length > 0) {
|
|
@@ -631,7 +631,7 @@ export var useLineChart = function (props) {
|
|
|
631
631
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
632
632
|
' ' +
|
|
633
633
|
heightUptoXaxis;
|
|
634
|
-
ppp4 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
634
|
+
ppp4 += ' L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
635
635
|
setFillPoints4(ppp4.replace('L', 'M'));
|
|
636
636
|
}
|
|
637
637
|
if ((areaChart !== null && areaChart !== void 0 ? areaChart : areaChart5) && data5.length > 0) {
|
|
@@ -642,7 +642,7 @@ export var useLineChart = function (props) {
|
|
|
642
642
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
643
643
|
' ' +
|
|
644
644
|
heightUptoXaxis;
|
|
645
|
-
ppp5 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
645
|
+
ppp5 += ' L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
646
646
|
setFillPoints5(ppp5.replace('L', 'M'));
|
|
647
647
|
}
|
|
648
648
|
}
|
|
@@ -676,11 +676,11 @@ export var useLineChart = function (props) {
|
|
|
676
676
|
var xx3 = svgPath(p3Array, curveType, curvature);
|
|
677
677
|
var xx4 = svgPath(p4Array, curveType, curvature);
|
|
678
678
|
var xx5 = svgPath(p5Array, curveType, curvature);
|
|
679
|
-
setPoints(getCurvePathWithSegments(xx, lineSegments, SEGMENT_START, SEGMENT_END));
|
|
680
|
-
setPoints2(getCurvePathWithSegments(xx2, lineSegments2, SEGMENT_START, SEGMENT_END));
|
|
681
|
-
setPoints3(getCurvePathWithSegments(xx3, lineSegments3, SEGMENT_START, SEGMENT_END));
|
|
682
|
-
setPoints4(getCurvePathWithSegments(xx4, lineSegments4, SEGMENT_START, SEGMENT_END));
|
|
683
|
-
setPoints5(getCurvePathWithSegments(xx5, lineSegments5, SEGMENT_START, SEGMENT_END));
|
|
679
|
+
setPoints(getCurvePathWithSegments(xx, lineSegments, SEGMENT_START, SEGMENT_END, curveType));
|
|
680
|
+
setPoints2(getCurvePathWithSegments(xx2, lineSegments2, SEGMENT_START, SEGMENT_END, curveType));
|
|
681
|
+
setPoints3(getCurvePathWithSegments(xx3, lineSegments3, SEGMENT_START, SEGMENT_END, curveType));
|
|
682
|
+
setPoints4(getCurvePathWithSegments(xx4, lineSegments4, SEGMENT_START, SEGMENT_END, curveType));
|
|
683
|
+
setPoints5(getCurvePathWithSegments(xx5, lineSegments5, SEGMENT_START, SEGMENT_END, curveType));
|
|
684
684
|
if (data.length > 1 && ((_f = props.showArrow1) !== null && _f !== void 0 ? _f : props.showArrows)) {
|
|
685
685
|
var arrowTipY = p1Array[p1Array.length - 1][1];
|
|
686
686
|
var arrowTipX = p1Array[p1Array.length - 1][0];
|
|
@@ -833,7 +833,7 @@ export var useLineChart = function (props) {
|
|
|
833
833
|
(initialSpacing + spacing * (secondaryData.length - 1)) +
|
|
834
834
|
' ' +
|
|
835
835
|
heightUptoXaxis;
|
|
836
|
-
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
836
|
+
ppp += ' L' + initialSpacing + ' ' + heightUptoXaxis + ' ';
|
|
837
837
|
setSecondaryFillPoints(ppp.replace('L', 'M'));
|
|
838
838
|
}
|
|
839
839
|
}
|
|
@@ -871,6 +871,7 @@ export var useLineChart = function (props) {
|
|
|
871
871
|
var stepHeight = (_237 = props.stepHeight) !== null && _237 !== void 0 ? _237 : containerHeight / noOfSections;
|
|
872
872
|
var stepValue = (_238 = props.stepValue) !== null && _238 !== void 0 ? _238 : maxValue / noOfSections;
|
|
873
873
|
var noOfSectionsBelowXAxis = (_239 = props.noOfSectionsBelowXAxis) !== null && _239 !== void 0 ? _239 : Math.round(Math.ceil(-mostNegativeValue / stepValue));
|
|
874
|
+
var containerHeightIncludingBelowXAxis = extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
874
875
|
var showXAxisIndices = (_240 = props.showXAxisIndices) !== null && _240 !== void 0 ? _240 : AxesAndRulesDefaults.showXAxisIndices;
|
|
875
876
|
var xAxisIndicesHeight = (_241 = props.xAxisIndicesHeight) !== null && _241 !== void 0 ? _241 : AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
876
877
|
var xAxisIndicesWidth = (_242 = props.xAxisIndicesWidth) !== null && _242 !== void 0 ? _242 : AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
@@ -881,7 +882,8 @@ export var useLineChart = function (props) {
|
|
|
881
882
|
var showFractionalValues = (_246 = props.showFractionalValues) !== null && _246 !== void 0 ? _246 : AxesAndRulesDefaults.showFractionalValues;
|
|
882
883
|
var horizontal = false;
|
|
883
884
|
var yAxisAtTop = false;
|
|
884
|
-
defaultPointerConfig.pointerStripHeight =
|
|
885
|
+
defaultPointerConfig.pointerStripHeight =
|
|
886
|
+
containerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
885
887
|
var pointerConfig = props.pointerConfig;
|
|
886
888
|
var getPointerProps = (_247 = props.getPointerProps) !== null && _247 !== void 0 ? _247 : null;
|
|
887
889
|
var pointerHeight = (_248 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _248 !== void 0 ? _248 : defaultPointerConfig.height;
|
|
@@ -1427,6 +1429,7 @@ export var useLineChart = function (props) {
|
|
|
1427
1429
|
stripStrokeDashArray: stripStrokeDashArray,
|
|
1428
1430
|
unFocusOnPressOut: unFocusOnPressOut,
|
|
1429
1431
|
delayBeforeUnFocus: delayBeforeUnFocus,
|
|
1432
|
+
containerHeightIncludingBelowXAxis: containerHeightIncludingBelowXAxis,
|
|
1430
1433
|
lineGradient: lineGradient,
|
|
1431
1434
|
lineGradientDirection: lineGradientDirection,
|
|
1432
1435
|
lineGradientStartColor: lineGradientStartColor,
|
package/dist/PieChart/main.d.ts
CHANGED
|
@@ -55,9 +55,10 @@ export declare const getPieChartMainProps: (props: PieChartMainProps) => {
|
|
|
55
55
|
labelComponentWidth: number;
|
|
56
56
|
labelComponentHeight: number;
|
|
57
57
|
labelComponentMargin: number;
|
|
58
|
+
avoidOverlappingOfLabels: boolean;
|
|
58
59
|
};
|
|
59
60
|
externalLabelComponent: ((item?: pieDataItem, index?: number) => any) | undefined;
|
|
60
|
-
getExternaLabelProperties: (item: pieDataItem, mx: number, my: number, cx: number, cy: number) => {
|
|
61
|
+
getExternaLabelProperties: (item: pieDataItem, mx: number, my: number, cx: number, cy: number, prevSide: string, prevLabelComponentX: number) => {
|
|
61
62
|
labelLineColor: string;
|
|
62
63
|
labelLineThickness: number;
|
|
63
64
|
labelComponentHeight: number;
|
|
@@ -67,7 +68,9 @@ export declare const getPieChartMainProps: (props: PieChartMainProps) => {
|
|
|
67
68
|
outY: number;
|
|
68
69
|
finalX: number;
|
|
69
70
|
labelComponentX: number;
|
|
71
|
+
labelComponentY: number;
|
|
70
72
|
localExternalLabelComponent: null;
|
|
73
|
+
isRightHalf: boolean;
|
|
71
74
|
} | {
|
|
72
75
|
labelLineColor: import("react-native").ColorValue;
|
|
73
76
|
labelLineThickness: number;
|
|
@@ -78,6 +81,8 @@ export declare const getPieChartMainProps: (props: PieChartMainProps) => {
|
|
|
78
81
|
outY: number;
|
|
79
82
|
finalX: number;
|
|
80
83
|
labelComponentX: number;
|
|
84
|
+
labelComponentY: number;
|
|
81
85
|
localExternalLabelComponent: ((item?: pieDataItem, index?: number) => any) | undefined;
|
|
86
|
+
isRightHalf: boolean;
|
|
82
87
|
};
|
|
83
88
|
};
|
package/dist/PieChart/main.js
CHANGED
|
@@ -36,7 +36,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
36
36
|
};
|
|
37
37
|
import { defaultLabelLineConfig, emptyExternaLabelProperties, getTextSizeForPieLabels } from '../utils';
|
|
38
38
|
export var getPieChartMainProps = function (props) {
|
|
39
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
|
|
40
40
|
var isThreeD = props.isThreeD, isBiggerPie = props.isBiggerPie, paddingHorizontal = props.paddingHorizontal, paddingVertical = props.paddingVertical, extraRadius = props.extraRadius, showExternalLabels = props.showExternalLabels, externalLabelComponent = props.externalLabelComponent;
|
|
41
41
|
var propData = props.data;
|
|
42
42
|
var data = [];
|
|
@@ -79,9 +79,10 @@ export var getPieChartMainProps = function (props) {
|
|
|
79
79
|
thickness: (_x = (_w = props.labelLineConfig) === null || _w === void 0 ? void 0 : _w.thickness) !== null && _x !== void 0 ? _x : defaultLabelLineConfig.thickness,
|
|
80
80
|
labelComponentWidth: (_z = (_y = props.labelLineConfig) === null || _y === void 0 ? void 0 : _y.labelComponentWidth) !== null && _z !== void 0 ? _z : defaultLabelLineConfig.labelComponentWidth,
|
|
81
81
|
labelComponentHeight: (_1 = (_0 = props.labelLineConfig) === null || _0 === void 0 ? void 0 : _0.labelComponentHeight) !== null && _1 !== void 0 ? _1 : defaultLabelLineConfig.labelComponentHeight,
|
|
82
|
-
labelComponentMargin: (_3 = (_2 = props.labelLineConfig) === null || _2 === void 0 ? void 0 : _2.labelComponentMargin) !== null && _3 !== void 0 ? _3 : defaultLabelLineConfig.labelComponentMargin
|
|
82
|
+
labelComponentMargin: (_3 = (_2 = props.labelLineConfig) === null || _2 === void 0 ? void 0 : _2.labelComponentMargin) !== null && _3 !== void 0 ? _3 : defaultLabelLineConfig.labelComponentMargin,
|
|
83
|
+
avoidOverlappingOfLabels: (_5 = (_4 = props.labelLineConfig) === null || _4 === void 0 ? void 0 : _4.avoidOverlappingOfLabels) !== null && _5 !== void 0 ? _5 : defaultLabelLineConfig.avoidOverlappingOfLabels
|
|
83
84
|
};
|
|
84
|
-
var tiltAngle = (
|
|
85
|
+
var tiltAngle = (_6 = props.tiltAngle) !== null && _6 !== void 0 ? _6 : '55deg';
|
|
85
86
|
if (tiltAngle &&
|
|
86
87
|
!isNaN(Number(tiltAngle)) &&
|
|
87
88
|
!(tiltAngle + '').endsWith('deg')) {
|
|
@@ -93,12 +94,12 @@ export var getPieChartMainProps = function (props) {
|
|
|
93
94
|
: donut || props.centerLabelComponent
|
|
94
95
|
? 'outward'
|
|
95
96
|
: 'mid';
|
|
96
|
-
var showTextBackground = (
|
|
97
|
-
var textBackgroundColor = (
|
|
98
|
-
var showValuesAsLabels = (
|
|
99
|
-
var showGradient = (
|
|
100
|
-
var gradientCenterColor = (
|
|
101
|
-
var toggleFocusOnPress = (
|
|
97
|
+
var showTextBackground = (_7 = props.showTextBackground) !== null && _7 !== void 0 ? _7 : false;
|
|
98
|
+
var textBackgroundColor = (_8 = props.textBackgroundColor) !== null && _8 !== void 0 ? _8 : 'white';
|
|
99
|
+
var showValuesAsLabels = (_9 = props.showValuesAsLabels) !== null && _9 !== void 0 ? _9 : false;
|
|
100
|
+
var showGradient = (_10 = props.showGradient) !== null && _10 !== void 0 ? _10 : false;
|
|
101
|
+
var gradientCenterColor = (_11 = props.gradientCenterColor) !== null && _11 !== void 0 ? _11 : 'white';
|
|
102
|
+
var toggleFocusOnPress = (_12 = props.toggleFocusOnPress) !== null && _12 !== void 0 ? _12 : true;
|
|
102
103
|
var minShiftX = 0;
|
|
103
104
|
var maxShiftX = 0;
|
|
104
105
|
var minShiftY = 0;
|
|
@@ -143,7 +144,7 @@ export var getPieChartMainProps = function (props) {
|
|
|
143
144
|
return pAcc + (acc - pAcc) / 2;
|
|
144
145
|
});
|
|
145
146
|
pData = __spreadArray([0], __read(pData), false);
|
|
146
|
-
var getExternaLabelProperties = function (item, mx, my, cx, cy) {
|
|
147
|
+
var getExternaLabelProperties = function (item, mx, my, cx, cy, prevSide, prevLabelComponentX) {
|
|
147
148
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
148
149
|
if (!showExternalLabels)
|
|
149
150
|
return emptyExternaLabelProperties;
|
|
@@ -162,17 +163,35 @@ export var getPieChartMainProps = function (props) {
|
|
|
162
163
|
var outY = my + (isRightHalf ? yFactor : -yFactor);
|
|
163
164
|
var inX = mx + (isRightHalf ? -xFactor : xFactor);
|
|
164
165
|
var inY = my + (isRightHalf ? -yFactor : yFactor);
|
|
166
|
+
var labelComponentY = outY;
|
|
167
|
+
var side = isRightHalf ? 'right' : 'left';
|
|
168
|
+
var isOnPole = labelLineConfig.avoidOverlappingOfLabels &&
|
|
169
|
+
Math.abs(inX - outX) < 4 &&
|
|
170
|
+
side === prevSide;
|
|
165
171
|
var finalX = isRightHalf ? cx * 2 + labelLineLength : -labelLineLength;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
if (isOnPole) {
|
|
173
|
+
finalX = outX;
|
|
174
|
+
labelComponentY += outY > cy ? 10 : -10;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
finalX = isRightHalf
|
|
178
|
+
? finalX > outX
|
|
179
|
+
? finalX
|
|
180
|
+
: outX
|
|
181
|
+
: finalX < outX
|
|
182
|
+
? finalX
|
|
183
|
+
: outX;
|
|
184
|
+
}
|
|
173
185
|
var labelComponentX = isRightHalf
|
|
174
|
-
? finalX + labelComponentMargin
|
|
175
|
-
: finalX - labelComponentWidth - labelComponentMargin;
|
|
186
|
+
? finalX + (isOnPole ? -10 : labelComponentMargin)
|
|
187
|
+
: finalX - labelComponentWidth - (isOnPole ? -20 : labelComponentMargin);
|
|
188
|
+
// In case both previous & current labels are at pole, then their labels might again overlap, to counter this, we vertically shift the current label
|
|
189
|
+
if (labelLineConfig.avoidOverlappingOfLabels &&
|
|
190
|
+
isOnPole &&
|
|
191
|
+
Math.abs(prevLabelComponentX - labelComponentX) < 30) {
|
|
192
|
+
labelComponentY += outY > cy ? 20 : -20;
|
|
193
|
+
outY += outY > cy ? 20 : -20;
|
|
194
|
+
}
|
|
176
195
|
var localExternalLabelComponent = (_q = item.externalLabelComponent) !== null && _q !== void 0 ? _q : props.externalLabelComponent;
|
|
177
196
|
return {
|
|
178
197
|
labelLineColor: labelLineColor,
|
|
@@ -184,7 +203,9 @@ export var getPieChartMainProps = function (props) {
|
|
|
184
203
|
outY: outY,
|
|
185
204
|
finalX: finalX,
|
|
186
205
|
labelComponentX: labelComponentX,
|
|
187
|
-
|
|
206
|
+
labelComponentY: labelComponentY,
|
|
207
|
+
localExternalLabelComponent: localExternalLabelComponent,
|
|
208
|
+
isRightHalf: isRightHalf
|
|
188
209
|
};
|
|
189
210
|
};
|
|
190
211
|
return {
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,6 @@ export { type StripAndLabelProps } from './components/common/types';
|
|
|
34
34
|
/***********************************************************************************************************************
|
|
35
35
|
/********************************* common utils, constants and types ********************************
|
|
36
36
|
/***********************************************************************************************************************/
|
|
37
|
-
export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset } from './utils';
|
|
37
|
+
export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset, pointsWithPaddedRepititions } from './utils';
|
|
38
38
|
export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
|
|
39
39
|
export { type RuleType, type RuleTypes, type RulesConfig, CurveType, EdgePosition, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type horizSectionPropTypes, type HorizSectionsType, type BarAndLineChartsWrapperTypes, type Pointer, type HighlightedRange, type LineSegment, type LineSvgProps, type LineProperties, type DataSet, Framework, type XAxisConfig, type LineInBarChartPropsType, type DataPointProps, type Linecap, type IntersectionAreaConfig, type LabelLineConfig } from './utils/types';
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,6 @@ export { getTopAndLeftForStripAndLabel } from './components/common/StripAndLabel
|
|
|
29
29
|
/***********************************************************************************************************************
|
|
30
30
|
/********************************* common utils, constants and types ********************************
|
|
31
31
|
/***********************************************************************************************************************/
|
|
32
|
-
export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset } from './utils';
|
|
32
|
+
export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset, pointsWithPaddedRepititions } from './utils';
|
|
33
33
|
export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
|
|
34
34
|
export { CurveType, EdgePosition, Framework } from './utils/types';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export declare const svgQuadraticCurvePath: (points: number[][]) => string;
|
|
|
10
10
|
export declare const svgPath: (points: number[][], curveType?: CurveType, curvature?: number) => string;
|
|
11
11
|
export declare const bezierCommand: (point: number[], i: number, a: number[][], curvature: number) => string;
|
|
12
12
|
export declare const getSegmentString: (lineSegment: LineSegment[] | undefined, index: number, startDelimeter: string, endDelimeter: string) => string;
|
|
13
|
-
export declare const getCurvePathWithSegments: (path: string, lineSegment: LineSegment[] | undefined, startDelimeter: string, endDelimeter: string) => string;
|
|
13
|
+
export declare const getCurvePathWithSegments: (path: string, lineSegment: LineSegment[] | undefined, startDelimeter: string, endDelimeter: string, curveType: CurveType) => string;
|
|
14
14
|
export declare const getPreviousSegmentsLastPoint: (isCurved: boolean, previousSegment: string) => string;
|
|
15
15
|
export declare const getPathWithHighlight: (data: lineDataItem[], i: number, highlightedRange: HighlightedRange, startIndex: number, endIndex: number, getX: (i: number) => number, getY: (value: number) => number) => string;
|
|
16
|
-
export declare const getRegionPathObjects: (points: string, color: ColorValue, currentLineThickness: number, thickness: number, strokeDashArray: number[], isCurved: boolean, startDelimeter: string, stop: string, endDelimeter: string) => LineProperties[];
|
|
17
|
-
export declare const getSegmentedPathObjects: (points: string, color: ColorValue, currentLineThickness: number, thickness: number, strokeDashArray: number[], isCurved: boolean, startDelimeter: string, endDelimeter: string) => LineProperties[];
|
|
16
|
+
export declare const getRegionPathObjects: (points: string, color: ColorValue, currentLineThickness: number, thickness: number, strokeDashArray: number[], isCurved: boolean, startDelimeter: string, stop: string, endDelimeter: string, curveType: CurveType) => LineProperties[];
|
|
17
|
+
export declare const getSegmentedPathObjects: (points: string, color: ColorValue, currentLineThickness: number, thickness: number, strokeDashArray: number[], isCurved: boolean, startDelimeter: string, endDelimeter: string, curveType: CurveType) => LineProperties[];
|
|
18
18
|
export declare const getArrowPoints: (arrowTipX: number, arrowTipY: number, x1: number, y1: number, arrowLength?: number, arrowWidth?: number, showArrowBase?: boolean) => string;
|
|
19
19
|
interface ReferenceLinesConfig {
|
|
20
20
|
showReferenceLine1?: boolean;
|
|
@@ -109,7 +109,9 @@ export declare const emptyExternaLabelProperties: {
|
|
|
109
109
|
outY: number;
|
|
110
110
|
finalX: number;
|
|
111
111
|
labelComponentX: number;
|
|
112
|
+
labelComponentY: number;
|
|
112
113
|
localExternalLabelComponent: null;
|
|
114
|
+
isRightHalf: boolean;
|
|
113
115
|
};
|
|
114
116
|
export declare const defaultLabelLineConfig: {
|
|
115
117
|
length: number;
|
|
@@ -119,5 +121,7 @@ export declare const defaultLabelLineConfig: {
|
|
|
119
121
|
labelComponentWidth: number;
|
|
120
122
|
labelComponentHeight: number;
|
|
121
123
|
labelComponentMargin: number;
|
|
124
|
+
avoidOverlappingOfLabels: boolean;
|
|
122
125
|
};
|
|
126
|
+
export declare const pointsWithPaddedRepititions: (oldPoints: string, newPoints: string) => string[];
|
|
123
127
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -87,21 +87,21 @@ export var svgQuadraticCurvePath = function (points) {
|
|
|
87
87
|
var cpX1 = (xMid + points[i][0]) / 2;
|
|
88
88
|
var cpX2 = (xMid + points[i + 1][0]) / 2;
|
|
89
89
|
path +=
|
|
90
|
-
'Q ' +
|
|
90
|
+
' Q ' +
|
|
91
91
|
cpX1 +
|
|
92
|
-
',
|
|
92
|
+
',' +
|
|
93
93
|
points[i][1] +
|
|
94
94
|
', ' +
|
|
95
95
|
xMid +
|
|
96
|
-
',
|
|
96
|
+
',' +
|
|
97
97
|
yMid +
|
|
98
|
-
(' Q
|
|
98
|
+
(' Q' +
|
|
99
99
|
cpX2 +
|
|
100
|
-
',
|
|
100
|
+
',' +
|
|
101
101
|
points[i + 1][1] +
|
|
102
102
|
', ' +
|
|
103
103
|
points[i + 1][0] +
|
|
104
|
-
',
|
|
104
|
+
',' +
|
|
105
105
|
points[i + 1][1]);
|
|
106
106
|
}
|
|
107
107
|
return path;
|
|
@@ -157,15 +157,16 @@ export var getSegmentString = function (lineSegment, index, startDelimeter, endD
|
|
|
157
157
|
var segment = lineSegment === null || lineSegment === void 0 ? void 0 : lineSegment.find(function (segment) { return segment.startIndex === index; });
|
|
158
158
|
return segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : '';
|
|
159
159
|
};
|
|
160
|
-
export var getCurvePathWithSegments = function (path, lineSegment, startDelimeter, endDelimeter) {
|
|
160
|
+
export var getCurvePathWithSegments = function (path, lineSegment, startDelimeter, endDelimeter, curveType) {
|
|
161
161
|
if (!(lineSegment === null || lineSegment === void 0 ? void 0 : lineSegment.length))
|
|
162
162
|
return path;
|
|
163
|
+
var char = curveType === CurveType.QUADRATIC ? 'Q ' : 'C'; // space after Q is intentional, it signifies the first Q as their are 2 Qs equivalent to 1 C, and to counter this, we placed space after the 1st Q
|
|
163
164
|
var newPath = '';
|
|
164
|
-
var pathArray = path.split(
|
|
165
|
+
var pathArray = path.split(char);
|
|
165
166
|
var _loop_1 = function (i) {
|
|
166
167
|
var segment = lineSegment === null || lineSegment === void 0 ? void 0 : lineSegment.find(function (segment) { return segment.startIndex === i; });
|
|
167
168
|
newPath +=
|
|
168
|
-
(pathArray[i].startsWith('M') ? '' :
|
|
169
|
+
(pathArray[i].startsWith('M') ? '' : char) +
|
|
169
170
|
pathArray[i] +
|
|
170
171
|
(segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : '');
|
|
171
172
|
};
|
|
@@ -286,10 +287,11 @@ export var getPathWithHighlight = function (data, i, highlightedRange, startInde
|
|
|
286
287
|
}
|
|
287
288
|
return path;
|
|
288
289
|
};
|
|
289
|
-
export var getRegionPathObjects = function (points, color, currentLineThickness, thickness, strokeDashArray, isCurved, startDelimeter, stop, endDelimeter) {
|
|
290
|
+
export var getRegionPathObjects = function (points, color, currentLineThickness, thickness, strokeDashArray, isCurved, startDelimeter, stop, endDelimeter, curveType) {
|
|
290
291
|
var _a, _b;
|
|
291
292
|
var ar = [{ d: '', color: '', strokeWidth: 0 }];
|
|
292
293
|
var tempStr = points;
|
|
294
|
+
var char = curveType === CurveType.QUADRATIC ? 'Q' : 'C';
|
|
293
295
|
if (!points.startsWith(startDelimeter)) {
|
|
294
296
|
/** ******************** line upto first segment *****************/
|
|
295
297
|
var lineSvgProps = {
|
|
@@ -326,7 +328,7 @@ export var getRegionPathObjects = function (points, color, currentLineThickness,
|
|
|
326
328
|
var stringUptoNextSegment = tempStr.substring(0, nextDelimiterIndex);
|
|
327
329
|
/** ******************** line upto the next segment *****************/
|
|
328
330
|
if (nextDelimiterIndex !== -1 &&
|
|
329
|
-
stringUptoNextSegment.includes(isCurved ?
|
|
331
|
+
stringUptoNextSegment.includes(isCurved ? char : 'L')) {
|
|
330
332
|
var previousSegment_1 = ar[ar.length - 1].d;
|
|
331
333
|
var moveToLastPointOfPreviousSegment_1 = getPreviousSegmentsLastPoint(isCurved, previousSegment_1);
|
|
332
334
|
var lineSvgProps_1 = {
|
|
@@ -357,10 +359,11 @@ export var getRegionPathObjects = function (points, color, currentLineThickness,
|
|
|
357
359
|
ar.shift();
|
|
358
360
|
return ar;
|
|
359
361
|
};
|
|
360
|
-
export var getSegmentedPathObjects = function (points, color, currentLineThickness, thickness, strokeDashArray, isCurved, startDelimeter, endDelimeter) {
|
|
362
|
+
export var getSegmentedPathObjects = function (points, color, currentLineThickness, thickness, strokeDashArray, isCurved, startDelimeter, endDelimeter, curveType) {
|
|
361
363
|
var _a, _b;
|
|
362
364
|
var ar = [{ d: '', color: '', strokeWidth: 0 }];
|
|
363
365
|
var tempStr = points;
|
|
366
|
+
var char = curveType === CurveType.QUADRATIC ? 'Q' : 'C';
|
|
364
367
|
if (!points.startsWith(startDelimeter)) {
|
|
365
368
|
/** ******************** line upto first segment *****************/
|
|
366
369
|
var lineSvgProps = {
|
|
@@ -385,13 +388,21 @@ export var getSegmentedPathObjects = function (points, color, currentLineThickne
|
|
|
385
388
|
var s = 0;
|
|
386
389
|
var i = void 0;
|
|
387
390
|
for (i = 0; i < segment.length; i++) {
|
|
388
|
-
if (segment[i] === (isCurved ?
|
|
389
|
-
|
|
390
|
-
|
|
391
|
+
if (segment[i] === (isCurved ? char : 'L')) {
|
|
392
|
+
if (curveType === CurveType.QUADRATIC) {
|
|
393
|
+
if (segment[i + 1] == ' ')
|
|
394
|
+
c++;
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
c++;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (c >= segmentLength) {
|
|
391
401
|
if (segment[i] === ' ')
|
|
392
402
|
s++;
|
|
393
|
-
if (s === (isCurved ? 3 : 2))
|
|
403
|
+
if (s === (isCurved ? (char === 'Q' ? 5 : 3) : 2)) {
|
|
394
404
|
break;
|
|
405
|
+
}
|
|
395
406
|
}
|
|
396
407
|
}
|
|
397
408
|
segment = segment.substring(0, i);
|
|
@@ -412,7 +423,7 @@ export var getSegmentedPathObjects = function (points, color, currentLineThickne
|
|
|
412
423
|
var stringUptoNextSegment = tempStr.substring(0, nextDelimiterIndex);
|
|
413
424
|
/** ******************** line upto the next segment *****************/
|
|
414
425
|
if (nextDelimiterIndex !== -1 &&
|
|
415
|
-
stringUptoNextSegment.includes(isCurved ?
|
|
426
|
+
stringUptoNextSegment.includes(isCurved ? char : 'L')) {
|
|
416
427
|
var previousSegment_2 = ar[ar.length - 1].d;
|
|
417
428
|
var moveToLastPointOfPreviousSegment_2 = getPreviousSegmentsLastPoint(isCurved, previousSegment_2);
|
|
418
429
|
var lineSvgProps_2 = {
|
|
@@ -1033,7 +1044,9 @@ export var emptyExternaLabelProperties = {
|
|
|
1033
1044
|
outY: 0,
|
|
1034
1045
|
finalX: 0,
|
|
1035
1046
|
labelComponentX: 0,
|
|
1036
|
-
|
|
1047
|
+
labelComponentY: 0,
|
|
1048
|
+
localExternalLabelComponent: null,
|
|
1049
|
+
isRightHalf: false
|
|
1037
1050
|
};
|
|
1038
1051
|
export var defaultLabelLineConfig = {
|
|
1039
1052
|
length: 10,
|
|
@@ -1042,5 +1055,114 @@ export var defaultLabelLineConfig = {
|
|
|
1042
1055
|
thickness: 1,
|
|
1043
1056
|
labelComponentWidth: 20,
|
|
1044
1057
|
labelComponentHeight: 10,
|
|
1045
|
-
labelComponentMargin: 4
|
|
1058
|
+
labelComponentMargin: 4,
|
|
1059
|
+
avoidOverlappingOfLabels: true
|
|
1060
|
+
};
|
|
1061
|
+
var secondLastIndexOf = function (text, seq) {
|
|
1062
|
+
// assuming seq is a single char
|
|
1063
|
+
var strCopy = text;
|
|
1064
|
+
var lastIndex = strCopy.lastIndexOf(seq);
|
|
1065
|
+
strCopy =
|
|
1066
|
+
strCopy.substring(0, lastIndex) + 'x' + strCopy.substring(lastIndex + 1);
|
|
1067
|
+
return strCopy.lastIndexOf(seq);
|
|
1068
|
+
};
|
|
1069
|
+
var thirdLastIndexOf = function (text, seq) {
|
|
1070
|
+
// assuming seq is a single char
|
|
1071
|
+
var strCopy = text;
|
|
1072
|
+
var lastIndex = strCopy.lastIndexOf(seq);
|
|
1073
|
+
strCopy =
|
|
1074
|
+
strCopy.substring(0, lastIndex) + 'x' + strCopy.substring(lastIndex + 1);
|
|
1075
|
+
lastIndex = strCopy.lastIndexOf(seq);
|
|
1076
|
+
strCopy =
|
|
1077
|
+
strCopy.substring(0, lastIndex) + 'x' + strCopy.substring(lastIndex + 1);
|
|
1078
|
+
return strCopy.lastIndexOf(seq);
|
|
1079
|
+
};
|
|
1080
|
+
export var pointsWithPaddedRepititions = function (oldPoints, newPoints) {
|
|
1081
|
+
/*
|
|
1082
|
+
** Handles these cases-
|
|
1083
|
+
**
|
|
1084
|
+
** 1. Straight line chart
|
|
1085
|
+
** 2. Curved Line chart
|
|
1086
|
+
** 3. Straight Area chart -> we need to repeatedly add the 3rd last substring from the points array which represents the last point
|
|
1087
|
+
** 4. Curved Area chart -> we need to repeatedly add the 3nd last substring (the 2 last substrings start with L while the 3rd last will start with C) from the points array which represents the last point
|
|
1088
|
+
*/
|
|
1089
|
+
var oldPointsCopy = oldPoints.trim();
|
|
1090
|
+
var newPointsCopy = newPoints.trim();
|
|
1091
|
+
var char = oldPointsCopy.indexOf('C') === -1 ? 'L' : 'C';
|
|
1092
|
+
var oldPointsCopyAr = oldPointsCopy.split(char);
|
|
1093
|
+
var newPointsCopyAr = newPointsCopy.split(char);
|
|
1094
|
+
var oldPointsCopyLen = oldPointsCopyAr.length - 1;
|
|
1095
|
+
var newPointsCopyLen = newPointsCopyAr.length - 1;
|
|
1096
|
+
var diff = Math.abs(oldPointsCopyLen - newPointsCopyLen);
|
|
1097
|
+
var lastSequence = oldPointsCopyLen < newPointsCopyLen
|
|
1098
|
+
? oldPointsCopyAr[oldPointsCopyLen].trim()
|
|
1099
|
+
: newPointsCopyAr[newPointsCopyLen].trim();
|
|
1100
|
+
var indexOfL = lastSequence.indexOf('L');
|
|
1101
|
+
var isCurvedAreaChart = char === 'C' && indexOfL !== -1;
|
|
1102
|
+
var isStraightAreaChart = !isCurvedAreaChart &&
|
|
1103
|
+
oldPointsCopyAr[0].substring(1).trim() ===
|
|
1104
|
+
oldPointsCopyAr[oldPointsCopyLen].trim();
|
|
1105
|
+
var repeats = isCurvedAreaChart
|
|
1106
|
+
? lastSequence.substring(0, indexOfL)
|
|
1107
|
+
: isStraightAreaChart
|
|
1108
|
+
? oldPointsCopyLen < newPointsCopyLen
|
|
1109
|
+
? oldPointsCopyAr[oldPointsCopyLen - 2]
|
|
1110
|
+
: newPointsCopyAr[newPointsCopyLen - 2]
|
|
1111
|
+
: lastSequence;
|
|
1112
|
+
repeats = char + (repeats === null || repeats === void 0 ? void 0 : repeats.trim());
|
|
1113
|
+
if (isCurvedAreaChart) {
|
|
1114
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1115
|
+
oldPointsCopy = oldPointsCopy
|
|
1116
|
+
.substring(0, secondLastIndexOf(oldPointsCopy, 'L'))
|
|
1117
|
+
.trim();
|
|
1118
|
+
}
|
|
1119
|
+
else {
|
|
1120
|
+
newPointsCopy = newPointsCopy
|
|
1121
|
+
.substring(0, secondLastIndexOf(newPointsCopy, 'L'))
|
|
1122
|
+
.trim();
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
if (isStraightAreaChart) {
|
|
1126
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1127
|
+
oldPointsCopy = oldPointsCopy
|
|
1128
|
+
.substring(0, thirdLastIndexOf(oldPointsCopy, 'L'))
|
|
1129
|
+
.trim();
|
|
1130
|
+
}
|
|
1131
|
+
else {
|
|
1132
|
+
newPointsCopy = newPointsCopy
|
|
1133
|
+
.substring(0, thirdLastIndexOf(newPointsCopy, 'L'))
|
|
1134
|
+
.trim();
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
for (var i = 0; i < diff; i++) {
|
|
1138
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1139
|
+
oldPointsCopy += " ".concat(repeats);
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
newPointsCopy += " ".concat(repeats);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
oldPointsCopy = oldPointsCopy.trim();
|
|
1146
|
+
newPointsCopy = newPointsCopy.trim();
|
|
1147
|
+
if (isCurvedAreaChart) {
|
|
1148
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1149
|
+
oldPointsCopy +=
|
|
1150
|
+
' ' + oldPoints.substring(secondLastIndexOf(oldPoints, 'L'));
|
|
1151
|
+
}
|
|
1152
|
+
else {
|
|
1153
|
+
newPointsCopy +=
|
|
1154
|
+
' ' + newPoints.substring(secondLastIndexOf(newPoints, 'L'));
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
if (isStraightAreaChart) {
|
|
1158
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1159
|
+
oldPointsCopy +=
|
|
1160
|
+
' ' + oldPoints.substring(thirdLastIndexOf(oldPoints, 'L'));
|
|
1161
|
+
}
|
|
1162
|
+
else {
|
|
1163
|
+
newPointsCopy +=
|
|
1164
|
+
' ' + newPoints.substring(thirdLastIndexOf(newPoints, 'L'));
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return [oldPointsCopy.trim(), newPointsCopy.trim()];
|
|
1046
1168
|
};
|
package/dist/utils/types.d.ts
CHANGED