Hi there,
A while ago I was asked to make a “temporary” graph for a website, and it turns out it wasn’t so temporary after all, which now landed me in a mess with weeknumbers and years. To summarize and not drag you into it, it comes down to the question: in what way can you sort ticks, besides the default alphabetic order?
So I have an array with all my ticks on the X-axis:
x: {
label: "Week number →",
labelAnchor: 'right',
ticks: ['12', '14', '16', '18', '20', '22', '24', '26', '28', '30', '32', '34', '36', '38', '40', '42', '44', '46', '48', '50', '52', '02', '04'],
tickSize: 0,
},
As you can see I only want to show even week numbers, but I’m going from the data from 2021 to 2022. Unfortunately, the ticks seem to be sorted alphabetically, which means the ‘02’ and ‘04’ ticks get shown all the way on the left before ‘12’, ‘14’ and the rest, which makes my graph get out of order:
// x-axis:
02, 04, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32 .... // you get the gist :)
I couldn’t find anything helpful on this in the API (on Github) or any of the tutorials that came up in Google for Observable Plot. Does anyone have a lead or the knowledge on how to do this? Thanks in advance. I’ve had a really rough year and this issue, as small as it may be, is giving me a lot of stress, so you’d really be helping a colleague out