gifted-charts-core 0.1.15 → 0.1.16
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/package.json +1 -1
- package/src/BarChart/index.d.ts +3 -0
- package/src/BarChart/index.js +7 -4
- package/src/BarChart/index.ts +9 -1
- package/src/BarChart/types.d.ts +8 -1
- package/src/BarChart/types.ts +8 -0
- package/src/LineChart/index.js +3 -1
- package/src/LineChart/index.ts +4 -1
- package/src/LineChart/types.d.ts +5 -1
- package/src/LineChart/types.ts +6 -0
- package/src/components/BarAndLineChartsWrapper/index.js +37 -35
- package/src/components/BarAndLineChartsWrapper/index.ts +4 -3
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/index.ts +4 -3
- package/src/utils/constants.d.ts +1 -0
- package/src/utils/constants.js +1 -0
- package/src/utils/constants.ts +1 -0
- package/src/utils/index.js +11 -7
- package/src/utils/index.ts +8 -3
- package/src/utils/types.d.ts +9 -0
- package/src/utils/types.ts +10 -0
package/package.json
CHANGED
package/src/BarChart/index.d.ts
CHANGED
|
@@ -172,7 +172,9 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
172
172
|
noOfSectionsBelowXAxis: number;
|
|
173
173
|
leftShiftForLastIndexTooltip: number;
|
|
174
174
|
label: any;
|
|
175
|
+
secondaryLabel: any;
|
|
175
176
|
labelTextStyle: any;
|
|
177
|
+
secondaryLabelTextStyle: any;
|
|
176
178
|
pointerConfig: import("../utils/types").Pointer | undefined;
|
|
177
179
|
yAxisExtraHeightAtTop: number;
|
|
178
180
|
yAxisOffset: number;
|
|
@@ -181,6 +183,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
181
183
|
stepValue: number;
|
|
182
184
|
negativeStepHeight: number;
|
|
183
185
|
negativeStepValue: number;
|
|
186
|
+
secondaryXAxis: import("../utils/types").XAxisConfig | undefined;
|
|
184
187
|
};
|
|
185
188
|
barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes;
|
|
186
189
|
yAxisExtraHeightAtTop: number;
|
package/src/BarChart/index.js
CHANGED
|
@@ -394,7 +394,7 @@ export var useBarChart = function (props) {
|
|
|
394
394
|
outputRange: [0, initialSpacing + totalWidth]
|
|
395
395
|
});
|
|
396
396
|
var getPropsCommonForBarAndStack = function (item, index) {
|
|
397
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
397
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
398
398
|
return {
|
|
399
399
|
item: item,
|
|
400
400
|
index: index,
|
|
@@ -449,15 +449,18 @@ export var useBarChart = function (props) {
|
|
|
449
449
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
450
450
|
leftShiftForLastIndexTooltip: (_g = props.leftShiftForLastIndexTooltip) !== null && _g !== void 0 ? _g : 0,
|
|
451
451
|
label: (_h = item.label) !== null && _h !== void 0 ? _h : (((_j = props.xAxisLabelTexts) === null || _j === void 0 ? void 0 : _j[index]) ? props.xAxisLabelTexts[index] : ''),
|
|
452
|
-
|
|
452
|
+
secondaryLabel: (_o = (_k = item.secondaryLabel) !== null && _k !== void 0 ? _k : (_m = (_l = props.secondaryXAxis) === null || _l === void 0 ? void 0 : _l.labelTexts) === null || _m === void 0 ? void 0 : _m[index]) !== null && _o !== void 0 ? _o : '',
|
|
453
|
+
labelTextStyle: (_p = item.labelTextStyle) !== null && _p !== void 0 ? _p : props.xAxisLabelTextStyle,
|
|
454
|
+
secondaryLabelTextStyle: (_t = (_s = (_q = item.secondaryLabelTextStyle) !== null && _q !== void 0 ? _q : (_r = props.secondaryXAxis) === null || _r === void 0 ? void 0 : _r.labelsTextStyle) !== null && _s !== void 0 ? _s : item.labelTextStyle) !== null && _t !== void 0 ? _t : props.xAxisLabelTextStyle,
|
|
453
455
|
pointerConfig: pointerConfig,
|
|
454
456
|
yAxisExtraHeightAtTop: yAxisExtraHeightAtTop,
|
|
455
457
|
yAxisOffset: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0,
|
|
456
458
|
focusedBarIndex: focusedBarIndex,
|
|
457
459
|
stepHeight: stepHeight,
|
|
458
460
|
stepValue: stepValue,
|
|
459
|
-
negativeStepHeight: (
|
|
460
|
-
negativeStepValue: (
|
|
461
|
+
negativeStepHeight: (_u = props.negativeStepHeight) !== null && _u !== void 0 ? _u : stepHeight,
|
|
462
|
+
negativeStepValue: (_v = props.negativeStepValue) !== null && _v !== void 0 ? _v : stepValue,
|
|
463
|
+
secondaryXAxis: props.secondaryXAxis
|
|
461
464
|
};
|
|
462
465
|
};
|
|
463
466
|
var barAndLineChartsWrapperProps = {
|
package/src/BarChart/index.ts
CHANGED
|
@@ -695,7 +695,14 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
695
695
|
label:
|
|
696
696
|
item.label ??
|
|
697
697
|
(props.xAxisLabelTexts?.[index] ? props.xAxisLabelTexts[index] : ''),
|
|
698
|
+
secondaryLabel:
|
|
699
|
+
item.secondaryLabel ?? props.secondaryXAxis?.labelTexts?.[index] ?? '',
|
|
698
700
|
labelTextStyle: item.labelTextStyle ?? props.xAxisLabelTextStyle,
|
|
701
|
+
secondaryLabelTextStyle:
|
|
702
|
+
item.secondaryLabelTextStyle ??
|
|
703
|
+
props.secondaryXAxis?.labelsTextStyle ??
|
|
704
|
+
item.labelTextStyle ??
|
|
705
|
+
props.xAxisLabelTextStyle,
|
|
699
706
|
pointerConfig,
|
|
700
707
|
yAxisExtraHeightAtTop,
|
|
701
708
|
yAxisOffset: yAxisOffset ?? 0,
|
|
@@ -703,7 +710,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
703
710
|
stepHeight,
|
|
704
711
|
stepValue,
|
|
705
712
|
negativeStepHeight: props.negativeStepHeight ?? stepHeight,
|
|
706
|
-
negativeStepValue: props.negativeStepValue ?? stepValue
|
|
713
|
+
negativeStepValue: props.negativeStepValue ?? stepValue,
|
|
714
|
+
secondaryXAxis: props.secondaryXAxis
|
|
707
715
|
}
|
|
708
716
|
}
|
|
709
717
|
|
package/src/BarChart/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ColorValue, type GestureResponderEvent, type ViewStyle } from 'react-native';
|
|
2
2
|
import { type yAxisSides } from '../utils/constants';
|
|
3
|
-
import { type CurveType, type Pointer, type RuleType, type RulesConfig, type referenceConfigType, type secondaryYAxisType } from '../utils/types';
|
|
3
|
+
import { XAxisConfig, type CurveType, type Pointer, type RuleType, type RulesConfig, type referenceConfigType, type secondaryYAxisType } from '../utils/types';
|
|
4
4
|
import { type Component, type ReactNode } from 'react';
|
|
5
5
|
import { type lineDataItem } from '../LineChart/types';
|
|
6
6
|
export interface stackDataItem {
|
|
@@ -292,6 +292,7 @@ export interface BarChartPropsType {
|
|
|
292
292
|
focusedBarIndex?: number;
|
|
293
293
|
adjustToWidth?: boolean;
|
|
294
294
|
parentWidth?: number;
|
|
295
|
+
secondaryXAxis?: XAxisConfig;
|
|
295
296
|
}
|
|
296
297
|
export interface FocusedBarConfig {
|
|
297
298
|
color?: ColorValue;
|
|
@@ -405,6 +406,9 @@ export interface barDataItem {
|
|
|
405
406
|
topLabelComponentHeight?: number;
|
|
406
407
|
spacing?: number;
|
|
407
408
|
labelWidth?: number;
|
|
409
|
+
secondaryLabel?: string;
|
|
410
|
+
secondaryLabelComponent?: Function;
|
|
411
|
+
secondaryLabelTextStyle?: any;
|
|
408
412
|
barBackgroundPattern?: () => ReactNode;
|
|
409
413
|
patternId?: string;
|
|
410
414
|
barMarginBottom?: number;
|
|
@@ -473,9 +477,11 @@ export interface RenderBarsPropsType {
|
|
|
473
477
|
opacity?: number;
|
|
474
478
|
side?: string;
|
|
475
479
|
labelTextStyle?: any;
|
|
480
|
+
secondaryLabelTextStyle?: any;
|
|
476
481
|
item: barDataItem;
|
|
477
482
|
index: number;
|
|
478
483
|
label: string;
|
|
484
|
+
secondaryLabel: string;
|
|
479
485
|
containerHeight?: number;
|
|
480
486
|
maxValue: number;
|
|
481
487
|
spacing: number;
|
|
@@ -543,6 +549,7 @@ export interface RenderBarsPropsType {
|
|
|
543
549
|
stepValue: number;
|
|
544
550
|
negativeStepHeight: number;
|
|
545
551
|
negativeStepValue: number;
|
|
552
|
+
secondaryXAxis?: XAxisConfig;
|
|
546
553
|
}
|
|
547
554
|
export interface trianglePropTypes {
|
|
548
555
|
style: any;
|
package/src/BarChart/types.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from 'react-native'
|
|
6
6
|
import { type yAxisSides } from '../utils/constants'
|
|
7
7
|
import {
|
|
8
|
+
XAxisConfig,
|
|
8
9
|
type CurveType,
|
|
9
10
|
type Pointer,
|
|
10
11
|
type RuleType,
|
|
@@ -328,6 +329,7 @@ export interface BarChartPropsType {
|
|
|
328
329
|
|
|
329
330
|
adjustToWidth?: boolean
|
|
330
331
|
parentWidth?: number
|
|
332
|
+
secondaryXAxis?: XAxisConfig
|
|
331
333
|
}
|
|
332
334
|
|
|
333
335
|
export interface FocusedBarConfig {
|
|
@@ -445,6 +447,9 @@ export interface barDataItem {
|
|
|
445
447
|
topLabelComponentHeight?: number
|
|
446
448
|
spacing?: number
|
|
447
449
|
labelWidth?: number
|
|
450
|
+
secondaryLabel?: string
|
|
451
|
+
secondaryLabelComponent?: Function
|
|
452
|
+
secondaryLabelTextStyle?: any
|
|
448
453
|
barBackgroundPattern?: () => ReactNode
|
|
449
454
|
patternId?: string
|
|
450
455
|
barMarginBottom?: number
|
|
@@ -515,10 +520,12 @@ export interface RenderBarsPropsType {
|
|
|
515
520
|
opacity?: number
|
|
516
521
|
side?: string
|
|
517
522
|
labelTextStyle?: any
|
|
523
|
+
secondaryLabelTextStyle?: any
|
|
518
524
|
|
|
519
525
|
item: barDataItem
|
|
520
526
|
index: number
|
|
521
527
|
label: string
|
|
528
|
+
secondaryLabel: string
|
|
522
529
|
containerHeight?: number
|
|
523
530
|
maxValue: number
|
|
524
531
|
spacing: number
|
|
@@ -590,6 +597,7 @@ export interface RenderBarsPropsType {
|
|
|
590
597
|
stepValue: number
|
|
591
598
|
negativeStepHeight: number
|
|
592
599
|
negativeStepValue: number
|
|
600
|
+
secondaryXAxis?: XAxisConfig
|
|
593
601
|
}
|
|
594
602
|
|
|
595
603
|
export interface trianglePropTypes {
|
package/src/LineChart/index.js
CHANGED
|
@@ -237,7 +237,9 @@ export var useLineChart = function (props) {
|
|
|
237
237
|
var _339 = computeMaxAndMinItems(data0 !== null && data0 !== void 0 ? data0 : data, props.roundToDigits, props.showFractionalValues), maxItem = _339.maxItem, minItem = _339.minItem;
|
|
238
238
|
var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxItem);
|
|
239
239
|
var mostNegativeValue = (_98 = props.mostNegativeValue) !== null && _98 !== void 0 ? _98 : minItem;
|
|
240
|
-
var overflowTop = (_99 = props.overflowTop) !== null && _99 !== void 0 ? _99 :
|
|
240
|
+
var overflowTop = ((_99 = props.overflowTop) !== null && _99 !== void 0 ? _99 : props.secondaryXAxis)
|
|
241
|
+
? AxesAndRulesDefaults.overflowTopWithSecondaryXAxis
|
|
242
|
+
: AxesAndRulesDefaults.overflowTop;
|
|
241
243
|
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, overflowTop);
|
|
242
244
|
var getX = function (index) { return initialSpacing + spacing * index - 1; };
|
|
243
245
|
var getY = function (value) {
|
package/src/LineChart/index.ts
CHANGED
|
@@ -446,7 +446,10 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
446
446
|
|
|
447
447
|
const mostNegativeValue = props.mostNegativeValue ?? minItem
|
|
448
448
|
|
|
449
|
-
const overflowTop =
|
|
449
|
+
const overflowTop =
|
|
450
|
+
props.overflowTop ?? props.secondaryXAxis
|
|
451
|
+
? AxesAndRulesDefaults.overflowTopWithSecondaryXAxis
|
|
452
|
+
: AxesAndRulesDefaults.overflowTop
|
|
450
453
|
|
|
451
454
|
const extendedContainerHeight = getExtendedContainerHeightWithPadding(
|
|
452
455
|
containerHeight,
|
package/src/LineChart/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GestureResponderEvent, type ColorValue } from 'react-native';
|
|
2
2
|
import { type yAxisSides } from '../utils/constants';
|
|
3
|
-
import { type CurveType, type DataSet, type EdgePosition, type HighlightedRange, type LineSegment, type Pointer, type RuleType, type RulesConfig, type arrowConfigType, type referenceConfigType, type secondaryLineConfigType, type secondaryYAxisType } from '../utils/types';
|
|
3
|
+
import { XAxisConfig, type CurveType, type DataSet, type EdgePosition, type HighlightedRange, type LineSegment, type Pointer, type RuleType, type RulesConfig, type arrowConfigType, type referenceConfigType, type secondaryLineConfigType, type secondaryYAxisType } from '../utils/types';
|
|
4
4
|
export interface LineChartPropsType {
|
|
5
5
|
height?: number;
|
|
6
6
|
overflowTop?: number;
|
|
@@ -299,12 +299,16 @@ export interface LineChartPropsType {
|
|
|
299
299
|
parentWidth?: number;
|
|
300
300
|
onChartAreaPress?: (event: GestureResponderEvent) => void;
|
|
301
301
|
onBackgroundPress?: (event: GestureResponderEvent) => void;
|
|
302
|
+
secondaryXAxis?: XAxisConfig;
|
|
302
303
|
}
|
|
303
304
|
export interface lineDataItem {
|
|
304
305
|
value: number;
|
|
305
306
|
label?: string;
|
|
306
307
|
labelComponent?: Function;
|
|
307
308
|
labelTextStyle?: any;
|
|
309
|
+
secondaryLabel?: string;
|
|
310
|
+
secondaryLabelComponent?: Function;
|
|
311
|
+
secondaryLabelTextStyle?: any;
|
|
308
312
|
dataPointText?: string;
|
|
309
313
|
textShiftX?: number;
|
|
310
314
|
textShiftY?: number;
|
package/src/LineChart/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GestureResponderEvent, type ColorValue } from 'react-native'
|
|
2
2
|
import { type yAxisSides } from '../utils/constants'
|
|
3
3
|
import {
|
|
4
|
+
XAxisConfig,
|
|
4
5
|
type CurveType,
|
|
5
6
|
type DataSet,
|
|
6
7
|
type EdgePosition,
|
|
@@ -334,6 +335,8 @@ export interface LineChartPropsType {
|
|
|
334
335
|
|
|
335
336
|
onChartAreaPress?: (event: GestureResponderEvent) => void
|
|
336
337
|
onBackgroundPress?: (event: GestureResponderEvent) => void
|
|
338
|
+
|
|
339
|
+
secondaryXAxis?: XAxisConfig
|
|
337
340
|
}
|
|
338
341
|
|
|
339
342
|
export interface lineDataItem {
|
|
@@ -341,6 +344,9 @@ export interface lineDataItem {
|
|
|
341
344
|
label?: string
|
|
342
345
|
labelComponent?: Function
|
|
343
346
|
labelTextStyle?: any
|
|
347
|
+
secondaryLabel?: string
|
|
348
|
+
secondaryLabelComponent?: Function
|
|
349
|
+
secondaryLabelTextStyle?: any
|
|
344
350
|
dataPointText?: string
|
|
345
351
|
textShiftX?: number
|
|
346
352
|
textShiftY?: number
|
|
@@ -37,7 +37,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
37
37
|
import { useEffect, useState } from 'react';
|
|
38
38
|
import { AxesAndRulesDefaults, BarDefaults } from '../../utils/constants';
|
|
39
39
|
export var useBarAndLineChartsWrapper = function (props) {
|
|
40
|
-
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
|
|
40
|
+
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;
|
|
41
41
|
var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL;
|
|
42
42
|
var yAxisAtTop = rtl ? !props.yAxisAtTop : props.yAxisAtTop;
|
|
43
43
|
var hideOrigin = (_a = axesAndRulesProps.hideOrigin) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.hideOrigin;
|
|
@@ -46,48 +46,49 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
46
46
|
var yAxisColor = (_c = axesAndRulesProps.yAxisColor) !== null && _c !== void 0 ? _c : AxesAndRulesDefaults.yAxisColor;
|
|
47
47
|
var yAxisExtraHeight = (_d = axesAndRulesProps.yAxisExtraHeight) !== null && _d !== void 0 ? _d : containerHeight / 20;
|
|
48
48
|
var trimYAxisAtTop = (_e = axesAndRulesProps.trimYAxisAtTop) !== null && _e !== void 0 ? _e : AxesAndRulesDefaults.trimYAxisAtTop;
|
|
49
|
-
var overflowTop =
|
|
50
|
-
var yAxisThickness = (
|
|
51
|
-
var xAxisColor = (
|
|
49
|
+
var overflowTop = axesAndRulesProps.overflowTop;
|
|
50
|
+
var yAxisThickness = (_f = axesAndRulesProps.yAxisThickness) !== null && _f !== void 0 ? _f : AxesAndRulesDefaults.yAxisThickness;
|
|
51
|
+
var xAxisColor = (_g = axesAndRulesProps.xAxisColor) !== null && _g !== void 0 ? _g : AxesAndRulesDefaults.xAxisColor;
|
|
52
52
|
var xAxisLength = axesAndRulesProps.xAxisLength;
|
|
53
|
-
var xAxisType = (
|
|
54
|
-
var xAxisLabelsVerticalShift = (
|
|
53
|
+
var xAxisType = (_h = axesAndRulesProps.xAxisType) !== null && _h !== void 0 ? _h : AxesAndRulesDefaults.xAxisType;
|
|
54
|
+
var xAxisLabelsVerticalShift = (_j = axesAndRulesProps.xAxisLabelsVerticalShift) !== null && _j !== void 0 ? _j : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
|
|
55
55
|
var xAxisLabelsHeight = axesAndRulesProps.xAxisLabelsHeight;
|
|
56
56
|
var xAxisTextNumberOfLines = axesAndRulesProps.xAxisTextNumberOfLines;
|
|
57
|
-
var dashWidth = (
|
|
58
|
-
var dashGap = (
|
|
59
|
-
var backgroundColor = (
|
|
60
|
-
var hideRules = (
|
|
57
|
+
var dashWidth = (_k = axesAndRulesProps.dashWidth) !== null && _k !== void 0 ? _k : AxesAndRulesDefaults.dashWidth;
|
|
58
|
+
var dashGap = (_l = axesAndRulesProps.dashGap) !== null && _l !== void 0 ? _l : AxesAndRulesDefaults.dashGap;
|
|
59
|
+
var backgroundColor = (_m = axesAndRulesProps.backgroundColor) !== null && _m !== void 0 ? _m : AxesAndRulesDefaults.backgroundColor;
|
|
60
|
+
var hideRules = (_o = axesAndRulesProps.hideRules) !== null && _o !== void 0 ? _o : AxesAndRulesDefaults.hideRules;
|
|
61
61
|
var rulesLength = axesAndRulesProps.rulesLength;
|
|
62
|
-
var rulesType = (
|
|
63
|
-
var rulesThickness = (
|
|
64
|
-
var rulesColor = (
|
|
65
|
-
var rulesConfigArray = (
|
|
66
|
-
var showYAxisIndices = (
|
|
67
|
-
var yAxisIndicesHeight = (
|
|
68
|
-
var yAxisIndicesWidth = (
|
|
69
|
-
var yAxisIndicesColor = (
|
|
70
|
-
var hideYAxisText = (
|
|
71
|
-
var yAxisTextNumberOfLines = (
|
|
72
|
-
var yAxisLabelPrefix = (
|
|
73
|
-
var yAxisLabelSuffix = (
|
|
62
|
+
var rulesType = (_p = axesAndRulesProps.rulesType) !== null && _p !== void 0 ? _p : AxesAndRulesDefaults.rulesType;
|
|
63
|
+
var rulesThickness = (_q = axesAndRulesProps.rulesThickness) !== null && _q !== void 0 ? _q : AxesAndRulesDefaults.rulesThickness;
|
|
64
|
+
var rulesColor = (_r = axesAndRulesProps.rulesColor) !== null && _r !== void 0 ? _r : AxesAndRulesDefaults.rulesColor;
|
|
65
|
+
var rulesConfigArray = (_s = axesAndRulesProps.rulesConfigArray) !== null && _s !== void 0 ? _s : AxesAndRulesDefaults.rulesConfigArray;
|
|
66
|
+
var showYAxisIndices = (_t = axesAndRulesProps.showYAxisIndices) !== null && _t !== void 0 ? _t : false;
|
|
67
|
+
var yAxisIndicesHeight = (_u = axesAndRulesProps.yAxisIndicesHeight) !== null && _u !== void 0 ? _u : AxesAndRulesDefaults.yAxisIndicesHeight;
|
|
68
|
+
var yAxisIndicesWidth = (_v = axesAndRulesProps.yAxisIndicesWidth) !== null && _v !== void 0 ? _v : AxesAndRulesDefaults.yAxisIndicesWidth;
|
|
69
|
+
var yAxisIndicesColor = (_w = axesAndRulesProps.yAxisIndicesColor) !== null && _w !== void 0 ? _w : AxesAndRulesDefaults.yAxisIndicesColor;
|
|
70
|
+
var hideYAxisText = (_x = axesAndRulesProps.hideYAxisText) !== null && _x !== void 0 ? _x : AxesAndRulesDefaults.hideYAxisText;
|
|
71
|
+
var yAxisTextNumberOfLines = (_y = axesAndRulesProps.yAxisTextNumberOfLines) !== null && _y !== void 0 ? _y : AxesAndRulesDefaults.yAxisTextNumberOfLines;
|
|
72
|
+
var yAxisLabelPrefix = (_z = axesAndRulesProps.yAxisLabelPrefix) !== null && _z !== void 0 ? _z : '';
|
|
73
|
+
var yAxisLabelSuffix = (_0 = axesAndRulesProps.yAxisLabelSuffix) !== null && _0 !== void 0 ? _0 : '';
|
|
74
74
|
var yAxisTextStyle = axesAndRulesProps.yAxisTextStyle;
|
|
75
75
|
var secondaryYAxis = axesAndRulesProps.secondaryYAxis;
|
|
76
76
|
var stepValue = axesAndRulesProps.stepValue;
|
|
77
77
|
var negativeStepValue = axesAndRulesProps.negativeStepValue;
|
|
78
78
|
var roundToDigits = axesAndRulesProps.roundToDigits;
|
|
79
79
|
var referenceLinesConfig = axesAndRulesProps.referenceLinesConfig;
|
|
80
|
-
var referenceLinesOverChartContent = (
|
|
81
|
-
var showVerticalLines = (
|
|
82
|
-
var verticalLinesThickness = (
|
|
80
|
+
var referenceLinesOverChartContent = (_1 = referenceLinesConfig.referenceLinesOverChartContent) !== null && _1 !== void 0 ? _1 : AxesAndRulesDefaults.referenceLinesOverChartContent;
|
|
81
|
+
var showVerticalLines = (_2 = axesAndRulesProps.showVerticalLines) !== null && _2 !== void 0 ? _2 : AxesAndRulesDefaults.showVerticalLines;
|
|
82
|
+
var verticalLinesThickness = (_3 = axesAndRulesProps.verticalLinesThickness) !== null && _3 !== void 0 ? _3 : AxesAndRulesDefaults.verticalLinesThickness;
|
|
83
83
|
var verticalLinesHeight = axesAndRulesProps.verticalLinesHeight;
|
|
84
|
-
var verticalLinesColor = (
|
|
85
|
-
var verticalLinesStrokeDashArray = (
|
|
86
|
-
var verticalLinesShift = (
|
|
87
|
-
var verticalLinesZIndex = (
|
|
88
|
-
var verticalLinesSpacing = (
|
|
89
|
-
var verticalLinesUptoDataPoint = (
|
|
84
|
+
var verticalLinesColor = (_4 = axesAndRulesProps.verticalLinesColor) !== null && _4 !== void 0 ? _4 : AxesAndRulesDefaults.verticalLinesColor;
|
|
85
|
+
var verticalLinesStrokeDashArray = (_5 = axesAndRulesProps.verticalLinesStrokeDashArray) !== null && _5 !== void 0 ? _5 : AxesAndRulesDefaults.verticalLinesStrokeDashArray;
|
|
86
|
+
var verticalLinesShift = (_6 = axesAndRulesProps.verticalLinesShift) !== null && _6 !== void 0 ? _6 : AxesAndRulesDefaults.verticalLinesShift;
|
|
87
|
+
var verticalLinesZIndex = (_7 = axesAndRulesProps.verticalLinesZIndex) !== null && _7 !== void 0 ? _7 : AxesAndRulesDefaults.verticalLinesZIndex;
|
|
88
|
+
var verticalLinesSpacing = (_8 = axesAndRulesProps.verticalLinesSpacing) !== null && _8 !== void 0 ? _8 : AxesAndRulesDefaults.verticalLinesSpacing;
|
|
89
|
+
var verticalLinesUptoDataPoint = (_9 = axesAndRulesProps.verticalLinesUptoDataPoint) !== null && _9 !== void 0 ? _9 : AxesAndRulesDefaults.verticalLinesUptoDataPoint;
|
|
90
90
|
var noOfVerticalLines = axesAndRulesProps.noOfVerticalLines;
|
|
91
|
+
var secondaryXAxis = axesAndRulesProps.secondaryXAxis;
|
|
91
92
|
var verticalLinesAr = noOfVerticalLines
|
|
92
93
|
? __spreadArray([], __read(Array(noOfVerticalLines).keys()), false) : __spreadArray([], __read(Array(stackData ? stackData.length : data.length).keys()), false);
|
|
93
94
|
var horizSectionProps = {
|
|
@@ -149,7 +150,8 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
149
150
|
roundToDigits: roundToDigits,
|
|
150
151
|
secondaryData: secondaryData,
|
|
151
152
|
secondaryYAxis: secondaryYAxis,
|
|
152
|
-
formatYLabel: axesAndRulesProps.formatYLabel
|
|
153
|
+
formatYLabel: axesAndRulesProps.formatYLabel,
|
|
154
|
+
secondaryXAxis: secondaryXAxis
|
|
153
155
|
};
|
|
154
156
|
var lineInBarChartProps = {
|
|
155
157
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
@@ -157,7 +159,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
157
159
|
spacing: spacing,
|
|
158
160
|
containerHeight: containerHeight,
|
|
159
161
|
lineConfig: lineConfig,
|
|
160
|
-
maxValue: (
|
|
162
|
+
maxValue: (_10 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _10 !== void 0 ? _10 : maxValue,
|
|
161
163
|
animatedWidth: animatedWidth,
|
|
162
164
|
lineBehindBars: lineBehindBars,
|
|
163
165
|
points: points,
|
|
@@ -175,7 +177,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
175
177
|
var verticalLinesProps = {
|
|
176
178
|
verticalLinesAr: verticalLinesAr,
|
|
177
179
|
verticalLinesSpacing: verticalLinesSpacing,
|
|
178
|
-
spacing: (
|
|
180
|
+
spacing: (_11 = lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.spacing) !== null && _11 !== void 0 ? _11 : spacing,
|
|
179
181
|
initialSpacing: initialSpacing,
|
|
180
182
|
verticalLinesZIndex: verticalLinesZIndex,
|
|
181
183
|
verticalLinesHeight: verticalLinesHeight,
|
|
@@ -229,7 +231,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
229
231
|
: difBwWidthHeight - 40) /
|
|
230
232
|
2 +
|
|
231
233
|
(yAxisAtTop ? (rtl ? (props.width ? 12 : 40) : 12) : 52), ")");
|
|
232
|
-
var
|
|
234
|
+
var _12 = __read(useState(false), 2), canMomentum = _12[0], setCanMomentum = _12[1];
|
|
233
235
|
var isCloseToEnd = function (_a) {
|
|
234
236
|
var layoutMeasurement = _a.layoutMeasurement, contentOffset = _a.contentOffset, contentSize = _a.contentSize;
|
|
235
237
|
return isRTL
|
|
@@ -78,8 +78,7 @@ export const useBarAndLineChartsWrapper = (
|
|
|
78
78
|
axesAndRulesProps.yAxisExtraHeight ?? containerHeight / 20
|
|
79
79
|
const trimYAxisAtTop =
|
|
80
80
|
axesAndRulesProps.trimYAxisAtTop ?? AxesAndRulesDefaults.trimYAxisAtTop
|
|
81
|
-
const overflowTop =
|
|
82
|
-
axesAndRulesProps.overflowTop ?? AxesAndRulesDefaults.overflowTop
|
|
81
|
+
const overflowTop = axesAndRulesProps.overflowTop
|
|
83
82
|
const yAxisThickness =
|
|
84
83
|
axesAndRulesProps.yAxisThickness ?? AxesAndRulesDefaults.yAxisThickness
|
|
85
84
|
const xAxisColor =
|
|
@@ -162,6 +161,7 @@ export const useBarAndLineChartsWrapper = (
|
|
|
162
161
|
axesAndRulesProps.verticalLinesUptoDataPoint ??
|
|
163
162
|
AxesAndRulesDefaults.verticalLinesUptoDataPoint
|
|
164
163
|
const noOfVerticalLines = axesAndRulesProps.noOfVerticalLines
|
|
164
|
+
const secondaryXAxis = axesAndRulesProps.secondaryXAxis
|
|
165
165
|
|
|
166
166
|
const verticalLinesAr = noOfVerticalLines
|
|
167
167
|
? [...Array(noOfVerticalLines).keys()]
|
|
@@ -233,7 +233,8 @@ export const useBarAndLineChartsWrapper = (
|
|
|
233
233
|
|
|
234
234
|
secondaryData,
|
|
235
235
|
secondaryYAxis,
|
|
236
|
-
formatYLabel: axesAndRulesProps.formatYLabel
|
|
236
|
+
formatYLabel: axesAndRulesProps.formatYLabel,
|
|
237
|
+
secondaryXAxis
|
|
237
238
|
}
|
|
238
239
|
|
|
239
240
|
const lineInBarChartProps = {
|
package/src/index.d.ts
CHANGED
|
@@ -35,4 +35,4 @@ export { getTopAndLeftForStripAndLabel } from './components/common/StripAndLabel
|
|
|
35
35
|
/***********************************************************************************************************************/
|
|
36
36
|
export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset } from './utils';
|
|
37
37
|
export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
|
|
38
|
-
export { type RuleType, type RuleTypes, type RulesConfig,
|
|
38
|
+
export { type RuleType, type RuleTypes, type RulesConfig, CurveType, EdgePosition, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type horizSectionPropTypes, type HorizSectionsType, type BarAndLineChartsWrapperTypes, type Pointer, type HighlightedRange, type LineSegment, type LineSvgProps, type LineProperties, type DataSet, Framework, type XAxisConfig } from './utils/types';
|
package/src/index.js
CHANGED
|
@@ -31,3 +31,4 @@ export { getTopAndLeftForStripAndLabel } from './components/common/StripAndLabel
|
|
|
31
31
|
/***********************************************************************************************************************/
|
|
32
32
|
export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset } from './utils';
|
|
33
33
|
export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
|
|
34
|
+
export { CurveType, EdgePosition, Framework } from './utils/types';
|
package/src/index.ts
CHANGED
|
@@ -128,8 +128,8 @@ export {
|
|
|
128
128
|
type RuleType,
|
|
129
129
|
type RuleTypes,
|
|
130
130
|
type RulesConfig,
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
CurveType,
|
|
132
|
+
EdgePosition,
|
|
133
133
|
type LabelsPosition,
|
|
134
134
|
type PointerEvents,
|
|
135
135
|
type secondaryYAxisType,
|
|
@@ -145,5 +145,6 @@ export {
|
|
|
145
145
|
type LineSvgProps,
|
|
146
146
|
type LineProperties,
|
|
147
147
|
type DataSet,
|
|
148
|
-
|
|
148
|
+
Framework,
|
|
149
|
+
type XAxisConfig
|
|
149
150
|
} from './utils/types'
|
package/src/utils/constants.d.ts
CHANGED
package/src/utils/constants.js
CHANGED
package/src/utils/constants.ts
CHANGED
package/src/utils/index.js
CHANGED
|
@@ -476,7 +476,7 @@ export var getArrowPoints = function (arrowTipX, arrowTipY, x1, y1, arrowLength,
|
|
|
476
476
|
return arrowPoints;
|
|
477
477
|
};
|
|
478
478
|
export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue, maxValue) {
|
|
479
|
-
var _a, _b, _c, _d;
|
|
479
|
+
var _a, _b, _c, _d, _e;
|
|
480
480
|
var secondaryYAxis = !props.secondaryYAxis || props.secondaryYAxis === true
|
|
481
481
|
? {}
|
|
482
482
|
: props.secondaryYAxis;
|
|
@@ -486,13 +486,15 @@ export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue,
|
|
|
486
486
|
yAxisColor: props.yAxisColor,
|
|
487
487
|
yAxisExtraHeight: props.yAxisExtraHeight,
|
|
488
488
|
trimYAxisAtTop: props.trimYAxisAtTop,
|
|
489
|
-
overflowTop: props.overflowTop
|
|
489
|
+
overflowTop: ((_a = props.overflowTop) !== null && _a !== void 0 ? _a : props.secondaryXAxis)
|
|
490
|
+
? AxesAndRulesDefaults.overflowTopWithSecondaryXAxis
|
|
491
|
+
: AxesAndRulesDefaults.overflowTop,
|
|
490
492
|
yAxisThickness: props.yAxisThickness,
|
|
491
493
|
xAxisColor: props.xAxisColor,
|
|
492
494
|
xAxisLength: props.xAxisLength,
|
|
493
495
|
xAxisType: props.xAxisType,
|
|
494
|
-
xAxisTextNumberOfLines: (
|
|
495
|
-
xAxisThickness: (
|
|
496
|
+
xAxisTextNumberOfLines: (_b = props.xAxisTextNumberOfLines) !== null && _b !== void 0 ? _b : 1,
|
|
497
|
+
xAxisThickness: (_c = props.xAxisThickness) !== null && _c !== void 0 ? _c : AxesAndRulesDefaults.xAxisThickness,
|
|
496
498
|
xAxisLabelsHeight: props.xAxisLabelsHeight,
|
|
497
499
|
xAxisLabelsVerticalShift: props.xAxisLabelsVerticalShift,
|
|
498
500
|
dashWidth: props.dashWidth,
|
|
@@ -541,11 +543,13 @@ export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue,
|
|
|
541
543
|
stepValue: stepValue,
|
|
542
544
|
negativeStepValue: negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue,
|
|
543
545
|
secondaryYAxis: props.secondaryYAxis,
|
|
544
|
-
formatYLabel: props.formatYLabel
|
|
546
|
+
formatYLabel: props.formatYLabel,
|
|
547
|
+
secondaryXAxis: props.secondaryXAxis
|
|
545
548
|
};
|
|
546
|
-
if (((
|
|
549
|
+
if (((_d = props.secondaryYAxis) !== null && _d !== void 0 ? _d : (_e = props.lineConfig) === null || _e === void 0 ? void 0 : _e.isSecondary) &&
|
|
547
550
|
maxValue !== undefined &&
|
|
548
|
-
secondaryYAxis &&
|
|
551
|
+
secondaryYAxis &&
|
|
552
|
+
secondaryYAxis.maxValue === undefined) {
|
|
549
553
|
axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue: maxValue });
|
|
550
554
|
}
|
|
551
555
|
return axesAndRulesProps;
|
package/src/utils/index.ts
CHANGED
|
@@ -679,7 +679,10 @@ export const getAxesAndRulesProps = (
|
|
|
679
679
|
yAxisColor: props.yAxisColor,
|
|
680
680
|
yAxisExtraHeight: props.yAxisExtraHeight,
|
|
681
681
|
trimYAxisAtTop: props.trimYAxisAtTop,
|
|
682
|
-
overflowTop:
|
|
682
|
+
overflowTop:
|
|
683
|
+
props.overflowTop ?? props.secondaryXAxis
|
|
684
|
+
? AxesAndRulesDefaults.overflowTopWithSecondaryXAxis
|
|
685
|
+
: AxesAndRulesDefaults.overflowTop,
|
|
683
686
|
yAxisThickness: props.yAxisThickness,
|
|
684
687
|
xAxisColor: props.xAxisColor,
|
|
685
688
|
xAxisLength: props.xAxisLength,
|
|
@@ -739,12 +742,14 @@ export const getAxesAndRulesProps = (
|
|
|
739
742
|
negativeStepValue: negativeStepValue ?? stepValue,
|
|
740
743
|
|
|
741
744
|
secondaryYAxis: props.secondaryYAxis,
|
|
742
|
-
formatYLabel: props.formatYLabel
|
|
745
|
+
formatYLabel: props.formatYLabel,
|
|
746
|
+
secondaryXAxis: props.secondaryXAxis
|
|
743
747
|
}
|
|
744
748
|
if (
|
|
745
749
|
(props.secondaryYAxis ?? props.lineConfig?.isSecondary) &&
|
|
746
750
|
maxValue !== undefined &&
|
|
747
|
-
secondaryYAxis &&
|
|
751
|
+
secondaryYAxis &&
|
|
752
|
+
secondaryYAxis.maxValue === undefined
|
|
748
753
|
) {
|
|
749
754
|
axesAndRulesProps.secondaryYAxis = { ...secondaryYAxis, maxValue }
|
|
750
755
|
}
|
package/src/utils/types.d.ts
CHANGED
|
@@ -30,6 +30,14 @@ export interface RulesConfig {
|
|
|
30
30
|
dashWidth?: number;
|
|
31
31
|
dashGap?: number;
|
|
32
32
|
}
|
|
33
|
+
export interface XAxisConfig {
|
|
34
|
+
thickness?: number;
|
|
35
|
+
color?: ColorValue;
|
|
36
|
+
labelsDistanceFromXaxis?: number;
|
|
37
|
+
labelsHeight?: number;
|
|
38
|
+
labelsTextStyle?: any;
|
|
39
|
+
labelTexts?: string[];
|
|
40
|
+
}
|
|
33
41
|
export type PointerEvents = 'box-none' | 'none' | 'box-only' | 'auto';
|
|
34
42
|
export interface secondaryYAxisType {
|
|
35
43
|
noOfSections?: number;
|
|
@@ -171,6 +179,7 @@ export interface horizSectionPropTypes {
|
|
|
171
179
|
formatYLabel?: (label: string) => string;
|
|
172
180
|
onlyReferenceLines?: boolean;
|
|
173
181
|
renderReferenceLines?: boolean;
|
|
182
|
+
secondaryXAxis?: XAxisConfig;
|
|
174
183
|
}
|
|
175
184
|
interface HorizSectionObject {
|
|
176
185
|
value: string;
|
package/src/utils/types.ts
CHANGED
|
@@ -38,6 +38,15 @@ export interface RulesConfig {
|
|
|
38
38
|
dashGap?: number
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export interface XAxisConfig {
|
|
42
|
+
thickness?: number
|
|
43
|
+
color?: ColorValue
|
|
44
|
+
labelsDistanceFromXaxis?: number
|
|
45
|
+
labelsHeight?: number
|
|
46
|
+
labelsTextStyle?: any
|
|
47
|
+
labelTexts?: string[]
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
export type PointerEvents = 'box-none' | 'none' | 'box-only' | 'auto'
|
|
42
51
|
|
|
43
52
|
export interface secondaryYAxisType {
|
|
@@ -193,6 +202,7 @@ export interface horizSectionPropTypes {
|
|
|
193
202
|
formatYLabel?: (label: string) => string
|
|
194
203
|
onlyReferenceLines?: boolean
|
|
195
204
|
renderReferenceLines?: boolean
|
|
205
|
+
secondaryXAxis?: XAxisConfig
|
|
196
206
|
}
|
|
197
207
|
|
|
198
208
|
interface HorizSectionObject {
|