react-native-gifted-charts 1.2.2 → 1.2.5

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/README.md CHANGED
@@ -96,7 +96,6 @@ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the
96
96
  | Issue | Solution |
97
97
  | ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
98
98
  | [BarChart - Value and section line don't match](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/35) | [Comment by the owner](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/35#issuecomment-972673281) |
99
- | **Invariant Violation: requireNativeComponent: "RNCWebView" was not found in the UIManager.** | install `react-native-webview` |
100
99
  | Setting `height`, `maxValue`, `stepValue`, `stepHeight`, or `noOfSections` breaks the chart | Please make sure that<br/> `maxValue = noOfSections * stepValue;` <br/>is followed. [See this](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/71) |
101
100
 
102
101
  ## To-dos
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.2.2",
3
+ "version": "1.2.5",
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": [
@@ -25,6 +25,7 @@ type Props = {
25
25
 
26
26
  item: itemType;
27
27
  index: number;
28
+ label: String;
28
29
  containerHeight?: number;
29
30
  maxValue: number;
30
31
  spacing?: number;
@@ -108,6 +109,8 @@ const RenderBars = (props: Props) => {
108
109
  opacity,
109
110
  animationDuration,
110
111
  autoShiftLabels,
112
+ label,
113
+ labelTextStyle,
111
114
  } = props;
112
115
 
113
116
  const barMarginBottom =
@@ -527,8 +530,8 @@ const RenderBars = (props: Props) => {
527
530
  />
528
531
  )}
529
532
  {isAnimated
530
- ? renderAnimatedLabel(item.label || '', item.labelTextStyle, item.value)
531
- : renderLabel(item.label || '', item.labelTextStyle, item.value)}
533
+ ? renderAnimatedLabel(label, labelTextStyle, item.value)
534
+ : renderLabel(label, labelTextStyle, item.value)}
532
535
  </TouchableOpacity>
533
536
  );
534
537
  };
@@ -11,6 +11,7 @@ type Props = {
11
11
  topLabelComponent?: Component;
12
12
  topLabelContainerStyle?: Style;
13
13
  opacity?: number;
14
+ label: String;
14
15
  labelTextStyle?: any;
15
16
  disablePress?: boolean;
16
17
 
@@ -66,6 +67,8 @@ const RenderStackBars = (props: Props) => {
66
67
  spacing,
67
68
  rotateLabel,
68
69
  xAxisThickness,
70
+ label,
71
+ labelTextStyle,
69
72
  } = props;
70
73
  const disablePress = props.disablePress || false;
71
74
  const renderLabel = (label: String, labelTextStyle: any) => {
@@ -246,7 +249,7 @@ const RenderStackBars = (props: Props) => {
246
249
  />
247
250
  )}
248
251
  {static2DSimple(item)}
249
- {renderLabel(item.label || '', item.labelTextStyle)}
252
+ {renderLabel(label || '', labelTextStyle)}
250
253
  </View>
251
254
  );
252
255
  };
@@ -119,6 +119,8 @@ type PropTypes = {
119
119
  hideOrigin?: Boolean;
120
120
  labelWidth?: number;
121
121
  yAxisLabelTexts?: Array<string>;
122
+ xAxisLabelTexts?: Array<string>;
123
+ xAxisLabelTextStyle?: any;
122
124
  yAxisLabelPrefix?: String;
123
125
  yAxisLabelSuffix?: String;
124
126
  autoShiftLabels?: Boolean;
@@ -1385,6 +1387,15 @@ export const BarChart = (props: PropTypes) => {
1385
1387
  barBorderRadius={props.barBorderRadius}
1386
1388
  barBackgroundPattern={props.barBackgroundPattern}
1387
1389
  patternId={props.patternId}
1390
+ label={
1391
+ item.label ||
1392
+ (props.xAxisLabelTexts && props.xAxisLabelTexts[index]
1393
+ ? props.xAxisLabelTexts[index]
1394
+ : '')
1395
+ }
1396
+ labelTextStyle={
1397
+ item.labelTextStyle || props.xAxisLabelTextStyle
1398
+ }
1388
1399
  />
1389
1400
  );
1390
1401
  })
@@ -1436,6 +1447,15 @@ export const BarChart = (props: PropTypes) => {
1436
1447
  barBackgroundPattern={props.barBackgroundPattern}
1437
1448
  patternId={props.patternId}
1438
1449
  barMarginBottom={props.barMarginBottom}
1450
+ label={
1451
+ item.label ||
1452
+ (props.xAxisLabelTexts && props.xAxisLabelTexts[index]
1453
+ ? props.xAxisLabelTexts[index]
1454
+ : '')
1455
+ }
1456
+ labelTextStyle={
1457
+ item.labelTextStyle || props.xAxisLabelTextStyle
1458
+ }
1439
1459
  />
1440
1460
  ))}
1441
1461
  </Fragment>
