react-native-gifted-charts 1.2.8 → 1.2.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "src/index.tsx",
6
6
  "files": [
@@ -22,6 +22,7 @@ import Svg, {
22
22
  Circle,
23
23
  Rect,
24
24
  Text as CanvasText,
25
+ Line,
25
26
  } from 'react-native-svg';
26
27
  import {svgPath, bezierCommand} from '../utils';
27
28
  import Rule from '../Components/lineSvg';
@@ -347,6 +348,7 @@ type Pointer = {
347
348
  hidePointer3?: boolean;
348
349
  hidePointer4?: boolean;
349
350
  hidePointer5?: boolean;
351
+ strokeDashArray?: Array<number>;
350
352
  };
351
353
 
352
354
  export const LineChart = (props: propTypes) => {
@@ -2399,24 +2401,77 @@ export const LineChart = (props: propTypes) => {
2399
2401
  }}
2400
2402
  />
2401
2403
  )}
2404
+ </View>
2405
+ );
2406
+ };
2407
+
2408
+ const renderStripAndLabel = () => {
2409
+ let pointerItemLocal, pointerYLocal;
2410
+
2411
+ pointerItemLocal = [pointerItem];
2412
+ let arr = [pointerY];
2413
+ if (pointerY2 !== 0) {
2414
+ arr.push(pointerY2);
2415
+ pointerItemLocal.push(pointerItem2);
2416
+ }
2417
+ if (pointerY3 !== 0) {
2418
+ arr.push(pointerY3);
2419
+ pointerItemLocal.push(pointerItem3);
2420
+ }
2421
+ if (pointerY4 !== 0) {
2422
+ arr.push(pointerY4);
2423
+ pointerItemLocal.push(pointerItem4);
2424
+ }
2425
+ if (pointerY5 !== 0) {
2426
+ arr.push(pointerY5);
2427
+ pointerItemLocal.push(pointerItem5);
2428
+ }
2429
+ pointerYLocal = Math.min(...arr);
2430
+
2431
+ return (
2432
+ <View
2433
+ style={{
2434
+ position: 'absolute',
2435
+ left: pointerX + (pointerItemLocal[0].pointerShiftX || 0),
2436
+ top: pointerYLocal,
2437
+ }}>
2402
2438
  {showPointerStrip && (
2403
2439
  <View
2404
2440
  style={{
2405
2441
  position: 'absolute',
2406
- left: pointerRadius || pointerWidth / 2,
2442
+ left: (pointerRadius || pointerWidth) - pointerStripWidth / 4,
2407
2443
  top: pointerStripUptoDataPoint
2408
2444
  ? pointerRadius || pointerStripHeight / 2
2409
2445
  : -pointerYLocal + 8,
2446
+ width: pointerStripWidth,
2410
2447
  height: pointerStripUptoDataPoint
2411
- ? containerHeight - pointerYLocal - 10
2448
+ ? containerHeight - pointerYLocal + 5 - xAxisThickness
2412
2449
  : pointerStripHeight,
2413
- width: pointerStripWidth,
2414
- backgroundColor: pointerStripColor,
2415
2450
  marginTop: pointerStripUptoDataPoint
2416
2451
  ? 0
2417
2452
  : containerHeight - pointerStripHeight,
2418
- }}
2419
- />
2453
+ }}>
2454
+ <Svg>
2455
+ <Line
2456
+ stroke={pointerStripColor}
2457
+ strokeWidth={pointerStripWidth}
2458
+ strokeDasharray={
2459
+ pointerConfig.strokeDashArray
2460
+ ? pointerConfig.strokeDashArray
2461
+ : ''
2462
+ }
2463
+ x1={0}
2464
+ y1={0}
2465
+ x2={0}
2466
+ // strokeLinecap="round"
2467
+ y2={
2468
+ pointerStripUptoDataPoint
2469
+ ? containerHeight - pointerYLocal + 5 - xAxisThickness
2470
+ : pointerStripHeight
2471
+ }
2472
+ />
2473
+ </Svg>
2474
+ </View>
2420
2475
  )}
2421
2476
 
2422
2477
  {pointerLabelComponent && (
@@ -2783,7 +2838,6 @@ export const LineChart = (props: propTypes) => {
2783
2838
  endOpacity,
2784
2839
  strokeDashArray,
2785
2840
  )}
2786
- {pointerX ? renderPointer(lineNumber) : null}
2787
2841
  </View>
2788
2842
  );
2789
2843
  };
@@ -2985,7 +3039,6 @@ export const LineChart = (props: propTypes) => {
2985
3039
  endOpacity,
2986
3040
  strokeDashArray,
2987
3041
  )}
2988
- {pointerX ? renderPointer(lineNumber) : null}
2989
3042
  </Animated.View>
2990
3043
  );
2991
3044
  };
@@ -3220,6 +3273,24 @@ export const LineChart = (props: propTypes) => {
3220
3273
  strokeDashArray5,
3221
3274
  )
3222
3275
  : null}
3276
+ {pointerX ? (
3277
+ <View
3278
+ style={{
3279
+ position: 'absolute',
3280
+ height:
3281
+ containerHeight + 10 + horizSectionsBelow.length * stepHeight,
3282
+ bottom: 60 + labelsExtraHeight,
3283
+ width: totalWidth,
3284
+ zIndex: 20,
3285
+ }}>
3286
+ {renderPointer(1)}
3287
+ {points2 ? renderPointer(2) : null}
3288
+ {points3 ? renderPointer(3) : null}
3289
+ {points4 ? renderPointer(4) : null}
3290
+ {points5 ? renderPointer(5) : null}
3291
+ {renderStripAndLabel()}
3292
+ </View>
3293
+ ) : null}
3223
3294
  {data.map((item: itemType, index: number) => {
3224
3295
  // console.log('item', item)
3225
3296
  return (