gifted-charts-core 0.1.6 → 0.1.7
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/LineChart/index.d.ts +3 -1
- package/src/LineChart/index.js +90 -65
- package/src/LineChart/index.ts +44 -13
- package/src/LineChart/types.d.ts +2 -0
- package/src/LineChart/types.ts +2 -0
- 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/types.d.ts +1 -0
- package/src/utils/types.ts +3 -2
package/package.json
CHANGED
package/src/LineChart/index.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
|
|
|
45
45
|
setPointerItem4: import("react").Dispatch<import("react").SetStateAction<lineDataItem | undefined>>;
|
|
46
46
|
pointerY5: number;
|
|
47
47
|
setPointerY5: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
48
|
+
pointerYsForDataSet: number[];
|
|
49
|
+
setPointerYsForDataSet: import("react").Dispatch<import("react").SetStateAction<number[]>>;
|
|
48
50
|
pointerItem5: lineDataItem | undefined;
|
|
49
51
|
setPointerItem5: import("react").Dispatch<import("react").SetStateAction<lineDataItem | undefined>>;
|
|
50
52
|
secondaryPointerY: number;
|
|
@@ -363,6 +365,7 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
|
|
|
363
365
|
showDataPointOnFocus: boolean;
|
|
364
366
|
showStripOnFocus: boolean;
|
|
365
367
|
showTextOnFocus: boolean;
|
|
368
|
+
showDataPointLabelOnFocus: boolean;
|
|
366
369
|
stripHeight: number | undefined;
|
|
367
370
|
stripWidth: number;
|
|
368
371
|
stripColor: any;
|
|
@@ -376,7 +379,6 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
|
|
|
376
379
|
lineGradientEndColor: string;
|
|
377
380
|
getPointerY: (value: number) => number;
|
|
378
381
|
initialisePointers: () => void;
|
|
379
|
-
setPointerConfig: (initialPointerIndex: number, item: lineDataItem, x: number, y: number, y2: number, y3: number, y4: number, y5: number) => void;
|
|
380
382
|
barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes;
|
|
381
383
|
yAxisExtraHeightAtTop: number;
|
|
382
384
|
};
|
package/src/LineChart/index.js
CHANGED
|
@@ -30,49 +30,50 @@ import { AxesAndRulesDefaults, LineDefaults, SEGMENT_END, SEGMENT_START, chartTy
|
|
|
30
30
|
import { adjustToOffset, computeMaxAndMinItems, getAllArrowProperties, getArrowPoints, getAxesAndRulesProps, getCurvePathWithSegments, getExtendedContainerHeightWithPadding, getInterpolatedData, getLineSegmentsForMissingValues, getMaxValue, getNoOfSections, getPathWithHighlight, getSanitisedData, getSecondaryDataWithOffsetIncluded, getSegmentString, svgPath } from '../utils';
|
|
31
31
|
import { EdgePosition } from '../utils/types';
|
|
32
32
|
export var useLineChart = function (props) {
|
|
33
|
-
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, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255, _256, _257, _258, _259, _260, _261, _262, _263, _264, _265, _266, _267, _268, _269, _270, _271, _272, _273, _274, _275, _276, _277, _278, _279, _280, _281, _282, _283, _284, _285, _286, _287, _288, _289, _290, _291;
|
|
34
|
-
var animations = props.animations, showDataPointsForMissingValues = props.showDataPointsForMissingValues,
|
|
33
|
+
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, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160, _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176, _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192, _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208, _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224, _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240, _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255, _256, _257, _258, _259, _260, _261, _262, _263, _264, _265, _266, _267, _268, _269, _270, _271, _272, _273, _274, _275, _276, _277, _278, _279, _280, _281, _282, _283, _284, _285, _286, _287, _288, _289, _290, _291, _292;
|
|
34
|
+
var animations = props.animations, showDataPointsForMissingValues = props.showDataPointsForMissingValues, _293 = props.interpolateMissingValues, interpolateMissingValues = _293 === void 0 ? true : _293, onlyPositive = props.onlyPositive, yAxisOffset = props.yAxisOffset, parentWidth = props.parentWidth;
|
|
35
35
|
var curvature = (_a = props.curvature) !== null && _a !== void 0 ? _a : LineDefaults.curvature;
|
|
36
36
|
var curveType = (_b = props.curveType) !== null && _b !== void 0 ? _b : LineDefaults.curveType;
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
37
|
+
var _294 = __read(useState(0), 2), scrollX = _294[0], setScrollX = _294[1];
|
|
38
|
+
var _295 = __read(useState(''), 2), arrow1Points = _295[0], setArrow1Points = _295[1];
|
|
39
|
+
var _296 = __read(useState(''), 2), arrow2Points = _296[0], setArrow2Points = _296[1];
|
|
40
|
+
var _297 = __read(useState(''), 2), arrow3Points = _297[0], setArrow3Points = _297[1];
|
|
41
|
+
var _298 = __read(useState(''), 2), arrow4Points = _298[0], setArrow4Points = _298[1];
|
|
42
|
+
var _299 = __read(useState(''), 2), arrow5Points = _299[0], setArrow5Points = _299[1];
|
|
43
|
+
var _300 = __read(useState(''), 2), secondaryArrowPoints = _300[0], setSecondaryArrowPoints = _300[1];
|
|
44
|
+
var _301 = __read(useState(-1), 2), pointerIndex = _301[0], setPointerIndex = _301[1];
|
|
45
|
+
var _302 = __read(useState(0), 2), pointerX = _302[0], setPointerX = _302[1];
|
|
46
|
+
var _303 = __read(useState(0), 2), pointerY = _303[0], setPointerY = _303[1];
|
|
47
|
+
var _304 = __read(useState(), 2), pointerItem = _304[0], setPointerItem = _304[1];
|
|
48
|
+
var _305 = __read(useState(0), 2), pointerY2 = _305[0], setPointerY2 = _305[1];
|
|
49
|
+
var _306 = __read(useState(), 2), pointerItem2 = _306[0], setPointerItem2 = _306[1];
|
|
50
|
+
var _307 = __read(useState(0), 2), pointerY3 = _307[0], setPointerY3 = _307[1];
|
|
51
|
+
var _308 = __read(useState(), 2), pointerItem3 = _308[0], setPointerItem3 = _308[1];
|
|
52
|
+
var _309 = __read(useState(0), 2), pointerY4 = _309[0], setPointerY4 = _309[1];
|
|
53
|
+
var _310 = __read(useState(), 2), pointerItem4 = _310[0], setPointerItem4 = _310[1];
|
|
54
|
+
var _311 = __read(useState(0), 2), pointerY5 = _311[0], setPointerY5 = _311[1];
|
|
55
|
+
var _312 = __read(useState([]), 2), pointerYsForDataSet = _312[0], setPointerYsForDataSet = _312[1];
|
|
56
|
+
var _313 = __read(useState(), 2), pointerItem5 = _313[0], setPointerItem5 = _313[1];
|
|
57
|
+
var _314 = __read(useState(0), 2), secondaryPointerY = _314[0], setSecondaryPointerY = _314[1];
|
|
58
|
+
var _315 = __read(useState(), 2), secondaryPointerItem = _315[0], setSecondaryPointerItem = _315[1];
|
|
59
|
+
var _316 = __read(useState(0), 2), responderStartTime = _316[0], setResponderStartTime = _316[1];
|
|
60
|
+
var _317 = __read(useState(false), 2), responderActive = _317[0], setResponderActive = _317[1];
|
|
61
|
+
var _318 = __read(useState(''), 2), points = _318[0], setPoints = _318[1];
|
|
62
|
+
var _319 = __read(useState(''), 2), points2 = _319[0], setPoints2 = _319[1];
|
|
63
|
+
var _320 = __read(useState(''), 2), points3 = _320[0], setPoints3 = _320[1];
|
|
64
|
+
var _321 = __read(useState(''), 2), points4 = _321[0], setPoints4 = _321[1];
|
|
65
|
+
var _322 = __read(useState(''), 2), points5 = _322[0], setPoints5 = _322[1];
|
|
66
|
+
var _323 = __read(useState(''), 2), secondaryPoints = _323[0], setSecondaryPoints = _323[1];
|
|
67
|
+
var _324 = __read(useState(''), 2), fillPoints = _324[0], setFillPoints = _324[1];
|
|
68
|
+
var _325 = __read(useState(''), 2), fillPoints2 = _325[0], setFillPoints2 = _325[1];
|
|
69
|
+
var _326 = __read(useState(''), 2), fillPoints3 = _326[0], setFillPoints3 = _326[1];
|
|
70
|
+
var _327 = __read(useState(''), 2), fillPoints4 = _327[0], setFillPoints4 = _327[1];
|
|
71
|
+
var _328 = __read(useState(''), 2), fillPoints5 = _328[0], setFillPoints5 = _328[1];
|
|
72
|
+
var _329 = __read(useState(''), 2), secondaryFillPoints = _329[0], setSecondaryFillPoints = _329[1];
|
|
73
|
+
var _330 = __read(useState([]), 2), pointsFromSet = _330[0], setPointsFromSet = _330[1];
|
|
74
|
+
var _331 = __read(useState([]), 2), fillPointsFromSet = _331[0], setFillPointsFromSet = _331[1];
|
|
75
|
+
var _332 = __read(useState([]), 2), arrowPointsFromSet = _332[0], setArrowPointsFromSet = _332[1];
|
|
76
|
+
var _333 = __read(useState(-1), 2), selectedIndex = _333[0], setSelectedIndex = _333[1];
|
|
76
77
|
var noOfSections = getNoOfSections(props.noOfSections, props.maxValue, props.stepValue);
|
|
77
78
|
var containerHeight = (_c = props.height) !== null && _c !== void 0 ? _c : (((_d = props.stepHeight) !== null && _d !== void 0 ? _d : 0) * noOfSections ||
|
|
78
79
|
AxesAndRulesDefaults.containerHeight);
|
|
@@ -229,7 +230,7 @@ export var useLineChart = function (props) {
|
|
|
229
230
|
var textColor4 = (_94 = (_93 = props.textColor4) !== null && _93 !== void 0 ? _93 : props.textColor) !== null && _94 !== void 0 ? _94 : LineDefaults.textColor;
|
|
230
231
|
var textColor5 = (_96 = (_95 = props.textColor5) !== null && _95 !== void 0 ? _95 : props.textColor) !== null && _96 !== void 0 ? _96 : LineDefaults.textColor;
|
|
231
232
|
var totalWidth = initialSpacing + spacing * (data0 !== null && data0 !== void 0 ? data0 : data).length;
|
|
232
|
-
var
|
|
233
|
+
var _334 = computeMaxAndMinItems(data0 !== null && data0 !== void 0 ? data0 : data, props.roundToDigits, props.showFractionalValues), maxItem = _334.maxItem, minItem = _334.minItem;
|
|
233
234
|
var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxItem);
|
|
234
235
|
var mostNegativeValue = (_97 = props.mostNegativeValue) !== null && _97 !== void 0 ? _97 : minItem;
|
|
235
236
|
var overflowTop = (_98 = props.overflowTop) !== null && _98 !== void 0 ? _98 : 0;
|
|
@@ -337,7 +338,7 @@ export var useLineChart = function (props) {
|
|
|
337
338
|
var endOpacity5 = (_177 = props.endOpacity5) !== null && _177 !== void 0 ? _177 : endOpacity;
|
|
338
339
|
defaultArrowConfig.strokeWidth = (_179 = (_178 = dataSet === null || dataSet === void 0 ? void 0 : dataSet[0]) === null || _178 === void 0 ? void 0 : _178.thickness) !== null && _179 !== void 0 ? _179 : thickness1;
|
|
339
340
|
defaultArrowConfig.strokeColor = (_181 = (_180 = dataSet === null || dataSet === void 0 ? void 0 : dataSet[0]) === null || _180 === void 0 ? void 0 : _180.color) !== null && _181 !== void 0 ? _181 : color1;
|
|
340
|
-
var
|
|
341
|
+
var _335 = getAllArrowProperties(props, defaultArrowConfig), arrowLength1 = _335.arrowLength1, arrowWidth1 = _335.arrowWidth1, arrowStrokeWidth1 = _335.arrowStrokeWidth1, arrowStrokeColor1 = _335.arrowStrokeColor1, arrowFillColor1 = _335.arrowFillColor1, showArrowBase1 = _335.showArrowBase1, arrowLength2 = _335.arrowLength2, arrowWidth2 = _335.arrowWidth2, arrowStrokeWidth2 = _335.arrowStrokeWidth2, arrowStrokeColor2 = _335.arrowStrokeColor2, arrowFillColor2 = _335.arrowFillColor2, showArrowBase2 = _335.showArrowBase2, arrowLength3 = _335.arrowLength3, arrowWidth3 = _335.arrowWidth3, arrowStrokeWidth3 = _335.arrowStrokeWidth3, arrowStrokeColor3 = _335.arrowStrokeColor3, arrowFillColor3 = _335.arrowFillColor3, showArrowBase3 = _335.showArrowBase3, arrowLength4 = _335.arrowLength4, arrowWidth4 = _335.arrowWidth4, arrowStrokeWidth4 = _335.arrowStrokeWidth4, arrowStrokeColor4 = _335.arrowStrokeColor4, arrowFillColor4 = _335.arrowFillColor4, showArrowBase4 = _335.showArrowBase4, arrowLength5 = _335.arrowLength5, arrowWidth5 = _335.arrowWidth5, arrowStrokeWidth5 = _335.arrowStrokeWidth5, arrowStrokeColor5 = _335.arrowStrokeColor5, arrowFillColor5 = _335.arrowFillColor5, showArrowBase5 = _335.showArrowBase5, arrowLengthsFromSet = _335.arrowLengthsFromSet, arrowWidthsFromSet = _335.arrowWidthsFromSet, arrowStrokeWidthsFromSet = _335.arrowStrokeWidthsFromSet, arrowStrokeColorsFromSet = _335.arrowStrokeColorsFromSet, arrowFillColorsFromSet = _335.arrowFillColorsFromSet, showArrowBasesFromSet = _335.showArrowBasesFromSet;
|
|
341
342
|
var secondaryLineConfig = {
|
|
342
343
|
zIndex: (_183 = (_182 = props.secondaryLineConfig) === null || _182 === void 0 ? void 0 : _182.zIndex) !== null && _183 !== void 0 ? _183 : zIndex1,
|
|
343
344
|
curved: (_185 = (_184 = props.secondaryLineConfig) === null || _184 === void 0 ? void 0 : _184.curved) !== null && _185 !== void 0 ? _185 : props.curved,
|
|
@@ -955,17 +956,18 @@ export var useLineChart = function (props) {
|
|
|
955
956
|
var showDataPointOnFocus = (_279 = props.showDataPointOnFocus) !== null && _279 !== void 0 ? _279 : LineDefaults.showDataPointOnFocus;
|
|
956
957
|
var showStripOnFocus = (_280 = props.showStripOnFocus) !== null && _280 !== void 0 ? _280 : LineDefaults.showStripOnFocus;
|
|
957
958
|
var showTextOnFocus = (_281 = props.showTextOnFocus) !== null && _281 !== void 0 ? _281 : LineDefaults.showTextOnFocus;
|
|
959
|
+
var showDataPointLabelOnFocus = (_282 = props.showDataPointLabelOnFocus) !== null && _282 !== void 0 ? _282 : LineDefaults.showDataPointLabelOnFocus;
|
|
958
960
|
var stripHeight = props.stripHeight;
|
|
959
|
-
var stripWidth = (
|
|
960
|
-
var stripColor = (
|
|
961
|
-
var stripOpacity = (
|
|
962
|
-
var unFocusOnPressOut = (
|
|
963
|
-
var delayBeforeUnFocus = (
|
|
961
|
+
var stripWidth = (_283 = props.stripWidth) !== null && _283 !== void 0 ? _283 : LineDefaults.stripWidth;
|
|
962
|
+
var stripColor = (_284 = props.stripColor) !== null && _284 !== void 0 ? _284 : color1;
|
|
963
|
+
var stripOpacity = (_285 = props.stripOpacity) !== null && _285 !== void 0 ? _285 : (startOpacity1 + endOpacity1) / 2;
|
|
964
|
+
var unFocusOnPressOut = (_286 = props.unFocusOnPressOut) !== null && _286 !== void 0 ? _286 : LineDefaults.unFocusOnPressOut;
|
|
965
|
+
var delayBeforeUnFocus = (_287 = props.delayBeforeUnFocus) !== null && _287 !== void 0 ? _287 : LineDefaults.delayBeforeUnFocus;
|
|
964
966
|
var containerHeightIncludingBelowXAxis = extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
965
|
-
var lineGradient = (
|
|
966
|
-
var lineGradientDirection = (
|
|
967
|
-
var lineGradientStartColor = (
|
|
968
|
-
var lineGradientEndColor = (
|
|
967
|
+
var lineGradient = (_288 = props.lineGradient) !== null && _288 !== void 0 ? _288 : LineDefaults.lineGradient;
|
|
968
|
+
var lineGradientDirection = (_289 = props.lineGradientDirection) !== null && _289 !== void 0 ? _289 : 'vertical';
|
|
969
|
+
var lineGradientStartColor = (_290 = props.lineGradientStartColor) !== null && _290 !== void 0 ? _290 : LineDefaults.lineGradientStartColor;
|
|
970
|
+
var lineGradientEndColor = (_291 = props.lineGradientEndColor) !== null && _291 !== void 0 ? _291 : LineDefaults.lineGradientEndColor;
|
|
969
971
|
var getPointerY = function (value) {
|
|
970
972
|
return value
|
|
971
973
|
? containerHeight -
|
|
@@ -977,23 +979,36 @@ export var useLineChart = function (props) {
|
|
|
977
979
|
var initialisePointers = function () {
|
|
978
980
|
var _a, _b, _c, _d;
|
|
979
981
|
if (initialPointerIndex !== -1) {
|
|
980
|
-
var item_1 = (data0 !== null && data0 !== void 0 ? data0 : data)[initialPointerIndex];
|
|
981
982
|
var x_1 = initialSpacing +
|
|
982
983
|
spacing * initialPointerIndex -
|
|
983
984
|
(pointerRadius || pointerWidth / 2) -
|
|
984
985
|
1;
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
986
|
+
if (dataSet === null || dataSet === void 0 ? void 0 : dataSet.length) {
|
|
987
|
+
var item_1 = dataSet[0].data[initialPointerIndex];
|
|
988
|
+
if (initialPointerAppearDelay) {
|
|
989
|
+
setTimeout(function () {
|
|
990
|
+
setPointerConfigForDataSet(initialPointerIndex, item_1, x_1);
|
|
991
|
+
}, initialPointerAppearDelay);
|
|
992
|
+
}
|
|
993
|
+
else {
|
|
994
|
+
setPointerConfigForDataSet(initialPointerIndex, item_1, x_1);
|
|
995
|
+
}
|
|
994
996
|
}
|
|
995
997
|
else {
|
|
996
|
-
|
|
998
|
+
var item_2 = (data0 !== null && data0 !== void 0 ? data0 : data)[initialPointerIndex];
|
|
999
|
+
var y_1 = getPointerY(item_2.value);
|
|
1000
|
+
var y2_1 = getPointerY((_a = data2 === null || data2 === void 0 ? void 0 : data2[initialPointerIndex]) === null || _a === void 0 ? void 0 : _a.value);
|
|
1001
|
+
var y3_1 = getPointerY((_b = data3 === null || data3 === void 0 ? void 0 : data3[initialPointerIndex]) === null || _b === void 0 ? void 0 : _b.value);
|
|
1002
|
+
var y4_1 = getPointerY((_c = data4 === null || data4 === void 0 ? void 0 : data4[initialPointerIndex]) === null || _c === void 0 ? void 0 : _c.value);
|
|
1003
|
+
var y5_1 = getPointerY((_d = data5 === null || data5 === void 0 ? void 0 : data5[initialPointerIndex]) === null || _d === void 0 ? void 0 : _d.value);
|
|
1004
|
+
if (initialPointerAppearDelay) {
|
|
1005
|
+
setTimeout(function () {
|
|
1006
|
+
setPointerConfig(initialPointerIndex, item_2, x_1, y_1, y2_1, y3_1, y4_1, y5_1);
|
|
1007
|
+
}, initialPointerAppearDelay);
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
setPointerConfig(initialPointerIndex, item_2, x_1, y_1, y2_1, y3_1, y4_1, y5_1);
|
|
1011
|
+
}
|
|
997
1012
|
}
|
|
998
1013
|
}
|
|
999
1014
|
};
|
|
@@ -1015,6 +1030,14 @@ export var useLineChart = function (props) {
|
|
|
1015
1030
|
setPointerY4(y4);
|
|
1016
1031
|
setPointerY5(y5);
|
|
1017
1032
|
};
|
|
1033
|
+
var setPointerConfigForDataSet = function (initialPointerIndex, item, x) {
|
|
1034
|
+
var _a;
|
|
1035
|
+
setPointerIndex(initialPointerIndex);
|
|
1036
|
+
setPointerItem(item);
|
|
1037
|
+
setPointerX(x);
|
|
1038
|
+
var initialPointerYs = (_a = dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set) { return getPointerY(set.data[initialPointerIndex].value); })) !== null && _a !== void 0 ? _a : [];
|
|
1039
|
+
setPointerYsForDataSet(initialPointerYs);
|
|
1040
|
+
};
|
|
1018
1041
|
var barAndLineChartsWrapperProps = {
|
|
1019
1042
|
chartType: chartTypes.LINE,
|
|
1020
1043
|
containerHeight: containerHeight,
|
|
@@ -1076,7 +1099,7 @@ export var useLineChart = function (props) {
|
|
|
1076
1099
|
pointerY: pointerY,
|
|
1077
1100
|
onEndReached: props.onEndReached,
|
|
1078
1101
|
onStartReached: props.onStartReached,
|
|
1079
|
-
endReachedOffset: (
|
|
1102
|
+
endReachedOffset: (_292 = props.endReachedOffset) !== null && _292 !== void 0 ? _292 : LineDefaults.endReachedOffset,
|
|
1080
1103
|
onMomentumScrollEnd: props.onMomentumScrollEnd
|
|
1081
1104
|
};
|
|
1082
1105
|
return {
|
|
@@ -1118,6 +1141,8 @@ export var useLineChart = function (props) {
|
|
|
1118
1141
|
setPointerItem4: setPointerItem4,
|
|
1119
1142
|
pointerY5: pointerY5,
|
|
1120
1143
|
setPointerY5: setPointerY5,
|
|
1144
|
+
pointerYsForDataSet: pointerYsForDataSet,
|
|
1145
|
+
setPointerYsForDataSet: setPointerYsForDataSet,
|
|
1121
1146
|
pointerItem5: pointerItem5,
|
|
1122
1147
|
setPointerItem5: setPointerItem5,
|
|
1123
1148
|
secondaryPointerY: secondaryPointerY,
|
|
@@ -1407,6 +1432,7 @@ export var useLineChart = function (props) {
|
|
|
1407
1432
|
showDataPointOnFocus: showDataPointOnFocus,
|
|
1408
1433
|
showStripOnFocus: showStripOnFocus,
|
|
1409
1434
|
showTextOnFocus: showTextOnFocus,
|
|
1435
|
+
showDataPointLabelOnFocus: showDataPointLabelOnFocus,
|
|
1410
1436
|
stripHeight: stripHeight,
|
|
1411
1437
|
stripWidth: stripWidth,
|
|
1412
1438
|
stripColor: stripColor,
|
|
@@ -1420,7 +1446,6 @@ export var useLineChart = function (props) {
|
|
|
1420
1446
|
lineGradientEndColor: lineGradientEndColor,
|
|
1421
1447
|
getPointerY: getPointerY,
|
|
1422
1448
|
initialisePointers: initialisePointers,
|
|
1423
|
-
setPointerConfig: setPointerConfig,
|
|
1424
1449
|
barAndLineChartsWrapperProps: barAndLineChartsWrapperProps,
|
|
1425
1450
|
yAxisExtraHeightAtTop: yAxisExtraHeightAtTop
|
|
1426
1451
|
};
|
package/src/LineChart/index.ts
CHANGED
|
@@ -76,6 +76,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
76
76
|
const [pointerY4, setPointerY4] = useState(0)
|
|
77
77
|
const [pointerItem4, setPointerItem4] = useState<lineDataItem>()
|
|
78
78
|
const [pointerY5, setPointerY5] = useState(0)
|
|
79
|
+
const [pointerYsForDataSet, setPointerYsForDataSet] = useState<number[]>([])
|
|
79
80
|
const [pointerItem5, setPointerItem5] = useState<lineDataItem>()
|
|
80
81
|
const [secondaryPointerY, setSecondaryPointerY] = useState(0)
|
|
81
82
|
const [secondaryPointerItem, setSecondaryPointerItem] = useState()
|
|
@@ -1640,6 +1641,8 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1640
1641
|
const showStripOnFocus =
|
|
1641
1642
|
props.showStripOnFocus ?? LineDefaults.showStripOnFocus
|
|
1642
1643
|
const showTextOnFocus = props.showTextOnFocus ?? LineDefaults.showTextOnFocus
|
|
1644
|
+
const showDataPointLabelOnFocus =
|
|
1645
|
+
props.showDataPointLabelOnFocus ?? LineDefaults.showDataPointLabelOnFocus
|
|
1643
1646
|
const stripHeight = props.stripHeight
|
|
1644
1647
|
const stripWidth = props.stripWidth ?? LineDefaults.stripWidth
|
|
1645
1648
|
const stripColor = props.stripColor ?? color1
|
|
@@ -1669,24 +1672,35 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1669
1672
|
|
|
1670
1673
|
const initialisePointers = (): void => {
|
|
1671
1674
|
if (initialPointerIndex !== -1) {
|
|
1672
|
-
const item = (data0 ?? data)[initialPointerIndex]
|
|
1673
1675
|
const x =
|
|
1674
1676
|
initialSpacing +
|
|
1675
1677
|
spacing * initialPointerIndex -
|
|
1676
1678
|
(pointerRadius || pointerWidth / 2) -
|
|
1677
1679
|
1
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
}, initialPointerAppearDelay)
|
|
1680
|
+
if (dataSet?.length) {
|
|
1681
|
+
const item = dataSet[0].data[initialPointerIndex]
|
|
1682
|
+
if (initialPointerAppearDelay) {
|
|
1683
|
+
setTimeout(() => {
|
|
1684
|
+
setPointerConfigForDataSet(initialPointerIndex, item, x)
|
|
1685
|
+
}, initialPointerAppearDelay)
|
|
1686
|
+
} else {
|
|
1687
|
+
setPointerConfigForDataSet(initialPointerIndex, item, x)
|
|
1688
|
+
}
|
|
1688
1689
|
} else {
|
|
1689
|
-
|
|
1690
|
+
const item = (data0 ?? data)[initialPointerIndex]
|
|
1691
|
+
const y = getPointerY(item.value)
|
|
1692
|
+
const y2 = getPointerY(data2?.[initialPointerIndex]?.value)
|
|
1693
|
+
const y3 = getPointerY(data3?.[initialPointerIndex]?.value)
|
|
1694
|
+
const y4 = getPointerY(data4?.[initialPointerIndex]?.value)
|
|
1695
|
+
const y5 = getPointerY(data5?.[initialPointerIndex]?.value)
|
|
1696
|
+
|
|
1697
|
+
if (initialPointerAppearDelay) {
|
|
1698
|
+
setTimeout(() => {
|
|
1699
|
+
setPointerConfig(initialPointerIndex, item, x, y, y2, y3, y4, y5)
|
|
1700
|
+
}, initialPointerAppearDelay)
|
|
1701
|
+
} else {
|
|
1702
|
+
setPointerConfig(initialPointerIndex, item, x, y, y2, y3, y4, y5)
|
|
1703
|
+
}
|
|
1690
1704
|
}
|
|
1691
1705
|
}
|
|
1692
1706
|
}
|
|
@@ -1721,6 +1735,21 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1721
1735
|
setPointerY5(y5)
|
|
1722
1736
|
}
|
|
1723
1737
|
|
|
1738
|
+
const setPointerConfigForDataSet = (
|
|
1739
|
+
initialPointerIndex: number,
|
|
1740
|
+
item: lineDataItem,
|
|
1741
|
+
x: number
|
|
1742
|
+
) => {
|
|
1743
|
+
setPointerIndex(initialPointerIndex)
|
|
1744
|
+
setPointerItem(item)
|
|
1745
|
+
setPointerX(x)
|
|
1746
|
+
|
|
1747
|
+
const initialPointerYs =
|
|
1748
|
+
dataSet?.map((set) => getPointerY(set.data[initialPointerIndex].value)) ??
|
|
1749
|
+
[]
|
|
1750
|
+
setPointerYsForDataSet(initialPointerYs)
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1724
1753
|
const barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes = {
|
|
1725
1754
|
chartType: chartTypes.LINE,
|
|
1726
1755
|
containerHeight,
|
|
@@ -1830,6 +1859,8 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1830
1859
|
setPointerItem4,
|
|
1831
1860
|
pointerY5,
|
|
1832
1861
|
setPointerY5,
|
|
1862
|
+
pointerYsForDataSet,
|
|
1863
|
+
setPointerYsForDataSet,
|
|
1833
1864
|
pointerItem5,
|
|
1834
1865
|
setPointerItem5,
|
|
1835
1866
|
secondaryPointerY,
|
|
@@ -2119,6 +2150,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
2119
2150
|
showDataPointOnFocus,
|
|
2120
2151
|
showStripOnFocus,
|
|
2121
2152
|
showTextOnFocus,
|
|
2153
|
+
showDataPointLabelOnFocus,
|
|
2122
2154
|
stripHeight,
|
|
2123
2155
|
stripWidth,
|
|
2124
2156
|
stripColor,
|
|
@@ -2132,7 +2164,6 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
2132
2164
|
lineGradientEndColor,
|
|
2133
2165
|
getPointerY,
|
|
2134
2166
|
initialisePointers,
|
|
2135
|
-
setPointerConfig,
|
|
2136
2167
|
barAndLineChartsWrapperProps,
|
|
2137
2168
|
yAxisExtraHeightAtTop
|
|
2138
2169
|
}
|
package/src/LineChart/types.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export interface LineChartPropsType {
|
|
|
56
56
|
showDataPointOnFocus?: boolean;
|
|
57
57
|
showStripOnFocus?: boolean;
|
|
58
58
|
showTextOnFocus?: boolean;
|
|
59
|
+
showDataPointLabelOnFocus?: boolean;
|
|
59
60
|
stripHeight?: number;
|
|
60
61
|
stripWidth?: number;
|
|
61
62
|
stripColor?: ColorValue | string | any;
|
|
@@ -414,6 +415,7 @@ export interface LineChartBicolorPropsType {
|
|
|
414
415
|
showDataPointOnFocus?: boolean;
|
|
415
416
|
showStripOnFocus?: boolean;
|
|
416
417
|
showTextOnFocus?: boolean;
|
|
418
|
+
showDataPointLabelOnFocus?: boolean;
|
|
417
419
|
stripHeight?: number;
|
|
418
420
|
stripWidth?: number;
|
|
419
421
|
stripColor?: ColorValue | string | any;
|
package/src/LineChart/types.ts
CHANGED
|
@@ -70,6 +70,7 @@ export interface LineChartPropsType {
|
|
|
70
70
|
showDataPointOnFocus?: boolean
|
|
71
71
|
showStripOnFocus?: boolean
|
|
72
72
|
showTextOnFocus?: boolean
|
|
73
|
+
showDataPointLabelOnFocus?: boolean
|
|
73
74
|
stripHeight?: number
|
|
74
75
|
stripWidth?: number
|
|
75
76
|
stripColor?: ColorValue | string | any
|
|
@@ -461,6 +462,7 @@ export interface LineChartBicolorPropsType {
|
|
|
461
462
|
showDataPointOnFocus?: boolean
|
|
462
463
|
showStripOnFocus?: boolean
|
|
463
464
|
showTextOnFocus?: boolean
|
|
465
|
+
showDataPointLabelOnFocus?: boolean
|
|
464
466
|
stripHeight?: number
|
|
465
467
|
stripWidth?: number
|
|
466
468
|
stripColor?: ColorValue | string | any
|
package/src/utils/constants.d.ts
CHANGED
|
@@ -157,6 +157,7 @@ export declare const LineDefaults: {
|
|
|
157
157
|
showDataPointOnFocus: boolean;
|
|
158
158
|
showStripOnFocus: boolean;
|
|
159
159
|
showTextOnFocus: boolean;
|
|
160
|
+
showDataPointLabelOnFocus: boolean;
|
|
160
161
|
stripWidth: number;
|
|
161
162
|
unFocusOnPressOut: boolean;
|
|
162
163
|
delayBeforeUnFocus: number;
|
package/src/utils/constants.js
CHANGED
package/src/utils/constants.ts
CHANGED
package/src/utils/types.d.ts
CHANGED
|
@@ -248,6 +248,7 @@ export interface Pointer {
|
|
|
248
248
|
pointer3Color?: ColorValue;
|
|
249
249
|
pointer4Color?: ColorValue;
|
|
250
250
|
pointer5Color?: ColorValue;
|
|
251
|
+
pointerColorsForDataSet?: ColorValue[];
|
|
251
252
|
secondaryPointerColor?: ColorValue;
|
|
252
253
|
pointerComponent?: Function;
|
|
253
254
|
showPointerStrip?: boolean;
|
package/src/utils/types.ts
CHANGED
|
@@ -20,13 +20,13 @@ export interface RuleTypes {
|
|
|
20
20
|
|
|
21
21
|
export enum CurveType {
|
|
22
22
|
CUBIC,
|
|
23
|
-
QUADRATIC
|
|
23
|
+
QUADRATIC
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export enum EdgePosition {
|
|
27
27
|
AFTER_DATA_POINT,
|
|
28
28
|
AROUND_DATA_POINT,
|
|
29
|
-
BEFORE_DATA_POINT
|
|
29
|
+
BEFORE_DATA_POINT
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface RulesConfig {
|
|
@@ -280,6 +280,7 @@ export interface Pointer {
|
|
|
280
280
|
pointer3Color?: ColorValue
|
|
281
281
|
pointer4Color?: ColorValue
|
|
282
282
|
pointer5Color?: ColorValue
|
|
283
|
+
pointerColorsForDataSet?: ColorValue[]
|
|
283
284
|
secondaryPointerColor?: ColorValue
|
|
284
285
|
pointerComponent?: Function
|
|
285
286
|
showPointerStrip?: boolean
|