Hey, there! I’m running into what I suspect is a common barrier to learning to visualize data in Observable, so I’m going to ask in a more generalized way.
I have a basic array of player stats that I pulled from the API for an online shooter videogame:
I want to put them into a bar chart that preserves the order of the “stat” values from how they’re ordered in the array (so show a bar for “Kills”, then “Assists”, then “DamagerPer100”, then “DBNOs”. I’m choosing the pre-existing bar chart template from Observable Plot from the cell options menu, and then subbing in my own data references.
As you can see, the bar chart values are not in the same order as the array. The template seems to be sorting them in descending value. No problem, I can just remove the specified “sort” property and they’ll default to my order, right?
Apparently not. So, I pop over to the general Observable Plot collection and check out the entry on bar marks. The only mention of explicitly setting the order of the domain comes in this small passage:
So, I pop over to the linked page about Scales in Observable Plot, and the only mention I find of “discrete position” is this passage here:
As you can see, the example only references explicitly specifying single character domains, and only within a “point” or “band” scale. There’s no mention of how to apply this to a 2D chart like a bar mark, or even how to make that domain order derivative of actual data you’re referencing.
I popped into the Tutorials page and clicked into the D3 Gallery in hopes that maybe I could find a way to make a sorted bar chart with D3, but alas, the lone example is sorted by frequency.
So the question: What is the best way for someone (obviously) green on JavaScript to figure something like this out, without having to ask the forum every time?