Example #1
0
    $legendObj = $c->addLegend(50, 455, false, "", 8);
    $legendObj->setBackground(Transparent);
    // Add a title box to the chart using 8 pts Arial Bold font, with yellow (0xffff40)
    // background and a black border (0x0)
    $textBoxObj = $c->addTitle("{$symb}.{$pf_exch}: {$symb_name}\nExponential Moving Averages from {$first_date} to {$pf_working_date}", "arialbd.ttf", 12);
    // Set the y axis label format to US$nnnn
    $c->yAxis->setLabelFormat("£{value}");
    $m_yearFormat = "{value|yyyy}";
    $m_firstMonthFormat = "<*font=bold*>{value|mmm yy}";
    $m_otherMonthFormat = "{value|mmm}";
    $m_firstDayFormat = "<*font=bold*>{value|d mmm}";
    $m_otherDayFormat = "{value|d}";
    $m_firstHourFormat = "<*font=bold*>{value|d mmm\nh:nna}";
    $m_otherHourFormat = "{value|h:nna}";
    $m_timeLabelSpacing = 50;
    $c->xAxis->setMultiFormat(StartOfDayFilter(), $m_firstDayFormat, StartOfDayFilter(1, 0.5), $m_otherDayFormat, 1);
    $layer = $c->addLineLayer2();
    $layer->setXData($dates);
    $layer->addDataSet($ema_12, -1, "12 day");
    $layer->addDataSet($ema_26, -1, "26 day");
    $layer = $c->addHLOCLayer3($high, $low, $open, $close, 0x8000, 0xff0000);
    $layer->setXData($dates);
    // Output the chart
    header("Content-type: image/png");
    print $c->makeChart2(PNG);
} else {
    return;
}
?>
 
Example #2
0
 function setXLabels(&$a)
 {
     $a->setLabels2($this->m_timeStamps);
     if ($this->m_extraPoints < count($this->m_timeStamps)) {
         $tickStep = (int) ((count($this->m_timeStamps) - $this->m_extraPoints) * $this->m_timeLabelSpacing / ($this->m_totalWidth - $this->m_leftMargin - $this->m_rightMargin)) + 1;
         $timeRangeInSeconds = $this->m_timeStamps[count($this->m_timeStamps) - 1] - $this->m_timeStamps[$this->m_extraPoints];
         $secondsBetweenTicks = $timeRangeInSeconds / ($this->m_totalWidth - $this->m_leftMargin - $this->m_rightMargin) * $this->m_timeLabelSpacing;
         if ($secondsBetweenTicks * (count($this->m_timeStamps) - $this->m_extraPoints) <= $timeRangeInSeconds) {
             $tickStep = 1;
             if (count($this->m_timeStamps) > 1) {
                 $secondsBetweenTicks = $this->m_timeStamps[count($this->m_timeStamps) - 1] - $this->m_timeStamps[count($this->m_timeStamps) - 2];
             } else {
                 $secondsBetweenTicks = 86400;
             }
         }
         if ($secondsBetweenTicks > 360 * 86400 || $secondsBetweenTicks > 90 * 86400 && $timeRangeInSeconds >= 720 * 86400) {
             #yearly ticks
             $a->setMultiFormat2(StartOfYearFilter(), $this->m_yearFormat, $tickStep);
         } else {
             if ($secondsBetweenTicks >= 30 * 86400 || $secondsBetweenTicks > 7 * 86400 && $timeRangeInSeconds >= 60 * 86400) {
                 #monthly ticks
                 $monthBetweenTicks = (int) ($secondsBetweenTicks / 31 / 86400) + 1;
                 $a->setMultiFormat(StartOfYearFilter(), $this->m_firstMonthFormat, StartOfMonthFilter($monthBetweenTicks), $this->m_otherMonthFormat);
                 $a->setMultiFormat2(StartOfMonthFilter(), "-", 1, false);
             } else {
                 if ($secondsBetweenTicks >= 86400 || $secondsBetweenTicks > 6 * 3600 && $timeRangeInSeconds >= 86400) {
                     #daily ticks
                     $a->setMultiFormat(StartOfMonthFilter(), $this->m_firstDayFormat, StartOfDayFilter(1, 0.5), $this->m_otherDayFormat, $tickStep);
                 } else {
                     #hourly ticks
                     $a->setMultiFormat(StartOfDayFilter(1, 0.5), $this->m_firstHourFormat, StartOfHourFilter(1, 0.5), $this->m_otherHourFormat, $tickStep);
                 }
             }
         }
     }
 }