ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Problem with symetric 4 quadrant XYChart. Axis not the same lenght/size
Posted by Alex on Jul-14-2011 08:36
Attachments:
Hi guys,

I am having an issue with one of my charts.

Happens that i need the XYChart to have the exact same distance from the (0,0) for
each quadrant (4 of them). Right now i have set up all of the quadrants to be -40, 40
and -40,40 for X and Y.

However when i see the result for the chart is very obvious that the X axis is longer or
"bigger" than the Y axis and my client is saying that the chart itself is inaccurate.

Is there any way i can fix this and make both axis the same as well as the distance
between the points??? i mean, 10 to 20, 2o to 30, etc.. for all axis?

Here is the code i am using:
[code]
# Create a XYChart object of size 600 x 300 pixels, with a light blue (ccccff)
# background, a black border, and 1 pixel 3D border effect
$c = new XYChart(600, 540, 0xffffff, 0x333333, 0);/*manuki changed this
ccccff*/

# Add a title box to the chart using 16 pts Arial Bold Italic font, with white
text
# on deep blue background
$textBoxObj = $c->addTitle($client['client_name'], "arialbi.ttf", 16,0xffffff);
$textBoxObj->setBackground(0xff6633);/* manuki changed this was
000080*/

# Set the plotarea at (20, 60) and of size 560 x 360 pixels, with grey
(808080)
# border, and light grey (c0c0c0) horizontal and vertical grid lines. Set 4
quadrant
# coloring, where the colors of the quadrants alternate between lighter and
deeper
# grey (dddddd/eeeeee)
$plotAreaObj = $c->setPlotArea(20, 40, 560, 460, -1, -1, 0xc0c0c0, 0xffffff,
0xffffff);
$plotAreaObj->set4QBgColor(0xffffff, 0xffffff, 0xffffff, 0xffffff);/* manuki
changed this was ffffff y dddddd*/

# Set 4 quadrant mode, with both x and y axes symetrical around the origin
$c->setAxisAtOrigin(XYAxisAtOrigin, XAxisSymmetric + YAxisSymmetric);

# Add a legend box at (300, 460) (bottom center of the chart) with
horizontal layout.
# Use 8 pts Arial Bold font.
$legendBox = $c->addLegend(300, 4, false, "arialbd.ttf", 8);//was 460
instead of 4
$legendBox->setAlignment(BottomCenter);

# Set legend box background to light grey (dddddd) with a black border
$legendBox->setBackground(0xffffff, 0);

# Set left/right margin to 20 pixels and top/bottom margin to 5 pixels
$legendBox->setMargin2(20, 20, 5, 5);

# Add a titles to axes
$c->xAxis->setTitle("");
$c->yAxis->setTitle("");

$c->xAxis->setLinearScale(-40,40,10);
$c->yAxis->setLinearScale(-40,40,10);

$c->addExtraField($userName);  #this is {field0}

# Set axes width to 2 pixels
$c->xAxis->setWidth(1);
$c->yAxis->setWidth(1);

# Add scatter layer, using 15 pixels red (ff33333) X shape symbols
$c->addScatterLayer($dataX0, $dataY0, "Series 1", CircleShape, 8,
0xff6633);/*manuki changed this ff3333*/

# Add scatter layer, using 15 pixels green (33ff33) 6-sided polygon symbols
#$c->addScatterLayer($dataX1, $dataY1, "Group B", PolygonShape(6), 15,
0x33ff33);

# Add scatter layer, using 15 pixels blue (3333ff) triangle symbols
#$c->addScatterLayer($dataX2, $dataY2, "Group C", TriangleSymbol, 15,
0x3333ff);

# Output the chart
//header("Content-type: image/png");
//print($c->makeChart2(PNG));
global $imageMap,$chart1URL;
# Create the image and save it in a temporary location
$chart1URL = $c->makeSession( string_random_word() );
# Create an image map for the chart
$imageMap = $c->getHTMLImageMap("#", "", "class='dots' title=' {field0}
({x} , {value})'");
[/code]

Please find the output chart attached to this message

Thanks in advance!
Alex
alex.png

  Re: Problem with symetric 4 quadrant XYChart. Axis not the same lenght/size
Posted by Peter Kwan on Jul-14-2011 18:21
Hi Alex,

To set the axis to the same length, please set the plot aera so that it is a square.

In your current code, the size of the plot area is 560 x 460. Please change it to 460 x 460 (or 560 x 560 or some other size which is a square). For example:

$plotAreaObj = $c->setPlotArea(20, 40, 460, 460, -1, -1, 0xc0c0c0, 0xffffff,
0xffffff);

You may need to adjust the XYChart size too, so as to put the plot area at the center of the chart.

Hope this can help.

Regards
Peter Kwan