gpt4 book ai didi

javascript - Highcharts 对数 X 轴在没有零值或阈值低于零或最小值的情况下失败

转载 作者:行者123 更新时间:2023-12-02 14:16:34 28 4
gpt4 key购买 nike

我对对数 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”或“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"

关于javascript - Highcharts 对数 X 轴在没有零值或阈值低于零或最小值的情况下失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38979857/

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