Jump to content
  • 0

Stacked Area Chart Colors


Benades
 Share

Question

Hi, I managed to change a Stacked Column Chart colors by adding a header and setting a style to it:

<style>
rect.highcharts-point.highcharts-color-0{
fill: #006B3C;
}
rect.highcharts-point.highcharts-color-1{
fill: #682861;
}
rect.highcharts-point.highcharts-color-2{
fill: #CD9B06;
}
</style>

screenshot-c1dcn529.caspio.com-2021_07_07-15_17_04.png.a1feaeda0e463e2035d031ad0db48e75.png

Now I need to do the same with a Stacked Area Chart but cannot find the same heading to apply the color to (highcharts-color-0):

Capture12.thumb.PNG.5a04f66e7d9995ea9b37cbecfaa9f405.PNG

screenshot-c1dcn529.caspio.com-2021_07_07-15_15_15.png.ea73093c44b89e4584026cc4395c5dd7.png

When I use the same logic to style, it changes colors for all to the same color because there are no differentiating name:

<style>
path.highcharts-area{
fill: #CD9B06;
}
</style>

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1

Try JS instead,

 

<script type = "text/javascript" >

    var timer = setInterval(function() {
        //Find if chart exists using rect element every x milliseconds
        if (document.getElementsByTagName('rect') != null) {
            //Update Chart
            UpdateChart();
        }
    }, 500);


function UpdateChart() {
    try {

        Highcharts.charts[0].update({
            
//CHANGES HERE
          
          
  series: [

{color:'red'},
{color:'blue'},
{color:'yellow'}


]

//CHANGES END HERE

            
});
        //Stop checking
        clearInterval(timer);

    } catch (err) {
        //log errors
    }

}; 
</script>

basically makes the first one red, then blue, then yellow

 

No script:

image.thumb.png.2b3066ca6fde27e1ca351e18903b5a5d.png

 

With the script
image.thumb.png.b59afafa682347bf15dede281aacd6fb.png

Link to comment
Share on other sites

  • 0
7 hours ago, Benades said:

@TellMeWhy it works most of the time but there are instances where it does not change and I have to refresh the page multiple time for it to take effect. Any way to get around that?

Probably the rendering of charts, you can increase delay here, 500 means 500millisecond delay
image.png.e60a69b259fa59546a7a61f63ae2daa4.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...