gpt4 book ai didi

javascript - Highcharts/stock xAxis 仅显示年份

转载 作者:行者123 更新时间:2023-11-27 23:59:30 24 4
gpt4 key购买 nike

我正在用高股票构建一些图表。

我的数据如下:

[1133308800, 1.95492806759836],
[1135987200, 2.01739233585526],
[1138665600, 2.0725059567737],
[1141084800, 1.89533596472326],

以及我的 xAxis 设置:

            xAxis: {

labels: {
style: {
textTransform: 'uppercase',
color: '#a7b9c7',
fontFamily: 'Helvetica Neue, Helvetica',
fontSize: '11px'
}
},
lineWidth: 0,
minorGridLineWidth: 0,
lineColor: 'transparent',
minorTickLength: 0,
tickLength: 0,
plotLines: [{
color: '#3b3c40',
dashStyle: 'dot',
value: .5,
width: 1
}]
},

问题是 xAxis 上的标签类似于 14。 Jan 等。我只想得到我的数据中的年份。

    $.getJSON(name + '.json', function(data) {

seriesOptions[i] = {
name: name,
data: data,
color: colors[i]
};

seriesCounter += 1;

if (seriesCounter === names.length) {
createChart();
}
});

有人可以解释一下如何在 x 轴上仅显示年份吗?

enter image description here

最佳答案

您可以通过 dateTimeLabelFormats 配置日期时间标签

{
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
}

关于javascript - Highcharts/stock xAxis 仅显示年份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31944467/

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