Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing duplicate label bug in x Axis when choosing to use custom labe… #651

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Thu Oct 17 16:01:25 WEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,31 @@ public void setVerticalLabels(String[] verticalLabels) {
* false if it is a value for the y axis
* @return
*/
static int oldIdx = -1;
String result = "";
@Override
public String formatLabel(double value, boolean isValueX) {
synchronized public String formatLabel(double value, boolean isValueX) {

if (isValueX && mHorizontalLabels != null) {
double minX = mViewport.getMinX(false);
double maxX = mViewport.getMaxX(false);
double range = maxX - minX;
value = value-minX;
int idx = (int)((value/range) * (mHorizontalLabels.length-1));
return mHorizontalLabels[idx];
value = value - minX;
int idx = (int) ((value / range) * (mHorizontalLabels.length - 1));
// Log.e("StaticLabelsFormatter i= "+i, "formatLabel idx ="+idx+" " + mHorizontalLabels[i<mHorizontalLabels.length? i:mHorizontalLabels.length-1]);
if (oldIdx != idx)
result = mHorizontalLabels[idx];
else
result = mHorizontalLabels[idx + 1];
oldIdx = idx;
return result;

} else if (!isValueX && mVerticalLabels != null) {
double minY = mViewport.getMinY(false);
double maxY = mViewport.getMaxY(false);
double range = maxY - minY;
value = value-minY;
int idx = (int)((value/range) * (mVerticalLabels.length-1));
value = value - minY;
int idx = (int) ((value / range) * (mVerticalLabels.length - 1));
return mVerticalLabels[idx];
} else {
return mDynamicLabelFormatter.formatLabel(value, isValueX);
Expand Down