|
setLabels on xaxis of bubble chart |
Posted by Erik on Jul-01-2011 21:41 |
|
Hello,
I have a problem with custom labels on the x-axis of a bubble chart.
Ive initiated a XYChart and added 1 ScatterLayer. These are the values I added to the chart:
data X0 (array):
0 2011
1 2011
2 2012
3 2012
4 2012
5 2013
6 2013
7 2013
8 2014
9 9999
10 9999
11 9999
data Y0 (array):
0 1
1 2
2 1
3 2
4 3
5 1
6 2
7 3
8 1
9 1
10 2
11 3
data Z0 (array):
0 14
1 8
2 7
3 13
4 1
5 1
6 1
7 2
8 1
9 17
10 15
11 3
All goes well except the last value on the xchart should have the label "Longterm". So i added the option setLabels:
$xlabels = array("2011","2012","2013","2014","Longterm");
$chart->xAxis->setLabels($xlabels);
Now it sets the labels on the xaxis but somehow all the titles are set on the first point of the x axis and the values are set at the end... See the attachment.
Does someone know what the problem is? It looks like it sets the x values at the xaxis but it doesnt know where to set them.
Thanks
Erik
|
Re: setLabels on xaxis of bubble chart |
Posted by Peter Kwan on Jul-02-2011 00:17 |
|
Hi Erik,
For your case, you are using a label based x-axis. In this case, the x-coordinate is the array index of the label. So instead of using the x-coordinates (2011, 2011, 2012, 2012, 2012, 2013, 2013, 2013, 2014, 9999, 9999, 9999), please use (0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 4, 4).
Because the bubble has size, so a bubble with the center at the left edge will have the left half falls outside the plot area. So you may want to add some left/right margins to the x-axis as well. For example:
$c->xAxis->setMargin(50, 50);
Hope this can help.
Regards
Peter Kwan |
Re: setLabels on xaxis of bubble chart |
Posted by Erik on Jul-04-2011 15:50 |
|
Hi Peter,
That that was it! Thanks very much for your help.
Regards,
Erik |
|