gpt4 book ai didi

javascript - highcharts 类别问题

转载 作者:行者123 更新时间:2023-11-29 22:28:06 27 4
gpt4 key购买 nike

我正在为一个项目使用 Highcharts,它带来了一个 mysql 记录集。我有两件事找不到解决方案:

  1. 值始终在 3000 到 8000 之间,如何在 x 轴上显示 3000、3500、4000 等?
  2. 图表允许我放大,无论缩放级别如何,我都想显示 y 轴,有什么办法吗?

这是我的代码:

var SpectrumName = '<?php echo $SpectrumName; ?>';
var SpectrumDate = '<?php echo $SpectrumDate; ?>';
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
size:[ 400,250 ],
chart: {
renderTo: 'container',
zoomType: 'xy',
defaultSeriesType: 'line',
marginRight: 130,
marginBottom: 50,

},
title: {
text: 'AstroSpec Observation of: ' + SpectrumName,
x: -20 //center
},
subtitle: {
text: 'Acquired on: ' + SpectrumDate,
x: -20
},
xAxis: {
categories: [<?php echo $x_colf1; ?>],
labels: {
formatter: function() {
if (this.index % 500) { // even numbers only
return this.value;
} else {
return false;
}
}
}

},

yAxis: {min: 0,
title: {
text: ''
},
plotLines: [{
value: 30,
width: 3,
color: '#808080'
}]
},
plotOptions: {
series: {
enableMouseTracking: false,
marker: {
enabled: false
}
}
},

legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'R',
data: [<?php echo $y_axis; ?>]
}]
});


});

最佳答案

对于#1,尝试如下设置mintickInterval:

xAxis: {
min: 3000,
tickInterval: 500
}

我不太明白要求 # 2。

关于javascript - highcharts 类别问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8364967/

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