SetWeight ignored in version 4.0 / 4.1.1 / 4.21

141 views
Skip to first unread message

Frederic Van Den Houte

unread,
Jul 27, 2018, 5:46:42 AM7/27/18
to JpGraph
Hi,

I needed to upgrade jpgraph from version 3.50b1 to version 4x due to the upgrade to PHP 7

I cannot get the SetWeight for the plot line to work which was working in the older version.

I have also tried all the suggestions on the group but to no avail.

I have also contacted support by filling in a form on the website but have had no answer yet.

Anybody here got a solution to this problem?

Would this issue be resolved by jpgraph should I buy the Pro version or not?

Regards,
Frederic


David Martin

unread,
Jul 27, 2018, 7:16:50 AM7/27/18
to JpGraph
I have not had any issues with SetWeight for plot lines using 4.2 and PHP 7.2.x. For what it's worth here is a snippet that creates a line which is working fine.

// Create the line
$Ya
=new LinePlot($Yall,$Dall);
$Ya
->SetColor('#4A6EC6');
$Ya
->SetWeight(2);
$graph
->Add($Ya);

Frederic Van Den Houte

unread,
Jul 27, 2018, 8:02:55 AM7/27/18
to JpGraph
Hi David,

Hi David,

Below is the code which is working on the older version.

What I tried so far:
 - Adding the SetAntiAliasing to false
 - Comment the SetWeight setting in the template file out
 - Replace SetWeight with SetLineWeight
 - Moved the SetWeight before and after the new lineplot line
 - Moved the SetWeight before and after the Add... line

None of this made any difference to the line thickness on the graph, that's what made me think it might have to do with the PHP upgrade currently on PHP version 7.2.6.

$colorArray = array ("darkgreen", "darkred", "darkblue", "forestgreen");
$k
=-1;
// Create the plots
for ($x=1; $x<=4; $x++) {
 
if (count($_SESSION['ReportArray']['datay'.$x]) > 0) {
  $k
++;
  $Temp
['b'.$x.'plot'] = new LinePlot($_SESSION['ReportArray']['datay'.$x]);
  $graph
->img->SetAntiAliasing(false);
  $graph
->Add($Temp['b'.$x.'plot']);
  $Temp
['b'.$x.'plot']->SetLineWeight(3);
  $Temp
['b'.$x.'plot']->SetLegend ("Tank ".$x);
  $Temp
['b'.$x.'plot']->SetStyle("solid");
  $Temp
['b'.$x.'plot']->SetColor($colorArray[$k]);  
 
}
}

Am I missing something here?

Regards,
Frederic

David Martin

unread,
Jul 27, 2018, 8:23:38 AM7/27/18
to JpGraph
What font are you using and in what size? Are you using a theme for the graph?

Dave

Frederic Van Den Houte

unread,
Jul 27, 2018, 10:31:41 AM7/27/18
to JpGraph
Hi,

Not using a them as far as I know, below is the complete PHP file that generates the graph:

<?
session_start();
include ('../../db.php');
include ('../../functions.php');
ConnectDB();
require_once ('../../jpgraph/src/jpgraph.php');
require_once ('../../jpgraph/src/jpgraph_line.php');
// Create the graph and specify the scale for both Y-axis
$graph = new Graph(665,500,"auto");    
$graph->img->SetMargin(90,10,40,200); // left, right, top, bottom
$graph->SetScale("textlin");
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.5,0.9999,"center","bottom");
// Set the Title Of the Graph
$graph->title->Set($_SESSION['ReportArray']['title']);
$graph->title->SetFont(FF_FONT2,FS_BOLD);
// x-axis - the horizontal one
$graph->xaxis->SetTitle($_SESSION['ReportArray']['xtitle'],'middle');
$graph->xaxis->SetTitleSide(SIDE_BOTTOM);
$graph->xaxis->SetTitlemargin(75);
// Setup X-scale
$graph->xaxis->SetTickLabels($_SESSION['ReportArray']['datax']);
$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL,8);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
// y-axis - the vertical one
$graph->yaxis->SetTitle($_SESSION['ReportArray']['ytitle'],'middle');
$graph->yaxis->SetTitleSide(SIDE_BOTTOM);
$graph->yaxis->SetTitlemargin(75);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$colorArray = array ("darkgreen", "darkred", "darkblue", "forestgreen"); //, "darkslategray", "darkolivegreen", "darkgoldenrod4");
$k=-1;
// Create the bar plots

for ($x=1; $x<=4; $x++) {
 if (count($_SESSION['ReportArray']['datay'.$x]) > 0) {
  $k++;
  $Temp['b'.$x.'plot'] = new LinePlot($_SESSION['ReportArray']['datay'.$x]);
  $graph->img->SetAntiAliasing(false);
  $graph->Add($Temp['b'.$x.'plot']); 
  $Temp['b'.$x.'plot']->SetLineWeight(3);
  $Temp['b'.$x.'plot']->SetLegend ("Tank ".$x);
  $Temp['b'.$x.'plot']->SetStyle("solid");
  $Temp['b'.$x.'plot']->SetColor($colorArray[$k]);  
 }
}
$graph->Stroke();
?>


David Martin

unread,
Jul 27, 2018, 10:39:39 AM7/27/18
to JpGraph
Well I can't easily test take unfortunately but after you define your graph try adding 

$graph->clearTheme();

and see if that helps. Antialiasing only appears to be for images and should not have an impact from what I can see.
Message has been deleted

Frederic Van Den Houte

unread,
Jul 30, 2018, 5:04:57 AM7/30/18
to JpGraph
Hi David,

Thanks, this did the trick! 

I added the cleartheme(); as you suggested and all the graphs are working as before now.

I also had to remove the AntiAliasing line before the line thickness took effect.

Regards,
Frederic

Claude Deslandes

unread,
Aug 2, 2018, 8:37:49 AM8/2/18
to JpGraph
Good day David,

    Thank you for sharing the "clearTheme()" fonction... I did not know it existed.  :-/  Most questions is comming back the a theme taking over... and this probleme cost me many many hours of frustrating programming.

    Thanks.

     Claude :-)
Reply all
Reply to author
Forward
0 new messages