gpt4 book ai didi

javascript - 浮点轴交叉于

转载 作者:行者123 更新时间:2023-11-28 02:28:02 25 4
gpt4 key购买 nike

有谁知道是否可以使用flot为轴设置交叉值?如果您以此处为例

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

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

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

最佳答案

正如 @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

});

产品:

enter image description here

fiddle here .

关于javascript - 浮点轴交叉于,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14590871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com