tye.komistek
Posts: 1
Joined: Wed Apr 07, 2021 5:59 pm

Dynamic X-Axis

Wed Apr 07, 2021 7:46 pm

I have a graph that uses the .splice function as seen below:

Code: Select all

lines.splice(0, lines.length-720);

This limits the points on the graph to 720, or 30 days of hourly reports that update hourly.

The problem I'm facing is that the x-axis function that is recommended is for static readings:

Code: Select all

pointStart: Date.UTC(2020, 11, 3),pointInterval: 1 * 3600 * 1000}},

I know that the Date.now function can give a dynamic reading, however I need a Date.now minus 30 days in order for the x-axis titling to line up properly.

I don't know how to do that within the Highcharts API, this is the only results I find online which I dont know how to implement using the API's syntax:

https://stackoverflow.com/questions/113 ... javascript

dominik.c
Posts: 1373
Joined: Fri Aug 07, 2020 7:07 am

Re: Dynamic X-Axis

Thu Apr 08, 2021 10:49 am

Hello tye.komistek!

We appreciate you reaching out to us!

You can use min property and update it whenever you like.

One day equals: 60 * 60 * 24 * 1000, so you need to minus this value * 30 to your Date.

API references: https://api.highcharts.com/highcharts/xAxis.min

Demo: https://jsfiddle.net/BlackLabel/h78yzvqb/

Best regards!
Dominik Chudy
Highcharts Developer

Return to “Highcharts Usage”