score:2

Accepted answer

it is kinda possible. this code here produces:

enter image description here

it is not pretty code though.

score:0

have you tried putting a comma-separated list of values under xaxis:{ categories:[{'5/29/2007', '9/4/2007', '9/23/2008'}] }

and for the chart: { series: [{null}, {300}, {400}] }

i believe you can also use a delegate for the xaxis labels or series labels so that you can test the values against a threshold and drop them out.

score:3

you can do it easily with .islast and .isfirst, like this:

     xaxis: {
                type: 'datetime',
                labels: {
                    formatter: function() {
                        if(this.islast || this.isfirst)
                            return [whatever label calculation you need];
                        else return null;
                    },
                },
                title: {
                    text: 'date'
                }
            }

score:3

old question, but there's now a cleaner way to do this with tickpositions.

var chart = new highcharts.chart({
    chart: {
        renderto: 'container'
    },
  xaxis: {
     type: 'datetime',
     labels: {
         // when using tickpositions, you'll also need to specify a label format.
         format: '{value:%e. %b}',
     },         
     tickpositions: [date.utc(2007,05,29), date.utc(2007,09,04)]
  },
  credits: {
     enabled: false
  },
  series: [{
     data: [
        [date.utc(2007,05,29), 300], // this x-axis value should be labeled.
        [date.utc(2007,09,03), 300], // no label for this value
        [date.utc(2007,09,04), 200]  // this x-axis value should be labeled.
     ]         
  }]
});

jsfiddle demo

resulting chart enter image description here

score:4

regarding the (1) question, i believe you can't do that in datetime xaxis in highcharts. when setting that type of axis, the framework calculates the ticks shown in the correspondent axis depending on the data you have.

in answer to the (2) question, i believe that so far you can't skip times in the datetime axis. however, and even though i haven't tried, you might want to look at some workaround using categories so you can use a formatter and replace the ticks that you don't want.

despite all of the above, i did a workaround that you might want to use and that it just needs a little bit of formatting to be more or less what you were asking. here it is:

var chart = new highcharts.chart({
chart: {
    renderto: 'container'
},
xaxis: {
    type: 'datetime',
    labels: {
        enabled: false
    }

},

series: [{
    datalabels: {
        enabled:true,
        formatter: function(){
            if(this.point === this.series.data[this.series.data.length - 1])
            {
                return this.x
            }
            if(this.point === this.series.data[0])
            {
                return this.x
            }
        } 
    },
    data: [
        [date.utc(2007,05,29), 300], 
        [date.utc(2007,09,23), 300], 
        [date.utc(2007,09,04), 400]
    ]
}]

});

basically what i do is getting rid of the xaxis labels and just show the date in the point itself for the values that i want (first and last). notice that you might want to format how that date is shown because right now is showing the timestamp in ms.

you can see this live in jsfiddle: xaxis labels deleted


Related Query

More Query from same tag