This topic is locked

AnyChart : how do we set colors for stacked bar charts?

7/18/2023 1:36:58 PM
PHPRunner General questions
P
pmuckle authorDevClub member

Hi all,
How do we set colors for stacked bar charts?
I assume the code has to go into Javascript chart modify, but cannot find what code to put there.
Thanks for any help.
Pete

fhumanes 7/19/2023

Hello,
To know what type of programming you have to do to configure the Anychart graphics you have to access the manufacturer's website:
https://www.anychart.com/products/anychart/gallery/
You have to access the example of the type of graph that you need and there they explain in detail how it is done.
Also, in the doubt, Anychart's technical service helps you and give explanations to the topics you ask.
Greetings,
ernando

P
pmuckle authorDevClub member 7/19/2023

Thanks very much for your answer. I need to learn how to use them properly.
If I use one of the stacked bar charts built into Phprunner, do you know how the colors can be changed this way?
Two of the default blue colors they use are dificult to see when one is small.
Thanks again
Pete

fhumanes 7/20/2023

Hello,
I explain with an example the method I described.
This is the example link: https://www.anychart.com/products/anychart/gallery/Column_Charts/Beijing_2022_Winter_Olympics_Medal_Tally.php
In the example you have this coding:
` // create the first series with the mapped data
series = chart.column(firstSeriesData);
setupSeries(series, 'Gold', '#f9cd0e', '#dfb80c');

// create the second series with the mapped data
series = chart.column(secondSeriesData);
setupSeries(series, 'Silver', '#afb7c0', '#9aa0a6');

// create the third series with the mapped data
series = chart.column(thirdSeriesData);
setupSeries(series, 'Bronze', '#cc8469', '#ae7058');`At this point it is defining the colors for the series.
The problem is that part of the definition that Anychart requires is doing phprunner and then it is more complex to understand how e should include the parameters or configuration that the code generated by the product is lacking.
Hence I do not use the phprunner component and define the graphics through a plugin or snippet. This method requires programming.
Greetings,
fernando

P
pmuckle authorDevClub member 7/20/2023

Thanks Fernando,
I am going to have to learn how to do it with a plugin or snippet.
Is there a step-by-step guide to adding the plugin, getting data, where to put the code etc?
Thanks again for your help

Admin 7/21/2023

I understand that Fernando wants to pitch his wonderful blog every time but I don't see how using a code snippet can help you here as you already have chart.
You just need to to find the corresponding code in AnyChart's manual and use it in ChartModify event. With Fernando's approach you will have to do the same thing plus you would need to display the chart manually.

P
pmuckle authorDevClub member 10/3/2023

Just to update this; I wanted to change the default colors to a traffic light system, but have since realised that the reason AnyChart uses two shades of blue along with orange is because it is color-blind friendly, so will keep the defaults.