Line and valure are not the same color

14 views
Skip to first unread message

Emilio Frini

unread,
Jun 21, 2024, 3:57:07 AM6/21/24
to JpGraph
In this line graph the line are not the same color of the value put on top
of the line

I don't why

// Create the graph
$graph = new Graph(700, 400);
$graph->SetScale('textlin');

// Set titles
$graph->title->Set('Host gestiti negli ultimi 7 giorni');
$graph->xaxis->title->Set('Giorni');
$graph->yaxis->title->Set('Quantità');

// Set labels for the x-axis
$graph->xaxis->SetTickLabels($dates);
$graph->xaxis->SetLabelAngle(50);

// Create line plots
$hostElimPlot = new LinePlot($hostElimValues);
$hostElimPlot->SetLegend('Host Eliminati');
$hostElimPlot->SetColor('red');

$hostAggPlot = new LinePlot($hostAggValues);
$hostAggPlot->SetLegend('Host Aggiunti');
$hostAggPlot->SetColor('green');

$hostModPlot = new LinePlot($hostModValues);
$hostModPlot->SetLegend('Host Modificati');
$hostModPlot->SetColor('blue');

// Add the plots to the graph
$graph->Add($hostElimPlot);
$graph->Add($hostAggPlot);
$graph->Add($hostModPlot);

// Show values above each point
$hostElimPlot->value->Show();
$hostElimPlot->value->SetFormat('%d'); // Format values as integers
$hostElimPlot->value->SetColor('red');
$hostElimPlot->value->SetFont(FF_FONT1, FS_BOLD); // Imposta il font e lo stile
$hostElimPlot->value->SetMargin(5); // Imposta il margine rispetto al punto

$hostAggPlot->value->Show();
$hostAggPlot->value->SetFormat('%d'); // Format values as integers
$hostAggPlot->value->SetColor('green');
$hostAggPlot->value->SetFont(FF_FONT1, FS_BOLD); // Imposta il font e lo stile
$hostAggPlot->value->SetMargin(5); // Imposta il margine rispetto al punto

$hostModPlot->value->Show();
$hostModPlot->value->SetFormat('%d'); // Format values as integers
$hostModPlot->value->SetColor('blue');
$hostModPlot->value->SetFont(FF_FONT1, FS_BOLD); // Imposta il font e lo stile
$hostModPlot->value->SetMargin(5); // Imposta il margine rispetto al punto

// Display the legend
$graph->legend->SetFrameWeight(1);

// Debug: Messaggio prima del salvataggio del file
echo "Saving graph to $PERCORSO$FILENAME$ESTENSIONE\n";

// Output the graph
$graph->Stroke("$PERCORSO$FILENAME$ESTENSIONE");

// Debug: Messaggio dopo il salvataggio del file
echo "Graph saved successfully.\n";
?>

Reply all
Reply to author
Forward
0 new messages