2

In Highcharts, is there any way to select an entire column from a stacked column chart? If not, is there at least a way to style the whole column?

1 Answers1

0

I am not sure if there is a better way, but basically I use the stacked column to style columns based on the series.

I have a stacked column with a defined threshold. Lets say 2400. I created two series. One for columns less than the threshold and one for the columns greater than the threshold.

Something like this:

series: [{
name: '< 2400 ',
color: '#768e43',
data: [<?php
           $numItems = count($items);
       $i = 0;
       foreach ($items as $row) :
               if ($row['Total'] > $threshold) {
           $value = 0;
           } else {
           $value = $row['Ending'];
               }

           if ($i+1 != $numItems) {
                   echo $value . ", "; 
           } else {
           echo $value; 
           }
           $i++;
       endforeach;
          ?>]
}, {
name: '< 2400 ',
color: '#768e43',
data: [<?php
           $numItems = count($items);
       $i = 0;
       foreach ($items as $row) :
               if ($row['Total'] < $threshold) {
           $value = 0;
           } else {
           $value = $row['Ending'];
               }

           if ($i+1 != $numItems) {
                   echo $value . ", "; 
           } else {
           echo $value; 
           }
           $i++;
       endforeach;
          ?>]

So in this case, if the column is below the threshold of 2400 then it goes in the first series and is green, and if it is over it goes in the second series and the columns is red. Each column has two series but one is always 0.

Like I said there may be a better way to do it. This is something I threw together for a proof of concept but haven't gone back to scrutinize.