Exemplo n.º 1
0
 public function reg_data()
 {
     $_label = array('05-01', '05-02', '05-03', '05-04', '05-05', '05-06', '05-07', '05-08', '05-09', '05-10', '05-11', '05-12', '05-13', '05-14', '05-15');
     $_value = array(1235, 1125, 1323, 1389, 1256, 1568, 1383, 1677, 1953, 1798, 2089, 2215, 1738, 2189, 2315);
     $_max_value = 2500;
     $this->load->library('OFC_Chart');
     $title = new OFC_Elements_Title("日注册用户数(人)");
     //创建图表类型对象
     $element = new OFC_Charts_Bar_Glass();
     //设置图标值
     $element->set_values($_value);
     //$element->set_width( 2 );
     //$element->set_dot_style(array('type'=>"solid-dot",'dot-size'=>5,'halo-size'=>1,'colour'=>'#3D5C56'));
     //设置动画
     $element->set_on_show(array('type' => "pop-up", 'cascade' => 0.8, 'delay' => 0.1));
     $element->set_colour("#009829");
     //创建图表对象
     $chart = new OFC_Chart();
     $chart->set_title($title);
     //图表类型添加到图表
     $chart->add_element($element);
     //x轴
     $x_axis = new OFC_Elements_Axis_X();
     $x_axis->set_labels(array('labels' => $_label));
     $x_axis->set_steps(1);
     $chart->set_x_axis($x_axis);
     //y轴
     $y_axis = new OFC_Elements_Axis_Y();
     $y_axis->set_range(0, $_max_value, $_max_value / 10);
     $chart->set_y_axis($y_axis);
     //x 脚标
     $x_legend = new OFC_Elements_Legend_X('日期');
     $x_legend->set_style('{font-size: 20px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $chart->set_bg_colour('#ffffff');
     echo $chart->toPrettyString();
 }
Exemplo n.º 2
0
 public function chartDataAction()
 {
     // Disable layout and viewrenderer
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     // Get params
     $type = $this->_getParam('type');
     $start = $this->_getParam('start');
     $offset = $this->_getParam('offset', 0);
     $mode = $this->_getParam('mode');
     $chunk = $this->_getParam('chunk');
     $period = $this->_getParam('period');
     $periodCount = $this->_getParam('periodCount', 1);
     //$end = $this->_getParam('end');
     // Validate chunk/period
     if (!$chunk || !in_array($chunk, $this->_periods)) {
         $chunk = Zend_Date::DAY;
     }
     if (!$period || !in_array($period, $this->_periods)) {
         $period = Zend_Date::MONTH;
     }
     if (array_search($chunk, $this->_periods) >= array_search($period, $this->_periods)) {
         die('whoops');
         return;
     }
     // Validate start
     if ($start && !is_numeric($start)) {
         $start = strtotime($start);
     }
     if (!$start) {
         $start = time();
     }
     // Fixes issues with month view
     Zend_Date::setOptions(array('extend_month' => true));
     // Get timezone
     $timezone = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_locale_timezone', 'GMT');
     $viewer = Engine_Api::_()->user()->getViewer();
     if ($viewer && $viewer->getIdentity() && !empty($viewer->timezone)) {
         $timezone = $viewer->timezone;
     }
     // Make start fit to period?
     $startObject = new Zend_Date($start);
     $startObject->setTimezone($timezone);
     $partMaps = $this->_periodMap[$period];
     foreach ($partMaps as $partType => $partValue) {
         $startObject->set($partValue, $partType);
     }
     // Do offset
     if ($offset != 0) {
         $startObject->add($offset, $period);
     }
     // Get end time
     $endObject = new Zend_Date($startObject->getTimestamp());
     $endObject->setTimezone($timezone);
     $endObject->add($periodCount, $period);
     $endObject->sub(1, Zend_Date::SECOND);
     // Subtract one second
     // Get data
     $statsTable = Engine_Api::_()->getDbtable('statistics', 'core');
     $statsSelect = $statsTable->select()->where('type = ?', $type)->where('date >= ?', gmdate('Y-m-d H:i:s', $startObject->getTimestamp()))->where('date < ?', gmdate('Y-m-d H:i:s', $endObject->getTimestamp()))->order('date ASC');
     $rawData = $statsTable->fetchAll($statsSelect);
     // Now create data structure
     $currentObject = clone $startObject;
     $nextObject = clone $startObject;
     $data = array();
     $dataLabels = array();
     $cumulative = 0;
     $previous = 0;
     do {
         $nextObject->add(1, $chunk);
         $currentObjectTimestamp = $currentObject->getTimestamp();
         $nextObjectTimestamp = $nextObject->getTimestamp();
         $data[$currentObjectTimestamp] = $cumulative;
         // Get everything that matches
         $currentPeriodCount = 0;
         foreach ($rawData as $rawDatum) {
             $rawDatumDate = strtotime($rawDatum->date);
             if ($rawDatumDate >= $currentObjectTimestamp && $rawDatumDate < $nextObjectTimestamp) {
                 $currentPeriodCount += $rawDatum->value;
             }
         }
         // Now do stuff with it
         switch ($mode) {
             default:
             case 'normal':
                 $data[$currentObjectTimestamp] = $currentPeriodCount;
                 break;
             case 'cumulative':
                 $cumulative += $currentPeriodCount;
                 $data[$currentObjectTimestamp] = $cumulative;
                 break;
             case 'delta':
                 $data[$currentObjectTimestamp] = $currentPeriodCount - $previous;
                 $previous = $currentPeriodCount;
                 break;
         }
         $currentObject->add(1, $chunk);
     } while ($currentObject->getTimestamp() < $endObject->getTimestamp());
     // Reprocess label
     $labelStrings = array();
     $labelDate = new Zend_Date();
     foreach ($data as $key => $value) {
         $labelDate->set($key);
         $labelStrings[] = $this->view->locale()->toDate($labelDate, array('size' => 'short'));
         //date('D M d Y', $key);
     }
     // Let's expand them by 1.1 just for some nice spacing
     $minVal = min($data);
     $maxVal = max($data);
     $minVal = floor($minVal * ($minVal < 0 ? 1.1 : 1 / 1.1) / 10) * 10;
     $maxVal = ceil($maxVal * ($maxVal > 0 ? 1.1 : 1 / 1.1) / 10) * 10;
     // Remove some labels if there are too many
     $xlabelsteps = 1;
     if (count($data) > 10) {
         $xlabelsteps = ceil(count($data) / 10);
     }
     // Remove some grid lines if there are too many
     $xsteps = 1;
     if (count($data) > 100) {
         $xsteps = ceil(count($data) / 100);
     }
     // Create base chart
     require_once 'OFC/OFC_Chart.php';
     // Make x axis labels
     $x_axis_labels = new OFC_Elements_Axis_X_Label_Set();
     $x_axis_labels->set_steps($xlabelsteps);
     $x_axis_labels->set_labels($labelStrings);
     // Make x axis
     $labels = new OFC_Elements_Axis_X();
     $labels->set_labels($x_axis_labels);
     $labels->set_colour("#416b86");
     $labels->set_grid_colour("#dddddd");
     $labels->set_steps($xsteps);
     // Make y axis
     $yaxis = new OFC_Elements_Axis_Y();
     $yaxis->set_range($minVal, $maxVal);
     $yaxis->set_colour("#416b86");
     $yaxis->set_grid_colour("#dddddd");
     // Make data
     $graph = new OFC_Charts_Line();
     $graph->set_values(array_values($data));
     $graph->set_colour("#5ba1cd");
     // Make title
     $locale = Zend_Registry::get('Locale');
     $translate = Zend_Registry::get('Zend_Translate');
     $titleStr = $translate->_('_CORE_ADMIN_STATS_' . strtoupper(trim(preg_replace('/[^a-zA-Z0-9]+/', '_', $type), '_')));
     $title = new OFC_Elements_Title($titleStr . ': ' . $this->view->locale()->toDateTime($startObject) . ' to ' . $this->view->locale()->toDateTime($endObject));
     $title->set_style("{font-size: 14px;font-weight: bold;margin-bottom: 10px; color: #777777;}");
     // Make full chart
     $chart = new OFC_Chart();
     $chart->set_bg_colour('#ffffff');
     $chart->set_x_axis($labels);
     $chart->add_y_axis($yaxis);
     $chart->add_element($graph);
     $chart->set_title($title);
     // Send
     $this->getResponse()->setBody($chart->toPrettyString());
 }
Exemplo n.º 3
0
    $data_3[] = sin($i) * 1.9 + 4;
    // just show to two decimal places
    // in our labels:
    //$labels[] = number_format($tmp,2);
}
$title = new OFC_Elements_Title(date("D M d Y"));
$line_1 = new OFC_Charts_Line_Dot();
$line_1->set_values($data_1);
$line_1->set_halo_size(0);
$line_1->set_width(2);
$line_1->set_dot_size(4);
$line_2 = new OFC_Charts_Line_Dot();
$line_2->set_values($data_2);
$line_2->set_halo_size(1);
$line_2->set_width(1);
$line_2->set_dot_size(4);
$line_3 = new OFC_Charts_Line_Dot();
$line_3->set_values($data_3);
$line_3->set_halo_size(1);
$line_3->set_width(6);
$line_3->set_dot_size(4);
$y = new OFC_Elements_Axis_Y();
$y->set_range(0, 15, 5);
$chart = new OFC_Chart();
$chart->set_title($title);
$chart->add_element($line_1);
$chart->add_element($line_2);
$chart->add_element($line_3);
$chart->set_y_axis($y);
echo $chart->toPrettyString();
Exemplo n.º 4
0
chdir(dirname(__FILE__)."/lib");
include "open-flash-chart-object.php";

