score:-1
There are several xAxis options which may help do what you want.
http://api.highcharts.com/highcharts#xAxis.labels
Take a look at 'align' which specifies whether the labels are to the left or right of the tick, and also 'x' which allows you to specify a x-offset for the label from the tick.
score:-1
Have you tried to use tick placement ? http://api.highcharts.com/highcharts#xAxis.tickmarkPlacement
score:0
This can be done with a workaround by manually adjusting the label positioning via a callback (called on both load and redraw). Please see the fiddle linked to in my comment on this post: Highcharts - how can I center labels on a datetime x-axis?
score:2
There is no simple, out-of-the-box solution. You have to use events and reposition the labels accordingly. Here is a sample solution that also works when resizing the browser window (or otherwise forcing the chart to redraw), even when the tick count changes: http://jsfiddle.net/McNetic/eyyom2qg/3/
It works by attaching the same event handler to both the load
and the redraw
events:
$('#container').highcharts({
chart: {
events: {
load: fixLabels,
redraw: fixLabels
}
},
[...]
The handler itself looks like this:
var fixLabels = function() {
var labels = $('div.highcharts-xaxis-labels span', this.container).sort(function(a, b) {
return +parseInt($(a).css('left')) - +parseInt($(b).css('left'));
});
labels.css('margin-left',
(parseInt($(labels.get(1)).css('left')) - parseInt($(labels.get(0)).css('left'))) / 2
);
$(labels.get(this.xAxis[0].tickPositions.length - 1)).remove();
};
Basically, it works like this:
- Get all existing labels (when redrawn, this includes newly added ones). 2. Sort by css property 'left' (they are not sorted this way after some redrawing)
- Calculate offset between the first two labels (the offset is the same for all labels)
- Set half of the offset as margin-left of all labels, effectively shifting them half the offset to the right.
- Remove the rightmost label (moved outside of chart, by sometimes partly visible).
score:3
According to my understanding, the behavior you desire is:
http://jsfiddle.net/msjaiswal/U45Sr/2/
Let me break down the solution :
1. Monthly Data Points
One data point corresponding to one month :
var data = [
[Date.UTC(2003,1),0.872],
[Date.UTC(2003,2),0.8714],
[Date.UTC(2003,3),0.8638],
[Date.UTC(2003,4),0.8567],
[Date.UTC(2003,5),0.8536],
[Date.UTC(2003,6),0.8564],
..
]
2. Scale to display only yearly ticks
Use chart options like this:
xAxis: {
minRange : 30 * 24 * 3600 * 1000, //
minTickInterval: 12* 30 * 24 * 3600 * 1000 // An year
},
Source: stackoverflow.com
Related Query
- Highcharts: xAxis yearly labels centered between ticks
- HighCharts - Need more space between bottom of chart and Xaxis labels
- Is it possible to center the labels and data points between the ticks in a datetime xAxis for Highcharts?
- Highcharts - remove times between dates on a datetime xaxis type
- HighCharts - show last labels in xAxis
- Highcharts remove gap between start of xAxis and first value
- Highcharts : How to fix labels to the top when xAxis rotation is 90°?
- Difference between highcharts and highstock during real time trace and xAxis with max value
- Distance between x-axis labels and the chart in Highcharts
- Highcharts xAxis shows labels from drilldown on drillup
- Highcharts JS: Gap between X-Axis labels is too thin
- Overlapping labels in HighCharts on xAxis
- HighCharts - how to align (justify) xAxis labels left and right
- Highcharts xAxis labels do not auto rotate
- if statement for Highcharts xAxis labels
- Highcharts mixed column/spline, wrong xaxis labels
- How to change Highcharts xAxis formatting from yearly to monthly?
- Use images in Highcharts as xAxis labels
- How to display yearly values on xAxis in Highcharts
- Highchart data labels appear in middle if xAxis ticks
- HighCharts Polar Labels in between of sectors of circle
- Why are the xAxis labels in my Highcharts graphic so strangely positioned?
- rCharts Highcharts change xAxis labels
- Labels position of xAxis in Highcharts
- Highcharts prevent xAxis Labels hidden
- how to : limit xaxis labels in highcharts to prevent overlap
- Highcharts - column chart has space between bar and xAxis
- Highcharts Line Chart - Highlight xAxis labels on point hover
- Highcharts - second xAxis labels are not displayed
- Highcharts Interactivity between plots - looking for code improvements
More Query from same tag
- Highcharts display label for pie chart using html table as data source
- Highchart multiple series with csv
- Highcharts - How to set Pie Chart's background color dynamically
- script not running in templateurl
- Highcharts - fire legendItemClick event
- Highcharts - stop Y axis value change on redraw
- Highcharts animation with color blending
- how to show the remaining percent of Bar in Highcharts?
- Generate HighChart Colors Before Drawing Chart?
- Spline chart rounded edges
- Clickable Bars in js Highcharts?
- DotNet.Highcharts , Is there any way to use it in Winform application?
- Highcharts/Highstock DataGrouping & Approximation
- responsive highcharts with dynamic font size and widths
- Highcharts points and lines are missing
- set Highstock xAxis range within options object
- how to get value from other script? (in html)
- Highcharts - Enable border for 1 column/bar only?
- Highchart - Launch Sweetalert2 when click element
- High Charts, pie chart customaization
- Highcharts : Change opacity of a column chart
- Highcharts; disabling the tooltip for a single point renders a random little box
- How to handle mouse events on axis labels in highcharts
- HighCharts: Getting Y-Value in One Series Based on X-Value From Another Series
- Selenium WebDriver and Highchart testing
- Get SVG Data from Highcharts without displaying the chart
- How is it possible to show the menu of a chart with React Highcharts?
- Format X axis Label of Highcharts
- How to change the text color in Highcharts
- I am trying to include india map in my highchart code