hts
pChart user
Joined: Sat Apr 23, 2011 8:45 am Posts: 5 Location: K-Town, Germany
|
Bug in ManualScale
Hi, I'm trying to implement my old charts from pChart 1.x to pChart 2.1.1 and have problems using a manual scale. I want to display some data in Minutes:Seconds and want to have only full minutes at the scale. The AXIS_FORMAT_TIME in "i:s" is a great new feature of pChart 2.x but the scaling doesn't work as expected. Look at the original chart from pChart 1.x: (scale works as expected) Attachment:
File comment: Correct manualScale (but other problems) in pChart 1.x
Chart-1.x.png [ 20.27 KiB | Viewed 5315 times ]
With pChart 2.x the autoScale is not as nice as I want it to: Attachment:
File comment: Bad autoScale
Chart-2.x.png [ 38.83 KiB | Viewed 5315 times ]
So I'm using a manual scale. In this case it is computed to {Min: 180, Max: 600}: Attachment:
File comment: Broken manualScale
Chart-2.x-manual.png [ 25.18 KiB | Viewed 5315 times ]
To my code: I'm using an extra class for general settings (background etc.). The startImage() only draws the background and sets the defaults. Code: <?php // ... $Paces and $Distances are computed $Distances = array(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,5, 5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7); $Paces = (313,571,200,294,500,444,333,333,250,294,308,273,308,267,308,278,286,308,273,333,300,286,308,333,308, 308,278,313,294,263,308,286,286,333,273,316,333,308,286,267,333,294,313,294,294,364,294,273,308,267,333,294, 267,273,267,200,357,500,400,211,200,235,250,273,231,263,308,308,308,267,286,235,300,250,250,250,286,227,235,250); $skip = 0.1;
$ScaleFormat = array( "Mode" => SCALE_MODE_MANUAL, "ManualScale" => array(0 => array( "Min" => 60*floor(min($Paces)/60), "Max" => 60*ceil(max($Paces)/60))), "LabelSkip" => (1/$skip - 1), "XMargin" => 0);
$Draw = new Draw();
$Draw->pData->addPoints($Distances, 'Distanz'); $Draw->pData->addPoints($Paces, 'Pace'); $Draw->pData->setXAxisUnit(' km'); $Draw->pData->setAxisDisplay(0, AXIS_FORMAT_TIME, 'i:s'); $Draw->pData->setAbscissa('Distanz'); $Draw->pData->setPalette('Pace');
$Draw->setCaching(false); $Draw->startImage(); $Draw->drawScale($ScaleFormat); $Draw->drawSplineChart();
$Draw->finish(); ?>
... okay, playing a while I found '"Factors" => array(60);' as what I wanted. Nevertheless, the broken manualScale is a bug, not? And another request I will add here: What is about drawCubicCurve from pChart 1.x - this spline from pChart 2.x doesn't seem to be very cubic? Greetings, Hannes
|