gpt4 book ai didi

javascript - 根据缩放级别更改列数 : HighChart (column chart type)

转载 作者:行者123 更新时间:2023-12-03 11:48:24 25 4
gpt4 key购买 nike

我有 5 年的数据要在柱形图中显示。当我放大时,我想将每个月显示为列。但当我缩小时,它应该是每年的专栏。这对于 Highcharts 来说可能吗?

基本上我想根据缩放设置列数。

最佳答案

只有在 highstock 中您才能使用 dataGrouping - http://www.highcharts.com/docs/advanced-chart-features/data-grouping 。这可能就是您正在寻找的。示例:http://jsfiddle.net/w5bonc2c/

$(function () {
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=large-dataset.json&callback=?', function (data) {

// Create a timer
var start = +new Date();

// Create the chart
$('#container').highcharts('StockChart', {
chart: {
events: {
load: function () {
this.setTitle(null, {
text: 'Built chart in ' + (new Date() - start) + 'ms'
});
}
},
zoomType: 'x',
type: 'column'
},

rangeSelector: {
inputEnabled: $('#container').width() > 480,
buttons: [{
type: 'day',
count: 3,
text: '3d'
}, {
type: 'week',
count: 1,
text: '1w'
}, {
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 6,
text: '6m'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}],
selected: 3
},

yAxis: {
title: {
text: 'Temperature (°C)'
}
},

title: {
text: 'Hourly temperatures in Vik i Sogn, Norway, 2004-2010'
},

subtitle: {
text: 'Built chart in ...' // dummy text to reserve space for dynamic subtitle
},

series: [{
name: 'Temperature',
data: data,
pointStart: Date.UTC(2004, 3, 1),
pointInterval: 3600 * 1000,
tooltip: {
valueDecimals: 1,
valueSuffix: '°C'
}
}]

});
});
});

关于javascript - 根据缩放级别更改列数 : HighChart (column chart type),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25948014/

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