gifted-charts-core 0.1.12 → 0.1.13
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/package.json +1 -1
- package/src/BarChart/index.js +7 -7
- package/src/BarChart/index.ts +6 -6
- package/src/LineChart/LineChartBiColor.js +3 -3
- package/src/LineChart/LineChartBiColor.ts +3 -3
- package/src/LineChart/index.js +4 -1
- package/src/LineChart/index.ts +5 -2
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +1 -1
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.ts +1 -1
- package/src/components/BarAndLineChartsWrapper/index.js +1 -0
- package/src/components/BarAndLineChartsWrapper/index.ts +1 -0
- package/src/utils/types.d.ts +1 -0
- package/src/utils/types.ts +1 -0
package/package.json
CHANGED
package/src/BarChart/index.js
CHANGED
|
@@ -111,12 +111,12 @@ export var useBarChart = function (props) {
|
|
|
111
111
|
var scrollAnimation = (_t = props.scrollAnimation) !== null && _t !== void 0 ? _t : BarDefaults.scrollAnimation;
|
|
112
112
|
var scrollEventThrottle = (_u = props.scrollEventThrottle) !== null && _u !== void 0 ? _u : BarDefaults.scrollEventThrottle;
|
|
113
113
|
var labelsExtraHeight = (_v = props.labelsExtraHeight) !== null && _v !== void 0 ? _v : AxesAndRulesDefaults.labelsExtraHeight;
|
|
114
|
-
var totalWidth = initialSpacing;
|
|
114
|
+
var totalWidth = initialSpacing + endSpacing;
|
|
115
115
|
var maxItem = 0;
|
|
116
116
|
var minItem = 0;
|
|
117
117
|
if (props.stackData) {
|
|
118
|
-
props.stackData.forEach(function (stackItem) {
|
|
119
|
-
var _a, _b;
|
|
118
|
+
props.stackData.forEach(function (stackItem, index) {
|
|
119
|
+
var _a, _b, _c;
|
|
120
120
|
var stackSumMax = stackItem.stacks.reduce(function (acc, stack) { return acc + (stack.value >= 0 ? stack.value : 0); }, 0);
|
|
121
121
|
var stackSumMin = stackItem.stacks.reduce(function (acc, stack) { return acc + (stack.value < 0 ? stack.value : 0); }, 0);
|
|
122
122
|
if (stackSumMax > maxItem) {
|
|
@@ -127,11 +127,11 @@ export var useBarChart = function (props) {
|
|
|
127
127
|
}
|
|
128
128
|
totalWidth +=
|
|
129
129
|
((_b = (_a = stackItem.stacks[0].barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
|
|
130
|
-
spacing;
|
|
130
|
+
(index === data.length - 1 ? 0 : (_c = stackItem.spacing) !== null && _c !== void 0 ? _c : spacing);
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
134
|
-
data.forEach(function (item) {
|
|
134
|
+
data.forEach(function (item, index) {
|
|
135
135
|
var _a, _b, _c;
|
|
136
136
|
if (item.value > maxItem) {
|
|
137
137
|
maxItem = item.value;
|
|
@@ -141,7 +141,7 @@ export var useBarChart = function (props) {
|
|
|
141
141
|
}
|
|
142
142
|
totalWidth +=
|
|
143
143
|
((_b = (_a = item.barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
|
|
144
|
-
((_c = item.spacing) !== null && _c !== void 0 ? _c : spacing);
|
|
144
|
+
(index === data.length - 1 ? spacing : (_c = item.spacing) !== null && _c !== void 0 ? _c : spacing);
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
var secondaryMaxItem = 0;
|
|
@@ -391,7 +391,7 @@ export var useBarChart = function (props) {
|
|
|
391
391
|
});
|
|
392
392
|
var animatedWidth = widthValue === null || widthValue === void 0 ? void 0 : widthValue.interpolate({
|
|
393
393
|
inputRange: [0, 1],
|
|
394
|
-
outputRange: [0, initialSpacing + totalWidth
|
|
394
|
+
outputRange: [0, initialSpacing + totalWidth]
|
|
395
395
|
});
|
|
396
396
|
var getPropsCommonForBarAndStack = function (item, index) {
|
|
397
397
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
package/src/BarChart/index.ts
CHANGED
|
@@ -167,11 +167,11 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
167
167
|
const labelsExtraHeight =
|
|
168
168
|
props.labelsExtraHeight ?? AxesAndRulesDefaults.labelsExtraHeight
|
|
169
169
|
|
|
170
|
-
let totalWidth = initialSpacing
|
|
170
|
+
let totalWidth = initialSpacing + endSpacing
|
|
171
171
|
let maxItem = 0
|
|
172
172
|
let minItem = 0
|
|
173
173
|
if (props.stackData) {
|
|
174
|
-
props.stackData.forEach((stackItem) => {
|
|
174
|
+
props.stackData.forEach((stackItem, index) => {
|
|
175
175
|
const stackSumMax = stackItem.stacks.reduce(
|
|
176
176
|
(acc, stack) => acc + (stack.value >= 0 ? stack.value : 0),
|
|
177
177
|
0
|
|
@@ -190,10 +190,10 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
190
190
|
}
|
|
191
191
|
totalWidth +=
|
|
192
192
|
(stackItem.stacks[0].barWidth ?? props.barWidth ?? defaultBarWidth) +
|
|
193
|
-
spacing
|
|
193
|
+
(index === data.length - 1 ? 0 : stackItem.spacing ?? spacing)
|
|
194
194
|
})
|
|
195
195
|
} else {
|
|
196
|
-
data.forEach((item: barDataItem) => {
|
|
196
|
+
data.forEach((item: barDataItem, index) => {
|
|
197
197
|
if (item.value > maxItem) {
|
|
198
198
|
maxItem = item.value
|
|
199
199
|
}
|
|
@@ -202,7 +202,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
202
202
|
}
|
|
203
203
|
totalWidth +=
|
|
204
204
|
(item.barWidth ?? props.barWidth ?? defaultBarWidth) +
|
|
205
|
-
(item.spacing ?? spacing)
|
|
205
|
+
(index === data.length - 1 ? spacing : item.spacing ?? spacing)
|
|
206
206
|
})
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -632,7 +632,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
632
632
|
|
|
633
633
|
const animatedWidth = widthValue?.interpolate({
|
|
634
634
|
inputRange: [0, 1],
|
|
635
|
-
outputRange: [0, initialSpacing + totalWidth
|
|
635
|
+
outputRange: [0, initialSpacing + totalWidth]
|
|
636
636
|
})
|
|
637
637
|
|
|
638
638
|
const getPropsCommonForBarAndStack = (item: any, index: number) => {
|
|
@@ -81,17 +81,17 @@ export var useLineChartBiColor = function (props) {
|
|
|
81
81
|
var areaChart = (_w = props.areaChart) !== null && _w !== void 0 ? _w : false;
|
|
82
82
|
var textFontSize1 = (_x = props.textFontSize) !== null && _x !== void 0 ? _x : LineDefaults.textFontSize;
|
|
83
83
|
var textColor1 = (_y = props.textColor) !== null && _y !== void 0 ? _y : LineDefaults.textColor;
|
|
84
|
-
var totalWidth = initialSpacing;
|
|
84
|
+
var totalWidth = initialSpacing + endSpacing;
|
|
85
85
|
var maxItem = 0;
|
|
86
86
|
var minItem = 0;
|
|
87
|
-
data.forEach(function (item) {
|
|
87
|
+
data.forEach(function (item, index) {
|
|
88
88
|
if (item.value > maxItem) {
|
|
89
89
|
maxItem = item.value;
|
|
90
90
|
}
|
|
91
91
|
if (item.value < minItem) {
|
|
92
92
|
minItem = item.value;
|
|
93
93
|
}
|
|
94
|
-
totalWidth += spacing;
|
|
94
|
+
totalWidth += index === data.length - 1 ? 0 : spacing;
|
|
95
95
|
});
|
|
96
96
|
if ((_z = props.showFractionalValues) !== null && _z !== void 0 ? _z : props.roundToDigits) {
|
|
97
97
|
maxItem *= 10 * ((_0 = props.roundToDigits) !== null && _0 !== void 0 ? _0 : 1);
|
|
@@ -99,17 +99,17 @@ export const useLineChartBiColor = (
|
|
|
99
99
|
const textFontSize1 = props.textFontSize ?? LineDefaults.textFontSize
|
|
100
100
|
const textColor1 = props.textColor ?? LineDefaults.textColor
|
|
101
101
|
|
|
102
|
-
let totalWidth = initialSpacing
|
|
102
|
+
let totalWidth = initialSpacing + endSpacing
|
|
103
103
|
let maxItem = 0
|
|
104
104
|
let minItem = 0
|
|
105
|
-
data.forEach((item: bicolorLineDataItem) => {
|
|
105
|
+
data.forEach((item: bicolorLineDataItem, index) => {
|
|
106
106
|
if (item.value > maxItem) {
|
|
107
107
|
maxItem = item.value
|
|
108
108
|
}
|
|
109
109
|
if (item.value < minItem) {
|
|
110
110
|
minItem = item.value
|
|
111
111
|
}
|
|
112
|
-
totalWidth += spacing
|
|
112
|
+
totalWidth += index === data.length - 1 ? 0 : spacing
|
|
113
113
|
})
|
|
114
114
|
|
|
115
115
|
if (props.showFractionalValues ?? props.roundToDigits) {
|
package/src/LineChart/index.js
CHANGED
|
@@ -233,7 +233,7 @@ export var useLineChart = function (props) {
|
|
|
233
233
|
var textColor3 = (_93 = (_92 = props.textColor3) !== null && _92 !== void 0 ? _92 : props.textColor) !== null && _93 !== void 0 ? _93 : LineDefaults.textColor;
|
|
234
234
|
var textColor4 = (_95 = (_94 = props.textColor4) !== null && _94 !== void 0 ? _94 : props.textColor) !== null && _95 !== void 0 ? _95 : LineDefaults.textColor;
|
|
235
235
|
var textColor5 = (_97 = (_96 = props.textColor5) !== null && _96 !== void 0 ? _96 : props.textColor) !== null && _97 !== void 0 ? _97 : LineDefaults.textColor;
|
|
236
|
-
var totalWidth = initialSpacing + spacing * (data0 !== null && data0 !== void 0 ? data0 : data).length;
|
|
236
|
+
var totalWidth = initialSpacing + spacing * (data0 !== null && data0 !== void 0 ? data0 : data).length - 1 + endSpacing;
|
|
237
237
|
var _339 = computeMaxAndMinItems(data0 !== null && data0 !== void 0 ? data0 : data, props.roundToDigits, props.showFractionalValues), maxItem = _339.maxItem, minItem = _339.minItem;
|
|
238
238
|
var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxItem);
|
|
239
239
|
var mostNegativeValue = (_98 = props.mostNegativeValue) !== null && _98 !== void 0 ? _98 : minItem;
|
|
@@ -253,6 +253,9 @@ export var useLineChart = function (props) {
|
|
|
253
253
|
animations.forEach(function (item, index) {
|
|
254
254
|
item.addListener(function (val) {
|
|
255
255
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
256
|
+
if (typeof data[index] === 'undefined') {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
256
259
|
var temp = (_b = (_a = data[index]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
257
260
|
data[index].value = (_c = val === null || val === void 0 ? void 0 : val.value) !== null && _c !== void 0 ? _c : 0;
|
|
258
261
|
var pp = '';
|
package/src/LineChart/index.ts
CHANGED
|
@@ -428,7 +428,8 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
428
428
|
const textColor5 =
|
|
429
429
|
props.textColor5 ?? props.textColor ?? LineDefaults.textColor
|
|
430
430
|
|
|
431
|
-
const totalWidth =
|
|
431
|
+
const totalWidth =
|
|
432
|
+
initialSpacing + spacing * (data0 ?? data).length - 1 + endSpacing
|
|
432
433
|
|
|
433
434
|
const { maxItem, minItem } = computeMaxAndMinItems(
|
|
434
435
|
data0 ?? data,
|
|
@@ -469,7 +470,9 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
469
470
|
if (animateOnDataChange && animations) {
|
|
470
471
|
animations.forEach((item, index) => {
|
|
471
472
|
item.addListener((val) => {
|
|
472
|
-
if (typeof data[index] === 'undefined') {
|
|
473
|
+
if (typeof data[index] === 'undefined') {
|
|
474
|
+
return
|
|
475
|
+
}
|
|
473
476
|
|
|
474
477
|
const temp = data[index]?.value ?? 0
|
|
475
478
|
data[index].value = val?.value ?? 0
|
|
@@ -112,7 +112,7 @@ export var getHorizSectionVals = function (props) {
|
|
|
112
112
|
var showReferenceLine1 = referenceLinesConfig.showReferenceLine1, referenceLine1Position = referenceLinesConfig.referenceLine1Position, referenceLine1Config = referenceLinesConfig.referenceLine1Config, showReferenceLine2 = referenceLinesConfig.showReferenceLine2, referenceLine2Position = referenceLinesConfig.referenceLine2Position, referenceLine2Config = referenceLinesConfig.referenceLine2Config, showReferenceLine3 = referenceLinesConfig.showReferenceLine3, referenceLine3Position = referenceLinesConfig.referenceLine3Position, referenceLine3Config = referenceLinesConfig.referenceLine3Config;
|
|
113
113
|
var defaultReferenceConfig = {
|
|
114
114
|
thickness: rulesThickness,
|
|
115
|
-
width: (width || totalWidth -
|
|
115
|
+
width: (width || totalWidth - endSpacing) + endSpacing,
|
|
116
116
|
color: 'black',
|
|
117
117
|
type: rulesType,
|
|
118
118
|
dashWidth: dashWidth,
|
|
@@ -228,7 +228,7 @@ export const getHorizSectionVals = (props: horizSectionPropTypes) => {
|
|
|
228
228
|
|
|
229
229
|
const defaultReferenceConfig = {
|
|
230
230
|
thickness: rulesThickness,
|
|
231
|
-
width: (width || totalWidth -
|
|
231
|
+
width: (width || totalWidth - endSpacing) + endSpacing,
|
|
232
232
|
color: 'black',
|
|
233
233
|
type: rulesType,
|
|
234
234
|
dashWidth,
|
|
@@ -91,6 +91,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
91
91
|
var verticalLinesAr = noOfVerticalLines
|
|
92
92
|
? __spreadArray([], __read(Array(noOfVerticalLines).keys()), false) : __spreadArray([], __read(Array(stackData ? stackData.length : data.length).keys()), false);
|
|
93
93
|
var horizSectionProps = {
|
|
94
|
+
chartType: chartType,
|
|
94
95
|
width: width,
|
|
95
96
|
horizSections: horizSections,
|
|
96
97
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
package/src/utils/types.d.ts
CHANGED