Ejemplo n.º 1
1
function build_and_send_graph($data_rs, $chartType, $title)
{
    $gdImage = new GDImage(get_opendb_image_type());
    $imgType = $gdImage->getImageType();
    unset($gdImage);
    $graphCfg = _theme_graph_config();
    $chart = new StatsChartImpl($chartType, $graphCfg);
    $chart->setTitle($title);
    if (is_array($data_rs)) {
        usort($data_rs, "sort_data_element");
        // only show first 12 items - otherwise graph will not render correctly.
        if ($chartType == 'piechart' && count($data_rs) > 12) {
            $data_rs = array_slice($data_rs, 0, 11);
        }
        reset($data_rs);
        while (list(, $data_r) = each($data_rs)) {
            if ($chartType == 'piechart') {
                $chart->addData($data_r['display'] . " ({$data_r['value']})", $data_r['value']);
            } else {
                $chart->addData($data_r['display'], $data_r['value']);
            }
        }
    }
    $chart->render($imgType);
}
Ejemplo n.º 2
0
 function testPngBasicFunctions()
 {
     $gdImage = new GDImage('png');
     $this->assertEquals('png', $gdImage->getImageType());
     $this->assertEquals('png', $gdImage->getImageExtension());
     $this->assertEquals('image/png', $gdImage->getImageContentType());
     $this->assertEquals('./images/code_bg.png', $gdImage->_getImageSrc('code_bg'));
     $this->assertEquals(TRUE, $gdImage->isImageTypeValid('png'));
     $this->assertEquals(FALSE, $gdImage->isImageTypeValid('xxx'));
     print_r($gdImage->getErrors());
 }