开发者

Set different line format for a graph with more than one serie with pChart

开发者 https://www.devze.com 2022-12-25 17:32 出处:网络
I am actually using the pChart PHP library for generate graphs. I wanna know if it\'s possible to give a different line format for a graph with multiple series.

I am actually using the pChart PHP library for generate graphs.

I wanna know if it's possible to give a different line format for a graph with multiple series.

I need a line with for example 3px of width but other line with 1px of width. Is that pos开发者_开发百科sible?

In the official documentation only appears a function that give format to the lines of all series:

http://pchart.sourceforge.net/documentation.php?topic=pChart#setLineStyle

Thanks a lot.


I found the solution: it's possible to add series after draw each one. It's possible to add and remove series in order to make that trick.


You can do it with the function setSerieWeight():

$oData->addPoints($line1, 'serie1');
$oData->setSerieWeight('serie1', 1);

$oData->addPoints($line2, 'serie2');
$oData->setSerieWeight('serie2', 2);

$oData->addPoints($line3, 'serie3');
$oData->setSerieWeight('serie3', 3);

You can use other functions to change a serie format, like:

setPalette('serie', ['R' => 100, 'G' => 0, 'B' => 255])

to change color of a single serie.

0

精彩评论

暂无评论...
验证码 换一张
取 消