score:1
You can do this by using the xAxis.labels.formatter
. You need to come up with a solution to parse your decimal year into more readable times. To do this I used the code from this answer.
Sample code set:
function leapYear(year) {
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
function getMonthAndDayFromDayOfYear(dayOfYear, year) {
var daysInMonthArray = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (leapYear(year)) {
daysInMonthArray[2] = 29;
}
var daysLeft = dayOfYear;
var month = 0;
for (i = 0; i < daysInMonthArray.length; i++) {
var daysInThisMonth = daysInMonthArray[i];
if (daysLeft > daysInThisMonth) {
month += 1;
daysLeft -= daysInThisMonth;
} else {
break;
}
}
return {
month: month,
day: daysLeft
};
}
function convertDecimalDate(decimalDate) {
decimalDate = parseFloat(decimalDate);
var year = parseInt(decimalDate); // Get just the integer part for the year
var daysPerYear = leapYear(year) ? 366 : 365; // Set days per year based on leap year or not
var decimalYear = decimalDate - year; // A decimal representing portion of the year left
var dayOfYear = Math.ceil(decimalYear * daysPerYear); // day of Year: 1 to 355 (or 366)
var md = getMonthAndDayFromDayOfYear(dayOfYear, year);
var day = md['day'];
var month = md['month'];
return new Date(year, month, day);
}
Highcharts.chart('container', {
chart: {
type: 'column'
},
xAxis: {
labels: {
rotation: 45,
formatter: function() {
return convertDecimalDate(this.value);
}
}
},
tooltip: {
formatter: function() {
return '<b>' + this.series.name + '</b><br/>' +
this.x + ': ' + this.y;
}
},
series: [{
data: [
[2016.3610, 53.39000],
[2016.3881, 53.29000],
[2016.4153, 54.71000]
]
}]
});
Live demo.
You can use the same method for the tooltip formatter as well. Note that I did not pick out a particular data time format as you did not specify what you need (month/year, or day/month, etc).
score:0
Highcharts reads time in milliseconds, that is the only acceptable way of stating time.
See highcharts API on series.data.x.
So to go from your timestamp, you will need to convert it.
That said, if you do not care about dates, you can use your points as input. Highcharts will not recognize this as dates or time, but assuming that is how you want to show them, then that could work.
Source: stackoverflow.com
Related Query
- How to use decimal dates with Highcharts (such as 1992.9614)?
- How to use highcharts with angular 5?
- How To Use Epoch Time With Highcharts Series Data?
- How to use highcharts with princeXML?
- Highcharts How to get decimal point values on y-axis with big numbers
- How do I use an Highcharts Solid Gauge in angular 6 with typescript?
- How do I use Highcharts to display candlestick with small values?
- How to use Highmaps and Highcharts with Meteor?
- How to use Highcharts React to create chart with multiple lines for same XAxis?
- how to use highcharts tooltip formatter in python code
- How do I use dates from a LinkedHashMap for the x-axis on a Highcharts line graph (using Thymeleaf)?
- How to convert string array to ints to use with Highcharts
- How is the proper way to use HighCharts with StencilJS?
- How to use highcharts in reactjs with fetched data from API
- What's the code in Highcharts such that the bars (columns) in the same group use the same color?
- Highcharts how to use a percentage area with time
- How to have multiple highcharts with different series data in vuejs without repeating code
- How to use Highcharts theme with rCharts
- Parsing JSON for use with Highcharts using jquery .parseJSON or JSON.parse: how to remove quotes from function calls for formatters?
- Highcharts : How to use setData with a string obtained by ajax?
- How to use trellis chart with stacked column in Angular 10 using Highcharts
- how can I use rangeselector and navigation in highcharts in the given code
- In Highcharts How to keep rectangle such SVG elements attached with series data but not with pixel when resize,reflow,redraw,zooming in out?
- How to use custom JSON (not GeoJSON) with Highcharts map?
- How to get highcharts dates in the x axis?
- Highcharts - how to have a chart with dynamic height?
- How to Format Highcharts dataLabels Decimal Points
- How to include highcharts with bower?
- how to import highcharts with webpack and babel
- How to prevent highcharts from shortening labels with ellipsis
More Query from same tag
- Highcharts add series dynamically
- how to display the last five hours time from current time(hh:mm ) 12 hour format in high charts?
- Highcharts Series - want to show/hide all EXCEPT selected series (reversal of default logic)
- Change the color of legend symbol highchart
- how to display multiple chart on same page in mvc5
- Responsive behaviour for ng-highcharts with compiled ng-click on xAxis labels hidden on load
- Highcharts chart width issue on lazy loading of stylesheet
- Less Categories than Series on Highcharts
- my first highchart
- Jasper report color issue with Highcharts's plotOptions.fillColor
- Highchart - set a line style ( width, color...) on selection
- Error: Highcharts error #13 ionic angular
- Highcharts - add points to all series using json
- Highcharts - Organizing the raw data
- Can't get full screen buttons to work with highcharts-vue
- How to set opacity of a single bubble in Highcharts
- Highcharts Stock Chart, Series Padding?
- Json in perfect form but Highcharts chart won't populate
- HighCharts: Updating stops in yAxis does not work
- Enable Annotation Buttons using R's Highcharter Library
- highchart How can I get width parent element for calculated x max in xAxis
- Highcharts polar background color
- Highcharts CSS styling missing in exporting context button
- Show time in HH:MM on Xaxis Highcharts
- iPad - Highcharts interferes with links in the drop down
- CSS / Javascript: hidden div does not take full width after being shown
- How to set correct xAxis time data in Highcharts?
- HighCharts: Resize markers of scatter chart dynamically
- Prevent JSON.parse(data) from cutting off zero digit for String floats
- Add initial and final date to Range Selector Highstock