gifted-charts-core 0.1.30 → 0.1.31
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.js +7 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +108 -0
- package/package.json +1 -1
package/dist/LineChart/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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
|
}
|
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
package/dist/utils/index.js
CHANGED
|
@@ -1044,3 +1044,111 @@ export var defaultLabelLineConfig = {
|
|
|
1044
1044
|
labelComponentHeight: 10,
|
|
1045
1045
|
labelComponentMargin: 4
|
|
1046
1046
|
};
|
|
1047
|
+
var secondLastIndexOf = function (text, seq) {
|
|
1048
|
+
// assuming seq is a single char
|
|
1049
|
+
var strCopy = text;
|
|
1050
|
+
var lastIndex = strCopy.lastIndexOf(seq);
|
|
1051
|
+
strCopy =
|
|
1052
|
+
strCopy.substring(0, lastIndex) + 'x' + strCopy.substring(lastIndex + 1);
|
|
1053
|
+
return strCopy.lastIndexOf(seq);
|
|
1054
|
+
};
|
|
1055
|
+
var thirdLastIndexOf = function (text, seq) {
|
|
1056
|
+
// assuming seq is a single char
|
|
1057
|
+
var strCopy = text;
|
|
1058
|
+
var lastIndex = strCopy.lastIndexOf(seq);
|
|
1059
|
+
strCopy =
|
|
1060
|
+
strCopy.substring(0, lastIndex) + 'x' + strCopy.substring(lastIndex + 1);
|
|
1061
|
+
lastIndex = strCopy.lastIndexOf(seq);
|
|
1062
|
+
strCopy =
|
|
1063
|
+
strCopy.substring(0, lastIndex) + 'x' + strCopy.substring(lastIndex + 1);
|
|
1064
|
+
return strCopy.lastIndexOf(seq);
|
|
1065
|
+
};
|
|
1066
|
+
export var pointsWithPaddedRepititions = function (oldPoints, newPoints) {
|
|
1067
|
+
/*
|
|
1068
|
+
** Handles these cases-
|
|
1069
|
+
**
|
|
1070
|
+
** 1. Straight line chart
|
|
1071
|
+
** 2. Curved Line chart
|
|
1072
|
+
** 3. Straight Area chart -> we need to repeatedly add the 3rd last substring from the points array which represents the last point
|
|
1073
|
+
** 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
|
|
1074
|
+
*/
|
|
1075
|
+
var oldPointsCopy = oldPoints.trim();
|
|
1076
|
+
var newPointsCopy = newPoints.trim();
|
|
1077
|
+
var char = oldPointsCopy.indexOf('C') === -1 ? 'L' : 'C';
|
|
1078
|
+
var oldPointsCopyAr = oldPointsCopy.split(char);
|
|
1079
|
+
var newPointsCopyAr = newPointsCopy.split(char);
|
|
1080
|
+
var oldPointsCopyLen = oldPointsCopyAr.length - 1;
|
|
1081
|
+
var newPointsCopyLen = newPointsCopyAr.length - 1;
|
|
1082
|
+
var diff = Math.abs(oldPointsCopyLen - newPointsCopyLen);
|
|
1083
|
+
var lastSequence = oldPointsCopyLen < newPointsCopyLen
|
|
1084
|
+
? oldPointsCopyAr[oldPointsCopyLen].trim()
|
|
1085
|
+
: newPointsCopyAr[newPointsCopyLen].trim();
|
|
1086
|
+
var indexOfL = lastSequence.indexOf('L');
|
|
1087
|
+
var isCurvedAreaChart = char === 'C' && indexOfL !== -1;
|
|
1088
|
+
var isStraightAreaChart = !isCurvedAreaChart &&
|
|
1089
|
+
oldPointsCopyAr[0].substring(1).trim() ===
|
|
1090
|
+
oldPointsCopyAr[oldPointsCopyLen].trim();
|
|
1091
|
+
var repeats = isCurvedAreaChart
|
|
1092
|
+
? lastSequence.substring(0, indexOfL)
|
|
1093
|
+
: isStraightAreaChart
|
|
1094
|
+
? oldPointsCopyLen < newPointsCopyLen
|
|
1095
|
+
? oldPointsCopyAr[oldPointsCopyLen - 2]
|
|
1096
|
+
: newPointsCopyAr[newPointsCopyLen - 2]
|
|
1097
|
+
: lastSequence;
|
|
1098
|
+
repeats = char + (repeats === null || repeats === void 0 ? void 0 : repeats.trim());
|
|
1099
|
+
if (isCurvedAreaChart) {
|
|
1100
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1101
|
+
oldPointsCopy = oldPointsCopy
|
|
1102
|
+
.substring(0, secondLastIndexOf(oldPointsCopy, 'L'))
|
|
1103
|
+
.trim();
|
|
1104
|
+
}
|
|
1105
|
+
else {
|
|
1106
|
+
newPointsCopy = newPointsCopy
|
|
1107
|
+
.substring(0, secondLastIndexOf(newPointsCopy, 'L'))
|
|
1108
|
+
.trim();
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
if (isStraightAreaChart) {
|
|
1112
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1113
|
+
oldPointsCopy = oldPointsCopy
|
|
1114
|
+
.substring(0, thirdLastIndexOf(oldPointsCopy, 'L'))
|
|
1115
|
+
.trim();
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
newPointsCopy = newPointsCopy
|
|
1119
|
+
.substring(0, thirdLastIndexOf(newPointsCopy, 'L'))
|
|
1120
|
+
.trim();
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
for (var i = 0; i < diff; i++) {
|
|
1124
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1125
|
+
oldPointsCopy += " ".concat(repeats);
|
|
1126
|
+
}
|
|
1127
|
+
else {
|
|
1128
|
+
newPointsCopy += " ".concat(repeats);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
oldPointsCopy = oldPointsCopy.trim();
|
|
1132
|
+
newPointsCopy = newPointsCopy.trim();
|
|
1133
|
+
if (isCurvedAreaChart) {
|
|
1134
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1135
|
+
oldPointsCopy +=
|
|
1136
|
+
' ' + oldPoints.substring(secondLastIndexOf(oldPoints, 'L'));
|
|
1137
|
+
}
|
|
1138
|
+
else {
|
|
1139
|
+
newPointsCopy +=
|
|
1140
|
+
' ' + newPoints.substring(secondLastIndexOf(newPoints, 'L'));
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
if (isStraightAreaChart) {
|
|
1144
|
+
if (oldPointsCopyLen < newPointsCopyLen) {
|
|
1145
|
+
oldPointsCopy +=
|
|
1146
|
+
' ' + oldPoints.substring(thirdLastIndexOf(oldPoints, 'L'));
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
newPointsCopy +=
|
|
1150
|
+
' ' + newPoints.substring(thirdLastIndexOf(newPoints, 'L'));
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
return [oldPointsCopy.trim(), newPointsCopy.trim()];
|
|
1154
|
+
};
|