高图对数X轴失败,没有零值,也没有零或最小阈值

时间:2016-08-16 16:18:47

标签: javascript highcharts

我遇到了对数X轴的问题。 阈值大于0,x的最小值为1且所有X值都大于0.并且仍然给出了相同的错误Can't plot zero or subzero values on a logarithmic axis

这是一个问题(和代码)的小提琴 http://jsfiddle.net/y31gwofL/3/

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'line'
        },
        xAxis: {
            type: "logarithmic",
            min: 1
        },
                yAxis: {
            type: "linear"
        },
        series: [
        {
            type: "line",
            data: [
                {
                    "name": 1,
                    "y": 9.991242714224013
                },
                {
                    "name": 2,
                    "y": 9.991242714224013
                },
                {
                    "name": 3,
                    "y": 9.991242714224011
                },
                {
                    "name": 4,
                    "y": 9.991242714224015
                },
                {
                    "name": 5,
                    "y": 9.991242714224015
                },
                {
                    "name": 6,
                    "y": 9.991242714224008
                },
                {
                    "name": 7,
                    "y": 9.991242714224015
                },
                {
                    "name": 8,
                    "y": 9.991242714224015
                }
            ]
        }
    ]
    });
});

1 个答案:

答案 0 :(得分:2)

这种情况正在发生,因为您告诉它记录“1”或“2”或“3”等日志。您将xAxis定义为一系列类别而不是整数。制作您的系列数据:

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'line'
        },
        xAxis: {
            type: "logarithmic",
            min: 1
        },
                yAxis: {
            type: "linear"
        },
        series: [
        {
            type: "line",
            data: [
                {
                    "x": 1,
                    "y": 9.991242714224013
                },
                {
                    "x": 2,
                    "y": 9.991242714224013
                },
                {
                    "x": 3,
                    "y": 9.991242714224011
                },
                {
                    "x": 4,
                    "y": 9.991242714224015
                },
                {
                    "x": 5,
                    "y": 9.991242714224015
                },
                {
                    "x": 6,
                    "y": 9.991242714224008
                },
                {
                    "x": 7,
                    "y": 9.991242714224015
                },
                {
                    "x": 8,
                    "y": 9.991242714224015
                }
            ]
        }
    ]
    });
});

注意我已将"name"替换为"x"