How to change the colors of the columns of my graphics in High Charts

1

I have the following code, which is double Y axis ... but what I'm looking for is that when the columns are greater than 100, I change color, but I do not know how to introduce a color to a bar , since in the code of highcharts the color is the same for all the columns. My code is as follows:

<!DOCTYPE HTML>
  <html>
   <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Highcharts Example</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
     <script src="ss/code/highcharts.js"></script>

</head>
<body>

      <script src="ss/code/modules/drilldown.js"></script>
    <script type="text/javascript">
 $(function () {
    $('#container').highcharts({
        chart: {
            zoomType: 'xy'
        },
        title: {
            text: 'Informacion sobre Temperatura y Volumen'
        },/*
        subtitle: {
            text: 'Source: WorldClimate.com'
        },*/
        xAxis: [{
            categories: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun',
                'Jul', 'Ago', 'Set', 'Oct', 'Nov', 'Dic']
        }],
        yAxis: [{ // Primary yAxis
            labels: {
                format: '{value}°C',
                style: {
                    color: '#89A54E'
                }
            },
            title: {
                text: 'Temperatura',
                style: {
                    color: '#89A54E'
                }
            }
        }, { // Secondary yAxis
            title: {
                text: 'Volumen',
                style: {
                    color: '#4572A7'
                }
            },
            labels: {
                format: '{value} mm',
                style: {
                    color: '#4572A7'
                }
            },
            opposite: true
        }],
        tooltip: {
            shared: true
        },
        legend: {
            layout: 'vertical',
            align: 'left',
            x: 120,
            verticalAlign: 'top',
            y: 100,
            floating: true,
            backgroundColor: '#FFFFFF'
        },
        series: [{
            name: 'Volumen',
            color: '#4572A7',
            type: 'column',
            yAxis: 1,
            data: [109.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
            tooltip: {
                valueSuffix: ' mm'
            }

        }, {
            name: 'Temperatura',
            color: '#89A54E',
            type: 'spline',
            data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
            tooltip: {
                valueSuffix: '°C'
            }
        }]
    });
});


    </script>

  <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

    </body>
  </html>

How would the condition make me show another color if the bar is greater than 100?

    
asked by Kevincs7 19.10.2018 в 19:53
source

1 answer

1

Using the property plotOptions you can set a value ( value ), I show you the example where red is shown those values greater than 100 ... If they are less than or equal they are shown in color blue:

<!DOCTYPE HTML>
  <html>
   <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Highcharts Example</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
     <script src="ss/code/highcharts.js"></script>
     <script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

</head>
<body>

      <script src="ss/code/modules/drilldown.js"></script>
    <script type="text/javascript">
 $(function () {
    $('#container').highcharts({
        chart: {
            zoomType: 'xy'
        },
        title: {
            text: 'Informacion sobre Temperatura y Volumen'
        },/*
        subtitle: {
            text: 'Source: WorldClimate.com'
        },*/
        xAxis: [{
            categories: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun',
                'Jul', 'Ago', 'Set', 'Oct', 'Nov', 'Dic']
        }],
        yAxis: [{ // Primary yAxis
            labels: {
                format: '{value}°C',
                style: {
                    color: '#89A54E'
                }
            },
            title: {
                text: 'Temperatura',
                style: {
                    color: '#89A54E'
                }
            }
        }, { // Secondary yAxis
            title: {
                text: 'Volumen',
                style: {
                    color: '#4572A7'
                }
            },
            labels: {
                format: '{value} mm',
                style: {
                    color: '#4572A7'
                }
            },
            opposite: true
        }],
        tooltip: {
            shared: true
        },
        legend: {
            layout: 'vertical',
            align: 'left',
            x: 120,
            verticalAlign: 'top',
            y: 100,
            floating: true,
            backgroundColor: '#FFFFFF'
        },
        plotOptions: {
        	column: {
            	zones: [{
                	value: 100, // Valores mayores que 100 ...
                    color: 'blue' // Color establecido para los que no cumplan
                },{
                	color: 'red' //Valores mayor o igual a 100
                }]
            }
        },
        series: [{
            name: 'Volumen',
            type: 'column',
            yAxis: 1,
            data: [109.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
            tooltip: {
                valueSuffix: ' mm'
            }

        }, {
            name: 'Temperatura',
            color: '#89A54E',
            type: 'spline',
            data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
            tooltip: {
                valueSuffix: '°C'
            }
        }]
    });
});


    </script>

  <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

    </body>
  </html>

I hope it's your help, regards.

    
answered by 20.10.2018 / 01:36
source