1

有谁知道是否可以使用 flot 为轴设置交叉值?如果你在这里举个例子

http://www.flotcharts.org/flot/examples/threshold/index.html

如果能够设置 x 轴,使其在 0 处而不是在最小值处(本例中为 -10)与 y 交叉,那就太好了

我找不到办法做到这一点。我也找不到使用 highcharts 或 jqplot 的方法。

4

2 回答 2

1

正如@DNS 所提到的,您不会在 API 中找到它,但是当所有其他方法都失败时,请破解它!

$(function () {

    var data = [[0, -12], [7, 12], [8, 2.5], [12, 2.5]];  // some data series

    somePlot = $.plot($("#placeholder"), [ data ]); // plot it once

    var xaxis = somePlot.getAxes().xaxis; // get your x and y axis 
    var yaxis = somePlot.getAxes().yaxis;

    var abline = [[xaxis.datamin,0],[xaxis.datamax,0]]; // create a new line to serve as our xaxis, we are using the current xaxis extremes

    somePlot = $.plot($("#placeholder"), [ {data: data}, {color: 'black', data: abline, shadowSize:0} ], {}) // replot it with our new line

    $('.x1Axis .tickLabel').css('top',yaxis.p2c(0)+5+'px'); // move our xaxis tick labels to the zero location of the yaxis   

});

产生:

在此处输入图像描述

在这里拉小提琴。

于 2013-01-30T15:25:33.557 回答
0

不幸的是,目前这是不可能的;Flot 仅支持绘图边缘的轴。

您绝对应该打开一个问题以将其作为建议提交。

于 2013-01-29T20:55:22.613 回答