@@ -510,7 +510,7 @@ export class LineChartRenderer extends LineRadarRenderer {
510
510
private mLineBuffer : number [ ] ;
511
511
512
512
@profile
513
- public drawValuesForDataset ( c : Canvas , dataSet : LineDataSet ) {
513
+ public drawValuesForDataset ( c : Canvas , dataSet : LineDataSet , dataSetIndex : number ) {
514
514
const yKey = dataSet . yProperty ;
515
515
// apply the text-styling defined by the DataSet
516
516
this . applyValueTextStyle ( dataSet ) ;
@@ -524,26 +524,36 @@ export class LineChartRenderer extends LineRadarRenderer {
524
524
525
525
this . mXBounds . set ( this . mChart , dataSet , this . mAnimator ) ;
526
526
527
- const positions = trans . generateTransformedValues ( dataSet , this . mAnimator . getPhaseX ( ) , this . mAnimator . getPhaseY ( ) , this . mXBounds . min , this . mXBounds . max ) ;
527
+ const { points , count } = trans . generateTransformedValues ( dataSet , this . mAnimator . getPhaseX ( ) , this . mAnimator . getPhaseY ( ) , this . mXBounds . min , this . mXBounds . max ) ;
528
528
const formatter = dataSet . getValueFormatter ( ) ;
529
529
530
530
const iconsOffset = dataSet . getIconsOffset ( ) ;
531
531
const valuesOffset = dataSet . getValuesOffset ( ) ;
532
532
const drawIcons = dataSet . isDrawIconsEnabled ( ) ;
533
533
const drawValues = dataSet . isDrawValuesEnabled ( ) ;
534
- for ( let j = 0 ; j < positions . length ; j += 2 ) {
535
- let x = positions [ j ] ;
536
- let y = positions [ j + 1 ] ;
534
+ const length = count ;
535
+ const dataSetCount = dataSet . getEntryCount ( ) ;
536
+ for ( let j = 0 ; j < length ; j += 2 ) {
537
+ let x = points [ j ] ;
538
+ let y = points [ j + 1 ] ;
537
539
538
540
if ( ! this . mViewPortHandler . isInBoundsRight ( x ) ) break ;
539
541
540
542
if ( ! this . mViewPortHandler . isInBoundsLeft ( x ) || ! this . mViewPortHandler . isInBoundsY ( y ) ) continue ;
541
543
542
- let entry = dataSet . getEntryForIndex ( j / 2 + this . mXBounds . min ) ;
544
+ const index = j / 2 + this . mXBounds . min ;
545
+ let entry = dataSet . getEntryForIndex ( index ) ;
543
546
if ( ! entry ) continue ;
544
547
545
548
if ( drawValues ) {
546
- this . drawValue ( c , formatter . getFormattedValue ( entry [ yKey ] ) , valuesOffset . x + x , valuesOffset . y + y - valOffset , dataSet . getValueTextColor ( j / 2 ) ) ;
549
+ // console.log('drawValue', entry[yKey], entry, index, dataSetCount);
550
+ this . drawValue (
551
+ c ,
552
+ formatter . getFormattedValue ( entry [ yKey ] , entry , index , dataSetCount , dataSetIndex , this . mViewPortHandler ) ,
553
+ valuesOffset . x + x ,
554
+ valuesOffset . y + y - valOffset ,
555
+ dataSet . getValueTextColor ( j / 2 )
556
+ ) ;
547
557
}
548
558
549
559
if ( drawIcons && entry . icon != null ) {
0 commit comments