HighCharts Time-based Quarterly Data - xAxis Label Issue

前端 未结 2 575
死守一世寂寞
死守一世寂寞 2020-12-18 11:26

We are displaying dynamic data on our site. The user can select different types of time periods such as monthly, quarterly, annual, decennial, etc. Our issue comes in trying

2条回答
  •  死守一世寂寞
    2020-12-18 12:11

    You can use your own tickPositioner always, take a look: http://jsfiddle.net/yHmrZ/4/

    And code for tickPositioner and formatter:

            labels: {
                formatter: function () {
                    var s = "",
                        d = new Date(this.value),
                        q = Math.floor((d.getMonth() + 3) / 3); //get quarter
                    s = "Q" + q + " " + d.getFullYear();
                    return s;
                }
            },
            tickPositioner: function(min, max){
                var axis = this.axis,
                    act = min,
                    ticks = [];
                while( act < max ){
                    ticks.push(act);
                    act = act + (90 * 24 * 3600 * 1000); //three months
                }
                return ticks;
            },
    

提交回复
热议问题