Formatting X axis of chart when using time

Formatting X axis of chart when using time

  

I trying to use a scatter chart where the x axis is time, and the y axis is a decimal value. I was able to make a scatter chart appear, and was able to use the y-axis formatting to set min and max values. I can't seem to format the x-axis min and max values. XAxisFormat doesn't seem to do anything with time values. I've tried entering them as #hh\:mm\:ss# values in XAxisFormat_Init, but nothing happens.

Any tips on what I'm missing here?

Hi Chuck,

Did you look at the Highcharts documentation? Assuming this is a web app, if you look at the HTML source (via browser tools), do you see the formatting you applied in the generated HTML?

Hi Killian -

I couldn't figure out from the Highcharts documentation how to enter time values for x min and x max, at least in a manner that does something useful. However, I hadn't thought to use the generated HTML to see what it is actually picking up from my attempts. That might help me get to the answer. 

Thanks for the suggestion.

Chuck

Hi Chuck, you need to provide the x values in milliseconds since 1 January 1970. In addition, you need to set the following configuration on the XAxisJSON attribute of the AdvancedFormat structure: 

"type: 'datetime', labels:{ formatter: function() { return Highcharts.dateFormat('%H:%M:%S', this.value); } }"

Having done this, you can set a min and a max for the x-axis. To do this, you need also to provide the min and max as the number of milliseconds since 1 January 1970. You can use the XAxisFormat structure for this. It will work :)

I'm sending you an application exemplifying it. You see a line chart containing only two data points even though the serie passed to the graph contains four data points. The min and the max constraint is working :)


Hope this helps.

Greetings, Pedro

Solution

Hi Chuck, here is also the extension the application I uploaded depends upon. This extension only works for .NET.


Greetings, Pedro

Solution

Pedro -

Wow, thanks for the generous help. I need to work through this, but it seems like the key part is that your method turns the x labels into a simple number (milliseconds wrt 1 Jan 1970) instead of a more complex time or date-time. I'll give this a try.

Chuck

Hi Chuck, have you tried it out? Did it work? If that’s the case could you please mark this discussion as solved so that others get to know it? Otherwise, let us know if you’re still facing any challenge on this issue.

Greetings, Pedro

For anybody else reading this thread, just wanted to follow up and say that Pedro's suggestion does indeed solve the problem.