HighCharts Time-based Quarterly Data - xAxis Label Issue

前端 未结 2 574
死守一世寂寞
死守一世寂寞 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:00

    You can set tickInterval as three months

    http://jsfiddle.net/yHmrZ/5/

    tickInterval: 3 * 30 * 24 * 3600 * 1000,
    

    But when you would like to dynamic change ranges, you should use tickPostitioner

    0 讨论(0)
  • 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;
            },
    
    0 讨论(0)
提交回复
热议问题