assign color by lookup?

micaela's Avatar


05 Feb, 2020 04:42 AM

Hi - I am the definition of a total beginner so hopefully this isn't totally obvious, lol. I'm wondering if there's any way to assign colors based one value in a csv rather than having a bunch of colors repeat.

so for example in this i have the name of a book & the length of the book in pages showing. i would like to color code each bar (&associated title??) by the key "Genre." I'm fine doing this with random colors for the moment but ideally I'd love to be able to set my own. I started playing around on the left of my network but I got stuck pretty fast.

Any help appreciated - thanks!!

  1. Support Staff 1 Posted by john on 05 Feb, 2020 06:06 AM

    john's Avatar

    Hi Micaela,

    Welcome to the NodeBox community.

    You managed to get 95% of the way to your goal. You made the rest of your ring, isolated the distinct possible values of genre and assigned colors to them.

    The problem is that you have 211 books but only 12 distinct genres. How do you map those 12 genres back onto the 211 books?

    The solution is to make a little genre color lookup table before you create your book ring.

    You already have the distinct list of genres and distinct list of colors. All I did was add a make table node to turn that into a two-column lookup table.

    Now all you have to do is, for each line of your table, filter that lookup table to the genre of each book. The filter node will return one row of your lookup table with the genre and the color. Then all you have to do is lookup the color in that table and apply it to your labels and rectangles.

    Updated ndbx file and screenshot attached.

    If you want to use specific colors instead of hue spectrum, just build those colors with 12 color nodes and 2 combine nodes, or just type the RGB codes into a spreadsheet and read them in. Whatever colors you put in your lookup table will be applied to the ring.

    Fun little problem! Thanks for sharing it.


  2. 2 Posted by micaela on 06 Feb, 2020 12:30 AM

    micaela's Avatar

    wow, thank you so much!! this is perfect. i appreciate it!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • 7.32 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

04 Dec, 2023 10:18 PM
04 Dec, 2023 10:14 PM
04 Dec, 2023 11:38 AM
29 Nov, 2023 05:30 AM
28 Nov, 2023 12:38 AM


27 Nov, 2023 04:40 AM
26 Nov, 2023 10:02 AM
22 Nov, 2023 09:33 AM
20 Nov, 2023 08:54 PM
17 Nov, 2023 01:43 AM
15 Nov, 2023 06:58 AM