0

i am using achartengine to draw a graph, but i don't know how to align the x labels with the relative points in the graph. To add Y labels i use this method:

    private void addSampleData() {
    int i=0;
    for(i=0; i<count; i++){
        mCurrentSeries.add(i+1, list_peso[i]);
        mCurrentSeries2.add(i+1, list_peso_ideale[i]);
        list_peso_string[i] = Double.toString(list_peso[i]);
        mRenderer.addXTextLabel(i+1, list_data[i]);
        mRenderer.addYTextLabel(i+1, list_peso_string[i]);
    }

it works for the Y labels, but not for the X labels. How van i do?

Thanks in advance.

Dan D.
  • 32,246
  • 5
  • 63
  • 79
Gimmy88
  • 295
  • 2
  • 5
  • 13

1 Answers1

1

I dont understand why you are using i+1 in mRenderer.addYTextLabel(i+1, list_peso_string[i]); instead just use i it may solve your problem

and if u want custom lablels:::

suppose ur custom x-axis labels should be :private String[] mMonth = new String[] { "Jan", "Feb" , "Mar", "Apr", "May", "Jun", "Jul", "Aug" , "Sep", "Oct", "Nov", "Dec" };

so by using following loop can get graph as shown in this graph

int[] x = { 0,1,2,3,4,5,6,7 };
for(int i=0; i< x.length;i++){
    multiRenderer.addXTextLabel(i, mMonth[i]);          
} 

And take look at this Question and my answer

Community
  • 1
  • 1
Kiran
  • 3,095
  • 5
  • 23
  • 38
  • thx for the answer, by the way my X labels are ok, i mean that i have strings on the X labels, the problem is that i can't do the same with Y axis and i don't know why. – Gimmy88 Apr 22 '13 at 20:54
  • u want to display strings on y axis ? – Kiran Apr 23 '13 at 00:40