【问题标题】:HighCharts navigator and range scale not working?HighCharts 导航器和范围刻度不起作用?
【发布时间】:2016-01-26 20:30:16
【问题描述】:

需要帮助。如何使用 js 限制 json 数组的最小值和最大值。

这是我的问题,在 highstocks 上工作,我的日期是 unix 的第一天,但​​在数组中我有正确的日期。 所以我的导航器和范围刻度不起作用?

我的 json 数组在变量中

var data = <?php echo $data; ?>;

但我想像这样限制它

$.getJSON('https://www.highcharts.com/samples/data/from-sql.php?start=' + Math.round(e.min) +
                '&end=' + Math.round(e.max) + '&callback=?', function (data)

这是我的json结构

[1233014400000,12.96],  
[1233100800000,13.46],  
[1233187200000,13.29],  
[1233273600000,12.88],

$(function () {

var data = <?php echo $data; ?>; // geting json array [1233014400000,12.96] //

// Create the chart
$('#container_small').highcharts('StockChart', {

    rangeSelector : {
        selected : 1,
        enabled: true
    },

    title : {
        text : 'Tankerska Next Generation d.d.'
    },

    navigator : {
        enabled: true
    },

    series : [{
        name : 'Tankerska Next Generation d.d.',
        data : data,
        marker : {
            enabled : true,
            radius : 4
        },
        shadow : true,
        tooltip : {
            valueDecimals : 2
        }
    }]
});

});

感谢您的帮助

【问题讨论】:

  • 为什么不在后台过滤掉不必要的点呢?那么$data 将只提供所需的积分?

标签: javascript php arrays json highcharts


【解决方案1】:
function getMaxOfArray(numArray) {
  return Math.max.apply(null, numArray);
}

最小值也是如此。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-26
    • 2021-08-12
    相关资源
    最近更新 更多