|
Directional Plots with Associated Names |
Posted by Chris Burriss on May-02-2012 00:41 |
|
I'm trying to do something like the attached image.
(1) Is it possible to add directional pieces to a bar plot? If necessary (and permitted), I
could create an image of each directional section that is appended to the plotted section.
Optionally, if I can provide a starting and ending value per data point, I can trim the ends
by modifying the data points (i.e. increasing the lowest value and decreasing the highest
value by X 10% shy of the end point).
(2) How can I go about adding names above and below a plot?
I do apologize if this is clearly stated in the documentation somewhere. I have been looking
around but haven't stumbled upon what I'm after yet. Thanks!
|
Re: Directional Plots with Associated Names |
Posted by Peter Kwan on May-03-2012 00:23 |
|
Hi Chris,
(1) From your description, it seems you would like to "bar length" to be inclusive of the arrow. For example, if the bar represents 10 days, you would like the bar and the arrow together being 10 days long. Also, it seems the length of the arrow is fixed irrespective of the length of the bar (just like the height of the bar is a fix value).
In this type of representation, there is an issue if the bar turns out to be shorter than the arrow symbol. For example, if your bar is only 1 or 2 pixels wide, how would you like to draw the arrow? If you are sure this cannot happen due to the nature of your data, one easy method is to use a scatter layer to put symbols at the end points. For example, you may put right pointing triangles at the right end-points of the bars. The bars need to be shortened by certain number of pixels to leave space for the triangles. As the bar data are in data units, not in pixel units, you would need to convert the pixel length to data unit to determine the adjustments required. The scaling factor is "duration_of_the_axis / pixel_length_of_the_axis".
(2) How can I go about adding names above and below a plot?
I assume your blue and red arrows are created using two different layers. (The code is slightly different if they are from the same layer.) In this case, consider the layer for the blue bars. First, add an array of text strings for the names of the blue bars. Then use Layer.setDataLabelFormat to use the names as the data label, and use Layer.setDataLabelStyle to configure the font style and alignment relative to the bar. It is like:
layer.addExtraField(myArrayOfNames);
layer.setDataLabelFormat("{field0}");
layer.setDataLabelStyle("arial.ttf", 15, 0x0000ff).setAlignment(Chart.Bottom);
Hope this can help.
Regards
Peter Kwan |
|