Enter file directory with cd command at terminal
Description: Here's an example I'm taking an example of a project to explain.
1. Create a new project: Use Terminal input: ZF Create Project Airline format: ZF Create action Project Project-name Note: These formats can be viewed in the terminal input ZF
2, create a new ACTION:ZF Create action dirgramshow index format: ZF Create action Action-name Controller-name
3, a new MODEL:ZF create db-table flightinformation
Action Layer Code: indexcontroller.php
Copy Code code as follows:
Public Function indexaction ()
{
Action Body
$db = new Application_model_dbtable_flightinformation ();
/* Get the number of the last 30 days
* Select Day (boo_time) as Day,count (boo_autoid) as Count,boo_time from Bookinformation
where Flag_pass=0 and Date_sub (now (), Interval day) <=date (boo_time)
Group BY Date_format (Boo_time, '%m%d ')
*/
$sql = "Select Date_format (boo_time, '%m-%d ') as Day,count (boo_autoid) as Count from Bookinformation".
"Where Flag_pass=0 and Date_sub (now (), Interval day) <=date (Boo_time)".
"GROUP by Date_format (Boo_time, '%m%d ')";
$result = $db->getallinfo ($sql)->fetchall ();
$this->view->result= $result;
}
View Layer Code: dirgramshow.phtml
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Flight Line Chart </title>
<script language= "javascript" type= "Text/javascript"
Src= "<?php
echo $this->baseurl (). '/skin/source/jquery/jquery.js '?> ' ></script>
<script language= "javascript" type= "Text/javascript"
Src= "<?php
echo $this->baseurl (). '/skin/js/zjpjscharts.js '?> ' ></script>
<body>
<div id= "graph" >loading graph...</div>
<script type= "Text/javascript" >
var d=new Array ();
var color=new Array ();
<?php
foreach ($this->result as $key => $value) {
?>
D.push (The New Array (' <?php
echo $value [' Day ']?> ', <?php
echo $value [' count ']?>]);
Color.push (' #2D6B96 ');
<?php
}
?>
if (d!= "") {
[' #2D6B96 ', ' #327AAD ', ' #3E90C9 ', ' #55A7E3 ', ' #60B6F0 ', ' #81C4F0 ', ' #9CCEF0 ']
var myData = D;
var colors =color;
var myChart = new Jschart (' graph ', ' bar ');
Mychart.setdataarray (MyData);
Mychart.colorizebars (colors);
Mychart.settitle (' Airline diagram ');
Mychart.settitlecolor (' #8E8E8E ');
Mychart.setaxisnamex (");
Mychart.setaxisnamey (");
Mychart.setaxiscolor (' #C4C4C4 ');
Mychart.setaxisnamefontsize (16);
Mychart.setaxisnamecolor (' #999 ');
Mychart.setaxisvaluescolor (' #777 ');
Mychart.setaxiscolor (' #B5B5B5 ');
Mychart.setaxiswidth (1);
Mychart.setbarvaluescolor (' #2F6D99 ');
Mychart.setbaropacity (0.5);
Mychart.setaxispaddingtop (60);
Mychart.setaxispaddingbottom (40);
Mychart.setaxispaddingleft (45);
Mychart.settitlefontsize (11);
Mychart.setbarborderwidth (0);
Mychart.setbarspacingratio (50);
Mychart.setbaropacity (0.9);
Mychart.setflagradius (6);
Mychart.settooltip ([' North America ', ' U.S.A and Canada ']);
Mychart.settooltipposition (' NW ');
Mychart.settooltipoffset (3);
Mychart.setsize (616, 321);
/*mychart.setbackgroundimage (' <?php
echo $this->baseurl (). '/skin/image/zjpchart_bg.jpg '?> ');
Mychart.draw ();
}
</script>
</body>
Model Layer Code: flightinformation.php
Copy Code code as follows:
<?php
Class Application_model_dbtable_flightinformation extends Zend_db_table_abstract
{
protected $_name = ' flightinformation ';
Public Function Getallinfo ($sql) {
$adapter = Zend_registry::get (' db ');
$flightinformation = $adapter->query ($sql);
return $flightinformation;
}
}
The final effect figure is as follows: