-
Notifications
You must be signed in to change notification settings - Fork 1
/
chart-data.php
executable file
·84 lines (67 loc) · 2.1 KB
/
chart-data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
$catAllChildren = $oCat->getAllChildren($catToDisplay);
/*
$catFirstChildren = $objectCat->getFirstChildren($catToDisplay);
foreach ($catFirstChildren as $value) {
$tabCat["$value"] = $objectCat->getAllChildren($value);
}
// initialisation du tabeau pour le total de chaque année
foreach ($catFirstChildren as $value) {
$name = $objectCat->getName($value);
$total["$name"] = 0; // total pour l'année
}
// Boucle sur les mois
for($i=1;$i<=12;$i++) {
// Initialisation
$date_debut = mktime(0,0,0,"$i",'01','2008');
$day = getDaysInMonth($i,2007);
$date_fin = mktime(0,0,0,"$i","$day",'2008');
foreach ($catFirstChildren as $value) {
$name = $objectCat->getName($value);
$tab["$name"][$i] = 0;
}
$query = "SELECT * FROM transactions WHERE
date >= $date_debut AND
date <= $date_fin";
$result = $mysql->query($query);
while ($line = mysql_fetch_assoc($result)) {
extract($line);
if($valeur > 0) {
continue;
}
$valeur *= (-1);
foreach ($catFirstChildren as $value) {
if($categorie == $value || ($tabCat["$value"] != null && in_array($categorie,$tabCat["$value"]))) {
$name = $objectCat->getName($value);
$tab["$name"][$i] += $valeur;
$total["$name"] += $valeur;
}
}
}
}
/******************************************************************************/
// generate some random data:
die();
srand((double)microtime()*1000000);
$max = 50;
$data = array();
for( $i=0; $i<12; $i++ )
{
$data[] = rand(0,$max);
}
// use the chart class to build the chart:
include_once( 'ofc-library/open-flash-chart.php' );
$g = new graph();
// Spoon sales, March 2007
$g->title( 'Chaussures de Jie '. date("Y"), '{font-size: 26px;}' );
$g->set_data( $data );
// label each point with its value
$g->set_x_labels( array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec' ) );
// set the Y max
$g->set_y_max( 60 );
// label every 20 (0,20,40,60)
$g->y_label_steps( 6 );
// display the data
echo $g->render();
?>