带时间戳和非十进制y轴的highstocks日内图表

时间:2019-07-05 12:28:57

标签: highcharts timestamp

有一张带有大量数据的高位图表,大约60-80000的时间戳和总和。问题是我提供给highstock的数据都不包含小数,但highstock却显示了一些小数,如1.5,但是我的数据没有1.5。如果时间戳超过1小时或其他时间,高库存会平均数据吗?如果它确实对数据求平均,则将停止该求平均值,因为我不需要十进制数据

var chart = Highcharts.stockChart('container',{

    chart: {
        height: 400
    },

    title: {
        text: 'Tweets Count'
    },


xAxis: {
     gapGridLineWidth: 0,
     events: {
     afterSetExtremes: function (e) {
     min=e.min
     max=e.max
     src="http://34.66.198.6/"+id+"/map/"+parseInt(min).toString()+"/"+parseInt(max).toString()+"/"
     loadIframe("map",src)
     src="http://34.66.198.6/"+id+"/hashtags/"+parseInt(min).toString()+"/"+parseInt(max).toString()+"/"
     loadIframe("hashtags",src)
     src="http://34.66.198.6/"+id+"/mentions_screen_name/"+parseInt(min).toString()+"/"+parseInt(max).toString()+"/"
     loadIframe("mentions_screen_name",src)
     src="http://34.66.198.6/"+id+"/screen_name/"+parseInt(min).toString()+"/"+parseInt(max).toString()+"/"
     loadIframe("screen_name",src)
     src="http://34.66.198.6/"+id+"/sentiments/"+parseInt(min).toString()+"/"+parseInt(max).toString()+"/"
     loadIframe("sentiments",src)
     src="http://34.66.198.6/"+id+"/sentiments/"+parseInt(min).toString()+"/"+parseInt(max).toString()+"/All/all"
     loadIframe("twitter",src)
     src="http://34.66.198.6/"+id+"/sentiments/"+parseInt(min).toString()+"/"+parseInt(max).toString()+"/All/all/word"
     loadIframe("word-cloud",src)
         }
     }
 },

yAxis:{
 text:'Tweets Count'
 }

,        rangeSelector:{             纽扣: [{                 类型:“小时”,                 数:1                 文字:“ 1H”             },{                 类型:“ day”,                 数:1                 文字:“ 1D”             }, {                 类型:“ month”,                 数:1                 文字:“ 1M”             }, {                 类型:“年”,                 数:1                 文字:“ 1Y”             },             {                 类型:“全部”,                 数:1                 文字:“全部”             }],             已选择:1,             inputEnabled:否         }

    series: [{
        name: 'Tweets Count',
        data: {{data}},
        type: 'area',
        gapSize: 5,
        tooltip: {
            valueDecimals: 2
        },
        fillColor: {
            linearGradient: {
                x1: 0,
                y1: 0,
                x2: 0,
                y2: 1
            },
            stops: [
                [0, Highcharts.getOptions().colors[0]],
                [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
            ]
        },
        threshold: null
    }], 

    responsive: {
        rules: [{
            condition: {
                maxWidth: 500
            },
            chartOptions: {
                chart: {
                    height: 300
                },
                subtitle: {
                    text: null
                },
                navigator: {
                    enabled: false
                }
            }
        }]
    }
});

1 个答案:

答案 0 :(得分:0)

Highstock提供dataGrouping功能,默认情况下已启用。

请检查下面的文档,并将结果与​​:

您可以禁用dataGrouping或定义自己的approximation函数来对结果取整,例如:

series: [{
    data: [...],
    dataGrouping: {
        approximation: function(arr) {
            var len = arr.length,
                ret = Highcharts.approximations.sum(arr);

            if (Highcharts.isNumber(ret) && len) {
                ret = ret / len;
            }

            return Math.round(ret);
        }
    }
}]

实时演示: http://jsfiddle.net/BlackLabel/q6ukvrp9/

API参考: https://api.highcharts.com/highstock/series.line.dataGrouping.approximation

文档: https://www.highcharts.com/docs/advanced-chart-features/data-grouping