@@ -370,7 +370,7 @@ export class LineChartRenderer extends LineRadarRenderer {
370
370
const points = Utils . pointsFromBuffer ( float32arr ) ;
371
371
// console.log('generateLinearPath', index, points.length);
372
372
// if (isAndroid) {
373
- outputPath . setLines ( points , index ) ;
373
+ outputPath . setLines ( points , 0 , index ) ;
374
374
// }
375
375
return [ points , index ] ;
376
376
} else {
@@ -439,6 +439,9 @@ export class LineChartRenderer extends LineRadarRenderer {
439
439
this . mXBounds . set ( this . mChart , dataSet , this . mAnimator ) ;
440
440
441
441
const res = this . generateLinearPath ( dataSet , this . linePath ) ;
442
+
443
+ const colors = dataSet . getColors ( ) ;
444
+ const nbColors = colors . length ;
442
445
// if filled is enabled, close the path
443
446
if ( dataSet . isDrawFilledEnabled ( ) ) {
444
447
this . fillPath . reset ( ) ;
@@ -450,8 +453,23 @@ export class LineChartRenderer extends LineRadarRenderer {
450
453
451
454
// if (isAndroid || dataSet.isDashedLineEnabled()) {
452
455
if ( dataSet . getLineWidth ( ) > 0 ) {
453
- trans . pathValueToPixel ( this . linePath ) ;
454
- this . drawPath ( c , this . linePath , this . mRenderPaint ) ;
456
+ if ( nbColors === 1 ) {
457
+ trans . pathValueToPixel ( this . linePath ) ;
458
+ this . drawPath ( c , this . linePath , this . mRenderPaint ) ;
459
+ } else {
460
+ const xKey = dataSet . xProperty ;
461
+ const points = res [ 0 ] ;
462
+ let lastIndex = 0 ;
463
+ trans . pointValuesToPixel ( points ) ;
464
+ for ( let index = 0 ; index < nbColors ; index ++ ) {
465
+ const color = colors [ index ] ;
466
+ let colorIndex = color [ xKey ] as number ;
467
+ this . mRenderPaint . setColor ( color . color ) ;
468
+ this . linePath . setLines ( points , lastIndex * 2 , ( colorIndex - lastIndex + 1 ) * 2 ) ;
469
+ this . drawPath ( c , this . linePath , this . mRenderPaint ) ;
470
+ lastIndex = colorIndex ;
471
+ }
472
+ }
455
473
}
456
474
// } else {
457
475
// const points = res[0];
@@ -463,8 +481,12 @@ export class LineChartRenderer extends LineRadarRenderer {
463
481
}
464
482
465
483
@profile
466
- drawLines ( canvas : Canvas , points : number [ ] , offest , length , paint : Paint , matrix : Matrix ) {
467
- canvas . drawLines ( points , offest , length , paint , matrix ) ;
484
+ drawLines ( canvas : Canvas , points : number [ ] , offest , length , paint : Paint , matrix ?: Matrix ) {
485
+ if ( matrix ) {
486
+ canvas . drawLines ( points , offest , length , paint , matrix ) ;
487
+ } else {
488
+ canvas . drawLines ( points , offest , length , paint ) ;
489
+ }
468
490
}
469
491
470
492
protected drawFill ( c : Canvas , dataSet : ILineDataSet , spline : Path , trans : Transformer , bounds : XBounds ) {
0 commit comments