Bug with line and values color

29 views
Skip to first unread message

Emilio Frini

unread,
Jun 26, 2024, 8:05:46 AM6/26/24
to JpGraph
Hi expert
I did this PHP simple example in order to reproduce problem
The program works well , but if I like to change the color of the
first line from blue to red and the second line red di blue the lines
didn't change color

<?php
// Includi la libreria JPGraph
require_once ('/home/emilio/governance/jpgraph/src/jpgraph.php');
require_once ('/home/emilio/governance/jpgraph/src/jpgraph_bar.php');
require_once ('/home/emilio/governance/jpgraph/src/jpgraph_line.php');

// Dati per il grafico
$dataY1 = array(20, 9, 8, 15, 19, 24, 18);
$dataY2 = array(25, 17, 22, 18, 16, 25, 20);
$dataY3 = array(18, 23, 20, 22, 17, 26, 19);
$dataX = array("Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug");

// Creazione del grafico
$graph = new Graph(800,600);
$graph->SetScale('textlin');

// Titoli e intestazioni
$graph->title->Set('Grafico a Linee con Tre Serie');
$graph->xaxis->title->Set('Mese');
$graph->yaxis->title->Set('Valore');

// Imposta le etichette per l'asse X
$graph->xaxis->SetTickLabels($dataX);

// Creazione della prima linea
$lineplot1 = new LinePlot($dataY1);
$lineplot1->SetColor("blue");
$lineplot1->SetLegend('Serie 1');

// Creazione della seconda linea
$lineplot2 = new LinePlot($dataY2);
$lineplot2->SetColor("red");
$lineplot2->SetLegend('Serie 2');

// Creazione della terza linea
$lineplot3 = new LinePlot($dataY3);
$lineplot3->SetColor("green");
$lineplot3->SetLegend('Serie 3');
// Aggiunta delle linee al grafico
$graph->Add($lineplot1);
$graph->Add($lineplot2);
$graph->Add($lineplot3);

// Imposta la posizione della legenda
$graph->legend->SetPos(0.5,0.95,'center','bottom');
$graph->legend->SetFrameWeight(1);

// Aggiunta delle etichette dei valori per la prima linea
$lineplot1->value->Show();
$lineplot1->value->SetFormat('%d');
$lineplot1->value->SetColor("blue");

// Aggiunta delle etichette dei valori per la seconda linea
$lineplot2->value->Show();
$lineplot2->value->SetFormat('%d');
$lineplot2->value->SetColor("red");

// Aggiunta delle etichette dei valori per la terza linea
$lineplot3->value->Show();
$lineplot3->value->SetFormat('%d');
$lineplot3->value->SetColor("green");

// Visualizzazione del grafico
$graph->Stroke();
?>


Reply all
Reply to author
Forward
0 new messages