Different colors for different titles (Radar and Bar Graph)

83 views
Skip to first unread message

Tobias Reichert

unread,
Jul 25, 2020, 6:46:31 AM7/25/20
to JpGraph
Hello everyone.
I have 2 graphs (one radar and one bar graph) which have 11 titles each.
I want to color some axis titles in a different color than the others.
Is there any possibility to pass a color to each title? Using $graph->axis->title->SetColor($color); I am corrently only able to pass a string for one color. Arrays are not accepted.
Thanks in advance, Tobi

David Martin

unread,
Jul 25, 2020, 8:11:49 AM7/25/20
to JpGraph
Try setting the font and color for the title then set the title and repeat that for each title that you have.
Message has been deleted

event.techn...@googlemail.com

unread,
Jul 25, 2020, 6:14:51 PM7/25/20
to JpGraph
Thanks for your answer, but I do not get it.
I can only set the titles with an array, not one after each other. Am I wrong?

my code:
    $graph = new Graph\RadarGraph(1140, 850);
    $graph->SetCenter(0.52, 0.5);
    $graph->SetScale('lin', 0, 3);
    $graph->SetFrame(false);

    $graph->legend->SetPos(0.77,0.02,'left','top');
    $graph->legend->SetFont(FF_ARIAL,FS_NORMAL,16);

    $titles=['Lorem', 'Ipsum', 'Dolor', 'Sit', 'Amet'];
    $graph->SetTitles($titles);

eg. I would like to color Lorem red, Ipsum blue, ....

event.techn...@googlemail.com

unread,
Jul 26, 2020, 3:54:58 AM7/26/20
to JpGraph
I got it working for the bar graph by an array of colors for each title and setting it by:
$graph->xaxis->SetColor('black',$colors_array);

But doing this for the Radar Graph does not work.

event.techn...@googlemail.com

unread,
Jul 26, 2020, 4:45:54 AM7/26/20
to JpGraph
When I do the same on the radar:
$graph->axis->SetColor('black', $colors_array);

I get the following error:
imagecolorresolvealpha() expects parameter 2 to be int, string given
Reply all
Reply to author
Forward
0 new messages