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

Message ListMessage List     Post MessagePost Message

  Unable to manually scale axis
Posted by Harabek on Nov-30-2011 13:35
I am calling getMinValue() and getMaxValue(), doing math to narrow the window, calling
setDateRange() for the xAxis and setLinearScale() for both yAxi, calling makeChart2()
again, and yet not only is the image the same, but the getMinValue() and getMaxValue()
values aren't changing. What gives?!

Below is CodeSnippet#1, which makes the changes, CodeSnippet#2, which is the
supporting functions, and the Output, showing no change.

The chart object itself is pretty complex. I thought I'd covered my bases with the
setRounding(false, false) but apparently that's not enough. What's another likely culprit?

Thanks.

Code Snippet #1:

echo("<pre>");
$chart->makeChart2("PNG");
$start = $chart->getAxisLimits();
print_r($start);
$chart->setAxisLimits(
$start[0] + (($start[1] - $start[0]) * .25),
$start[1] - (($start[1] - $start[0]) * .25),
$start[2] + (($start[3] - $start[2]) * .25),
$start[3] - (($start[3] - $start[2]) * .25),
$start[4] + (($start[5] - $start[4]) * .25),
$start[5] - (($start[5] - $start[4]) * .25)
);
echo($start[0] + (($start[1] - $start[0]) * .25) . "\\n");
echo($start[1] - (($start[1] - $start[0]) * .25) . "\\n");
echo($start[2] + (($start[3] - $start[2]) * .25) . "\\n");
echo($start[3] - (($start[3] - $start[2]) * .25) . "\\n");
echo($start[4] + (($start[5] - $start[4]) * .25) . "\\n");
echo($start[5] - (($start[5] - $start[4]) * .25) . "\\n");
print_r($chart->getAxisLimits());
$chart->makeChart2("PNG");
print_r($chart->getAxisLimits());
echo("</pre>");

Code Snippet #2:

public function getAxisLimits() {
return(array(
$this->c->xAxis->getMinValue(),
$this->c->xAxis->getMaxValue(),
$this->c->yAxis->getMinValue(),
$this->c->yAxis->getMaxValue(),
$this->c->yAxis2->getMinValue(),
$this->c->yAxis2->getMaxValue()
));
}
public function setAxisLimits($xMin, $xMax, $y1Min, $y1Max, $y2Min, $y2Max) {
$this->c->xAxis->setRounding(false, false);
$this->c->yAxis->setRounding(false, false);
$this->c->yAxis2->setRounding(false, false);
$this->c->xAxis->setDateScale($xMin, $xMax);
$this->c->yAxis->setLinearScale($y1Min, $y1Max);
$this->c->yAxis2->setLinearScale($y2Min, $y2Max);
}

Output:

Array
(
    [0] => 63445489200
    [1] => 63445856400
    [2] => 0
    [3] => 0.95
    [4] => 0
    [5] => 100
)
63445581000
63445764600
0.2375
0.7125
25
75
Array
(
    [0] => 63445489200
    [1] => 63445856400
    [2] => 0
    [3] => 0.95
    [4] => 0
    [5] => 100
)
Array
(
    [0] => 63445489200
    [1] => 63445856400
    [2] => 0
    [3] => 0.95
    [4] => 0
    [5] => 100
)

  Re: Unable to manually scale axis
Posted by Peter Kwan on Dec-01-2011 02:31
Hi Harabek,

You cannot modify the chart object after calling makeChart or makeChart2. In particular, if ChartDirector is asked to set the axis scale (using makeChart, layoutAxes, layout, etc), your code modify the axis scale afterwards. If you would like to control the axis scale, you would need to set it before making the chart.

If you need to modify the chart object after making the chart, the only method is to create another chart object.

Hope this can help.

Regards
Peter Kwan