waynew Posted July 11, 2008 Share Posted July 11, 2008 Hey guys I have a problem. Okay, I'm just going paste the code first: Explanation of code in code... :-\ Problem stated below code. Thanks. <?php include('stats.php'); //This graph shows profit, cost and end price. if(isset($_GET['startdate']) && isset($_GET['enddate'])){ //check to see if user is wanting to limit dates $dates_selected = true; //this means that the user has chosen to select a time period. $start_date = $_GET['startdate']; //begin date. $end_date = $_GET['enddate']; //end date. $end_date = $end_date - $start_date; //Start date and end dates are not really dates. They are index keys. //If there are three months and the user wants to see only the last two months //the start date will be 1 and the end date will be 2. indexes begin at 0 //Split up together in order to maintain sync of timeline and sum. $x_months = array_slice($x_months,$start_date,$end_date+1); //$x_months is an array of ten months $monthly_profit = array_slice($monthly_profit,$start_date,$end_date+1); //$monthly_profit syncs in key with $x_months } include ( 'src/jpgraph.php'); include ('src/jpgraph_line.php' ); $graph = new Graph(900,400,"auto"); $graph->SetScale( "textlin"); $lineplot1 = new LinePlot($monthly_profit); $lineplot1 ->SetColor("blue"); $graph->xaxis->SetTickLabels($x_months); $lineplot1->SetLegend ("Profit"); $graph ->legend->Pos( 0.05,0.5,"right" ,"center"); $graph->img-> SetMargin(80,80 ,80,80); $graph->xaxis-> title->Set("Months" ); $graph->tabtitle->Set('Profit'); $graph->title->Set ('Roadway Sales'); $graph->Add($lineplot1); $graph->Stroke(); ?> The problem is that when I try to resize the timescale on the graph, the actual figure for each month is off. For instance, in March 08, no profit was recorded, yet when I resize the graph, Dec 07 is shown to have no profit when that's not the case. Link to comment https://forums.phpfreaks.com/topic/114274-small-graph-problem/ Share on other sites More sharing options...
waynew Posted July 11, 2008 Author Share Posted July 11, 2008 The problem isn't with the graph. It's with the arrays. Link to comment https://forums.phpfreaks.com/topic/114274-small-graph-problem/#findComment-587616 Share on other sites More sharing options...
waynew Posted July 11, 2008 Author Share Posted July 11, 2008 Please somebody help. Deadline is in an hour and I'm stumped. Link to comment https://forums.phpfreaks.com/topic/114274-small-graph-problem/#findComment-587648 Share on other sites More sharing options...
waynew Posted July 11, 2008 Author Share Posted July 11, 2008 I will explain a little clearer. $monthly_profit at the moment contains 10 values. $x_months contains 10 values. $monthly_profit[1] is the total profit for $x_months[1] and so on etc $x_months contains months, and $monthly_profit contains the total profit for those months. I've checked with sizeof and they are exact same size so they are on sync. Link to comment https://forums.phpfreaks.com/topic/114274-small-graph-problem/#findComment-587656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.