|
Associating layers with an x axis label |
Posted by Andy on Mar-02-2011 23:24 |
|
I currently have code which populates a bar chart with various lists of data (java Lists).
After the first list populates the chart, another list is called and so on.
The problem is that the lists are of varying size and relate to various and differently ordered labels on the x axis, so data is just added to the x axis, in the order it comes in.
Is there some method(s) I can use, which can tell the layer, to add itself to a particular position on the xaxis, not just from left to right? For example, can I give a layer or a position on the x axis a particular name, so all layers of this type, line up with a specific x axis label?
Hope this is not too confusing! |
Re: Associating layers with an x axis label |
Posted by Peter Kwan on Mar-03-2011 00:33 |
|
Hi Andy,
Yes. Suppose your x-axis labels are { "Apple", "Orange", "Pear", "Banana", "Mango" }, and suppose you have 3 bars at "Pear", "Mango" and "Orange", the code you can use is:
(a) Create an array of the same size as the x-axis labels (that is, an array of 5 elements).
(b) Copy the data values in the correct slot in the array. For the above example, the value for the "Pear" bar should be copied to the array position with index 2. Similarly, the "Mango" bar value should be copied to array position 4, and the "Orange" bar to array position 1.
Hope this can help.
Regards
Peter Kwan |
Re: Associating layers with an x axis label |
Posted by Andy on Mar-04-2011 00:41 |
|
Great idea again Peter. Built a solution based on this.
Thanks |
|