dongyi1982 2017-04-28 08:52 采纳率: 0%
浏览 34

从json添加highstock系列

I'm building highstock chart with big set of one serie data. For performance reasons I want to load smalest set of data at first called as 'Serie 1' (from one hour ago till now) and after that I need to add to this 'Serie 1' next points with data from two years ago till one hour ago. The data points is stored on every one minute since whole 2 years ago till now.

The method for get the next points and plot them code is below:

$.getJSON('dashboard/values.php?start='+ min +'&end=' + max, function(myData) {
    var seriesOptions = {
            name: 'water depth',
            yAxis: 0,
            id: 'depth',
            data: myData
    };

    var navigatorOptions = {
            yAxis: 1,
            data: myData
    };

    var obj = eval('[' + myData + ']');
    seriesOptions.data = obj;
    chart.addSeries(seriesOptions);

    var nav = chart.get('navigator');
    nav.setData(myData, false);
    chart.xAxis[0].setExtremes();
});

I have two problems to figure out:

  1. Added serie is as 'Serie 3' on chart instead of the 'Serie 1'
  2. After add new points the navigation bar is extended to January 1st 1979, but my data starts from April 28th 2015

The values.php file is:

<?php
header('Content-Type: text/JSON'); 
//... some SQL connection and query stuff
if ($result = $mysqli->query($sql)) {
    $emptyarray = array();
    while($row = $result->fetch_assoc()) {
        extract($row);
        $emptyarray[] = "[$datetime, $water_depth]";
    }

    $result->free();
}

$mysqli->close();
echo json_encode($emptyarray);

Also, if You have any other ideas how to display the chart with a big set of data with good performance speed, please share. I don't want to create four data tables holding data for minutes, hours, days and months respectively like it is described in this article.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么