score:2

Accepted answer

With Highcharts? There's not simple way to achieve that.

However, using Highstock, simply use xAxis.ordinal = true and everything will work. See: http://jsfiddle.net/G5S9L/8/

score:0

For the second question, you can simply extend the Point class(wrap applyOptions method), and set the categories of xAxis.

(function (H) {
    H.wrap(H.Point.prototype, 'applyOptions', function (applyOptions, options, x) {
        var point = applyOptions.call(this, options, x),
            series = point.series;

        // check if 
        // 1. there is a name(category)
        // 2. xAxis has the categories defined
        // 3. x value equals xIncrement
        if (point.name && series.xAxis.categories && point.x === series.xIncrement - 1) {

            // find a matching category?
            var idx = series.xAxis.categories.indexOf(point.name);
            if (idx >= 0) {
                point.x = idx;
            }
        }

        return point;
    });

})(Highcharts);

See fiddle: http://jsfiddle.net/G5S9L/17/


Related Query

More Query from same tag