lecho / hellocharts-android

Charts library for Android compatible with API 8+, several chart types with scaling, scrolling and animations 📊
Apache License 2.0
7.43k stars 1.61k forks source link

label of left/right axis overlap label of top axis #523

Open lxd19850415 opened 5 years ago

lxd19850415 commented 5 years ago

In function Paint.drawText , parameter x,y means left and bottom of label , so last(from bottom to top) label of left/right axis show too high . finally it overlap with label of top axis。

this is my method to fix it: in class “AxesRenderer”,and in function “drawAxisLabelsAndName”

        if (isAxisVertical) {
            if(valueToDrawIndex == valuesToDrawNumTab[position] - 1){  //last lable
                Paint.FontMetrics fontMetrics = labelPaintTab[position].getFontMetrics();
                float fontHight = (fontMetrics.bottom - fontMetrics.top);

                labelY = rawValuesTab[position][valueToDrawIndex] + fontHight; //avoid text overlap with top axis
            }else{

                labelY = rawValuesTab[position][valueToDrawIndex];
            }
        } else {
            labelX = rawValuesTab[position][valueToDrawIndex];
        }

Best Wishes!