2

I want to add specific points on GraphView that look like this:

enter image description here

This is what I have tried:

GraphView graphView = findViewById(R.id.graph_view);
graphView.getGridLabelRenderer().setNumVerticalLabels(9);
graphView.getGridLabelRenderer().setNumHorizontalLabels(9);
PointsGraphSeries<DataPoint> series = new PointsGraphSeries<>(new DataPoint[] {
        new DataPoint(-9, 9),
        new DataPoint(-9, 0),
        new DataPoint(-9, -9),
        new DataPoint(0, 9),
        new DataPoint(0, 0),
        new DataPoint(0, -9),
        new DataPoint(9, 9),
        new DataPoint(9, 0),
        new DataPoint(9, -9)
});
graphView.addSeries(series);
series.setShape(PointsGraphSeries.Shape.POINT);

And this is the result:

enter image description here

Is has nothing to do with what I want to achieve. The dots are not in the exact place like above. How to solve this?

Johans Bormman
  • 855
  • 2
  • 11
  • 23

1 Answers1

0

The reason that the dots in the bottom images do not look like they are exactly the same as in the first images is that you are looking at 2 different graphs :

Both of your images graphs are made out of those 2 things:
x-axis (every Horizontally point) and y-axis(every vertically point).

tl;dr - your 2 images have different Graph scales and it is giving you the illusion of misplaced points.

Now - in both of your images you have the same points but the main difference is that the first graph is scaling for every Integer (both on the x-axis and y-axis) and the second graph is scaling for every second Integer(for example on x-axis -6 -4 -2 0 2 4 6).

Let's take (0, 9) point as an example - in your first image you can clearly see both 0 on the x-axis and 9 on the y-axis and be sure that this is your point.
In your second image (for the exact same point) - you can see 0 on the x-axis really clear, 9 is there too on the y-axis - you just need to notice that is it above 8 and below 10(so it is on 9 and we are talking about the same points on both images after all).

Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
  • First of all thank you for your answer. So how to modify the code so it can look the same as the first image? – Johans Bormman Feb 18 '19 at 16:21
  • I am not an expert regarding graph view and how to change its scale- but I can recommend you to read the documentation and check if it is mentioned in there, hope that this was helpful. – Tamir Abutbul Feb 18 '19 at 16:30
  • If my answer helped you out please accept it so others with the same problem could relay on it knowing that this solved your problem – Tamir Abutbul Feb 18 '19 at 16:40
  • Tamir, it didn't solved my issue since I still don't know what to change in order to make it work as I want. – Johans Bormman Feb 18 '19 at 17:03
  • Have a look at [this link , it may help you](http://www.android-graphview.org/simple-graph/) – Tamir Abutbul Feb 18 '19 at 17:08
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/188621/discussion-between-tamir-abutbul-and-johans-bormman). – Tamir Abutbul Feb 18 '19 at 17:17
  • Please see [this](https://stackoverflow.com/questions/54752299/how-to-reduce-the-scale-of-graphview-to-one-in-android). – Johans Bormman Feb 18 '19 at 17:18
  • Why did you open a new question for? correct me if i am wrong but you just said that your problem is yet to solved – Tamir Abutbul Feb 18 '19 at 17:22