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 issue #35 float numbers #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions AndroidCharts/src/main/java/im/dacer/androidcharts/LineView.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class LineView extends View {
private int bottomTextHeight = 0;
private ArrayList<String> bottomTextList = new ArrayList<String>();
private ArrayList<ArrayList<Float>> dataLists;
private ArrayList<Integer> xCoordinateList = new ArrayList<Integer>();
private ArrayList<Integer> yCoordinateList = new ArrayList<Integer>();
private ArrayList<Double> xCoordinateList = new ArrayList<Double>();
private ArrayList<Double> yCoordinateList = new ArrayList<Double>();
private ArrayList<ArrayList<Dot>> drawDotLists = new ArrayList<ArrayList<Dot>>();
private Paint bottomTextPaint = new Paint();
private int bottomTextDescent;
Expand Down Expand Up @@ -275,7 +275,7 @@ private void refreshDrawDotList(int verticalGridNum) {
int drawDotSize = drawDotLists.get(k).isEmpty() ? 0 : drawDotLists.get(k).size();

for (int i = 0; i < dataLists.get(k).size(); i++) {
int x = xCoordinateList.get(i);
double x = xCoordinateList.get(i);
float y = getYAxesOf(dataLists.get(k).get(i), verticalGridNum);
if (i > drawDotSize - 1) {
drawDotLists.get(k).add(new Dot(x, 0, x, y, dataLists.get(k).get(i), k));
Expand Down Expand Up @@ -519,7 +519,7 @@ private Dot findPointAt(int x, int y) {

for (ArrayList<Dot> data : drawDotLists) {
for (Dot dot : data) {
final int pointX = dot.x;
final int pointX = (int) dot.x;
final int pointY = (int) dot.y;

r.set(pointX - width, pointY - width, pointX + width, pointY + width);
Expand All @@ -536,12 +536,12 @@ class Dot {
int x;
float y;
float data;
int targetX;
double targetX;
float targetY;
int linenumber;
int velocity = MyUtils.dip2px(getContext(), 18);

Dot(int x, float y, int targetX, float targetY, float data, int linenumber) {
Dot(double x, float y, double targetX, float targetY, float data, int linenumber) {
this.x = x;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, did you try out your changes? I was about to add them to my fork of the library, as unfortunately this repository seems unmaintained, but your commit doesn't compile for me. For example, this.x is an int while the local x is a double, causing the assignment to fail. Other type-casting errors are also showing.

this.y = y;
this.linenumber = linenumber;
Expand All @@ -553,7 +553,7 @@ Point setupPoint(Point point) {
return point;
}

Dot setTargetData(int targetX, float targetY, float data, int linenumber) {
Dot setTargetData(double targetX, float targetY, float data, int linenumber) {
this.targetX = targetX;
this.targetY = targetY;
this.data = data;
Expand All @@ -566,7 +566,7 @@ boolean isAtRest() {
}

void update() {
x = (int) updateSelf(x, targetX, velocity);
x = updateSelf(x, targetX, velocity);
y = updateSelf(y, targetY, velocity);
}

Expand Down