Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Pages: 1
Bonjour,
j essaye de récupérer plusieurs graphs sur une page pour créer un dashboard, j ai pu faire cela en codant directement sur le Controller, mais ce n est pas du tout propre en ayant zend framework et puis MVC, alors j ai pensé a stocker chaque code de graphe par fonctions sur une class Model (chaque Function associé a un graphe) je voudrais récupérer les datas ($data, $data1) de chaque graphe sur le Controller pour ensuite les passer sur la vue
Model:
<?php
class App_Model_Table_Dash extends Oft_Crud_Db_Table
{
protected function _setupDatabaseAdapter()
{
if (!$this->_db) {
$this->_db = Oft_App::getInstance()->getResource('multidb')->getDb('oracledb');
}
}
public function MoFsm(){
$view = $this->view;
$dateInBetween = array();
$SmsSum = array();
$smsSumGraph = array();
$y_axis_values = array();
$x_axis_values = array();
$conn = oci_connect('sm_statistics', 'sm_statistics',
'//10.241.45.5/ODS')or die ('Error binding string');
$queryparse = oci_parse($conn, $query);
oci_execute($queryparse);
while ($row_date = oci_fetch_array($queryparse,
OCI_ASSOC+OCI_RETURN_NULLS))
{
$y_axis_values[] = intval($row_date['SMSSUM']);
$x_axis_values[] = $row_date['DATETO'];
}
$chart = new open_flash_chart();
$y_axis = new y_axis();
$x_axis = new x_axis();
$default_dot = new line_dot();
$tooltip = new tooltip();
$x_labels = new x_axis_labels();
$x_labels->set_labels($x_axis_values);
$taille=sizeof($x_labels);
$step=2;
if ($taille>100) $step=4;
if ($taille>200) $step=8;
if ($taille>300) $step=12;
if ($taille>400) $step=24;
$x_labels->set_steps( $step );
$x_labels->rotate('45');
$x_axis->set_labels($x_labels);
$x_axis->set_offset(false);
$y_axis->set_range( 0, max($y_axis_values)+10, round( max($y_axis_values) / 4 ) );
$chart->set_x_axis( $x_axis );
$chart->add_y_axis( $y_axis );
//LINE
$line = new line();
$line->set_values( $y_axis_values );
$line->set_halo_size( 0 );
$line->set_width( 2 );
$chart->add_element($line);
$data = $chart->toPrettyString();
}
public function graph2 (){
$y_axis_values1 = array();
$x_axis_values1 = array();
$y_axis_values2 = array();
$x_axis_values2 = array();
$conn = oci_connect('sm_statistics', 'sm_statistics',
'//10.241.45.5/ODS')or die ('Error binding string');
$SuccRecMsgParse = oci_parse($conn, $query1);
oci_execute($SuccRecMsgParse);
while ($row_date1 = oci_fetch_array($SuccRecMsgParse,
OCI_ASSOC+OCI_RETURN_NULLS))
{
$y_axis_values1[] = intval($row_date1['SMSSUM']);
$x_axis_values1[] = $row_date1['DATETO'];
}
$MOtotalIncParse = oci_parse($conn, $query2);
oci_execute($MOtotalIncParse);
while ($row_date2 = oci_fetch_array($MOtotalIncParse,
OCI_ASSOC+OCI_RETURN_NULLS))
{
$y_axis_values2[] = intval($row_date2['SMSSUM']);
$x_axis_values2[] = $row_date2['DATETO'];
}
$y_axis1 = new y_axis();
$x_axis1 = new x_axis();
$default_dot = new line_dot();
$tooltip = new tooltip();
$x_labels1 = new x_axis_labels();
$x_labels1->set_labels($x_axis_values1);
$taille=sizeof($x_labels1);
$step=2;
if ($taille>100) $step=4;
if ($taille>200) $step=8;
if ($taille>300) $step=12;
if ($taille>400) $step=24;
$x_labels1->set_steps( $step );
$x_labels1->rotate('45');
$x_axis1->set_labels($x_labels1);
$x_axis1->set_offset(false);
$y_axis1->set_range( 0, max($y_axis_values1)+10, round( max($y_axis_values1) / 4 ) );
$default_dot = new line_dot();
$default_dot->set_colour('#DFC329');
$line_dot = new line();
$line_dot->set_default_dot_style($default_dot);
$line_dot->set_width( 4 );
$line_dot->set_colour( '#DFC329' );
$line_dot->set_values( $y_axis_values1 );
$line_dot->set_key( "SuccRecMsg", 10 );
$default_hollow_dot = new line_hollow();
$default_hollow_dot->set_colour('#6363AC');
$line_hollow = new line();
$line_hollow->set_default_dot_style($default_hollow_dot);
$line_hollow->set_width( 4 );
$line_hollow->set_colour( '#6363AC' );
$line_hollow->set_values( $y_axis_values2 );
$line_hollow->set_key( "MOtotalInc", 10 );
$chart1 =new open_flash_chart();
$chart1->set_x_axis( $x_axis1 );
$chart1->add_y_axis( $y_axis1 );
$chart1->add_element($line_dot);
$chart1->add_element($line_hollow);
$data1 = $chart1->toPrettyString();
}
}Hors ligne
Pages: 1