Highcharts time X axis

筅森魡賤 提交于 2020-02-25 13:22:45

问题


I would like to ask if somebody knows how to set X axis in Highcharts to time. My aplication is taking data from database and the frequency of the samples is 250ms. I want the X axis not to show counted values but something like time. I render 2500 values at once so that means 10 secs. The best would be to have on X axis and a mark there every 0.5 sec that means every 125 samples a mark. Like (0 samples = 0 sec);(125 samples = 0,5 sec);(500 samples = 1 sec);(725 samples = 1.5 sec)

Thank you for your opinions.....

                                chart () {
                                    var options = {
                                        chart: { 
                                            renderTo: 'services',
                                            type: 'line', 
                                            animation: 'false'
                                        },

                                      plotOptions: {
                                            series: {
                                                animation: {
                                                    duration: 10000
                                                }
                                            }
                                        },

                                        series: [{marker: {
                                                    enabled: false
                                                }}]
                                      };

回答1:


You can supply a custom label formatter. For example...

xAxis: {
    labels: {
        formatter: function () {
            return (baseTime + (this.value / 500)) + " sec";
        }
    }
},

where baseTime is the time of the first data point.

Documentation for custom label formatter can be found at...

http://api.highcharts.com/highcharts#xAxis.labels.formatter



来源:https://stackoverflow.com/questions/36798786/highcharts-time-x-axis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!