我已经Codeigniter
使用以下视图将 Fusion 图表实现到框架中。我正在使用提供的数据创建折线图,但是我想从同一个结构化数据库表中检索这些数据。
有什么办法吗?如果有人可以帮助我,我将不胜感激。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php
class Chart extends CI_Controller {
function __construct()
{
session_start();
parent::__construct();
if ( !isset($_SESSION['username']) ) {
redirect('admin');
}
}
public function index() {
$this->load->helper(array('url','fusioncharts')) ;
$graph_swfFile = base_url().'public/flash/Line.swf' ;
$graph_caption = 'Results' ;
$graph_numberPrefix = '€ ' ;
$graph_title = 'Results' ;
$graph_width = 600 ;
$graph_height = 250 ;
// Store Name of Products
$arrData[0][1] = "Novomatic";
$arrData[1][1] = "Atronic";
$arrData[2][1] = "Williams";
$arrData[3][1] = "Roulettes";
$arrData[4][1] = "IGT";
$arrData[5][1] = "Interblock";
//Store sales data
$arrData[0][2] = 567500;
$arrData[1][2] = 815300;
$arrData[2][2] = 556800;
$arrData[3][2] = 734500;
$arrData[4][2] = 676800;
$arrData[5][2] = 648500;
$strXML = "<graph caption='".$graph_caption."' numberPrefix='".$graph_numberPrefix."' formatNumberScale='0' decimalPrecision='0'>";
//Convert data to XML and append
foreach ($arrData as $arSubData) {
$strXML .= "<set name='" . $arSubData[1] . "' value='" . $arSubData[2] . "' color='".getFCColor()."' />";
}
//Close <chart> element
$strXML .= "</graph>";
$data['graph'] = renderChart($graph_swfFile, $graph_title, $strXML, "div" , $graph_width, $graph_height);
//$this->load->view('chart_view',$data) ;
$this->template->load('includes/template', 'chart_view' ,$data);
}
}