Example #1
0
        $data = json_decode(safe_output(get_parameter('data')), true);
        $max = get_parameter('max');
        $title = get_parameter('title');
        $mode = get_parameter('mode', 1);
        gd_histogram($width, $height, $mode, $data, $max, $font, $title);
        break;
    case 'progressbar':
        $width = get_parameter('width');
        $height = get_parameter('height');
        $progress = get_parameter('progress');
        $out_of_lim_str = get_parameter('out_of_lim_str', false);
        $out_of_lim_image = get_parameter('out_of_lim_image', false);
        $font = get_parameter('font');
        $title = get_parameter('title');
        $mode = get_parameter('mode', 1);
        gd_progress_bar($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image, $mode);
        break;
}
function histogram($chart_data, $width, $height, $font, $max, $title, $mode, $ttl = 1)
{
    $graph = array();
    $graph['data'] = $chart_data;
    $graph['width'] = $width;
    $graph['height'] = $height;
    $graph['font'] = $font;
    $graph['max'] = $max;
    $graph['title'] = $title;
    $graph['mode'] = $mode;
    $id_graph = serialize_in_temp($graph, null, $ttl);
    return "<img title='" . $graph["title"] . "' src='include/graphs/functions_gd.php?graph_type=histogram&ttl=" . $ttl . "&id_graph=" . $id_graph . "'>";
}
Example #2
0
    if (!$id_graph) {
        exit;
    }
    $graph = unserialize_in_temp($id_graph, true, $ttl);
    if (!isset($graph)) {
        exit;
    }
    if (!isset($graph['fontsize'])) {
        $graph['fontsize'] = 6;
    }
    switch ($graph_type) {
        case 'histogram':
            gd_histogram($graph['width'], $graph['height'], $graph['mode'], json_decode($graph['data'], true), $graph['max'], $graph['font'], $graph['title'], $graph['fontsize']);
            break;
        case 'progressbar':
            gd_progress_bar($graph['width'], $graph['height'], $graph['progress'], $graph['title'], $graph['font'], $graph['out_of_lim_str'], $graph['out_of_lim_image'], $graph['mode'], $graph['fontsize']);
            break;
        case 'funnel':
            gd_funnel_chart($graph['data'], $graph['font']);
            break;
    }
}
function gd_histogram($width, $height, $mode, $data, $max_value, $font, $title, $fontsize = 8)
{
    // $title is for future use
    $nvalues = count($data);
    Header("Content-type: image/png");
    $image = imagecreate($width, $height);
    $white = ImageColorAllocate($image, 255, 255, 255);
    imagecolortransparent($image, $white);
    $black = ImageColorAllocate($image, 0, 0, 0);