Jump to content

graphing help


ccrevcypsys

Recommended Posts

how would i put database information into this graph?

 

now i need to add ordering information compaired to songs.

Like if you where looking at a album page. I want a graph that shows the user how many times the song has been viewed vs purchased. I just need to know how to make it work for what that info on the songs

 

heres the graph code

<?php
include("includes/ini.inc.php");
include("includes/global.inc.php");
require_once("classes/db.inc.php");
$db = new db();
include_once("includes/functions.inc.php");
$config = fetchDbConfig("config");
include_once("includes/sessionStart.inc.php");
include_once("language/".$config['defaultLang']."/lang.inc.php");
$enableSSl = 1;
include("includes/sslSwitch.inc.php");
include("admin/includes/rte/fckeditor.php");
include_once("includes/session.inc.php");
include("classes/gd.inc.php");
include("includes/currencyVars.inc.php");
require("includes/cmp3split.inc.php"); 

include ("graph/jpgraph.php");
include ("graph/jpgraph_line.php");

$datay1 = 		array(80,7,5,8,3,5,5,4,8,6,5,5,3,2,5,1,2,0);
$datay2 = 	array( 4,5,4,5,6,5,7,4,7,4,4,3,2,4,1,2,2,1);
/*$datay3 = 		array(4,5,7,10,13,15,15,22,26,26,30,34,40,43,47,55,60,62);*/

// Create the graph. These two calls are always required
$graph = new Graph(300,200,"auto");	
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40,30,20,40);

// Create the linear plots for each category
$dplot[] = new LinePLot($datay1);
$dplot[] = new LinePLot($datay2);
/*$dplot[] = new LinePLot($datay3);*/

$dplot[0]->SetFillColor("red");
$dplot[1]->SetFillColor("blue");
/*$dplot[2]->SetFillColor("green");*/

// Create the accumulated graph
$accplot = new AccLinePlot($dplot);

// Add the plot to the graph
$graph->Add($accplot);

$graph->xaxis->SetTextTickInterval(2);
$graph->title->Set("".$product[0]['screenname']."");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");

$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

// Display the graph
$graph->Stroke();
?>

Now the code for the query

$query = "SELECT o.*,i.*,c.screenname,c.customer_id,
		  COUNT(o.productId) AS order_popularity 
		  FROM ".$glob['dbprefix']."inventory i
		  LEFT JOIN ".$glob['dbprefix']."customer c
		  ON c.customer_id=i.customer_id
		  LEFT JOIN ".$glob['dbprefix']."order_inv o
		  ON i.productId = o.productId
		  WHERE i.album_id=".$_GET['album_id']."
		  GROUP BY i.productId";

$albumInfo = $db->select($query);

Link to comment
https://forums.phpfreaks.com/topic/78000-graphing-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.