srand((double)microtime()*1000000);
$data = array();

// add random height bars:
for( $i=0; $i<10; $i++ )
  $data[] = rand(1,9);

require_once(OFC_LIBRARY_PATH . '/lib/OFC/OFC_Chart.php');

$title = new OFC_Elements_Title( date("D M d Y") );

$bar = new OFC_Charts_Bar_3d();
$bar->set_values( $data );
$bar->colour = '#D54C78';

$x_axis = new OFC_Elements_Axis_X();
$x_axis->set_3d( 5 );
$x_axis->colour = '#909090';
$x_axis->set_labels( array('poroto', '11-05-2011', '12-05-2011', '13-05-2011', '14-05-2011', '15-05-2011', '16-05-2011', '17-05-2011', '18-05-2011', '19-05-2011') );

$chart = new OFC_Chart();
$chart->set_title( $title );
$chart->add_element( $bar );
$chart->set_x_axis( $x_axis );

file_put_contents('tmp/sarasa.json', $chart->toPrettyString());

open_flash_chart_object( 700, 500, ROOT_URL . '/tmp/sarasa.json' );
Exemplo n.º 5
0
function render_chart($options = array())
{
    $genid = array_var($options, 'genid', gen_id());
    $title = array_var($options, 'title', '');
    $width = array_var($options, 'width', 700);
    $height = array_var($options, 'height', 500);
    $type = array_var($options, 'type', 'line');
    $x_range = array_var($options, 'x_range', array());
    $y_range = array_var($options, 'y_range', array());
    $x_labels = array_var($options, 'x_labels', array());
    $y_axis_right = array_var($options, 'y_axis_right');
    $y_values = array_var($options, 'data');
    $shapes = array_var($options, 'shapes', array());
    $label_step = array_var($options, 'label_step', 7);
    $title = new OFC_Elements_Title($title);
    $max = 0;
    $chart_values = array();
    foreach ($y_values as $y_values_array) {
        $data_object = create_chart_data_object($type, $y_values_array);
        $values_data = array_var($y_values_array, 'values', array());
        $max = count($values_data) > $max ? count($values_data) : $max;
        $chart_values[] = $data_object;
    }
    $x_range_start = array_var($x_range, 'start', 0);
    $x_range_end = array_var($x_range, 'end', 10) - $x_range_start > $max ? $max + $x_range_start - 1 : array_var($x_range, 'end', 10);
    $labels = array();
    $coef = floor(count($x_labels) / $label_step);
    if ($coef > 0) {
        $k = 0;
        foreach ($x_labels as $label) {
            $labels[] = $k % $coef == 0 ? $label : "";
            $k++;
        }
    } else {
        $labels = $x_labels;
    }
    $x_axis = new OFC_Elements_Axis_X();
    $x_axis->set_colours(array_var($options, 'x_axis_color', '#87C4FA'), array_var($options, 'x_grid_color', '#D4E8FA'));
    if (array_var($x_range, 'step')) {
        $x_axis->set_range($x_range_start, $x_range_end, array_var($x_range, 'step', 1));
    }
    $x_axis->set_labels_from_array($labels);
    $y_axis = new OFC_Elements_Axis_Y();
    $y_axis->set_colours(array_var($options, 'y_axis_color', '#87C4FA'), array_var($options, 'y_grid_color', '#D4E8FA'));
    if (array_var($y_range, 'step')) {
        $y_axis->set_range(array_var($y_range, 'start', 0), array_var($y_range, 'end', 10), array_var($y_range, 'step', 1));
    }
    $chart = new OFC_Chart();
    $chart->set_title($title);
    foreach ($chart_values as $cv) {
        $chart->add_element($cv);
    }
    $chart->set_x_axis($x_axis);
    $chart->set_y_axis($y_axis);
    $chart->set_bg_colour(array_var($options, 'back_color', '#FFFFFF'));
    if ($y_axis_right) {
        $chart->set_y_axis_right($y_axis);
    }
    foreach ($shapes as $s) {
        $shape = new shape(array_var($s, 'color', '#FA6900'));
        $points = array_var($s, 'points', array());
        foreach ($points as $p) {
            $shape->append_value(new shape_point($p['x'], $p['y']));
        }
        if (array_var($s, 'text')) {
            $shape->set_text(array_var($s, 'text'));
        }
        if (array_var($s, 'alpha')) {
            $shape->set_alpha(array_var($s, 'alpha'));
        }
        $chart->add_element($shape);
    }
    $filename = 'tmp/' . gen_id() . '.json';
    file_put_contents(ROOT . "/{$filename}", $chart->toPrettyString());
    open_flash_chart_object($width, $height, ROOT_URL . "/{$filename}", $genid);
    //	unlink(ROOT . "/$filename");
}
Exemplo n.º 6
0
Arquivo: Ofc.php Projeto: Aeryris/grid
    public function deploy()
    {
        $this->checkExportRights();
        if ($this->_filesLocation === null) {
            throw new Bvb_Grid_Exception($this->__("Please set Javascript and Flash file locations using SetFilesLocation()"));
        }
        $grid = array();
        $newData = array();
        $label = array();
        $result = array();
        parent::deploy();
        $data = parent::_buildGrid();
        if (count($data) == 0) {
            $this->_deploymentContent = '';
            return;
        }
        foreach ($data as $value) {
            foreach ($value as $final) {
                $result[$final['field']][] = is_numeric($final['value']) ? $final['value'] : strip_tags($final['value']);
            }
        }
        if (is_string($this->_xLabels) && isset($result[$this->_xLabels])) {
            $this->_xLabels = $result[$this->_xLabels];
        }
        $graph = new OFC_Chart();
        $title = new OFC_Elements_Title($this->_title);
        $title->set_style($this->_style);
        $graph->set_title($title);
        foreach ($this->_chartOptions as $key => $value) {
            $graph->{$key}($value);
        }
        if (count($this->_xLabels) > 0) {
            $x = new OFC_Elements_Axis_X();
            $x_axis_labels = new OFC_Elements_Axis_X_Label_Set();
            foreach ($this->_xAxisOptions as $key => $value) {
                $x_axis_labels->{$key}($value);
            }
            $x_axis_labels->set_labels($this->_xLabels);
            $x->set_labels($x_axis_labels);
            foreach ($this->_xLabelsOptions as $key => $value) {
                $x->{$key}($value);
            }
            $graph->set_x_axis($x);
        }
        if (!empty($this->_xLegendText) && !empty($this->_xLegendStyle)) {
            $x_legend = new OFC_Elements_Legend_X($this->_xLegendText);
            $x_legend->set_style($this->_xLegendStyle);
            $graph->set_x_legend($x_legend);
        }
        $min = 0;
        $max = 0;
        if (count($this->_values) == 0) {
            $this->setValues(key($result));
        }
        foreach ($this->_values as $key => $value) {
            if (is_array($value)) {
                $support = $value;
                sort($support);
                if (reset($support) < $min) {
                    $min = reset($support);
                }
                if (end($support) > $max) {
                    $max = end($support);
                }
                unset($support);
                $options = $this->_chartOptionsValues[$value];
                if (isset($options['chartType'])) {
                    $this->setChartType($options['chartType']);
                }
                $bar = new $this->_type();
                foreach ($options as $key => $prop) {
                    $bar->{$key}($prop);
                }
                $this->_type();
                $pie = array();
                if ($this->_type == 'Pie') {
                    foreach ($value as $key => $title) {
                        $pie[] = array('value' => $title, 'label' => $this->_xLabels[$key]);
                    }
                    $bar->set_values($pie);
                } else {
                    $bar->set_values($value);
                }
                $graph->add_element($bar);
            } elseif (is_string($value) && isset($result[$value])) {
                $options = $this->_chartOptionsValues[$value];
                if (isset($options['chartType'])) {
                    $this->setChartType($options['chartType']);
                }
                $bar = new $this->_type();
                foreach ($options as $key => $prop) {
                    $bar->{$key}($prop);
                }
                $value = array_map(create_function('$item', ' return (float)$item; '), $result[$value]);
                $support = $value;
                sort($support);
                if (reset($support) < $min) {
                    $min = reset($support);
                }
                if (end($support) > $max) {
                    $max = end($support);
                }
                unset($support);
                $pie = array();
                if ($this->_type == 'OFC_Charts_Pie') {
                    foreach ($value as $key => $title) {
                        $pie[] = array('value' => $title, 'label' => $this->_xLabels[$key]);
                    }
                    $bar->set_values($pie);
                } else {
                    $bar->set_values($value);
                }
                $graph->add_element($bar);
            }
        }
        $max = $max * 1.05;
        $y = new OFC_Elements_Axis_Y();
        $y->set_range($min, $max, ceil($max / 4));
        $graph->add_y_axis($y);
        $final = $graph->toPrettyString();
        if (!is_string($this->_chartId)) {
            $this->_chartId = 'chart_' . rand(1, 10000);
        }
        $script = '
        swfobject.embedSWF(
        "' . $this->_filesLocation['flash'] . '", "' . $this->_chartId . '",
        "' . $this->_chartDimensions['x'] . '", "' . $this->_chartDimensions['y'] . '", "9.0.0", "expressInstall.swf",{"id":"' . $this->_chartId . '"},{"z-index":"1","wmode":"transparent"} );

        function open_flash_chart_data(id)
        {
            return JSON.stringify(window[id]);
        }

        function findSWF(movieName) {
          if (navigator.appName.indexOf("Microsoft")!= -1) {
            return window[movieName];
          } else {
            return document[movieName];
          }
        }
        var ' . $this->_chartId . ' = ' . $final . ';';
        $final = '<div id="' . $this->_chartId . '" >
        loading...
        <br/>
        <p>
        Please note that this content requires flash player 9.0.0</br>
        To test for your version of flash, <a href="http://www.bobbyvandersluis.com/swfobject/testsuite_2_1/test_api_getflashplayerversion.html" target="_blank">click here</a>
        </p>
        </div>';
        if (!$this->_multiple) {
            $final = '<div style="width: 100%;text-align: center">' . $final . '</div>';
        }
        $this->getView()->headScript()->appendFile($this->_filesLocation['js']);
        $this->getView()->headScript()->appendFile($this->_filesLocation['json']);
        $this->getView()->headScript()->appendScript($script);
        $this->_deploymentContent = $final;
        return $this;
    }
 /**
  * @Route("/{anno}/{mes}/{assigned_user_id}/{width}/panel_detalle_discovery_metas_in_progress_data.json", name="panel_detalle_discovery_metas_in_progress_data", defaults={"anno"="2013","mes"="01"}, options={"expose"=true})
  */
 public function panelDetalleDiscoveryMetasPorAgenteDataAction($anno, $mes, $assigned_user_id, $width)
 {
     include_once __DIR__ . "/../Util/OFC/OFC_Chart.php";
     $title = new \OFC_Elements_Title('STATUS DE LAS REUNIONES V/S METAS DEL AGENTE ');
     $bar = new \OFC_Charts_Bar_Stack();
     $sql = "SELECT CONCAT(users.user_name,' ',users.first_name,' ', users.last_name) as owner, meetings.assigned_user_id, (SELECT count(*) FROM meetings m WHERE parent_type = 'Accounts' AND m.deleted = 0 AND YEAR(m.date_start) = 2015 AND m.assigned_user_id = meetings.assigned_user_id ) as meetings,(SELECT count(*) FROM meetings m2 INNER JOIN accounts_opportunities ON m2.parent_id = accounts_opportunities.opportunity_id  WHERE parent_type = 'Opportunities' AND 1 AND m2.deleted = 0 AND YEAR(m2.date_start) = " . $anno . " ) as meetings_opportunities FROM meetings INNER JOIN users ON users.id = meetings.assigned_user_id AND meetings.deleted = 0 AND meetings.assigned_user_id = '" . $assigned_user_id . "' GROUP BY assigned_user_id HAVING (meetings + meetings_opportunities) > 0;";
     $stmt = $this->container->get('doctrine')->getManager()->getConnection()->prepare($sql);
     $stmt->execute();
     //Valores
     $valor = 0;
     foreach ($stmt->fetchAll() as $data) {
         $valor = (int) $data['meetings'] + (int) $data['meetings_opportunities'];
         $bar->append_stack(array(new \OFC_Charts_Bar_Stack_Value((int) $data['meetings'], '#ff0000'), new \OFC_Charts_Bar_Stack_Value((int) $data['meetings_opportunities'], '#1240AB')));
     }
     //Metas
     $sql = "SELECT sem_1_c, sem_2_c FROM cammr_metasreuniones INNER JOIN cammr_metasreuniones_cstm ON cammr_metasreuniones_cstm.id_c = cammr_metasreuniones.id WHERE deleted = 0 AND anno_c = '" . $anno . "' AND user_id_c = '" . $assigned_user_id . "';";
     $stmt = $this->container->get('doctrine')->getManager()->getConnection()->prepare($sql);
     $stmt->execute();
     $meta = 0;
     foreach ($stmt->fetchAll() as $data) {
         $meta = $data['sem_1_c'] + $data['sem_2_c'];
         $bar->append_stack(array(new \OFC_Charts_Bar_Stack_Value((int) $data['sem_1_c'], '#ff0000'), new \OFC_Charts_Bar_Stack_Value((int) $data['sem_2_c'], '#1240AB')));
     }
     $y = new \OFC_Elements_Axis_Y();
     $max = round(max($valor, $meta) * 1.15, 0);
     $y->set_range(0, $max, round($max, -3));
     $x = new \OFC_Elements_Axis_X();
     $x->set_labels_from_array(array('Reuniones', 'Metas'));
     $chart = new \OFC_Chart();
     $chart->set_bg_colour('#FFFFFF');
     $chart->set_title($title);
     $chart->add_element($bar);
     $chart->set_x_axis($x);
     $chart->add_y_axis($y);
     $response = new Response($chart->toPrettyString());
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Exemplo n.º 8
0
/**
 * $array['title']
 * $array['legend_y']
 * $array['legend_x']
 * $array['values']
 * $array['values_key']
 * $array['range_max']
 * $array['range_step']
 * @param $array
 * @return unknown_type
 */
function create_chart_data($array)
{
    if (!$array) {
        return;
    }
    require_once 'OFC/OFC_Chart.php';
    $chart = new OFC_Chart();
    $chart->set_bg_colour('#ffffff');
    $title = new OFC_Elements_Title($array['title']);
    $title->set_style('{color: #567300; font-size: 16px; font-weight:bold;}');
    $chart->set_title($title);
    $yl = new OFC_Elements_Legend_Y($array['legend_y']);
    $yl->set_style('{font-size:18px;}');
    $chart->set_y_legend($yl);
    $xl = new OFC_Elements_Legend_X($array['legend_x']);
    $xl->set_style('{font-size:18px;color:#Ff0}');
    $chart->set_x_legend($xl);
    $elements = array();
    $colors = array('', '#CC00AA', '#9C48F0', '#b0de09', '#0d8ecf', '#ff6600', '#fcd202', '#E2EBFF', '#AAAAAA');
    foreach ($array['values'] as $k => $v) {
        ksort($v, SORT_STRING);
        $line = new OFC_Charts_Line();
        $line->set_key($array['values_key'][$k], 12);
        $colors[$k] ? $line->set_colour($colors[$k]) : '';
        $line->set_values(array_values($v));
        $default_dot = new OFC_Charts_Line_Dot();
        $default_dot->tooltip('#x_label#<br>#val#');
        $line->set_default_dot_style($default_dot);
        $elements[] = $line;
        $array['values'][$k] =& $v;
    }
    foreach ($elements as $element) {
        $chart->add_element($element);
    }
    $x = new OFC_Elements_Axis_X();
    $x->colour = '#909090';
    $x_axis_labels = new OFC_Elements_Axis_X_Label_Set();
    $x->set_steps($array['show_step']);
    $x_axis_labels->set_steps($array['show_step']);
    if (is_array($array['values'][0])) {
        $keys = array_keys($array['values'][0]);
    } else {
        $keys = array_keys($array['values']);
    }
    $x_axis_labels->set_labels($keys);
    $x_axis_labels->set_size(12);
    $x_axis_labels->set_colour('#Ff0');
    $x_axis_labels->set_rotate('-45');
    $x->set_labels($x_axis_labels);
    $chart->set_x_axis($x);
    $y = new OFC_Elements_Axis_Y();
    $range_min = isset($array['range_min']) ? $array['range_min'] : 0;
    $y->set_range($range_min, $array['range_max'], $array['range_step']);
    $chart->set_y_axis($y);
    return $chart->toPrettyString();
}