Brushes on categorical data

Hi,
as pure neebie i’m trying to define a parallel coordinate diagramm.
With examples i was quite succesful but now i’m struggling with the brushing:
The brushing of the observable example is much nicer, but won’t work with categorical data as example 2 does.
i therefore tried to mix them, but can’t get brushing to work so far.
I would be grateful for any help!
Best regards, Heiko

1 Like

Hi Heiko!

Happy to help you with your question, and welcome to the forum :slight_smile: Can you publish your notebook so that others can see it? Then I’ll be able to take a look and see what might be wrong.

Thank you!

ok, it’s published. I thought it was published automatically. Thanks for the quick reply!

1 Like

Hi Heiko, I sent you a suggestion for the fix – your min and max were inverted resulting in brushes that never matched anything. I also swapped your select for the observable Inputs.select which is more concise and also automatically selects the first option, since having nothing selected was resulting in the RuntimeError: Cannot read properties of undefined (reading 'domain') issue.

We’re very excited for new people to be learning Observable so any tips you have for how we can make this easier are very welcome! Thank you!

Changes are here: Comparing Brush with categorical data to Brush with categorical data / Observable

1 Like

Hi Duane, thank you very much for that quick fix!
But i’m affraid it doesn’t solve the main issue of the brushing categorical data with the script. I asume you can’t test with my data, so here’s a link to it: https://gist.github.com/hwoehrle/9388c9b91807e84b3158a150dbbc364b/raw/9998abc4341d64a4fcecf2fb61ec774830d5a3a2/Auswertung_B%C3%BCro_Parallel_1.CSV
If you change the data link and switch the color encoding to the last option “Ükh” the data is shown, but brushing is only possible on this last column, i guess because it is numeric.

Can you please take another look at it? Many thanks in advance!

Hi Heiko, take a look at the part of the code that applies the brush selection ranges (this is the part where I swapped min and max to fix your previous notebook). Can you see how this wouldn’t work for categorical data because the categories can’t be compared in that way? You need a way to be able to convert the categories into something that can be compared this way – likely using the appropriate y2 scale on the values and min and max, since the y2 scales map the categories into integer (pixel) values. I think this will be more valuable to you than me making the changes directly in the notebook since this is an important aspect of how scales and brushes work. Do update with how it works out or if you get stuck!

Some more details:

If you have an axis that uses myScale and draws the categorical values “Chicken - Fox - Corn”, and your brush has selected [“Chicken”, “Fox”] corresponding to [min, max], how can you test to see if each of the categories is within that range? Your current implementation checks to see if each category is >= min and <= max but comparing strings this way is not a proper test for this specific axis and scale. It would be better to apply myScale to everything, which outputs numbers, and then compare to see if the categorical values after the scale is applied fall within the range. e.g.

myScale(min) <= myScale(category) && myScale(max) >= myScale(category)
2 Likes