Background gradient for plot doesn't work

56 views
Skip to first unread message

Richard Perry

unread,
Dec 8, 2024, 4:46:39 PM12/8/24
to JpGraph
No matter what I try, the gradient just a shows as a 1px vertical line on the right side of the plot.  What am I missing?  

Here's the 411:

    $graph = new Graph(900,300);
    $graph->SetMargin(70,10,70,40);
    $graph->SetBackgroundGradient( 'red', 'yellow', GRAD_VER, BGRAD_PLOT);

    $graph->SetScale('textint');
    $graph->xaxis->title->Set('Date');
     
    $lineplot=new LinePlot($ydata);
    $graph->Add($lineplot);
    $lineplot->SetLegend('Systolic');
 
    $lineplot2=new LinePlot($ydata2);
    $graph->Add($lineplot2);   

    $lineplot->SetLegend('Systolic');
    $lineplot2->SetLegend('Diastolic');
    $graph->legend->Pos(0.05,0.5,'right','center');
   
    $graph->xaxis->SetTickLabels($xdata);
    $graph->Stroke();

TIA

Marc Toury

unread,
Dec 9, 2024, 7:37:56 AM12/9/24
to JpGraph
Hello,

The line : "SetBackgroundGradient" work if you put it just before the last one ($graph->Stroke();):

    $graph = new Graph(900,300);
    $graph->SetMargin(70,10,70,40);
    
    $graph->SetScale('textint');
    $graph->xaxis->title->Set('Date');
     
    $lineplot=new LinePlot($ydata);
    $graph->Add($lineplot);
    $lineplot->SetLegend('Systolic');
 
    $lineplot2=new LinePlot($ydata2);
    $graph->Add($lineplot2);   

    $lineplot->SetLegend('Systolic');
    $lineplot2->SetLegend('Diastolic');
    $graph->legend->Pos(0.05,0.5,'right','center');
   
    $graph->xaxis->SetTickLabels($xdata);
    $graph->SetBackgroundGradient( 'red', 'yellow', GRAD_VER, BGRAD_PLOT);
    $graph->Stroke();

Richard Perry

unread,
Dec 9, 2024, 7:31:38 PM12/9/24
to JpGraph
Hi Marc, unfortunately that didn't work. I'm stymied. I've tried stripping everything, legends, margins, the second line plot etc. to no avail.

Marc Toury

unread,
Dec 10, 2024, 12:52:05 PM12/10/24
to JpGraph
Jpgraph is quite sensitive. It doesn't take much to upset it.
 I also use Google Charts, but it doesn't cover all my needs.
Marc

Reply all
Reply to author
Forward
0 new messages