jpgraph: Setting line weight for line graph doesn't work

434 views
Skip to first unread message

SEMPERVIVUM1412

unread,
May 25, 2019, 4:59:22 AM5/25/19
to JpGraph
Hi there,
I don't succeed in increasing the line weight for my line graph. I set both, ant
ialiasing and faststroke to false but it doesn't help. I downloaded the latest version 4.2.6 yesterday.
My code:
<?php // content="text/plain; charset=utf-8"
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';

// die Daten, Temperatur und Feuchte (y-Achse) sowie Uhrzeit (x-Achse)
$temperaturA = [11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13];
$feuchteA = [70, 70, 75, 75, 80, 80, 85, 85, 90, 90, 85, 85];
$uhrzeitA = ["10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00"];

$graph = new Graph(600, 500);
$graph->SetMargin(40, 150, 40, 30);
$graph->SetMarginColor('white');

// Hier wird der Min- und Max-Wert fuer die Feuchte festgelegt
$graph->SetScale('intlin', 0, 100);
$graph->yscale->ticks->Set(10);
$graph->title->Set('Using multiple Y-axis');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 14);
$graph->xgrid->Show();
$graph->ygrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xgrid->SetColor('#E3E3E3');
$graph->xaxis->SetTickLabels($uhrzeitA);
$graph->img->SetAntiAliasing(false);

// Hier wird der Min- und Max-Wert fuer die Temperatur festgelegt
$graph->SetYScale(0, 'lin', -20, 30);

$graph->yaxis->SetColor('blue');

$p1 = new LinePlot($feuchteA);
$graph->Add($p1);
$p1->SetFastStroke(false);
$p1->SetStyle('solid');
$p1->SetLineWeight('10');
$p1->SetColor('blue');
$p1->SetLegend('Luftfeuchtigkeit');

$p2 = new LinePlot($temperaturA);
$graph->AddY(0, $p2);
$p1->SetFastStroke(false);
$p1->SetStyle('solid');
$p1->SetLineWeight('10');
$p2->SetColor('red');
$p2->SetLegend('Temperatur');
$graph->ynscale[0]->ticks->Set(5);
$graph->ynaxis[0]->SetColor('red');

// Output line
$graph->Stroke();


Any advice is appreciated.
Best regards - Ulrich

Cory L

unread,
May 28, 2019, 11:00:55 AM5/28/19
to JpGraph
Try setting the line weight as an integer like this

$p1->SetLineWeight(10);

(without the quotes)
that should work

SEMPERVIVUM1412

unread,
May 29, 2019, 6:49:15 AM5/29/19
to JpGraph
Tried it, but no success, doesn't work either.

Timo Verbeek

unread,
May 29, 2019, 10:17:14 AM5/29/19
to JpGraph
You might have the same issues we have on our production environment.
We run older version of GD cause that one is included in the linux distribution in AWS.
And we think that causes the disabling of antialiasing to not work at all.
We did the same thing as you but the antialiasing is still being applied.
Cause all lines get set to thickness 1 and stripped lines disappear.

Nicolas Montébran

unread,
Jan 7, 2020, 11:50:07 AM1/7/20
to JpGraph
Hello,

I have the same issue,

In PHP 7.3.11 with JPgraph 4.2.10, SetWeight for linepot doesn't work,
In PHP 5.3, it's ok with JPgraph 4.2.10,

do you now where is the issue ?

Thks by avance

Евгений Соколов

unread,
May 7, 2020, 2:57:59 PM5/7/20
to JpGraph
Open /jgraph/src/gd_image.inc.php, find "function Line", comment 

imageline($this->img,$x1,$y1,$x2,$y2,$this->current_color);

uncomment

$this->DrawLine($this->img, $x1, $y1, $x2, $y2, $this->line_weight, $this->current_color);

Thats it

Peter Stanberg

unread,
May 19, 2021, 6:05:46 AM5/19/21
to JpGraph
Yes, it works! Thx, evgenij.
Reply all
Reply to author
Forward
0 new messages