@@ -446,10 +446,10 @@ export class LineChartRenderer extends LineRadarRenderer {
446
446
}
447
447
}
448
448
449
- getMultiColorsShader ( colors : { color : string | Color ; [ k : string ] : any } [ ] , points , trans : Transformer , dataSet : LineDataSet , renderPaint : Paint ) {
449
+ getMultiColorsShader ( colors : { color : string | Color ; [ k : string ] : any } [ ] , points , trans : Transformer , dataSet : LineDataSet ) {
450
450
const nbColors = colors . length ;
451
451
const xKey = dataSet . xProperty ;
452
- if ( nbColors > 1 ) {
452
+ if ( nbColors > 0 ) {
453
453
trans . pointValuesToPixel ( points ) ;
454
454
const shaderColors = [ ] ;
455
455
const positions = [ ] ;
@@ -458,7 +458,7 @@ export class LineChartRenderer extends LineRadarRenderer {
458
458
const lastIndex = firstIndex + range ;
459
459
const width = this . mViewPortHandler . getChartWidth ( ) ;
460
460
const chartRect = this . mViewPortHandler . getChartRect ( ) ;
461
- let lastColor , lastColorPosX ;
461
+ let lastColor ;
462
462
463
463
const gradientDelta = 0 ;
464
464
const posDelta = gradientDelta / width ;
@@ -489,17 +489,6 @@ export class LineChartRenderer extends LineRadarRenderer {
489
489
}
490
490
const posX = Math . floor ( points [ ( colorIndex - firstIndex ) * 2 ] ) ;
491
491
const pos = ( posX - chartRect . left ) / width ;
492
- // if (posX - lastColorPosX < 3) {
493
- // // ignore too small
494
- // // lastColor = color.color;
495
- // shaderColors.pop();
496
- // shaderColors.pop();
497
- // positions.pop();
498
- // positions.pop();
499
- // lastColor = shaderColors[shaderColors.length -1];
500
- // lastColorPosX = positions[positions.length -1] * width + chartRect.left;
501
- // continue;
502
- // }
503
492
if ( lastColor ) {
504
493
if ( shaderColors . length === 0 ) {
505
494
shaderColors . push ( lastColor ) ;
@@ -511,13 +500,16 @@ export class LineChartRenderer extends LineRadarRenderer {
511
500
shaderColors . push ( color . color ) ;
512
501
positions . push ( pos + posDelta ) ;
513
502
lastColor = color . color ;
514
- lastColorPosX = posX ;
515
503
}
516
- if ( shaderColors . length > 1 ) {
517
- return new LinearGradient ( 0 , 0 , width , 0 , shaderColors , positions , TileMode . CLAMP ) ;
518
- } else if ( shaderColors . length === 1 ) {
519
- renderPaint . setColor ( shaderColors [ 0 ] ) ;
504
+ if ( shaderColors . length === 0 ) {
505
+ shaderColors . push ( colors [ 0 ] . color ) ;
506
+ positions . push ( 0 ) ;
520
507
}
508
+ if ( shaderColors . length === 1 ) {
509
+ shaderColors . push ( colors [ 0 ] . color ) ;
510
+ positions . push ( 1 ) ;
511
+ }
512
+ return new LinearGradient ( 0 , 0 , width , 0 , shaderColors , positions , TileMode . CLAMP ) ;
521
513
}
522
514
return null ;
523
515
}
@@ -559,9 +551,9 @@ export class LineChartRenderer extends LineRadarRenderer {
559
551
const nbColors = colors . length ;
560
552
const renderPaint = this . renderPaint ;
561
553
let paintColorsShader ;
562
- if ( nbColors > 1 ) {
554
+ if ( nbColors > 0 ) {
563
555
// TODO: we transforms points in there. Could be dangerous if used after
564
- paintColorsShader = this . getMultiColorsShader ( colors , points , trans , dataSet , renderPaint ) ;
556
+ paintColorsShader = this . getMultiColorsShader ( colors , points , trans , dataSet ) ;
565
557
}
566
558
567
559
let oldShader ;
0 commit comments