|
Set scale to Numbers of pixles |
Posted by Mattias Wardell on Aug-29-2014 01:50 |
|
Hi,
I'm trying to create a horizontal diagram that is based on weeks, i have the size of the plot
area, example 1280 pixels. I want to draw a line with the lenght of 125 pixels, but when i
use this value for the line becomes about 280 pixels.
What can I do?
Also, I have problem with the position of the labels when I swaped the axis, how can I
change it.
Thank you,
Mattias |
Re: Set scale to Numbers of pixles |
Posted by Peter Kwan on Aug-31-2014 14:09 |
|
Hi Mattias,
If you add the line as a line layer (eg. using addLineLayer), then the (x, y) coordinates will
be in the unit used in the x-axis and y-axis. For example, if the y-axis is using number of
weeks as the unit, then the y-coordinate will also be based on number of weeks. If the y-
axis is a date/time axis, the y-coordinate will be date/time.
If you would like to add a line entire in pixel units (both end points of a line is in pixel units),
you may use BaseChart.addLine instead of addLineLayer.
If you would like to add a line that is a mix of pixel and axis units (eg. the x-coordinate is in
axis units, but the y-coordinates is in pixel units, or the starting point is in axis units, and
the end point is in pixel units, or the starting point is in axis units, and the length is in pixel
units, etc), there are several methods:
(a) If you know the axis scale, you can translate the pixel units into axis units. In this way,
you can draw the line in pure pixel units or axis units.
(b) If you do not know the axis scale (eg. the axis is auto-scaled by ChartDirector), you
can use BaseChart.layout to auto-scale the axis first, then you can use XYChart.getXCoor,
XYChart.getYCoor, XYChart.getXValue and XYChart.getYValue to translate between pixel
and axis units.
Hope this can help.
Regards
Peter Kwan |
|