gifted-charts-core 0.1.39 → 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.
@@ -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.39",
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": [