Displaying Scale-X Times on a Chart
Problem:
I'm trying to simply show times across the bottom of a chart, 0:00 to 24:00 in 2 hour increments. It doesn't seem to be possible following the documentation. I'm passing in series data of measurements taken at 5 minute intervals.
Here's my example scale-x config (I'm generating the config from Python, so some formatting might look funny):
"scale-x": {
'min-value': 1690329600000,
'step': "5minute",
'max-items': 12,
"transform": {
"type": 'date',
"all": "%G:%i"
},
"tick": {
"visible": False
},
"guide": {
"visible": False
}
}
Issues:
- The minimum time, 1690329600000, represents midnight. Inexplicably, the chart starts at 20:00.
- It's showing 15 values, not 12. No combination of maxItems/Labels/Ticks changes this.
Is there any way to do this?
Solution:
About the issue of minimum time starting at a value that represents midnight and the chart starting at 20:00, you might want to comment out the utc attribute if you have it in your config. In this demo, that issue has been addressed on my end. About the issue of showing 15 values and not 12 on setting maxItems, in general, the library tries to adhere to the maxItems setting (so to choose less than that number, not exactly that one) However, sometimes, due to math rounding it's even possible there may be some extra labels, we preferred to have it this way rather than hiding some and make it irregular.