使用刻度将 x 轴更改为字符串数据类型不起作用

changing the x-axis to string datatype using ticks doesn't work

下面是我的脚本。即使在选项中使用刻度后,x 轴也不会更改为指定的字符串。另外如何设置y轴从哪个数字开始?目前它从 0.0 开始,但我需要它从 0.1 开始

   var data = [[1, 0.1], [2, 0.2], [3, 0.5], [4, 0.8], [5, 0.8], [6, 0.8], [7, 0.8], [8, 0.9], [9, 1.0], [10, 1.0], [11, 1.0], [12, 1.0]];

        var dataset = [{label: "unit price",data: data}];

        var options = {

            series: {
                lines: { show: true },
                points: {
                    radius: 3,
                    show: true
                },
            xaxis:{ticks: [[1,"foo"], [2,"bar"],  [4,"cat"], [5,"woo"],  [7,"cookie"], [8,"yay"] ]}

            }
        };

        $(document).ready(function () {
            $.plot($("#flot-placeholder"), dataset, options);
        });

xaxis属性直接属于选项的最顶层,不在series属性.
之下 对于轴的最小值,您可以使用 min 属性.

var options = {
    series: {
        lines: {
            show: true
        },
        points: {
            radius: 3,
            show: true
        }
    },
    xaxis: {
        ticks: [
            [1, "foo"],
            [2, "bar"],
            [4, "cat"],
            [5, "woo"],
            [7, "cookie"],
            [8, "yay"]
        ]
    },
    yaxis:{
        min: 0.1   
    }
};

查看此 fiddle for the full example and the documentation 了解更多信息。