Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom colors in multiline chart. #104

Open
dicktornfeldt opened this issue Sep 18, 2023 · 1 comment
Open

Custom colors in multiline chart. #104

dicktornfeldt opened this issue Sep 18, 2023 · 1 comment

Comments

@dicktornfeldt
Copy link

dicktornfeldt commented Sep 18, 2023

Can we set specific custom color to the different lines in a multiline chart?

Lets say I have 4 different charts on one page.

In two of the graphs there are three different lines (three different brands, X Y and Z).
In the third graph, there are only two different lines (two different brands, Y and Z).
In the last graph, there are only two different lines (two different brands, X and Z).

I always want brand X, brand Y and brand Z to have their own "brand-color" in all of the charts. Something like:

$chart->addSeriesPoint('Brand X', $date, $value, 'red');
$chart->addSeriesPoint('Brand Y', $date, $value, 'green');
$chart->addSeriesPoint('Brand Z', $date, $value, 'blue');

I know about setColors([...]). But with this I can't connect a color to a certain brand as it's not certain that all different brands will be present in all different charts.

@joalea
Copy link

joalea commented Oct 9, 2023

Hi,
You can set the color of each line in the multiline chart by adding: ->addColor()

$chart->addSeriesPoint('Brand X', $date, $value)->addColor('#b70000');
$chart->addSeriesPoint('Brand Y', $date, $value)->addColor('#239600');
$chart->addSeriesPoint('Brand Z', $date, $value)->addColor('#0619cc');

The documentation tells you to use addColors but this seems to be wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants