gifted-charts-core 0.1.71 → 0.1.74

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/dist/index.js CHANGED
@@ -10,6 +10,10 @@ export { useRenderBars } from './BarChart/RenderBars';
10
10
  /************************************************************************************************************************/
11
11
  export { useLineChart } from './LineChart';
12
12
  export { useLineChartBiColor } from './LineChart/LineChartBiColor';
13
+ /************************************************************************************************************************
14
+ /***************************************** Bubble Chart *****************************************
15
+ /************************************************************************************************************************/
16
+ export { useBubbleChart } from './BubbleChart';
13
17
  /***********************************************************************************************************************
14
18
  /***************************************** Pie Chart *****************************************
15
19
  /***********************************************************************************************************************/
@@ -4,7 +4,8 @@ import { type FontStyle } from 'react-native-svg';
4
4
  export declare enum chartTypes {
5
5
  BAR = 0,
6
6
  LINE = 1,
7
- LINE_BI_COLOR = 2
7
+ LINE_BI_COLOR = 2,
8
+ BUBBLE = 3
8
9
  }
9
10
  export declare const defaultCurvature = 0.2;
10
11
  export declare const defaultAnimationDuration = 800;
@@ -175,6 +176,12 @@ export declare const LineDefaults: {
175
176
  highlightEnabled: boolean;
176
177
  lowlightOpacity: number;
177
178
  };
179
+ export declare const BubbleDefaults: {
180
+ borderWidth: number;
181
+ borderColor: string;
182
+ opacity: number;
183
+ dataPointsColor: string;
184
+ };
178
185
  export declare const defaultLineConfig: defaultLineConfigType;
179
186
  export declare const defaultPointerConfig: {
180
187
  height: number;
@@ -309,6 +316,11 @@ export declare const radarChartDefaults: {
309
316
  showGradient: boolean;
310
317
  opacity: number;
311
318
  };
319
+ chartContainerProps: {
320
+ shiftX: number;
321
+ shiftY: number;
322
+ backgroundColor: string;
323
+ };
312
324
  asterLineStrokeDashArray: number[];
313
325
  isAnimated: boolean;
314
326
  animationDuration: number;
@@ -5,6 +5,7 @@ export var chartTypes;
5
5
  chartTypes[chartTypes["BAR"] = 0] = "BAR";
6
6
  chartTypes[chartTypes["LINE"] = 1] = "LINE";
7
7
  chartTypes[chartTypes["LINE_BI_COLOR"] = 2] = "LINE_BI_COLOR";
8
+ chartTypes[chartTypes["BUBBLE"] = 3] = "BUBBLE";
8
9
  })(chartTypes || (chartTypes = {}));
9
10
  export var defaultCurvature = 0.2;
10
11
  var defaultCurveType = CurveType.CUBIC;
@@ -187,6 +188,13 @@ export var LineDefaults = {
187
188
  highlightEnabled: false,
188
189
  lowlightOpacity: 0.3
189
190
  };
