Как изменить цвета столбцов моих графиков в High Charts


у меня есть следующий код, в котором он имеет двойную ось и ... но то, что я ищу, это то, что, когда в Столбцах количество больше 100, я меняю цвет, но nose как ввести цвет в полосу, так как в коде highcharts цвет одинаковый для всех столбцов. Мой код выглядит следующим образом:

<!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>

Как бы я сделал условие, чтобы показать мне другой цвет, если полоса больше 100?

Author: Kevincs7, 2018-10-19

1 answers

Используя свойство plotOptions Вы можете установить значение (value), я покажу вам пример, где он показывает красный цвет те значения больше 100... В случае, если они меньше или равны, они отображаются синим цветом:

<!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>

Надеюсь, что это ваша помощь, приветствия.

 1
Author: Blas David O. M., 2018-10-19 23:36:42