@@ -247,6 +247,8 @@ type propTypes = {
247
247
  textShiftX?: number;
248
248
  textShiftY?: number;
249
249
  yAxisLabelTexts?: Array<string>;
250
+ xAxisLabelTexts?: Array<string>;
251
+ xAxisLabelTextStyle?: any;
250
252
  width?: number;
251
253
  yAxisLabelPrefix?: String;
252
254
  yAxisLabelSuffix?: String;
@@ -254,6 +256,7 @@ type propTypes = {
254
256
  scrollAnimation?: Boolean;
255
257
  noOfSectionsBelowXAxis?: number;
256
258
  labelsExtraHeight?: number;
259
+ adjustToWidth?: Boolean;
257
260
  };
258
261
  type referenceConfigType = {
259
262
  thickness: number;
@@ -320,7 +323,12 @@ type Pointer = {
320
323
  height?: number;
321
324
  width?: number;
322
325
  radius?: number;
323
- color?: ColorValue;
326
+ pointerColor?: ColorValue;
327
+ pointer1Color?: ColorValue;
328
+ pointer2Color?: ColorValue;
329
+ pointer3Color?: ColorValue;
330
+ pointer4Color?: ColorValue;
331
+ pointer5Color?: ColorValue;
324
332
  pointerComponent?: Function;
325
333
  showPointerStrip?: boolean;
326
334
  pointerStripWidth?: number;
@@ -332,6 +340,13 @@ type Pointer = {
332
340
  shiftPointerLabelY?: number;
333
341
  pointerLabelWidth?: number;
334
342
  pointerVanishDelay?: number;
343
+ activatePointersOnLongPress?: boolean;
344
+ activatePointersDelay?: number;
345
+ hidePointer1?: boolean;
346
+ hidePointer2?: boolean;
347
+ hidePointer3?: boolean;
348
+ hidePointer4?: boolean;
349
+ hidePointer5?: boolean;
335
350
  };
336
351
 
337
352
  export const LineChart = (props: propTypes) => {
@@ -342,6 +357,28 @@ export const LineChart = (props: propTypes) => {
342
357
  pointerShiftX: 0,
343
358
  pointerShiftY: 0,
344
359
  });
360
+ const [pointerY2, setPointerY2] = useState(0);
361
+ const [pointerItem2, setPointerItem2] = useState({
362
+ pointerShiftX: 0,
363
+ pointerShiftY: 0,
364
+ });
365
+ const [pointerY3, setPointerY3] = useState(0);
366
+ const [pointerItem3, setPointerItem3] = useState({
367
+ pointerShiftX: 0,
368
+ pointerShiftY: 0,
369
+ });
370
+ const [pointerY4, setPointerY4] = useState(0);
371
+ const [pointerItem4, setPointerItem4] = useState({
372
+ pointerShiftX: 0,
373
+ pointerShiftY: 0,
374
+ });
375
+ const [pointerY5, setPointerY5] = useState(0);
376
+ const [pointerItem5, setPointerItem5] = useState({
377
+ pointerShiftX: 0,
378
+ pointerShiftY: 0,
379
+ });
380
+ const [responderStartTime, setResponderStartTime] = useState(0);
381
+ const [responderActive, setResponderActive] = useState(false);
345
382
  const [points, setPoints] = useState('');
346
383
  const [points2, setPoints2] = useState('');
347
384
  const [points3, setPoints3] = useState('');
@@ -422,7 +459,15 @@ export const LineChart = (props: propTypes) => {
422
459
  props.initialSpacing === 0 ? 0 : props.initialSpacing || 40;
423
460
  const thickness = props.thickness || 2;
424
461
 
425
- const spacing = props.spacing === 0 ? 0 : props.spacing || 60;
462
+ const adjustToWidth = props.adjustToWidth || false;
463
+
464
+ const spacing =
465
+ props.spacing === 0
466
+ ? 0
467
+ : props.spacing ||
468
+ (adjustToWidth
469
+ ? ((props.width || 200) - initialSpacing) / data.length
470
+ : 60);
426
471
 
427
472
  const xAxisThickness = props.xAxisThickness || 1;
428
473
  const dataPointsHeight1 =
@@ -1156,11 +1201,16 @@ export const LineChart = (props: propTypes) => {
1156
1201
  const stepValue = props.stepValue || maxValue / noOfSections;
1157
1202
  const noOfSectionsBelowXAxis =
1158
1203
  props.noOfSectionsBelowXAxis || -minValue / stepValue;
1159
- const thickness1 = props.thickness1 === 0 ? 0 : props.thickness || 1;
1160
- const thickness2 = props.thickness2 === 0 ? 0 : props.thickness || 1;
1161
- const thickness3 = props.thickness3 === 0 ? 0 : props.thickness || 1;
1162
- const thickness4 = props.thickness4 === 0 ? 0 : props.thickness || 1;
1163
- const thickness5 = props.thickness5 === 0 ? 0 : props.thickness || 1;
1204
+ const thickness1 =
1205
+ props.thickness1 === 0 ? 0 : props.thickness1 || props.thickness || 1;
1206
+ const thickness2 =
1207
+ props.thickness2 === 0 ? 0 : props.thickness2 || props.thickness || 1;
1208
+ const thickness3 =
1209
+ props.thickness3 === 0 ? 0 : props.thickness3 || props.thickness || 1;
1210
+ const thickness4 =
1211
+ props.thickness4 === 0 ? 0 : props.thickness4 || props.thickness || 1;
1212
+ const thickness5 =
1213
+ props.thickness5 === 0 ? 0 : props.thickness5 || props.thickness || 1;
1164
1214
 
1165
1215
  const strokeDashArray1 = props.strokeDashArray1 || props.strokeDashArray;
1166
1216
  const strokeDashArray2 = props.strokeDashArray2 || props.strokeDashArray;
@@ -1257,7 +1307,7 @@ export const LineChart = (props: propTypes) => {
1257
1307
  height: 0,
1258
1308
  width: 0,
1259
1309
  radius: 5,
1260
- color: 'red',
1310
+ pointerColor: 'red',
1261
1311
  pointerComponent: null,
1262
1312
  showPointerStrip: true,
1263
1313
  pointerStripHeight: containerHeight,
@@ -1268,72 +1318,114 @@ export const LineChart = (props: propTypes) => {
1268
1318
  shiftPointerLabelX: 0,
1269
1319
  shiftPointerLabelY: 0,
1270
1320
  pointerLabelWidth: 40,
1271
- pointerVanishDelay: 200,
1321
+ pointerVanishDelay: 150,
1322
+ activatePointersOnLongPress: false,
1323
+ activatePointersDelay: 150,
1324
+ hidePointer1: false,
1325
+ hidePointer2: false,
1326
+ hidePointer3: false,
1327
+ hidePointer4: false,
1328
+ hidePointer5: false,
1272
1329
  };
1273
1330
  const pointerConfig = props.pointerConfig || null;
1274
1331
  const pointerHeight =
1275
1332
  pointerConfig && pointerConfig.height
1276
- ? props.pointerConfig.height
1333
+ ? pointerConfig.height
1277
1334
  : defaultPointerConfig.height;
1278
1335
  const pointerWidth =
1279
1336
  pointerConfig && pointerConfig.width
1280
- ? props.pointerConfig.width
1337
+ ? pointerConfig.width
1281
1338
  : defaultPointerConfig.width;
1282
1339
  const pointerRadius =
1283
1340
  pointerConfig && pointerConfig.radius
1284
- ? props.pointerConfig.radius
1341
+ ? pointerConfig.radius
1285
1342
  : defaultPointerConfig.radius;
1286
1343
  const pointerColor =
1287
- pointerConfig && pointerConfig.color
1288
- ? props.pointerConfig.color
1289
- : defaultPointerConfig.color;
1344
+ pointerConfig && pointerConfig.pointerColor
1345
+ ? pointerConfig.pointerColor
1346
+ : defaultPointerConfig.pointerColor;
1290
1347
  const pointerComponent =
1291
1348
  pointerConfig && pointerConfig.pointerComponent
1292
- ? props.pointerConfig.pointerComponent
1349
+ ? pointerConfig.pointerComponent
1293
1350
  : defaultPointerConfig.pointerComponent;
1294
1351
 
1295
1352
  const showPointerStrip =
1296
1353
  pointerConfig && pointerConfig.showPointerStrip
1297
- ? props.pointerConfig.showPointerStrip
1354
+ ? pointerConfig.showPointerStrip
1298
1355
  : defaultPointerConfig.showPointerStrip;
1299
1356
  const pointerStripHeight =
1300
1357
  pointerConfig && pointerConfig.pointerStripHeight
1301
- ? props.pointerConfig.pointerStripHeight
1358
+ ? pointerConfig.pointerStripHeight
1302
1359
  : defaultPointerConfig.pointerStripHeight;
1303
1360
  const pointerStripWidth =
1304
1361
  pointerConfig && pointerConfig.pointerStripWidth
1305
- ? props.pointerConfig.pointerStripWidth
1362
+ ? pointerConfig.pointerStripWidth
1306
1363
  : defaultPointerConfig.pointerStripWidth;
1307
1364
  const pointerStripColor =
1308
1365
  pointerConfig && pointerConfig.pointerStripColor
1309
- ? props.pointerConfig.pointerStripColor
1366
+ ? pointerConfig.pointerStripColor
1310
1367
  : defaultPointerConfig.pointerStripColor;
1311
1368
  const pointerStripUptoDataPoint =
1312
1369
  pointerConfig && pointerConfig.pointerStripUptoDataPoint
1313
- ? props.pointerConfig.pointerStripUptoDataPoint
1370
+ ? pointerConfig.pointerStripUptoDataPoint
1314
1371
  : defaultPointerConfig.pointerStripUptoDataPoint;
1315
1372
  const pointerLabelComponent =
1316
1373
  pointerConfig && pointerConfig.pointerLabelComponent
1317
- ? props.pointerConfig.pointerLabelComponent
1374
+ ? pointerConfig.pointerLabelComponent
1318
1375
  : defaultPointerConfig.pointerLabelComponent;
1319
1376
  const shiftPointerLabelX =
1320
1377
  pointerConfig && pointerConfig.shiftPointerLabelX
1321
- ? props.pointerConfig.shiftPointerLabelX
1378
+ ? pointerConfig.shiftPointerLabelX
1322
1379
  : defaultPointerConfig.shiftPointerLabelX;
1323
1380
  const shiftPointerLabelY =
1324
1381
  pointerConfig && pointerConfig.shiftPointerLabelY
1325
- ? props.pointerConfig.shiftPointerLabelY
1382
+ ? pointerConfig.shiftPointerLabelY
1326
1383
  : defaultPointerConfig.shiftPointerLabelY;
1327
1384
  const pointerLabelWidth =
1328
1385
  pointerConfig && pointerConfig.pointerLabelWidth
1329
- ? props.pointerConfig.pointerLabelWidth
1386
+ ? pointerConfig.pointerLabelWidth
1330
1387
  : defaultPointerConfig.pointerLabelWidth;
1331
1388
  const pointerVanishDelay =
1332
1389
  pointerConfig && pointerConfig.pointerVanishDelay
1333
- ? props.pointerConfig.pointerVanishDelay
1390
+ ? pointerConfig.pointerVanishDelay
1334
1391
  : defaultPointerConfig.pointerVanishDelay;
1335
-
1336
- const disableScroll = props.disableScroll || pointerConfig || false;
1392
+ const activatePointersOnLongPress =
1393
+ pointerConfig && pointerConfig.activatePointersOnLongPress
1394
+ ? pointerConfig.activatePointersOnLongPress
1395
+ : defaultPointerConfig.activatePointersOnLongPress;
1396
+ const activatePointersDelay =
1397
+ pointerConfig && pointerConfig.activatePointersDelay
1398
+ ? pointerConfig.activatePointersDelay
1399
+ : defaultPointerConfig.activatePointersDelay;
1400
+ const hidePointer1 =
1401
+ pointerConfig && pointerConfig.hidePointer1
1402
+ ? pointerConfig.hidePointer1
1403
+ : defaultPointerConfig.hidePointer1;
1404
+ const hidePointer2 =
1405
+ pointerConfig && pointerConfig.hidePointer2
1406
+ ? pointerConfig.hidePointer2
1407
+ : defaultPointerConfig.hidePointer2;
1408
+ const hidePointer3 =
1409
+ pointerConfig && pointerConfig.hidePointer3
1410
+ ? pointerConfig.hidePointer3
1411
+ : defaultPointerConfig.hidePointer3;
1412
+ const hidePointer4 =
1413
+ pointerConfig && pointerConfig.hidePointer4
1414
+ ? pointerConfig.hidePointer4
1415
+ : defaultPointerConfig.hidePointer4;
1416
+ const hidePointer5 =
1417
+ pointerConfig && pointerConfig.hidePointer5
1418
+ ? pointerConfig.hidePointer5
1419
+ : defaultPointerConfig.hidePointer5;
1420
+ const disableScroll =
1421
+ props.disableScroll ||
1422
+ (pointerConfig
1423
+ ? activatePointersOnLongPress
1424
+ ? responderActive
1425
+ ? true
1426
+ : false
1427
+ : true
1428
+ : false);
1337
1429
  const showScrollIndicator = props.showScrollIndicator || false;
1338
1430
  const hideOrigin = props.hideOrigin || false;
1339
1431
 
@@ -2236,13 +2328,47 @@ export const LineChart = (props: propTypes) => {
2236
2328
  });
2237
2329
  };
2238
2330
 
2239
- const renderPointer = () => {
2331
+ const renderPointer = (lineNumber: number) => {
2332
+ if (lineNumber === 1 && hidePointer1) return;
2333
+ if (lineNumber === 2 && hidePointer2) return;
2334
+ if (lineNumber === 3 && hidePointer3) return;
2335
+ if (lineNumber === 4 && hidePointer4) return;
2336
+ if (lineNumber === 5 && hidePointer5) return;
2337
+ let pointerItemLocal, pointerYLocal, pointerColorLocal;
2338
+ switch (lineNumber) {
2339
+ case 1:
2340
+ pointerItemLocal = pointerItem;
2341
+ pointerYLocal = pointerY;
2342
+ pointerColorLocal = pointerConfig.pointer1Color || pointerColor;
2343
+ break;
2344
+ case 2:
2345
+ pointerItemLocal = pointerItem2;
2346
+ pointerYLocal = pointerY2;
2347
+ pointerColorLocal = pointerConfig.pointer2Color || pointerColor;
2348
+ break;
2349
+ case 3:
2350
+ pointerItemLocal = pointerItem3;
2351
+ pointerYLocal = pointerY3;
2352
+ pointerColorLocal = pointerConfig.pointer3Color || pointerColor;
2353
+ break;
2354
+ case 4:
2355
+ pointerItemLocal = pointerItem4;
2356
+ pointerYLocal = pointerY4;
2357
+ pointerColorLocal = pointerConfig.pointer4Color || pointerColor;
2358
+ break;
2359
+ case 5:
2360
+ pointerItemLocal = pointerItem5;
2361
+ pointerYLocal = pointerY5;
2362
+ pointerColorLocal = pointerConfig.pointer5Color || pointerColor;
2363
+ break;
2364
+ }
2365
+
2240
2366
  return (
2241
2367
  <View
2242
2368
  style={{
2243
2369
  position: 'absolute',
2244
- left: pointerX + (pointerItem.pointerShiftX || 0),
2245
- top: pointerY,
2370
+ left: pointerX + (pointerItemLocal.pointerShiftX || 0),
2371
+ top: pointerYLocal,
2246
2372
  }}>
2247
2373
  {pointerComponent ? (
2248
2374
  pointerComponent()
@@ -2251,8 +2377,8 @@ export const LineChart = (props: propTypes) => {
2251
2377
  style={{
2252
2378
  height: pointerHeight || pointerRadius * 2,
2253
2379
  width: pointerWidth || pointerRadius * 2,
2254
- marginTop: pointerItem.pointerShiftY || 0,
2255
- backgroundColor: pointerColor,
2380
+ marginTop: pointerItemLocal.pointerShiftY || 0,
2381
+ backgroundColor: pointerColorLocal,
2256
2382
  borderRadius: pointerRadius || 0,
2257
2383
  }}
2258
2384
  />
@@ -2264,9 +2390,9 @@ export const LineChart = (props: propTypes) => {
2264
2390
  left: pointerRadius || pointerWidth / 2,
2265
2391
  top: pointerStripUptoDataPoint
2266
2392
  ? pointerRadius || pointerStripHeight / 2
2267
- : -pointerY + 8,
2393
+ : -pointerYLocal + 8,
2268
2394
  height: pointerStripUptoDataPoint
2269
- ? containerHeight - pointerY - 10
2395
+ ? containerHeight - pointerYLocal - 10
2270
2396
  : pointerStripHeight,
2271
2397
  width: pointerStripWidth,
2272
2398
  backgroundColor: pointerStripColor,
@@ -2286,7 +2412,7 @@ export const LineChart = (props: propTypes) => {
2286
2412
  top:
2287
2413
  (pointerStripUptoDataPoint
2288
2414
  ? pointerRadius || pointerStripHeight / 2
2289
- : -pointerY + 8) -
2415
+ : -pointerYLocal + 8) -
2290
2416
  pointerLabelWidth / 2 +
2291
2417
  shiftPointerLabelY,
2292
2418
  marginTop: pointerStripUptoDataPoint
@@ -2294,14 +2420,161 @@ export const LineChart = (props: propTypes) => {
2294
2420
  : containerHeight - pointerStripHeight,
2295
2421
  width: pointerLabelWidth,
2296
2422
  }}>
2297
- {pointerLabelComponent(pointerItem)}
2423
+ {pointerLabelComponent(pointerItemLocal)}
2298
2424
  </View>
2299
2425
  )}
2300
2426
  </View>
2301
2427
  );
2302
2428
  };
2303
2429
 
2430
+ const lineSvgComponent = (
2431
+ points: any,
2432
+ currentLineThickness: number | undefined,
2433
+ color: string,
2434
+ fillPoints: any,
2435
+ startFillColor: string,
2436
+ endFillColor: string,
2437
+ startOpacity: number,
2438
+ endOpacity: number,
2439
+ strokeDashArray: Array<number> | undefined | null,
2440
+ ) => {
2441
+ return (
2442
+ <Svg>
2443
+ {strokeDashArray &&
2444
+ strokeDashArray.length === 2 &&
2445
+ typeof strokeDashArray[0] === 'number' &&
2446
+ typeof strokeDashArray[1] === 'number' ? (
2447
+ <Path
2448
+ d={points}
2449
+ fill="none"
2450
+ stroke={color}
2451
+ strokeWidth={currentLineThickness || thickness}
2452
+ strokeDasharray={strokeDashArray}
2453
+ />
2454
+ ) : (
2455
+ <Path
2456
+ d={points}
2457
+ fill="none"
2458
+ stroke={color}
2459
+ strokeWidth={currentLineThickness || thickness}
2460
+ />
2461
+ )}
2462
+
2463
+ {/*********************** For Area Chart ************/}
2464
+
2465
+ {areaChart && (
2466
+ <LinearGradient
2467
+ id="Gradient"
2468
+ x1="0"
2469
+ y1="0"
2470
+ x2={gradientDirection === 'horizontal' ? '1' : '0'}
2471
+ y2={gradientDirection === 'vertical' ? '1' : '0'}>
2472
+ <Stop
2473
+ offset="0"
2474
+ stopColor={startFillColor}
2475
+ stopOpacity={startOpacity.toString()}
2476
+ />
2477
+ <Stop
2478
+ offset="1"
2479
+ stopColor={endFillColor}
2480
+ stopOpacity={endOpacity.toString()}
2481
+ />
2482
+ </LinearGradient>
2483
+ )}
2484
+ {areaChart && (
2485
+ <Path
2486
+ d={fillPoints}
2487
+ fill="url(#Gradient)"
2488
+ stroke={'transparent'}
2489
+ strokeWidth={currentLineThickness || thickness}
2490
+ />
2491
+ )}
2492
+
2493
+ {/******************************************************************/}
2494
+
2495
+ {renderSpecificVerticalLines(data)}
2496
+ {renderSpecificVerticalLines(data2)}
2497
+ {renderSpecificVerticalLines(data3)}
2498
+ {renderSpecificVerticalLines(data4)}
2499
+ {renderSpecificVerticalLines(data5)}
2500
+
2501
+ {/*** !!! Here it's done thrice intentionally, trying to make it to only 1 breaks things !!! ***/}
2502
+ {!hideDataPoints1
2503
+ ? renderDataPoints(
2504
+ data,
2505
+ dataPointsShape1,
2506
+ dataPointsWidth1,
2507
+ dataPointsHeight1,
2508
+ dataPointsColor1,
2509
+ dataPointsRadius1,
2510
+ textColor1,
2511
+ textFontSize1,
2512
+ startIndex1,
2513
+ endIndex1,
2514
+ )
2515
+ : null}
2516
+ {!hideDataPoints2
2517
+ ? renderDataPoints(
2518
+ data2,
2519
+ dataPointsShape2,
2520
+ dataPointsWidth2,
2521
+ dataPointsHeight2,
2522
+ dataPointsColor2,
2523
+ dataPointsRadius2,
2524
+ textColor2,
2525
+ textFontSize2,
2526
+ startIndex2,
2527
+ endIndex2,
2528
+ )
2529
+ : null}
2530
+ {!hideDataPoints3
2531
+ ? renderDataPoints(
2532
+ data3,
2533
+ dataPointsShape3,
2534
+ dataPointsWidth3,
2535
+ dataPointsHeight3,
2536
+ dataPointsColor3,
2537
+ dataPointsRadius3,
2538
+ textColor3,
2539
+ textFontSize3,
2540
+ startIndex3,
2541
+ endIndex3,
2542
+ )
2543
+ : null}
2544
+ {!hideDataPoints4
2545
+ ? renderDataPoints(
2546
+ data4,
2547
+ dataPointsShape4,
2548
+ dataPointsWidth4,
2549
+ dataPointsHeight4,
2550
+ dataPointsColor4,
2551
+ dataPointsRadius4,
2552
+ textColor4,
2553
+ textFontSize4,
2554
+ startIndex4,
2555
+ endIndex4,
2556
+ )
2557
+ : null}
2558
+ {!hideDataPoints5
2559
+ ? renderDataPoints(
2560
+ data5,
2561
+ dataPointsShape5,
2562
+ dataPointsWidth5,
2563
+ dataPointsHeight5,
2564
+ dataPointsColor5,
2565
+ dataPointsRadius5,
2566
+ textColor5,
2567
+ textFontSize5,
2568
+ startIndex5,
2569
+ endIndex5,
2570
+ )
2571
+ : null}
2572
+ </Svg>
2573
+ );
2574
+ };
2575
+
2304
2576
  const renderLine = (
2577
+ lineNumber: number,
2305
2578
  points: any,
2306
2579
  currentLineThickness: number | undefined,
2307
2580
  color: string,
@@ -2318,6 +2591,10 @@ export const LineChart = (props: propTypes) => {
2318
2591
  onMoveShouldSetResponder={evt => (pointerConfig ? true : false)}
2319
2592
  onResponderGrant={evt => {
2320
2593
  if (!pointerConfig) return;
2594
+ setResponderStartTime(evt.timeStamp);
2595
+ if (activatePointersOnLongPress) {
2596
+ return;
2597
+ }
2321
2598
  let x = evt.nativeEvent.locationX;
2322
2599
  let factor = (x - initialSpacing) / spacing;
2323
2600
  factor = Math.round(factor);
@@ -2327,19 +2604,77 @@ export const LineChart = (props: propTypes) => {
2327
2604
  initialSpacing +
2328
2605
  spacing * factor -
2329
2606
  (pointerRadius || pointerWidth / 2) -
2330
- 3;
2607
+ 2;
2331
2608
  setPointerX(z);
2332
- let item = data[factor];
2333
- let y =
2609
+ let item, y;
2610
+ setPointerX(z);
2611
+ item = data[factor];
2612
+ y =
2334
2613
  containerHeight -
2335
2614
  (item.value * containerHeight) / maxValue -
2336
2615
  (pointerRadius || pointerHeight / 2) +
2337
2616
  10;
2338
2617
  setPointerY(y);
2339
2618
  setPointerItem(item);
2619
+ if (data2 && data2.length) {
2620
+ item = data2[factor];
2621
+ if (item) {
2622
+ y =
2623
+ containerHeight -
2624
+ (item.value * containerHeight) / maxValue -
2625
+ (pointerRadius || pointerHeight / 2) +
2626
+ 10;
2627
+ setPointerY2(y);
2628
+ setPointerItem2(item);
2629
+ }
2630
+ }
2631
+ if (data3 && data3.length) {
2632
+ item = data3[factor];
2633
+ if (item) {
2634
+ y =
2635
+ containerHeight -
2636
+ (item.value * containerHeight) / maxValue -
2637
+ (pointerRadius || pointerHeight / 2) +
2638
+ 10;
2639
+ setPointerY3(y);
2640
+ setPointerItem3(item);
2641
+ }
2642
+ }
2643
+ if (data4 && data4.length) {
2644
+ item = data4[factor];
2645
+ if (item) {
2646
+ y =
2647
+ containerHeight -
2648
+ (item.value * containerHeight) / maxValue -
2649
+ (pointerRadius || pointerHeight / 2) +
2650
+ 10;
2651
+ setPointerY4(y);
2652
+ setPointerItem4(item);
2653
+ }
2654
+ }
2655
+ if (data5 && data5.length) {
2656
+ item = data5[factor];
2657
+ if (item) {
2658
+ y =
2659
+ containerHeight -
2660
+ (item.value * containerHeight) / maxValue -
2661
+ (pointerRadius || pointerHeight / 2) +
2662
+ 10;
2663
+ setPointerY5(y);
2664
+ setPointerItem5(item);
2665
+ }
2666
+ }
2340
2667
  }}
2341
2668
  onResponderMove={evt => {
2342
2669
  if (!pointerConfig) return;
2670
+ if (
2671
+ activatePointersOnLongPress &&
2672
+ evt.timeStamp - responderStartTime < activatePointersDelay
2673
+ ) {
2674
+ return;
2675
+ } else {
2676
+ setResponderActive(true);
2677
+ }
2343
2678
  let x = evt.nativeEvent.locationX;
2344
2679
  let factor = (x - initialSpacing) / spacing;
2345
2680
  factor = Math.round(factor);
@@ -2349,18 +2684,69 @@ export const LineChart = (props: propTypes) => {
2349
2684
  initialSpacing +
2350
2685
  spacing * factor -
2351
2686
  (pointerRadius || pointerWidth / 2) -
2352
- 3;
2687
+ 2;
2688
+ let item, y;
2353
2689
  setPointerX(z);
2354
- let item = data[factor];
2355
- let y =
2690
+ item = data[factor];
2691
+ y =
2356
2692
  containerHeight -
2357
2693
  (item.value * containerHeight) / maxValue -
2358
2694
  (pointerRadius || pointerHeight / 2) +
2359
2695
  10;
2360
2696
  setPointerY(y);
2361
2697
  setPointerItem(item);
2698
+ if (data2 && data2.length) {
2699
+ item = data2[factor];
2700
+ if (item) {
2701
+ y =
2702
+ containerHeight -
2703
+ (item.value * containerHeight) / maxValue -
2704
+ (pointerRadius || pointerHeight / 2) +
2705
+ 10;
2706
+ setPointerY2(y);
2707
+ setPointerItem2(item);
2708
+ }
2709
+ }
2710
+ if (data3 && data3.length) {
2711
+ item = data3[factor];
2712
+ if (item) {
2713
+ y =
2714
+ containerHeight -
2715
+ (item.value * containerHeight) / maxValue -
2716
+ (pointerRadius || pointerHeight / 2) +
2717
+ 10;
2718
+ setPointerY3(y);
2719
+ setPointerItem3(item);
2720
+ }
2721
+ }
2722
+ if (data4 && data4.length) {
2723
+ item = data4[factor];
2724
+ if (item) {
2725
+ y =
2726
+ containerHeight -
2727
+ (item.value * containerHeight) / maxValue -
2728
+ (pointerRadius || pointerHeight / 2) +
2729
+ 10;
2730
+ setPointerY4(y);
2731
+ setPointerItem4(item);
2732
+ }
2733
+ }
2734
+ if (data5 && data5.length) {
2735
+ item = data5[factor];
2736
+ if (item) {
2737
+ y =
2738
+ containerHeight -
2739
+ (item.value * containerHeight) / maxValue -
2740
+ (pointerRadius || pointerHeight / 2) +
2741
+ 10;
2742
+ setPointerY5(y);
2743
+ setPointerItem5(item);
2744
+ }
2745
+ }
2362
2746
  }}
2363
2747
  onResponderRelease={evt => {
2748
+ setResponderStartTime(0);
2749
+ setResponderActive(false);
2364
2750
  setTimeout(() => setPointerX(0), pointerVanishDelay);
2365
2751
  }}
2366
2752
  style={{
@@ -2370,143 +2756,24 @@ export const LineChart = (props: propTypes) => {
2370
2756
  width: totalWidth,
2371
2757
  zIndex: 20,
2372
2758
  }}>
2373
- <Svg>
2374
- {strokeDashArray &&
2375
- strokeDashArray.length === 2 &&
2376
- typeof strokeDashArray[0] === 'number' &&
2377
- typeof strokeDashArray[1] === 'number' ? (
2378
- <Path
2379
- d={points}
2380
- fill="none"
2381
- stroke={color}
2382
- strokeWidth={currentLineThickness || thickness}
2383
- strokeDasharray={strokeDashArray}
2384
- />
2385
- ) : (
2386
- <Path
2387
- d={points}
2388
- fill="none"
2389
- stroke={color}
2390
- strokeWidth={currentLineThickness || thickness}
2391
- />
2392
- )}
2393
-
2394
- {/*********************** For Area Chart ************/}
2395
-
2396
- {areaChart && (
2397
- <LinearGradient
2398
- id="Gradient"
2399
- x1="0"
2400
- y1="0"
2401
- x2={gradientDirection === 'horizontal' ? '1' : '0'}
2402
- y2={gradientDirection === 'vertical' ? '1' : '0'}>
2403
- <Stop
2404
- offset="0"
2405
- stopColor={startFillColor}
2406
- stopOpacity={startOpacity.toString()}
2407
- />
2408
- <Stop
2409
- offset="1"
2410
- stopColor={endFillColor}
2411
- stopOpacity={endOpacity.toString()}
2412
- />
2413
- </LinearGradient>
2414
- )}
2415
- {areaChart && (
2416
- <Path
2417
- d={fillPoints}
2418
- fill="url(#Gradient)"
2419
- stroke={'transparent'}
2420
- strokeWidth={currentLineThickness || thickness}
2421
- />
2422
- )}
2423
-
2424
- {/******************************************************************/}
2425
-
2426
- {renderSpecificVerticalLines(data)}
2427
- {renderSpecificVerticalLines(data2)}
2428
- {renderSpecificVerticalLines(data3)}
2429
- {renderSpecificVerticalLines(data4)}
2430
- {renderSpecificVerticalLines(data5)}
2431
-
2432
- {/*** !!! Here it's done thrice intentionally, trying to make it to only 1 breaks things !!! ***/}
2433
- {!hideDataPoints1
2434
- ? renderDataPoints(
2435
- data,
2436
- dataPointsShape1,
2437
- dataPointsWidth1,
2438
- dataPointsHeight1,
2439
- dataPointsColor1,
2440
- dataPointsRadius1,
2441
- textColor1,
2442
- textFontSize1,
2443
- startIndex1,
2444
- endIndex1,
2445
- )
2446
- : null}
2447
- {!hideDataPoints2
2448
- ? renderDataPoints(
2449
- data2,
2450
- dataPointsShape2,
2451
- dataPointsWidth2,
2452
- dataPointsHeight2,
2453
- dataPointsColor2,
2454
- dataPointsRadius2,
2455
- textColor2,
2456
- textFontSize2,
2457
- startIndex2,
2458
- endIndex2,
2459
- )
2460
- : null}
2461
- {!hideDataPoints3
2462
- ? renderDataPoints(
2463
- data3,
2464
- dataPointsShape3,
2465
- dataPointsWidth3,
2466
- dataPointsHeight3,
2467
- dataPointsColor3,
2468
- dataPointsRadius3,
2469
- textColor3,
2470
- textFontSize3,
2471
- startIndex3,
2472
- endIndex3,
2473
- )
2474
- : null}
2475
- {!hideDataPoints4
2476
- ? renderDataPoints(
2477
- data4,
2478
- dataPointsShape4,
2479
- dataPointsWidth4,
2480
- dataPointsHeight4,
2481
- dataPointsColor4,
2482
- dataPointsRadius4,
2483
- textColor4,
2484
- textFontSize4,
2485
- startIndex4,
2486
- endIndex4,
2487
- )
2488
- : null}
2489
- {!hideDataPoints5
2490
- ? renderDataPoints(
2491
- data5,
2492
- dataPointsShape5,
2493
- dataPointsWidth5,
2494
- dataPointsHeight5,
2495
- dataPointsColor5,
2496
- dataPointsRadius5,
2497
- textColor5,
2498
- textFontSize5,
2499
- startIndex5,
2500
- endIndex5,
2501
- )
2502
- : null}
2503
- </Svg>
2504
- {pointerX ? renderPointer() : null}
2759
+ {lineSvgComponent(
2760
+ points,
2761
+ currentLineThickness,
2762
+ color,
2763
+ fillPoints,
2764
+ startFillColor,
2765
+ endFillColor,
2766
+ startOpacity,
2767
+ endOpacity,
2768
+ strokeDashArray,
2769
+ )}
2770
+ {pointerX ? renderPointer(lineNumber) : null}
2505
2771
  </View>
2506
2772
  );
2507
2773
  };
2508
2774
 
2509
2775
  const renderAnimatedLine = (
2776
+ lineNumber: number,
2510
2777
  points: any,
2511
2778
  animatedWidth: any,
2512
2779
  currentLineThickness: number | undefined,
@@ -2525,6 +2792,10 @@ export const LineChart = (props: propTypes) => {
2525
2792
  onMoveShouldSetResponder={evt => (pointerConfig ? true : false)}
2526
2793
  onResponderGrant={evt => {
2527
2794
  if (!pointerConfig) return;
2795
+ setResponderStartTime(evt.timeStamp);
2796
+ if (activatePointersOnLongPress) {
2797
+ return;
2798
+ }
2528
2799
  let x = evt.nativeEvent.locationX;
2529
2800
  let factor = (x - initialSpacing) / spacing;
2530
2801
  factor = Math.round(factor);
@@ -2534,19 +2805,77 @@ export const LineChart = (props: propTypes) => {
2534
2805
  initialSpacing +
2535
2806
  spacing * factor -
2536
2807
  (pointerRadius || pointerWidth / 2) -
2537
- 3;
2808
+ 2;
2809
+ setPointerX(z);
2810
+ let item, y;
2538
2811
  setPointerX(z);
2539
- let item = data[factor];
2540
- let y =
2812
+ item = data[factor];
2813
+ y =
2541
2814
  containerHeight -
2542
2815
  (item.value * containerHeight) / maxValue -
2543
2816
  (pointerRadius || pointerHeight / 2) +
2544
2817
  10;
2545
2818
  setPointerY(y);
2546
2819
  setPointerItem(item);
2820
+ if (data2 && data2.length) {
2821
+ item = data2[factor];
2822
+ if (item) {
2823
+ y =
2824
+ containerHeight -
2825
+ (item.value * containerHeight) / maxValue -
2826
+ (pointerRadius || pointerHeight / 2) +
2827
+ 10;
2828
+ setPointerY2(y);
2829
+ setPointerItem2(item);
2830
+ }
2831
+ }
2832
+ if (data3 && data3.length) {
2833
+ item = data3[factor];
2834
+ if (item) {
2835
+ y =
2836
+ containerHeight -
2837
+ (item.value * containerHeight) / maxValue -
2838
+ (pointerRadius || pointerHeight / 2) +
2839
+ 10;
2840
+ setPointerY3(y);
2841
+ setPointerItem3(item);
2842
+ }
2843
+ }
2844
+ if (data4 && data4.length) {
2845
+ item = data4[factor];
2846
+ if (item) {
2847
+ y =
2848
+ containerHeight -
2849
+ (item.value * containerHeight) / maxValue -
2850
+ (pointerRadius || pointerHeight / 2) +
2851
+ 10;
2852
+ setPointerY4(y);
2853
+ setPointerItem4(item);
2854
+ }
2855
+ }
2856
+ if (data5 && data5.length) {
2857
+ item = data5[factor];
2858
+ if (item) {
2859
+ y =
2860
+ containerHeight -
2861
+ (item.value * containerHeight) / maxValue -
2862
+ (pointerRadius || pointerHeight / 2) +
2863
+ 10;
2864
+ setPointerY5(y);
2865
+ setPointerItem5(item);
2866
+ }
2867
+ }
2547
2868
  }}
2548
2869
  onResponderMove={evt => {
2549
2870
  if (!pointerConfig) return;
2871
+ if (
2872
+ activatePointersOnLongPress &&
2873
+ evt.timeStamp - responderStartTime < activatePointersDelay
2874
+ ) {
2875
+ return;
2876
+ } else {
2877
+ setResponderActive(true);
2878
+ }
2550
2879
  let x = evt.nativeEvent.locationX;
2551
2880
  let factor = (x - initialSpacing) / spacing;
2552
2881
  factor = Math.round(factor);
@@ -2556,18 +2885,69 @@ export const LineChart = (props: propTypes) => {
2556
2885
  initialSpacing +
2557
2886
  spacing * factor -
2558
2887
  (pointerRadius || pointerWidth / 2) -
2559
- 3;
2888
+ 2;
2889
+ let item, y;
2560
2890
  setPointerX(z);
2561
- let item = data[factor];
2562
- let y =
2891
+ item = data[factor];
2892
+ y =
2563
2893
  containerHeight -
2564
2894
  (item.value * containerHeight) / maxValue -
2565
2895
  (pointerRadius || pointerHeight / 2) +
2566
2896
  10;
2567
2897
  setPointerY(y);
2568
2898
  setPointerItem(item);
2899
+ if (data2 && data2.length) {
2900
+ item = data2[factor];
2901
+ if (item) {
2902
+ y =
2903
+ containerHeight -
2904
+ (item.value * containerHeight) / maxValue -
2905
+ (pointerRadius || pointerHeight / 2) +
2906
+ 10;
2907
+ setPointerY2(y);
2908
+ setPointerItem2(item);
2909
+ }
2910
+ }
2911
+ if (data3 && data3.length) {
2912
+ item = data3[factor];
2913
+ if (item) {
2914
+ y =
2915
+ containerHeight -
2916
+ (item.value * containerHeight) / maxValue -
2917
+ (pointerRadius || pointerHeight / 2) +
2918
+ 10;
2919
+ setPointerY3(y);
2920
+ setPointerItem3(item);
2921
+ }
2922
+ }
2923
+ if (data4 && data4.length) {
2924
+ item = data4[factor];
2925
+ if (item) {
2926
+ y =
2927
+ containerHeight -
2928
+ (item.value * containerHeight) / maxValue -
2929
+ (pointerRadius || pointerHeight / 2) +
2930
+ 10;
2931
+ setPointerY4(y);
2932
+ setPointerItem4(item);
2933
+ }
2934
+ }
2935
+ if (data5 && data5.length) {
2936
+ item = data5[factor];
2937
+ if (item) {
2938
+ y =
2939
+ containerHeight -
2940
+ (item.value * containerHeight) / maxValue -
2941
+ (pointerRadius || pointerHeight / 2) +
2942
+ 10;
2943
+ setPointerY5(y);
2944
+ setPointerItem5(item);
2945
+ }
2946
+ }
2569
2947
  }}
2570
2948
  onResponderRelease={evt => {
2949
+ setResponderStartTime(0);
2950
+ setResponderActive(false);
2571
2951
  setTimeout(() => setPointerX(0), pointerVanishDelay);
2572
2952
  }}
2573
2953
  style={{
@@ -2578,138 +2958,18 @@ export const LineChart = (props: propTypes) => {
2578
2958
  zIndex: -1,
2579
2959
  // backgroundColor: 'wheat',
2580
2960
  }}>
2581
- <Svg>
2582
- {strokeDashArray &&
2583
- strokeDashArray.length === 2 &&
2584
- typeof strokeDashArray[0] === 'number' &&
2585
- typeof strokeDashArray[1] === 'number' ? (
2586
- <Path
2587
- d={points}
2588
- fill="none"
2589
- stroke={color}
2590
- strokeWidth={currentLineThickness || thickness}
2591
- strokeDasharray={strokeDashArray}
2592
- />
2593
- ) : (
2594
- <Path
2595
- d={points}
2596
- fill="none"
2597
- stroke={color}
2598
- strokeWidth={currentLineThickness || thickness}
2599
- />
2600
- )}
2601
-
2602
- {/*********************** For Area Chart ************/}
2603
-
2604
- {areaChart && (
2605
- <LinearGradient
2606
- id="Gradient"
2607
- x1="0"
2608
- y1="0"
2609
- x2={gradientDirection === 'horizontal' ? '1' : '0'}
2610
- y2={gradientDirection === 'vertical' ? '1' : '0'}>
2611
- <Stop
2612
- offset="0"
2613
- stopColor={startFillColor}
2614
- stopOpacity={startOpacity.toString()}
2615
- />
2616
- <Stop
2617
- offset="1"
2618
- stopColor={endFillColor}
2619
- stopOpacity={endOpacity.toString()}
2620
- />
2621
- </LinearGradient>
2622
- )}
2623
- {areaChart && (
2624
- <Path
2625
- d={fillPoints}
2626
- fill="url(#Gradient)"
2627
- stroke={'transparent'}
2628
- strokeWidth={currentLineThickness || thickness}
2629
- />
2630
- )}
2631
-
2632
- {/******************************************************************/}
2633
-
2634
- {renderSpecificVerticalLines(data)}
2635
- {renderSpecificVerticalLines(data2)}
2636
- {renderSpecificVerticalLines(data3)}
2637
- {renderSpecificVerticalLines(data4)}
2638
- {renderSpecificVerticalLines(data5)}
2639
-
2640
- {/*** !!! Here it's done thrice intentionally, trying to make it to only 1 breaks things !!! ***/}
2641
- {!hideDataPoints1
2642
- ? renderDataPoints(
2643
- data,
2644
- dataPointsShape1,
2645
- dataPointsWidth1,
2646
- dataPointsHeight1,
2647
- dataPointsColor1,
2648
- dataPointsRadius1,
2649
- textColor1,
2650
- textFontSize1,
2651
- startIndex1,
2652
- endIndex1,
2653
- )
2654
- : null}
2655
- {!hideDataPoints2
2656
- ? renderDataPoints(
2657
- data2,
2658
- dataPointsShape2,
2659
- dataPointsWidth2,
2660
- dataPointsHeight2,
2661
- dataPointsColor2,
2662
- dataPointsRadius2,
2663
- textColor2,
2664
- textFontSize2,
2665
- startIndex2,
2666
- endIndex2,
2667
- )
2668
- : null}
2669
- {!hideDataPoints3
2670
- ? renderDataPoints(
2671
- data3,
2672
- dataPointsShape3,
2673
- dataPointsWidth3,
2674
- dataPointsHeight3,
2675
- dataPointsColor3,
2676
- dataPointsRadius3,
2677
- textColor3,
2678
- textFontSize3,
2679
- startIndex3,
2680
- endIndex3,
2681
- )
2682
- : null}
2683
- {!hideDataPoints4
2684
- ? renderDataPoints(
2685
- data4,
2686
- dataPointsShape4,
2687
- dataPointsWidth4,
2688
- dataPointsHeight4,
2689
- dataPointsColor4,
2690
- dataPointsRadius4,
2691
- textColor4,
2692
- textFontSize4,
2693
- startIndex4,
2694
- endIndex4,
2695
- )
2696
- : null}
2697
- {!hideDataPoints5
2698
- ? renderDataPoints(
2699
- data5,
2700
- dataPointsShape5,
2701
- dataPointsWidth5,
2702
- dataPointsHeight5,
2703
- dataPointsColor5,
2704
- dataPointsRadius5,
2705
- textColor5,
2706
- textFontSize5,
2707
- startIndex5,
2708
- endIndex5,
2709
- )
2710
- : null}
2711
- </Svg>
2712
- {pointerX ? renderPointer() : null}
2961
+ {lineSvgComponent(
2962
+ points,
2963
+ currentLineThickness,
2964
+ color,
2965
+ fillPoints,
2966
+ startFillColor,
2967
+ endFillColor,
2968
+ startOpacity,
2969
+ endOpacity,
2970
+ strokeDashArray,
2971
+ )}
2972
+ {pointerX ? renderPointer(lineNumber) : null}
2713
2973
  </Animated.View>
2714
2974
  );
2715
2975
  };
@@ -2808,6 +3068,7 @@ export const LineChart = (props: propTypes) => {
2808
3068
 
2809
3069
  {isAnimated
2810
3070
  ? renderAnimatedLine(
3071
+ 1,
2811
3072
  points,
2812
3073
  animatedWidth,
2813
3074
  thickness1,
@@ -2820,6 +3081,7 @@ export const LineChart = (props: propTypes) => {
2820
3081
  strokeDashArray1,
2821
3082
  )
2822
3083
  : renderLine(
3084
+ 1,
2823
3085
  points,
2824
3086
  thickness1,
2825
3087
  color1,
@@ -2833,6 +3095,7 @@ export const LineChart = (props: propTypes) => {
2833
3095
  {points2
2834
3096
  ? isAnimated
2835
3097
  ? renderAnimatedLine(
3098
+ 2,
2836
3099
  points2,
2837
3100
  animatedWidth2,
2838
3101
  thickness2,
@@ -2845,6 +3108,7 @@ export const LineChart = (props: propTypes) => {
2845
3108
  strokeDashArray2,
2846
3109
  )
2847
3110
  : renderLine(
3111
+ 2,
2848
3112
  points2,
2849
3113
  thickness2,
2850
3114
  color2,
@@ -2859,6 +3123,7 @@ export const LineChart = (props: propTypes) => {
2859
3123
  {points3
2860
3124
  ? isAnimated
2861
3125
  ? renderAnimatedLine(
3126
+ 3,
2862
3127
  points3,
2863
3128
  animatedWidth3,
2864
3129
  thickness3,
@@ -2871,6 +3136,7 @@ export const LineChart = (props: propTypes) => {
2871
3136
  strokeDashArray3,
2872
3137
  )
2873
3138
  : renderLine(
3139
+ 3,
2874
3140
  points3,
2875
3141
  thickness3,
2876
3142
  color3,
@@ -2885,6 +3151,7 @@ export const LineChart = (props: propTypes) => {
2885
3151
  {points4
2886
3152
  ? isAnimated
2887
3153
  ? renderAnimatedLine(
3154
+ 4,
2888
3155
  points4,
2889
3156
  animatedWidth4,
2890
3157
  thickness4,
@@ -2897,6 +3164,7 @@ export const LineChart = (props: propTypes) => {
2897
3164
  strokeDashArray4,
2898
3165
  )
2899
3166
  : renderLine(
3167
+ 4,
2900
3168
  points4,
2901
3169
  thickness4,
2902
3170
  color4,
@@ -2911,6 +3179,7 @@ export const LineChart = (props: propTypes) => {
2911
3179
  {points5
2912
3180
  ? isAnimated
2913
3181
  ? renderAnimatedLine(
3182
+ 5,
2914
3183
  points5,
2915
3184
  animatedWidth5,
2916
3185
  thickness5,
@@ -2923,6 +3192,7 @@ export const LineChart = (props: propTypes) => {
2923
3192
  strokeDashArray5,
2924
3193
  )
2925
3194
  : renderLine(
3195
+ 5,
2926
3196
  points5,
2927
3197
  thickness5,
2928
3198
  color5,
@@ -2941,14 +3211,20 @@ export const LineChart = (props: propTypes) => {
2941
3211
  {isAnimated
2942
3212
  ? renderAnimatedLabel(
2943
3213
  index,
2944
- item.label,
2945
- item.labelTextStyle,
3214
+ item.label ||
3215
+ (props.xAxisLabelTexts && props.xAxisLabelTexts[index]
3216
+ ? props.xAxisLabelTexts[index]
3217
+ : ''),
3218
+ item.labelTextStyle || props.xAxisLabelTextStyle,
2946
3219
  item.labelComponent,
2947
3220
  )
2948
3221
  : renderLabel(
2949
3222
  index,
2950
- item.label,
2951
- item.labelTextStyle,
3223
+ item.label ||
3224
+ (props.xAxisLabelTexts && props.xAxisLabelTexts[index]
3225
+ ? props.xAxisLabelTexts[index]
3226
+ : ''),
3227
+ item.labelTextStyle || props.xAxisLabelTextStyle,
2952
3228
  item.labelComponent,
2953
3229
  )}
2954
3230
  {/* {renderLabel(index, item.label, item.labelTextStyle)} */}
package/src/todos.md CHANGED
@@ -1,7 +1,6 @@
1
1
  ## Feature requests
2
2
 
3
3
  1. OnPress function on Pie Chart https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/111
4
- 2. Change startingPoint default props on PieChart https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/132
5
4
 
6
5
  ## To-dos in documentation-
7
6
 
@@ -14,9 +13,10 @@
14
13
  7. Prepare a doc for Bar chart with barMarginBottom
15
14
  8. Prepare a doc for reference lines
16
15
  9. Prepare a doc for labelsPosition in Pie and Donut charts
16
+ 8. Prepare a doc for adjustToWidth in Line and Area charts
17
+ 9. Prepare a doc for xAxisLabelTexts and xAxisLabelTextStyle in Bar, Line And Area Charts
17
18
 
18
19
  ## Architecture Enhancement
19
20
 
20
- 1. Get rid of canvas (currently being used only for Pie charts)
21
- 2. Make it compliant with React js
22
- 3. Write tests
21
+ 1. Make it compliant with React js
22
+ 2. Write tests