Php highcharts
Posté : 22 janv. 2015, 00:43
Salut a tous
Je suis tres content de m'inscrire sur ce forum
Je suis en train de realiser un graphique en utilisant php et highchart qui doit avoir ces donnees qui se chargent en fonction d'un page de connection. J'ai un table user, chaque user a access a un office et un user a acces a tous les offices. si le user ayant access a tous les offices se connecte le graphique doit afficher 3 colonnes, si le user a access u un office le graphique doit afficher une colonne du user correspondant. voici mes demarches
1- page connection
[javascript]<script type="text/javascript">
//piechart
$(document).ready(function() {
Highcharts.getOptions().colors[0] = {
linearGradient: { x1: 0, y1: 0, x2: 1, y2: 0 },
stops: [ [ 0, '#4572A7' ],
[ 0.7, '#CCFFFF' ],
[ 1, '#4572A7' ] ]
};
var options = {
chart: {
renderTo: 'container5',
backgroundColor: 'white',
width: 450,
height: 360,
options3d: {
enabled: true,
alpha: 5,
beta: 5,
viewDistance: 5,
depth: 10
},
backgroundColor: '#F5F5F5'
},
title: {
text: 'Productions Month To Date',
style: {
color: 'blue',
fontWeight: 'bold',
fontSize: '16px',
fontFamily: 'Arial, Helvetica, sans-serif',
fontStyle: 'normal'
}
},
xAxis: {categories: []},
yAxis: {
title: {
text: ''
}
},
credits: {
enabled: false
},
tooltip: {
enabled: true,
formatter: function() {
return '<b>'+ this.series.name +
'</span>: <span style="color:black;">' + '$' + '' + '' + Highcharts.numberFormat(this.y, 2) + '</span>';
}
},
plotOptions: {
column: {
colorByPoint: true,
dataLabels: {
enabled: false,
}
}
},
series: [{
type: 'column',
name: 'Productions',
data: []
}]
}
$.getJSON("data201.php", function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options);
});
});
</script>[/javascript]
- je voudrais afficher la production mensuelle pour un user qui a acces a un office et les productions pour le use qui a acces aux 3 offices
- Je compte beaucoup sur vous en attendant votre interaction
merci beaucoup
Je suis tres content de m'inscrire sur ce forum
Je suis en train de realiser un graphique en utilisant php et highchart qui doit avoir ces donnees qui se chargent en fonction d'un page de connection. J'ai un table user, chaque user a access a un office et un user a acces a tous les offices. si le user ayant access a tous les offices se connecte le graphique doit afficher 3 colonnes, si le user a access u un office le graphique doit afficher une colonne du user correspondant. voici mes demarches
1- page connection
<form method="post" action="traitement.php">
<fieldset>
<table border="2" cellspacing="2" cellpadding="2" style="margin:auto;margin-top:30px;">
<tr align="center">
<td><input type="text" name="username" placeholder="username" size="30"></td>
</tr>
2- page qui traitement
<?php
$conn=($GLOBALS["___mysqli_ston"] = mysqli_connect('', '', ''));
((bool)mysqli_query($conn, "USE OpenDent"));
if(strlen($_POST['username'])>0 && strlen($_POST['password'])>0)
{
$u=$_POST['username'];
$p=$_POST['password'];
echo"Utilisateur".$u;
$sql="select * from User";
$req=mysqli_query($GLOBALS["___mysqli_ston"], $sql);
while($d=mysqli_fetch_array($req))
{
if($d['Type']=='Of' && $d['UserName']==$u && $d['Password']==$p)
{
session_start();
$_SESSION['username']=$u;
$_SESSION['password']=$p;
header('Location:data.php');
((mysqli_free_result($req) || (is_object($req) && (get_class($req) == "mysqli_result"))) ? true : false);
}
else
{
//java script echo '<body onLoad="alert(\'Utilisateur non reconnu...\')">';
header('location:login_view1.php');
}
}
}
else
{
//java script echo '<body onLoad="alert(\'Utilisateur non reconnu...\')">';
header('location:login_view1.php');
}
((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
?>
3- la page data.php qui doit afficher les donnees en format json
<?php
$con = ($GLOBALS["___mysqli_ston"] = mysqli_connect("", "mrprophete", "Bposs2014"));
if (!$con) {
die('Could not connect: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
}
((bool)mysqli_query( $con, "USE OpenDent"));
session_start();
$u = $_SESSION['username'];
$p = $_SESSION['password'];
$query = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT date_format(TranDate,'%b') as TranDate, Sum(p.production) as Production, o.OfficeName
FROM OpenDent.production p
inner join
OpenDent.User u
On p.oid = u.oid
inner join
OpenDent.Office o
On
o.OID= p.oid
Where u.UserName='".$u."' and u.Password='".$p."' and
YEAR(Trandate) = '2014'
group by month(TranDate), o.OfficeName
having sum(p.production)>0");
$category = array();
$category['name'] = 'TranDate';
$series1 = array();
$series1['name'] = 'Production';
$series2 = array();
$series2['name'] = 'OfficeName';
while($r = mysqli_fetch_array($query)) {
$category['data'][] = $r['TranDate'];
$series1['data'][] = $r['Production'];
$series2['data'][] = $r['OfficeName'];
}
$result = array();
array_push($result,$category);
array_push($result,$series1);
array_push($result,$series2);
print json_encode($result, JSON_NUMERIC_CHECK);
((is_null($___mysqli_res = mysqli_close($con))) ? false : $___mysqli_res);
?>
4- la page du graphique[javascript]<script type="text/javascript">
//piechart
$(document).ready(function() {
Highcharts.getOptions().colors[0] = {
linearGradient: { x1: 0, y1: 0, x2: 1, y2: 0 },
stops: [ [ 0, '#4572A7' ],
[ 0.7, '#CCFFFF' ],
[ 1, '#4572A7' ] ]
};
var options = {
chart: {
renderTo: 'container5',
backgroundColor: 'white',
width: 450,
height: 360,
options3d: {
enabled: true,
alpha: 5,
beta: 5,
viewDistance: 5,
depth: 10
},
backgroundColor: '#F5F5F5'
},
title: {
text: 'Productions Month To Date',
style: {
color: 'blue',
fontWeight: 'bold',
fontSize: '16px',
fontFamily: 'Arial, Helvetica, sans-serif',
fontStyle: 'normal'
}
},
xAxis: {categories: []},
yAxis: {
title: {
text: ''
}
},
credits: {
enabled: false
},
tooltip: {
enabled: true,
formatter: function() {
return '<b>'+ this.series.name +
'</span>: <span style="color:black;">' + '$' + '' + '' + Highcharts.numberFormat(this.y, 2) + '</span>';
}
},
plotOptions: {
column: {
colorByPoint: true,
dataLabels: {
enabled: false,
}
}
},
series: [{
type: 'column',
name: 'Productions',
data: []
}]
}
$.getJSON("data201.php", function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options);
});
});
</script>[/javascript]
- je voudrais afficher la production mensuelle pour un user qui a acces a un office et les productions pour le use qui a acces aux 3 offices
- Je compte beaucoup sur vous en attendant votre interaction
merci beaucoup