0

一直在寻找和尝试我发现和能想到的每一件事。我正在尝试为 Y 轴(时间毫秒)的图表设置最小值,为 x 轴上的百分比设置最大值 100,但无法弄清楚将

{min: 0} // 时间

{max: 100} // for the percent x-axis

有些地方它可以工作,但会带走一些图表数据或菜单

完整代码:

$(function () {
    $('#container').highcharts({
        chart: {
            zoomType: 'xy'
        },
        title: {
            text: 'Network Ping Results'
        },
        subtitle: {
            text: ''
        },
        xAxis: [{
            //echo php dates for data
            categories: [<?php echo $categories;?>]
        }],
        // Primary yAxis Time ms
        yAxis: [{ 
            labels: {
                format: '{value} ms',
                style: {
                    color: '#89A54E'
                }

            },
            title: {
                text: 'Average Time',
                style: {
                    color: '#89A54E'
                }
            }
        },
        // Secondary yAxis 
        { 
            title: {
                text: 'Packet Loss',
                style: {
                    color: '#4572A7'
                }
            },
            labels: {
                format: '{value} %',
                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: 'Packet Loss',
            color: '#4572A7',
            type: 'column',
            yAxis: 1,
            //Data echo for packet loss:
            data: [<?php echo $packet_loss;?>],
            tooltip: {
                valueSuffix: '%'
            }

        }, {
            name: 'Average Time',
            color: '#89A54E',
            type: 'spline',
            //Data echo for time:
            data: [<?php echo $avg_times;?>],
            tooltip: {
                valueSuffix: ' ms'
            }
        }]
    });
});
4

0 回答 0