0

I am a bit new to MPAndroidChart library and I am going to make a line chart for my data. I intend to set yaxis values exactly in the center of each grid rectangle which is inside them.

How that would be possible ?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • (If you can't add images to this, then just create your images at imgur.com and add the links either in the post (best) or in the comments, and someone will add them to the post for you). – halfer May 05 '18 at 21:03

2 Answers2

0

I am actually trying to do this also,get the Y values show up above the graph in the center X axis, but I was having trouble. I know you have to override the draw method in your MarkerView class, the code I was using is below. Maybe you can play with it and get the results you need. Other questions about this I was looking at had posX = getXoffset() & posY = 0 but for some reason I wasn't able to get the getXoffset() Override method.

@Override
public void draw(Canvas canvas, float posX, float posY) {
    posX = 400;
    posY = -30;

    canvas.translate(posX,posY);
    draw(canvas);
    canvas.translate(-posX,-posY);

}
  • BroadwayMayField, tnx but what I am gonna do is : I have four labels on xaxis and 4 yaxis values. I wanna set each of these yaxis values right in the center of related xaxis labels. would it be possible without adding marker ? did you get my idea ? thank you very much. – davood yazdipoor May 01 '18 at 15:45
0

I am not getting what exactly do you want. Try this:

lineChart.getXAxis().setCenterAxisLabels(true);
Muhammad Saad Rafique
  • 3,158
  • 1
  • 13
  • 21