【问题标题】:Changing number of columns based on the zoom level : HighChart (column chart type)根据缩放级别更改列数:HighChart(柱形图类型)
【发布时间】:2014-09-23 23:18:41
【问题描述】:

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

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

【问题讨论】:

    标签: javascript highcharts


    【解决方案1】:

    只有在 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'
                    }
                }]
    
            });
        });
    });
    

    【讨论】:

      猜你喜欢
      • 2011-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多