admin管理员组

文章数量:1194606

My chart is displaying data day-by-day (user and system sent SMS/Newsletters). So time part is not relevant and unnecessary. Here is an example: / where time "12:00" is displayed.

How can I force Highcharts to never display the time part in a "datetime" axis?

EDIT: Highcharts will display dates w/wo times based on chart or screen size. I've updated jsfiddle removing some data and now it's displaying also time parts.

My chart is displaying data day-by-day (user and system sent SMS/Newsletters). So time part is not relevant and unnecessary. Here is an example: http://jsfiddle.net/uaxZP/1/ where time "12:00" is displayed.

How can I force Highcharts to never display the time part in a "datetime" axis?

EDIT: Highcharts will display dates w/wo times based on chart or screen size. I've updated jsfiddle removing some data and now it's displaying also time parts.

Share Improve this question edited Jul 9, 2012 at 14:37 gremo asked Jul 9, 2012 at 14:03 gremogremo 48.9k80 gold badges269 silver badges447 bronze badges 3
  • 2 Is this still a problem? I see only dates on your fiddle. – Mike Robinson Commented Jul 9, 2012 at 14:12
  • i would think about using highstock since you have your data in this format – Mina Gabriel Commented Jul 9, 2012 at 14:20
  • @MikeRobinson here we are, updated fiddle showing times. – gremo Commented Jul 9, 2012 at 14:29
Add a comment  | 

2 Answers 2

Reset to default 12

You can intercept the x-axis label function and change it's output. In my example, I've changed it to render short dates:

http://jsfiddle.net/uaxZP/3/

{ xAxis: 
    labels: {
        formatter: function() {
             return Highcharts.dateFormat("%b %e", this.value);
        }
    }
}

        

The xAxis.labels.formatter property allows control over this. You also may notice I'm using Highcharts.dateFormat, which is a utility function for rendering dates. This is not mandatory, but it's a nice built in feature. Documentation on the xAxis formatter is here:

http://www.highcharts.com/ref/#xAxis-labels--formatter

The easiest way to do is using "minTickInterval"

xAxis: {
       minTickInterval: 24 * 3600 * 1000
}

http://api.highcharts.com/highcharts#xAxis.minTickInterval

本文标签: javascriptHighcharts datetime axishow to disable time part (show only dates)Stack Overflow