score:1
It's not that straightforward because Highcharts automatically determines the labels to use when the x-axis is of the type 'datetime':
To set labels like '10:33' you need to create your own categories. Luckily these can simply be derived from your data and the desired time interval.
Here's a working example: http://jsfiddle.net/Rt7ZV/
We just take the given start date, interval and number of points and build an array of the categories to be used as the x-axis labels.
function getTimes(numTimes, interval) {
var ms = (new Date(2012, 02, 30, 10, 33)).getTime();
var times = [];
var startDate = new Date(ms);
times.push(startDate.getHours() + ":" + startDate.getMinutes());
for (var i = 1; i< numTimes; i++)
{
ms += interval;
var nextTime = (new Date()).setTime(ms);
var nextDate = new Date(nextTime);
times.push(nextDate.getHours() + ":" + pad(nextDate.getMinutes(), 2));
}
return times;
}
function pad(num, size) {
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}
var data = [1, 2, 3, 4, 5, 3, 2, 5, 7, 6, 4];
var interval = 10*60*1000
var timeCategories = getTimes(data.length, interval);
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'x',
spacingRight: 20
},
title: {
text: 'Time series'
},
xAxis: {
categories: timeCategories,
title: {
text: null
},
startOnTick: false
},
yAxis: {
title: {
text: 'Exchange rate'
},
startOnTick: false,
showFirstLabel: true
},
tooltip: {
shared: true
},
legend: {
enabled: false
},
series: [{
type: 'line',
name: 'time series',
data: [
1, 2, 3, 4, 5, 3, 2, 5, 7, 6, 4
]
}]
});
});
});
score:1
I found the tickPositions property on xAxis, which isn't documented on highcharts, only on highstock, but seems to work fine on both. With this property you can specify which values you want to hace a tick for, and work perfectly for my problem.
Source: stackoverflow.com
Related Articles
- Highcharts, how can I start xAxis on an arbitrary time
- Highcharts - How to start x axis from an arbitrary value
- Highcharts remove gap between start of xAxis and first value
- Difference between highcharts and highstock during real time trace and xAxis with max value
- Highstock Highcharts date time data on Xaxis
- Highcharts xAxis datetime from start
- Highcharts xAxis doesn't get the right time format
- show two different series with different start intervals with the same xAxis highcharts
- Highcharts not starting at give start time
- Highcharts datetimex axis incorrect start time and interval
- Highcharts multiple series force xAxis start point
- Show time in HH:MM on Xaxis Highcharts
- Highcharts - tooltip time value does not match xAxis
- Display time on Xaxis with line chart make by Highcharts
- Highcharts datetime axis, how to disable time part (show only dates)?
- HighCharts show datetime format on xAxis
- Show only time labels on xAxis. Highcharts
- How can i hide all the Series in highcharts at a time
- Highcharts convert x-axis time to localtime
- How To Use Epoch Time With Highcharts Series Data?
- Highcharts - remove times between dates on a datetime xaxis type
- HighCharts - show last labels in xAxis
- php: laravel slow view render time when rendering javascript for highcharts
- Highcharts chart with 'datetime' xAxis - use categories on drilldown
- display content on highcharts Xaxis and Yaxis title in form of subscript and superscript
- Highcharts - specifying order of stacked time series
- Highcharts - time off by 1 hour
- Appending Data with Highcharts (real time updating chart)
- how to set xAxis pointInterval(update: tickInterval) in highcharts
- Panning in Highcharts will not allow to go back to the max of the xAxis
- Highcharts: getting blank chart with JSON
- How to add different series data for each categories in Stacked Column chart in Highcharts?
- Highcharts: Area chart: fill in space between 0 and first point
- Can I have multiple plotlines with Highcharts?
- Highcharts scatter plot with time only
- Highcharts column range dataLabels reversed
- Highcharts - multiple plot with the same x scale
- Highcharts Pie Chart data corrupted
- Divide X axis by Clickable Zones in HIghchart
- Highcharts: Displaying Linechart with missing datapoints
- Handle touch event on Apple - Highcharts
- Tooltip Options not working for Highcharts Treemap
- Loading json data to highcharts with multiple series
- Is it possible to use null datapoints with a datetime x-axis?
- Custom YTD Option in HighStock Range Selector
- Negative Fill color in AreaSpline Graph
- Alternate for highcharts-more
- HighCharts Polar Labels in between of sectors of circle
- How to get Yaxis values from highchart
- Updating single category data in Highcharts column chart