Support_38
asked on
Chart in PHP
Good Morning.
I need to create a PHP page where the result of a select is brought in the form of html chart.
The select is simple, it will be two columns:
Column 1 - Analyst
Column 2 - Number
The Select returns the number of incidents assigned to each analyst.
I would like the help of experts for the development of this code.
Attached an example that I generate in excel
The select will run on SQL Server.
Thank you.
Capturar.PNG
I need to create a PHP page where the result of a select is brought in the form of html chart.
The select is simple, it will be two columns:
Column 1 - Analyst
Column 2 - Number
The Select returns the number of incidents assigned to each analyst.
I would like the help of experts for the development of this code.
Attached an example that I generate in excel
The select will run on SQL Server.
Thank you.
Capturar.PNG
You might want to consider JpGraph.
If you need some hands-on help, you might want to consider using E-E Gigs, where you can pay an expert to help you build the app. Here's how to do the basics, using simulated data that might be found in the query results set.
http://iconoun.com/demo/temp_alex.php
If you need some hands-on help, you might want to consider using E-E Gigs, where you can pay an expert to help you build the app. Here's how to do the basics, using simulated data that might be found in the query results set.
http://iconoun.com/demo/temp_alex.php
<?php // demo/temp_alex.php
/**
* http://www.experts-exchange.com/questions/28932886/Chart-in-PHP.html
*
* http://jpgraph.net/
*/
error_reporting(E_ALL);
ob_start();
// A SIMULATED RESULTS SET FROM A SQL QUERY
$results_set = array
( [ 'user' => 'user1', 'qtde' => 60 ]
, [ 'user' => 'user2', 'qtde' => 33 ]
, [ 'user' => 'user3', 'qtde' => 26 ]
, [ 'user' => 'user4', 'qtde' => 23 ]
, [ 'user' => 'user5', 'qtde' => 21 ]
, [ 'user' => 'user6', 'qtde' => 15 ]
, [ 'user' => 'user7', 'qtde' => 11 ]
, [ 'user' => 'user14', 'qtde' => 3 ]
, [ 'user' => 'user27', 'qtde' => 1 ]
)
;
// COLLECT THE DATA SET FROM THE SQL RESULTS SET
$datas = $users = [];
foreach ($results_set as $row)
{
$users[] = $row['user'];
$datas[] = $row['qtde'];
}
// THE GRAPH TOOL
require_once ('jpgraph-3.5.0b1/src/jpgraph.php');
require_once ('jpgraph-3.5.0b1/src/jpgraph_bar.php');
// THE GRAPH SIZE AND STRUCTURE
$graph = new Graph(400,400);
$graph->SetScale("textlin");
$graph->SetTheme(new UniversalTheme);
$graph->yaxis->SetTickPositions(array(0,20,40,60,80,100), array(10,30,50,70,90));
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels($users);
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
// ADD THE DATA TO THE GRAPH
$barplot = new BarPlot($datas);
$graph->Add($barplot);
$barplot->SetColor("white");
$barplot->SetFillColor("red");
$graph->title->Set("Example Bar Plot");
// DISPLAY THE GRAPH
$graph->Stroke();
ASKER
Good Morning,
Has helped a lot, I'll do here, then I say if it worked.
Thank you.
Has helped a lot, I'll do here, then I say if it worked.
Thank you.
greetings Alex, , The way that a PHP and javascript CHART is made depends on the Chart you need to build. I looked at the image in your Capturar.PNG that you have here, and at the very Top of that Image , you have columns labeled A to M , can you tell us what code you used to make that chart, and what the columns labeled A to M, are used for?
Also if you tell us about what the things to need to chart, like "Prices", "Car Sales", "Voting Results" or "Sports Scores", then we can tell you what we might use to chart that type of value in a vertical Chart.
The more you can say about your chart, the more we can tell you about the ways to do it.
Also if you tell us about what the things to need to chart, like "Prices", "Car Sales", "Voting Results" or "Sports Scores", then we can tell you what we might use to chart that type of value in a vertical Chart.
The more you can say about your chart, the more we can tell you about the ways to do it.
ASKER
Hello,
It is a portal where you will be told the number of alarms assigned to each analyst.
The query is quite simple.
The select is attached.
Thank you.
select.txt
It is a portal where you will be told the number of alarms assigned to each analyst.
The query is quite simple.
The select is attached.
Thank you.
select.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
It helped.
It helped.
ASKER
Thank you for your help.
http://www.chartjs.org/
http://www.highcharts.com/
https://d3js.org/
http://morrisjs.github.io/morris.js/
.... and many more
You will see for both samples, you just need to output json data
http://www.chartjs.org/docs/#bar-chart-introduction
Open in new window