hi i've been struggling while make chart want , i'm getting close.
first have performance data of stock portfolio should on yaxis #1... that's good. want benchmark on yaxis #2... line plot works, scale weird :
notice how starts @ 50 , goes 10, 15, 20, etc... thing scale should between 3400 , 3800 since that's range of data.
here code :
<?php // content="text/plain; charset=utf-8" require($_server['document_root'] . '/wp-blog-header.php'); require_once ('jpgraph.php'); require_once ('jpgraph_line.php'); require_once ('jpgraph_date.php'); require_once ('jpgraph_utils.inc.php'); // dataset $data = get_transient( 'daily_nav' ); $ydata = $data[1]; $xdata = $data[0]; $data2 = get_transient( 'cac40_history' ); $ydata2 = array_reverse($data2[1]); $xdata2 = array_reverse($data2[0]); $dateutils = new datescaleutils(); list($tickpositions, $mintickpositions) = datescaleutils::getticks($xdata); // setup basic graph $width=800; $height=500; $graph = new graph($width, $height); $graph->setscale('datlin'); $graph->setyscale(0,'lin'); $graph->setyscale(1,'lin'); $graph->setmargin(60,20,40,60); $graph->xaxis->setpos('min'); $graph->xaxis->settickpositions($tickpositions,$mintickpositions); // setup titles $graph->title->setfont(ff_georgia,fs_normal,16); $graph->title->set('performance vs. cac40'); $graph->subtitle->setfont(ff_arial,fs_italic,10); $graph->subtitle->set('graphique journalier depuis la création en juin 2012'); // setup labels correctly format on x-axis $graph->xaxis->setfont(ff_arial,fs_normal,8); $graph->xaxis->setlabelangle(30); // second paramter set 'true' make library interpret // format string date format. use month + year format m-d-y $graph->xaxis->setlabelformatstring('m-y',true); // , add line. use 2 plots in order // more distinct border on graph $lp2 = new lineplot($ydata,$xdata); $lp2->setcolor('#71a7da'); $graph->add($lp2); $graph->xgrid->show(); $graph->addy(0,$lp2); // second chart $lp3 = new lineplot($ydata2, $xdata2); $lp3->setcolor('blue'); //$graph->add($lp3); //$graph->xgrid->show(); $graph->addy(1,$lp3); // , send client $graph->stroke(); ?>
would great if can help, can't figure 1 out. thanks
i quite newbie had same issue myself minute ago. missing zeros on right? try changing margin settings?
$graph->setmargin(60,50,40,60);
Comments
Post a Comment