@@ -120,34 +120,31 @@ public void renderAxisLine(Canvas c) {
120120 */
121121 protected void drawYLabels (Canvas c , float fixedPosition , float [] positions , float offset ) {
122122
123- if (mYAxis .isShowSpecificLabelPositions ()) {
124- float [] specificLabelsPositions = new float [mYAxis .getSpecificLabelPositions ().length * 2 ];
125- for (int i = 0 ; i < mYAxis .getSpecificLabelPositions ().length ; i ++) {
126- specificLabelsPositions [i * 2 + 1 ] = mYAxis .getSpecificLabelPositions ()[i ];
127- }
128- mTrans .pointValuesToPixel (specificLabelsPositions );
123+ final int from ;
124+ final int to ;
129125
130- for (int i = 0 ; i < mYAxis .getSpecificLabelPositions ().length ; i ++) {
131- float y = specificLabelsPositions [i * 2 + 1 ];
132- if (mViewPortHandler .isInBoundsY (y )) {
133- String text = mYAxis .getValueFormatter ().getFormattedValue (mYAxis .getSpecificLabelPositions ()[i ], mYAxis );
134- c .drawText (text , fixedPosition , y + offset , mAxisLabelPaint );
135- }
136- }
137- return ;
126+ if (mYAxis .isShowSpecificLabelPositions ()) {
127+ from = 0 ;
128+ to = mYAxis .isDrawTopYLabelEntryEnabled ()
129+ ? mYAxis .getSpecificLabelPositions ().length
130+ : (mYAxis .getSpecificLabelPositions ().length - 1 );
131+ } else {
132+ from = mYAxis .isDrawBottomYLabelEntryEnabled () ? 0 : 1 ;
133+ to = mYAxis .isDrawTopYLabelEntryEnabled ()
134+ ? mYAxis .mEntryCount
135+ : (mYAxis .mEntryCount - 1 );
138136 }
139137
140- final int from = mYAxis .isDrawBottomYLabelEntryEnabled () ? 0 : 1 ;
141- final int to = mYAxis .isDrawTopYLabelEntryEnabled ()
142- ? mYAxis .mEntryCount
143- : (mYAxis .mEntryCount - 1 );
144-
145138 float xOffset = mYAxis .getLabelXOffset ();
146139
147140 // draw
148141 for (int i = from ; i < to ; i ++) {
149-
150- String text = mYAxis .getFormattedLabel (i );
142+ String text ;
143+ if (mYAxis .isShowSpecificLabelPositions ()) {
144+ text = mYAxis .getValueFormatter ().getFormattedValue (mYAxis .getSpecificLabelPositions ()[i ], mYAxis );
145+ } else {
146+ text = mYAxis .getFormattedLabel (i );
147+ }
151148
152149 c .drawText (text ,
153150 fixedPosition + xOffset ,
@@ -226,14 +223,24 @@ protected Path linePath(Path p, int i, float[] positions) {
226223 */
227224 protected float [] getTransformedPositions () {
228225
229- if (mGetTransformedPositionsBuffer .length != mYAxis .mEntryCount * 2 ){
230- mGetTransformedPositionsBuffer = new float [mYAxis .mEntryCount * 2 ];
226+ if (mYAxis .isShowSpecificLabelPositions ()) {
227+ if (mGetTransformedPositionsBuffer .length != mYAxis .getSpecificLabelPositions ().length * 2 ) {
228+ mGetTransformedPositionsBuffer = new float [mYAxis .getSpecificLabelPositions ().length * 2 ];
229+ }
230+ } else {
231+ if (mGetTransformedPositionsBuffer .length != mYAxis .mEntryCount * 2 ) {
232+ mGetTransformedPositionsBuffer = new float [mYAxis .mEntryCount * 2 ];
233+ }
231234 }
232235 float [] positions = mGetTransformedPositionsBuffer ;
233236
234237 for (int i = 0 ; i < positions .length ; i += 2 ) {
235238 // only fill y values, x values are not needed for y-labels
236- positions [i + 1 ] = mYAxis .mEntries [i / 2 ];
239+ if (mYAxis .isShowSpecificLabelPositions ()) {
240+ positions [i + 1 ] = mYAxis .getSpecificLabelPositions ()[i / 2 ];
241+ } else {
242+ positions [i + 1 ] = mYAxis .mEntries [i / 2 ];
243+ }
237244 }
238245
239246 mTrans .pointValuesToPixel (positions );
0 commit comments