gifted-charts-core 0.1.38 → 0.1.40

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.
@@ -275,10 +275,10 @@ export var useLineChart = function (props) {
275
275
  var valuesRange = Math.max.apply(Math, __spreadArray([], __read(mergedPrimaryDataArrays.map(function (i) { return Math.max(i.value, 0); })), false)) - // find the largest +ve number
276
276
  Math.min.apply(// find the largest +ve number
277
277
  Math, __spreadArray([], __read(mergedPrimaryDataArrays.map(function (i) { return Math.max(i.value, 0); })), false)); // find the smallest +ve number
278
- var showFractionalValues = (_104 = props.showFractionalValues) !== null && _104 !== void 0 ? _104 : valuesRange <= 1;
278
+ var showFractionalValues = (_104 = props.showFractionalValues) !== null && _104 !== void 0 ? _104 : (isFinite(valuesRange) && valuesRange <= 1);
279
279
  var roundToDigits = (_105 = props.roundToDigits) !== null && _105 !== void 0 ? _105 : (showFractionalValues ? indexOfFirstNonZeroDigit(valuesRange) + 1 : 0);
280
280
  var _352 = computeMaxAndMinItems(mergedPrimaryDataArrays, roundToDigits, showFractionalValues), maxItem = _352.maxItem, minItem = _352.minItem;
281
- var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxItem);
281
+ var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxItem) || 10;
282
282
  var mostNegativeValue = (_106 = props.mostNegativeValue) !== null && _106 !== void 0 ? _106 : minItem;
283
283
  var overflowTop = ((_107 = props.overflowTop) !== null && _107 !== void 0 ? _107 : props.secondaryXAxis)
284
284
  ? AxesAndRulesDefaults.overflowTopWithSecondaryXAxis
@@ -85,4 +85,6 @@ export declare const getPieChartMainProps: (props: PieChartMainProps) => {
85
85
  localExternalLabelComponent: ((item?: pieDataItem, index?: number) => any) | undefined;
86
86
  isRightHalf: boolean;
87
87
  };
88
+ coordinates: any[];
89
+ onPressed: (item: pieDataItem, index: number) => void;
88
90
  };
@@ -209,6 +209,41 @@ export var getPieChartMainProps = function (props) {
209
209
  isRightHalf: isRightHalf
210
210
  };
211
211
  };
212
+ var coordinates = [];
213
+ data.forEach(function (item, index) {
214
+ var nextItem;
215
+ if (index === pData.length - 1)
216
+ nextItem = pData[0];
217
+ else
218
+ nextItem = pData[index + 1];
219
+ var sx = cx * (1 + Math.sin(2 * pi * pData[index] + initialAngle)) +
220
+ (item.shiftX || 0);
221
+ var sy = cy * (1 - Math.cos(2 * pi * pData[index] + initialAngle)) +
222
+ (item.shiftY || 0);
223
+ var ax = cx * (1 + Math.sin(2 * pi * nextItem + initialAngle)) +
224
+ (item.shiftX || 0);
225
+ var ay = cy * (1 - Math.cos(2 * pi * nextItem + initialAngle)) +
226
+ (item.shiftY || 0);
227
+ coordinates[index] = { sx: sx, sy: sy, ax: ax, ay: ay };
228
+ });
229
+ var onPressed = function (item, index) {
230
+ if (item.onPress) {
231
+ item.onPress();
232
+ }
233
+ else if (props.onPress) {
234
+ props.onPress(item, index);
235
+ }
236
+ if (props.focusOnPress) {
237
+ if (props.selectedIndex === index || props.isBiggerPie) {
238
+ if (toggleFocusOnPress) {
239
+ props.setSelectedIndex(-1);
240
+ }
241
+ }
242
+ else {
243
+ props.setSelectedIndex(index);
244
+ }
245
+ }
246
+ };
212
247
  return {
213
248
  isThreeD: isThreeD,
214
249
  isBiggerPie: isBiggerPie,
@@ -259,6 +294,8 @@ export var getPieChartMainProps = function (props) {
259
294
  showExternalLabels: showExternalLabels,
260
295
  labelLineConfig: labelLineConfig,
261
296
  externalLabelComponent: externalLabelComponent,
262
- getExternaLabelProperties: getExternaLabelProperties
297
+ getExternaLabelProperties: getExternaLabelProperties,
298
+ coordinates: coordinates,
299
+ onPressed: onPressed
263
300
  };
264
301
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
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": [