191
+ // Bubble chart specific
192
+ export var BubbleDefaults = {
193
+ borderWidth: 0,
194
+ borderColor: '#333',
195
+ opacity: 0.8,
196
+ dataPointsColor: 'skyblue'
197
+ };
190
198
  export var defaultLineConfig = {
191
199
  initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
192
200
  curved: false,
@@ -217,7 +225,8 @@ export var defaultLineConfig = {
217
225
  focusEnabled: false,
218
226
  focusedDataPointColor: LineDefaults.focusedDataPointColor,
219
227
  focusedDataPointRadius: LineDefaults.dataPointsRadius,
220
- showDataPointLabelOnFocus: LineDefaults.showDataPointLabelOnFocus
228
+ showDataPointLabelOnFocus: LineDefaults.showDataPointLabelOnFocus,
229
+ setFocusedDataPointIndex: function () { }
221
230
  };
222
231
  export var defaultPointerConfig = {
223
232
  height: 0,
@@ -259,14 +268,14 @@ export var defaultPointerConfig = {
259
268
  };
260
269
  // Pie chart specific
261
270
  export var pieColors = [
262
- 'cyan',
263
- 'green',
264
- 'orange',
265
- 'purple',
266
- '#bbff00',
267
- 'red',
268
- 'blue',
269
- 'pink'
271
+ '#ccc',
272
+ '#888',
273
+ '#bbb',
274
+ '#777',
275
+ '#aaa',
276
+ '#666',
277
+ '#999',
278
+ '#555'
270
279
  ];
271
280
  export var populationDefaults = {
272
281
  height: 200,
@@ -363,6 +372,11 @@ export var radarChartDefaults = {
363
372
  showGradient: false,
364
373
  opacity: 0.7
365
374
  },
375
+ chartContainerProps: {
376
+ shiftX: 0,
377
+ shiftY: 0,
378
+ backgroundColor: 'transparent'
379
+ },
366
380
  asterLineStrokeDashArray: [4, 4],
367
381
  isAnimated: false,
368
382
  animationDuration: 800,
@@ -1,7 +1,7 @@
1
1
  import { type ColorValue } from 'react-native';
2
2
  import { lineDataItemNullSafe, type IDataSanitisationProps, type lineDataItem } from '../LineChart/types';
3
3
  import { type arrowConfigType, CurveType, type HighlightedRange, type LineProperties, type LineSegment, Framework, referenceConfigType, secondaryYAxisType } from './types';
4
- import { type lineConfigType, type BarChartPropsType, type FocusedBarConfig, type barDataItem, barDataItemNullSafe } from '../BarChart/types';
4
+ import { type lineConfigType, type BarChartPropsType, type FocusedBarConfig, type barDataItem, barDataItemNullSafe, lineConfigWithSetFocusedDataPointIndexType } from '../BarChart/types';
5
5
  import { type extendedLineChartPropsType } from '../LineChart';
6
6
  import { type extendedBarChartPropsType } from '../BarChart';
7
7
  export declare const getCumulativeWidth: (data: any, index: number, spacing: number) => number;
@@ -93,7 +93,7 @@ export declare const getLabelTextUtil: (val: string, index: number, showFraction
93
93
  export declare const getXForLineInBar: (index: number, firstBarWidth: number, currentBarWidth: number, yAxisLabelWidth: number, lineConfig: any, spacing: number) => number;
94
94
  export declare const getYForLineInBar: (value: number | undefined, shiftY: number | undefined, containerHeight: number, maxValue: number, yAxisOffset: number) => number;
95
95
  export declare const clone: (obj: any) => any;
96
- export declare const getLineConfigForBarChart: (lineConfig: lineConfigType, barInitialSpacing: number) => lineConfigType;
96
+ export declare const getLineConfigForBarChart: (lineConfig: lineConfigType, barInitialSpacing: number, focusedDataPointIndex: number, setFocusedDataPointIndex: (i: number) => void) => lineConfigWithSetFocusedDataPointIndexType;
97
97
  export declare const getNoOfSections: (noOfSections: number | undefined, maxValue: number | undefined, stepValue: number | undefined) => number;
98
98
  export declare const getMaxValue: (maxValue: number | undefined, stepValue: number | undefined, noOfSections: number, maxItem: number) => number;
99
99
  export declare const getMostNegativeValue: (minValue: number | undefined, stepValue: number | undefined, noOfSections: number | undefined, minItem: number) => number;
@@ -494,7 +494,7 @@ export var getArrowPoints = function (arrowTipX, arrowTipY, x1, y1, arrowLength,
494
494
  return arrowPoints;
495
495
  };
496
496
  export var getAxesAndRulesProps = function (props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits) {
497
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
497
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
498
498
  var secondaryYAxis = typeof props.secondaryYAxis === 'boolean' ? {} : props.secondaryYAxis;
499
499
  var axesAndRulesProps = {
500
500
  yAxisSide: props.yAxisSide,
@@ -576,15 +576,19 @@ export var getAxesAndRulesProps = function (props, containerHeight, stepHeight,
576
576
  secondaryYAxis.maxValue === undefined) {
577
577
  axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue: secondaryMaxValue });
578
578
  }
579
- var secondaryNoOfSections = (_j = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSections) !== null && _j !== void 0 ? _j : noOfSections;
580
- var secondaryStepValue = (_k = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepValue) !== null && _k !== void 0 ? _k : ((_l = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _l !== void 0 ? _l : secondaryMaxValue) / secondaryNoOfSections;
581
- var secondaryStepHeight = (_m = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight) !== null && _m !== void 0 ? _m : containerHeight / secondaryNoOfSections;
582
- var secondaryNegativeStepValue = (_o = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepValue) !== null && _o !== void 0 ? _o : secondaryStepValue;
583
- var secondaryNoOfSectionsBelowXAxis = (_p = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSectionsBelowXAxis) !== null && _p !== void 0 ? _p : (secondaryNegativeStepValue
584
- ? Math.ceil(((_q = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue) !== null && _q !== void 0 ? _q : secondaryMinItem) /
579
+ var secondaryNoOfSections = ((_j = props.secondaryYAxis) !== null && _j !== void 0 ? _j : (_k = props.lineConfig) === null || _k === void 0 ? void 0 : _k.isSecondary)
580
+ ? (_l = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSections) !== null && _l !== void 0 ? _l : noOfSections
581
+ : 0;
582
+ var secondaryStepValue = (_m = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepValue) !== null && _m !== void 0 ? _m : (secondaryNoOfSections
583
+ ? ((_o = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _o !== void 0 ? _o : secondaryMaxValue) / secondaryNoOfSections
584
+ : 0);
585
+ var secondaryStepHeight = (_p = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight) !== null && _p !== void 0 ? _p : (secondaryNoOfSections ? containerHeight / secondaryNoOfSections : 0);
586
+ var secondaryNegativeStepValue = (_q = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepValue) !== null && _q !== void 0 ? _q : secondaryStepValue;
587
+ var secondaryNoOfSectionsBelowXAxis = (_r = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSectionsBelowXAxis) !== null && _r !== void 0 ? _r : (secondaryNegativeStepValue
588
+ ? Math.ceil(((_s = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue) !== null && _s !== void 0 ? _s : secondaryMinItem) /
585
589
  -secondaryNegativeStepValue)
586
590
  : 0);
587
- axesAndRulesProps.secondaryYAxisConfig = __assign(__assign({}, secondaryYAxis), { stepHeight: secondaryStepHeight, stepValue: secondaryStepValue, negativeStepHeight: (_r = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepHeight) !== null && _r !== void 0 ? _r : secondaryStepHeight, negativeStepValue: secondaryNegativeStepValue, noOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis, showFractionalValues: showSecondaryFractionalValues, roundToDigits: secondaryRoundToDigits });
591
+ axesAndRulesProps.secondaryYAxisConfig = __assign(__assign({}, secondaryYAxis), { stepHeight: secondaryStepHeight, stepValue: secondaryStepValue, negativeStepHeight: (_t = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepHeight) !== null && _t !== void 0 ? _t : secondaryStepHeight, negativeStepValue: secondaryNegativeStepValue, noOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis, showFractionalValues: showSecondaryFractionalValues, roundToDigits: secondaryRoundToDigits });
588
592
  return axesAndRulesProps;
589
593
  };
590
594
  export var getExtendedContainerHeightWithPadding = function (containerHeight, overflowTop) { return containerHeight + (overflowTop !== null && overflowTop !== void 0 ? overflowTop : 0) + 10; };
@@ -795,7 +799,7 @@ export var clone = function (obj) {
795
799
  }
796
800
  return temp;
797
801
  };
798
- export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
802
+ export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing, focusedDataPointIndex, setFocusedDataPointIndex) {
799
803
  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
804
  return {
801
805
  initialSpacing: (_b = (_a = lineConfig.initialSpacing) !== null && _a !== void 0 ? _a : barInitialSpacing) !== null && _b !== void 0 ? _b : defaultLineConfig.initialSpacing,
@@ -840,7 +844,8 @@ export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
840
844
  focusEnabled: (_21 = lineConfig.focusEnabled) !== null && _21 !== void 0 ? _21 : defaultLineConfig.focusEnabled,
841
845
  focusedDataPointColor: (_22 = lineConfig.focusedDataPointColor) !== null && _22 !== void 0 ? _22 : defaultLineConfig.focusedDataPointColor,
842
846
  focusedDataPointRadius: (_23 = lineConfig.focusedDataPointRadius) !== null && _23 !== void 0 ? _23 : defaultLineConfig.focusedDataPointRadius,
843
- focusedDataPointIndex: lineConfig.focusedDataPointIndex,
847
+ focusedDataPointIndex: focusedDataPointIndex,
848
+ setFocusedDataPointIndex: setFocusedDataPointIndex,
844
849
  showDataPointLabelOnFocus: (_24 = lineConfig.showDataPointLabelOnFocus) !== null && _24 !== void 0 ? _24 : defaultLineConfig.showDataPointLabelOnFocus
845
850
  };
846
851
  };
@@ -132,6 +132,7 @@ export interface ExtendedLineConfigType extends lineConfigType {
132
132
  startIndex: number;
133
133
  endIndex: number;
134
134
  dataPointsHeight: number;
135
+ setFocusedDataPointIndex: (i: number) => void;
135
136
  }
136
137
  export interface LineInBarChartPropsType {
137
138
  yAxisLabelWidth: number;
@@ -507,4 +508,11 @@ export interface ColorFromToY {
507
508
  to: number;
508
509
  color: ColorValue;
509
510
  }
511
+ export interface RadarChartContainerProps {
512
+ height?: number;
513
+ width?: number;
514
+ shiftX?: number;
515
+ shiftY?: number;
516
+ backgroundColor?: ColorValue;
517
+ }
510
518
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.1.71",
3
+ "version": "0.1.74",
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": [