gifted-charts-core 0.1.70 → 0.1.71

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.
@@ -64,7 +64,6 @@ export interface stackDataItem {
64
64
  verticalLineStrokeDashArray?: number[];
65
65
  verticalLineShift?: number;
66
66
  verticalLineZIndex?: number;
67
- noOfVerticalLine?: number;
68
67
  verticalLineSpacing?: number;
69
68
  verticalLineStrokeLinecap?: Linecap;
70
69
  }
@@ -385,6 +384,7 @@ export interface lineConfigType {
385
384
  dataPointsHeight?: number;
386
385
  dataPointsColor?: ColorValue | string | any;
387
386
  dataPointsRadius?: number;
387
+ dataPointLabelComponent?: (item: lineDataItem, index: number) => ReactNode;
388
388
  textColor?: ColorValue | string | any;
389
389
  textFontSize?: number;
390
390
  textShiftX?: number;
@@ -401,6 +401,7 @@ export interface lineConfigType {
401
401
  focusedDataPointColor?: ColorValue;
402
402
  focusedDataPointRadius?: number;
403
403
  focusedDataPointIndex?: number;
404
+ showDataPointLabelOnFocus?: boolean;
404
405
  }
405
406
  export interface defaultLineConfigType {
406
407
  initialSpacing: number;
@@ -418,6 +419,7 @@ export interface defaultLineConfigType {
418
419
  dataPointsHeight: number;
419
420
  dataPointsColor: ColorValue | string | any;
420
421
  dataPointsRadius: number;
422
+ dataPointLabelComponent?: (item: lineDataItem, index: number) => ReactNode;
421
423
  textColor: ColorValue | string | any;
422
424
  textFontSize: number;
423
425
  textShiftX: number;
@@ -433,6 +435,7 @@ export interface defaultLineConfigType {
433
435
  focusEnabled: boolean;
434
436
  focusedDataPointColor: ColorValue;
435
437
  focusedDataPointRadius: number;
438
+ showDataPointLabelOnFocus: boolean;
436
439
  }
437
440
  interface arrowType {
438
441
  length?: number;
@@ -499,7 +502,6 @@ export interface barDataItem {
499
502
  verticalLineStrokeDashArray?: number[];
500
503
  verticalLineShift?: number;
501
504
  verticalLineZIndex?: number;
502
- noOfVerticalLine?: number;
503
505
  verticalLineSpacing?: number;
504
506
  verticalLineStrokeLinecap?: Linecap;
505
507
  }
@@ -1406,20 +1406,30 @@ export var useLineChart = function (props) {
1406
1406
  };
1407
1407
  var pointerItemLocal = [];
1408
1408
  if (pointerConfig) {
1409
- pointerItemLocal = [
1410
- __assign(__assign({}, pointerItem), { value: (_330 = (_329 = props.data) === null || _329 === void 0 ? void 0 : _329[pointerIndex]) === null || _330 === void 0 ? void 0 : _330.value })
1411
- ];
1412
- if (pointerY2 !== 0) {
1413
- pointerItemLocal.push(__assign(__assign({}, pointerItem), { value: (_332 = (_331 = props.data2) === null || _331 === void 0 ? void 0 : _331[pointerIndex]) === null || _332 === void 0 ? void 0 : _332.value }));
1414
- }
1415
- if (pointerY3 !== 0) {
1416
- pointerItemLocal.push(__assign(__assign({}, pointerItem), { value: (_334 = (_333 = props.data3) === null || _333 === void 0 ? void 0 : _333[pointerIndex]) === null || _334 === void 0 ? void 0 : _334.value }));
1417
- }
1418
- if (pointerY4 !== 0) {
1419
- pointerItemLocal.push(__assign(__assign({}, pointerItem), { value: (_336 = (_335 = props.data4) === null || _335 === void 0 ? void 0 : _335[pointerIndex]) === null || _336 === void 0 ? void 0 : _336.value }));
1409
+ if (dataSet) {
1410
+ pointerItemLocal = dataSet.map(function (dataItem) {
1411
+ var _a, _b, _c;
1412
+ return ({
1413
+ value: (_c = (_b = (_a = dataItem === null || dataItem === void 0 ? void 0 : dataItem.data) === null || _a === void 0 ? void 0 : _a[pointerIndex]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : 0
1414
+ });
1415
+ });
1420
1416
  }
1421
- if (pointerY5 !== 0) {
1422
- pointerItemLocal.push(__assign(__assign({}, pointerItem), { value: (_338 = (_337 = props.data5) === null || _337 === void 0 ? void 0 : _337[pointerIndex]) === null || _338 === void 0 ? void 0 : _338.value }));
1417
+ else {
1418
+ pointerItemLocal = [
1419
+ __assign(__assign({}, pointerItem), { value: (_330 = (_329 = props.data) === null || _329 === void 0 ? void 0 : _329[pointerIndex]) === null || _330 === void 0 ? void 0 : _330.value })
1420
+ ];
1421
+ if (pointerY2 !== 0) {
1422
+ pointerItemLocal.push(__assign(__assign({}, pointerItem), { value: (_332 = (_331 = props.data2) === null || _331 === void 0 ? void 0 : _331[pointerIndex]) === null || _332 === void 0 ? void 0 : _332.value }));
1423
+ }
1424
+ if (pointerY3 !== 0) {
1425
+ pointerItemLocal.push(__assign(__assign({}, pointerItem), { value: (_334 = (_333 = props.data3) === null || _333 === void 0 ? void 0 : _333[pointerIndex]) === null || _334 === void 0 ? void 0 : _334.value }));
1426
+ }
1427
+ if (pointerY4 !== 0) {
1428
+ pointerItemLocal.push(__assign(__assign({}, pointerItem), { value: (_336 = (_335 = props.data4) === null || _335 === void 0 ? void 0 : _335[pointerIndex]) === null || _336 === void 0 ? void 0 : _336.value }));
1429
+ }
1430
+ if (pointerY5 !== 0) {
1431
+ pointerItemLocal.push(__assign(__assign({}, pointerItem), { value: (_338 = (_337 = props.data5) === null || _337 === void 0 ? void 0 : _337[pointerIndex]) === null || _338 === void 0 ? void 0 : _338.value }));
1432
+ }
1423
1433
  }
1424
1434
  }
1425
1435
  return {
@@ -388,7 +388,6 @@ export interface lineDataItem {
388
388
  verticalLineStrokeDashArray?: number[];
389
389
  verticalLineShift?: number;
390
390
  verticalLineZIndex?: number;
391
- noOfVerticalLine?: number;
392
391
  verticalLineSpacing?: number;
393
392
  verticalLineStrokeLinecap?: Linecap;
394
393
  pointerShiftX?: number;
@@ -42,7 +42,7 @@ export var getPieChartMainProps = function (props) {
42
42
  var isThreeD = props.isThreeD, isBiggerPie = props.isBiggerPie, paddingHorizontal = props.paddingHorizontal, paddingVertical = props.paddingVertical, extraRadius = props.extraRadius, showExternalLabels = props.showExternalLabels, externalLabelComponent = props.externalLabelComponent, showTooltip = props.showTooltip, tooltipWidth = props.tooltipWidth, persistTooltip = props.persistTooltip, tooltipComponent = props.tooltipComponent, _13 = props.tooltipDuration, tooltipDuration = _13 === void 0 ? PieTooltipDefaults.tooltipDuration : _13, _14 = props.tooltipVerticalShift, tooltipVerticalShift = _14 === void 0 ? PieTooltipDefaults.tooltipVerticalShift : _14, _15 = props.tooltipHorizontalShift, tooltipHorizontalShift = _15 === void 0 ? PieTooltipDefaults.tooltipHorizontalShift : _15, _16 = props.showValuesAsTooltipText, showValuesAsTooltipText = _16 === void 0 ? PieTooltipDefaults.showValuesAsTooltipText : _16, _17 = props.tooltipTextNoOfLines, tooltipTextNoOfLines = _17 === void 0 ? PieTooltipDefaults.tooltipTextNoOfLines : _17, _18 = props.tooltipBackgroundColor, tooltipBackgroundColor = _18 === void 0 ? PieTooltipDefaults.tooltipBackgroundColor : _18, _19 = props.tooltipBorderRadius, tooltipBorderRadius = _19 === void 0 ? PieTooltipDefaults.tooltipBorderRadius : _19, font = props.font, fontWeight = props.fontWeight, fontStyle = props.fontStyle, edgesPressable = props.edgesPressable, tooltipSelectedIndex = props.tooltipSelectedIndex, setTooltipSelectedIndex = props.setTooltipSelectedIndex;
43
43
  var propData = props.data;
44
44
  var data = [];
45
- var minisculeDataItem = props.data.map(function (item) { return item.value; }).reduce(function (v, a) { return v + a; }) / 160000;
45
+ var minisculeDataItem = props.data.map(function (item) { return item.value; }).reduce(function (v, a) { return v + a; }, 0) / 160000;
46
46
  var itemHasInnerComponent = false;
47
47
  if (propData) {
48
48
  for (var i = 0; i < propData.length; i++) {
@@ -132,7 +132,7 @@ export var getPieChartMainProps = function (props) {
132
132
  var cy = radius;
133
133
  total =
134
134
  data && data.length > 0
135
- ? data.map(function (item) { return item.value; }).reduce(function (v, a) { return v + a; })
135
+ ? data.map(function (item) { return item.value; }).reduce(function (v, a) { return v + a; }, 0)
136
136
  : 0;
137
137
  var acc = 0;
138
138
  var pData = data.map(function (item) {
@@ -60,7 +60,8 @@ export var usePopulationPyramid = function (props) {
60
60
  : height;
61
61
  var stepHeight = (_s = props.stepHeight) !== null && _s !== void 0 ? _s : containerHeight / noOfSections;
62
62
  var xAxisLabelsHeight = 30;
63
- var containerHeightWithXaxisLabels = containerHeight + xAxisLabelsHeight + Math.max(0, xAxisLabelShiftY);
63
+ var additionalHeightForShift = Math.max(0, xAxisLabelShiftY || 0);
64
+ var containerHeightWithXaxisLabels = containerHeight + xAxisLabelsHeight + additionalHeightForShift;
64
65
  var mid = (width + yAxisLabelWidth) / 2;
65
66
  var leftMax = Math.max.apply(Math, __spreadArray([], __read(data.map(function (item) { return item.left; })), false));
66
67
  var rightMax = Math.max.apply(Math, __spreadArray([], __read(data.map(function (item) { return item.right; })), false));
@@ -44,7 +44,6 @@ export declare const useBarAndLineChartsWrapper: (props: BarAndLineChartsWrapper
44
44
  verticalLineStrokeDashArray: any;
45
45
  verticalLineShift: any;
46
46
  verticalLineZIndex: any;
47
- noOfVerticalLine: any;
48
47
  verticalLineSpacing: any;
49
48
  verticalLineStrokeLinecap: any;
50
49
  }[];
@@ -99,7 +99,7 @@ export var useBarAndLineChartsWrapper = function (props) {
99
99
  var secondaryXAxis = axesAndRulesProps.secondaryXAxis;
100
100
  var verticalLinesAr = noOfVerticalLines
101
101
  ? __spreadArray([], __read(Array(noOfVerticalLines).keys()), false) : (stackData !== null && stackData !== void 0 ? stackData : data).map(function (item) {
102
- var showVerticalLine = item.showVerticalLine, verticalLineThickness = item.verticalLineThickness, verticalLineHeight = item.verticalLineHeight, verticalLineColor = item.verticalLineColor, verticalLineStrokeDashArray = item.verticalLineStrokeDashArray, verticalLineShift = item.verticalLineShift, verticalLineZIndex = item.verticalLineZIndex, noOfVerticalLine = item.noOfVerticalLine, verticalLineSpacing = item.verticalLineSpacing, verticalLineStrokeLinecap = item.verticalLineStrokeLinecap;
102
+ var showVerticalLine = item.showVerticalLine, verticalLineThickness = item.verticalLineThickness, verticalLineHeight = item.verticalLineHeight, verticalLineColor = item.verticalLineColor, verticalLineStrokeDashArray = item.verticalLineStrokeDashArray, verticalLineShift = item.verticalLineShift, verticalLineZIndex = item.verticalLineZIndex, verticalLineSpacing = item.verticalLineSpacing, verticalLineStrokeLinecap = item.verticalLineStrokeLinecap;
103
103
  return {
104
104
  showVerticalLine: showVerticalLine,
105
105
  verticalLineThickness: verticalLineThickness,
@@ -108,7 +108,6 @@ export var useBarAndLineChartsWrapper = function (props) {
108
108
  verticalLineStrokeDashArray: verticalLineStrokeDashArray,
109
109
  verticalLineShift: verticalLineShift,
110
110
  verticalLineZIndex: verticalLineZIndex,
111
- noOfVerticalLine: noOfVerticalLine,
112
111
  verticalLineSpacing: verticalLineSpacing,
113
112
  verticalLineStrokeLinecap: verticalLineStrokeLinecap
114
113
  };
@@ -216,7 +216,8 @@ export var defaultLineConfig = {
216
216
  isSecondary: false,
217
217
  focusEnabled: false,
218
218
  focusedDataPointColor: LineDefaults.focusedDataPointColor,
219
- focusedDataPointRadius: LineDefaults.dataPointsRadius
219
+ focusedDataPointRadius: LineDefaults.dataPointsRadius,
220
+ showDataPointLabelOnFocus: LineDefaults.showDataPointLabelOnFocus
220
221
  };
221
222
  export var defaultPointerConfig = {
222
223
  height: 0,
@@ -796,7 +796,7 @@ export var clone = function (obj) {
796
796
  return temp;
797
797
  };
798
798
  export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
799
- 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, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23;
799
+ 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, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
800
800
  return {
801
801
  initialSpacing: (_b = (_a = lineConfig.initialSpacing) !== null && _a !== void 0 ? _a : barInitialSpacing) !== null && _b !== void 0 ? _b : defaultLineConfig.initialSpacing,
802
802
  spacing: lineConfig.spacing,
@@ -814,6 +814,7 @@ export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
814
814
  dataPointsWidth: (_p = lineConfig.dataPointsWidth) !== null && _p !== void 0 ? _p : defaultLineConfig.dataPointsWidth,
815
815
  dataPointsColor: (_q = lineConfig.dataPointsColor) !== null && _q !== void 0 ? _q : defaultLineConfig.dataPointsColor,
816
816
  dataPointsRadius: (_r = lineConfig.dataPointsRadius) !== null && _r !== void 0 ? _r : defaultLineConfig.dataPointsRadius,
817
+ dataPointLabelComponent: lineConfig.dataPointLabelComponent,
817
818
  textColor: (_s = lineConfig.textColor) !== null && _s !== void 0 ? _s : defaultLineConfig.textColor,
818
819
  textFontSize: (_t = lineConfig.textFontSize) !== null && _t !== void 0 ? _t : defaultLineConfig.textFontSize,
819
820
  textShiftX: (_u = lineConfig.textShiftX) !== null && _u !== void 0 ? _u : defaultLineConfig.textShiftX,
@@ -839,7 +840,8 @@ export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
839
840
  focusEnabled: (_21 = lineConfig.focusEnabled) !== null && _21 !== void 0 ? _21 : defaultLineConfig.focusEnabled,
840
841
  focusedDataPointColor: (_22 = lineConfig.focusedDataPointColor) !== null && _22 !== void 0 ? _22 : defaultLineConfig.focusedDataPointColor,
841
842
  focusedDataPointRadius: (_23 = lineConfig.focusedDataPointRadius) !== null && _23 !== void 0 ? _23 : defaultLineConfig.focusedDataPointRadius,
842
- focusedDataPointIndex: lineConfig.focusedDataPointIndex
843
+ focusedDataPointIndex: lineConfig.focusedDataPointIndex,
844
+ showDataPointLabelOnFocus: (_24 = lineConfig.showDataPointLabelOnFocus) !== null && _24 !== void 0 ? _24 : defaultLineConfig.showDataPointLabelOnFocus
843
845
  };
844
846
  };
845
847
  export var getNoOfSections = function (noOfSections, maxValue, stepValue) {
@@ -169,6 +169,8 @@ export interface DataPointProps {
169
169
  selectedIndex: number;
170
170
  yAxisOffset: number;
171
171
  opacity: number;
172
+ svgHeight: number;
173
+ totalWidth: number;
172
174
  }
173
175
  export interface referenceConfigType {
174
176
  thickness?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.1.70",
3
+ "version": "0.1.71",
4
4
  "description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
5
5
  "main": "./dist/index.js",
6
6
  "files": [