Пример #1
0
 function doAutoScaleYAxis()
 {
     //Check if we should autoscale y-axis
     if (!$this->yscale->IsSpecified() && count($this->plots) > 0) {
         list($min, $max) = $this->GetPlotsYMinMax($this->plots);
         $lres = $this->GetLinesYMinMax($this->lines);
         if (is_array($lres)) {
             list($linmin, $linmax) = $lres;
             $min = min($min, $linmin);
             $max = max($max, $linmax);
         }
         $tres = $this->GetTextsYMinMax();
         if (is_array($tres)) {
             list($tmin, $tmax) = $tres;
             $min = min($min, $tmin);
             $max = max($max, $tmax);
         }
         $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
     } elseif ($this->yscale->IsSpecified() && ($this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified())) {
         // The tick calculation will use the user suplied min/max values to determine
         // the ticks. If auto_ticks is false the exact user specifed min and max
         // values will be used for the scale.
         // If auto_ticks is true then the scale might be slightly adjusted
         // so that the min and max values falls on an even major step.
         $min = $this->yscale->scale[0];
         $max = $this->yscale->scale[1];
         $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor, $this->yscale->auto_ticks);
         // Now make sure we show enough precision to accurate display the
         // labels. If this is not done then the user might end up with
         // a scale that might actually start with, say 13.5, butdue to rounding
         // the scale label will ony show 14.
         if (abs(floor($min) - $min) > 0) {
             // If the user has set a format then we bail out
             if ($this->yscale->ticks->label_formatstr == '' && $this->yscale->ticks->label_dateformatstr == '') {
                 $this->yscale->ticks->precision = abs(floor(log10(abs(floor($min) - $min)))) + 1;
             }
         }
     }
 }