gifted-charts-core 0.1.25 → 0.1.26

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.
@@ -9,6 +9,7 @@ export interface stackDataItem {
9
9
  onLongPress?: any;
10
10
  onPressOut?: any;
11
11
  label?: string;
12
+ labelWidth?: number;
12
13
  labelsDistanceFromXaxis?: number;
13
14
  barWidth?: number;
14
15
  spacing?: number;
@@ -74,6 +75,7 @@ export interface StackedBarChartPropsType {
74
75
  onPress?: Function;
75
76
  onLongPress?: Function;
76
77
  onPressOut?: Function;
78
+ labelWidth?: number;
77
79
  rotateLabel?: boolean;
78
80
  showXAxisIndices: boolean;
79
81
  xAxisIndicesHeight: number;
@@ -25,6 +25,15 @@ var __read = (this && this.__read) || function (o, n) {
25
25
  }
26
26
  return ar;
27
27
  };
28
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
+ if (ar || !(i in from)) {
31
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32
+ ar[i] = from[i];
33
+ }
34
+ }
35
+ return to.concat(ar || Array.prototype.slice.call(from));
36
+ };
28
37
  import { useEffect, useMemo, useState } from 'react';
29
38
  import { AxesAndRulesDefaults, LineDefaults, SEGMENT_END, SEGMENT_START, chartTypes, defaultArrowConfig, defaultPointerConfig } from '../utils/constants';
30
39
  import { adjustToOffset, computeMaxAndMinItems, getAllArrowProperties, getArrowPoints, getAxesAndRulesProps, getCurvePathWithSegments, getExtendedContainerHeightWithPadding, getInterpolatedData, getLineSegmentsForMissingValues, getMaxValue, getNoOfSections, getPathWithHighlight, getSanitisedData, getSecondaryDataWithOffsetIncluded, getSegmentString, svgPath } from '../utils';
@@ -134,6 +143,9 @@ export var useLineChart = function (props) {
134
143
  var endIndex4 = (_y = props.endIndex4) !== null && _y !== void 0 ? _y : data4.length - 1;
135
144
  var startIndex5 = (_z = props.startIndex5) !== null && _z !== void 0 ? _z : 0;
136
145
  var endIndex5 = (_0 = props.endIndex5) !== null && _0 !== void 0 ? _0 : data5.length - 1;
146
+ var lengthOfLongestDataArray = Math.max(data.length, data2.length, data3.length, data4.length, data5.length);
147
+ var maxLengthOfDataOrSet = dataSet
148
+ ? Math.max.apply(Math, __spreadArray([], __read(dataSet.map(function (item) { return item.data.length; })), false)) : lengthOfLongestDataArray;
137
149
  var lineSegments = !interpolateMissingValues
138
150
  ? getLineSegmentsForMissingValues(props.data)
139
151
  : props.lineSegments;
@@ -150,9 +162,6 @@ export var useLineChart = function (props) {
150
162
  ? getLineSegmentsForMissingValues(props.data5)
151
163
  : props.lineSegments5;
152
164
  var highlightedRange = props.highlightedRange;
153
- var newPoints = '';
154
- var newFillPoints = '';
155
- var counter = 0;
156
165
  var adjustToWidth = (_1 = props.adjustToWidth) !== null && _1 !== void 0 ? _1 : false;
157
166
  var initialSpacing = (_2 = props.initialSpacing) !== null && _2 !== void 0 ? _2 : LineDefaults.initialSpacing;
158
167
  var endSpacing = (_3 = props.endSpacing) !== null && _3 !== void 0 ? _3 : (adjustToWidth ? 0 : LineDefaults.endSpacing);
@@ -233,7 +242,7 @@ export var useLineChart = function (props) {
233
242
  var textColor3 = (_93 = (_92 = props.textColor3) !== null && _92 !== void 0 ? _92 : props.textColor) !== null && _93 !== void 0 ? _93 : LineDefaults.textColor;
234
243
  var textColor4 = (_95 = (_94 = props.textColor4) !== null && _94 !== void 0 ? _94 : props.textColor) !== null && _95 !== void 0 ? _95 : LineDefaults.textColor;
235
244
  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 - 1 + endSpacing;
245
+ var totalWidth = initialSpacing + spacing * maxLengthOfDataOrSet - 1 + endSpacing;
237
246
  var _339 = computeMaxAndMinItems(data0 !== null && data0 !== void 0 ? data0 : data, props.roundToDigits, props.showFractionalValues), maxItem = _339.maxItem, minItem = _339.minItem;
238
247
  var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxItem);
239
248
  var mostNegativeValue = (_98 = props.mostNegativeValue) !== null && _98 !== void 0 ? _98 : minItem;
@@ -480,7 +489,7 @@ export var useLineChart = function (props) {
480
489
  var pp4 = '';
481
490
  var pp5 = '';
482
491
  if (!props.curved) {
483
- for (var i = 0; i < data.length; i++) {
492
+ for (var i = 0; i < lengthOfLongestDataArray; i++) {
484
493
  if (i >= startIndex1 && i <= endIndex1) {
485
494
  if (stepChart !== null && stepChart !== void 0 ? stepChart : stepChart1) {
486
495
  pp += getStepPath(data, i);
@@ -643,7 +652,7 @@ export var useLineChart = function (props) {
643
652
  var p3Array = [];
644
653
  var p4Array = [];
645
654
  var p5Array = [];
646
- for (var i = 0; i < data.length; i++) {
655
+ for (var i = 0; i < lengthOfLongestDataArray; i++) {
647
656
  if (i >= startIndex1 && i <= endIndex1) {
648
657
  p1Array.push([getX(i), getY(data[i].value)]);
649
658
  }
@@ -883,10 +883,12 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
883
883
  // 4. None has valid value -> this is already handled in preprocessing
884
884
  var pre = data.slice(0, index);
885
885
  var post = data.slice(index + 1, n);
886
- var preValidIndex = pre
886
+ var preCount = pre.length - 1;
887
+ var tempPreValidIndex = pre
887
888
  .slice()
888
889
  .reverse()
889
890
  .findIndex(function (item) { return typeof item.value === 'number'; });
891
+ var preValidIndex = tempPreValidIndex >= 0 ? preCount - tempPreValidIndex : tempPreValidIndex;
890
892
  var postValidInd = post.findIndex(function (item) { return typeof item.value === 'number'; });
891
893
  var postValidIndex = postValidInd + index + 1;
892
894
  var count, step;
@@ -903,10 +905,12 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
903
905
  // 1. There's only 1 valid value in the pre -> this is already handled in preprocessing
904
906
  // 2. There are more than valid values in pre
905
907
  var secondPre = data.slice(0, preValidIndex);
906
- var secondPreIndex = secondPre
908
+ var secondPreCount = pre.length - 1;
909
+ var tempSecondPreIndex = secondPre
907
910
  .slice()
908
911
  .reverse()
909
912
  .findIndex(function (item) { return typeof item.value === 'number'; });
913
+ var secondPreIndex = tempSecondPreIndex >= 0 ? secondPreCount - tempSecondPreIndex : tempSecondPreIndex;
910
914
  count = preValidIndex - secondPreIndex;
911
915
  step = (data[secondPreIndex].value - data[preValidIndex].value) / count;
912
916
  data[index].value =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
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": [