<?php
/*
+-----------------------------------------------------------------------------+
| $Id: curve.php 2010-05-24 12:37:44Z Bleakwind $
| Handle for Build picture
| Copyright (c) 2003-2010 Bleakwind (www.weaverdream.com)
| http://www.weaverdream.com/
| Release under the GNU Lesser General Public License Version 3 (LGPLv3):
|   http://www.gnu.org/licenses/lgpl.html
+-----------------------------------------------------------------------------+
*/

$color   = array();
$color[] = "00BBEC";
$color[] = "00AD5F";
$color[] = "F24385";
$color[] = "6600FF";
$color[] = "8E7DE5";
$color[] = "EB4847";
$color[] = "8E7DE5";
$color[] = "2489B0";
$color[] = "515151";
$color[] = "62D8B6";
$color[] = "FACA57";
$color[] = "875546";
$color[] = "C2E254";
$color[] = "F4A469";
$color[] = "F972A1";
$color[] = "FF6784";
$color[] = "BD59D4";

if( preg_match("/^[a-z]+$/",$sys->get['name']) && array_key_exists($sys->get['name'], $vote_array) ){

    $sql = "SELECT * FROM activity_vote_item
            WHERE sort='healthfeast2006' AND name='".$sys->get['name']."'";
    $result = &$db->Execute($sql);
    if (!$result) {
        echo $db->ErrorMsg();
    } else {

        while (!$result->EOF) {
            $number_array[$result->fields['value']] = $result->fields['number'];
            $result->MoveNext();
        }
        $i = 0;
        foreach($vote_array[$sys->get['name']]['value'] as $value => $value_name){
            $array_data[]  = (int)$number_array[$value];
            $array_label[] = $value_name;// 标签
            $array_color[] = $color[$i]; //颜色
            $i++;
        }
        $title        = $vote_array[$sys->get['name']]['name'];
        $image_width  = 580;
        $image_height = 200+15*count($array_data);
        $curve_width  = 500;
        $curve_height = 120;

        //////
        $bwcurve = new bwcurve($image_width,$image_height);
        $bwcurve->set_curve($curve_width,$curve_height);
        $bwcurve->set_curve_place(40,20);
        $bwcurve->set_curve_curvewidth(16);
        $bwcurve->set_bgcolor("FFFFFF");
        $bwcurve->set_curve_bgcolor("FDFFFD");
        $bwcurve->set_curve_gridcolor("E1F0FF");
        $bwcurve->set_font("fonts/simsun.ttc","9","000000");
        $bwcurve->set_data($array_data,$array_label,$array_color);
        $bwcurve->set_returntype("column_erect","all","3");
        $bwcurve->set_labeltype_x("list","5","all");
        $bwcurve->set_labeltype_y("all","55");

        $bwcurve->set_chinese($title,"fonts/jingdianteheijian.ttf","F98106",12,60,30);
        $bwcurve->set_copyimage("images/curve_logo.png",60,$image_width-60,$image_height-20);
        $bwcurve->set_english("www.weaverdream.com","2","5DC255",$image_width-70,1);

        $bwcurve->output();
        //////
    }

} else {
    echo "error...";
}

?>
