Skip to content

colorLookup to assign colors to nominal data #2

@jbfaden

Description

@jbfaden

Since Autoplot renders events as a solid bar and there's typically no room for labels, it would be nice if the server could suggest that colors be used depending on the data. With my HAPI prototyping server, I have the weather conditions as indicated by the NOAA website where I collect the data. It has condition labels like "Fair" and "Mostly Cloudy", which are coded "CLR" and "SCT085". I convey these in the stream https://jfaden.net/HapiServerDemo/hapi/info?id=icwc in 12 bytes.

To color these, I add to the info node:

    "x_colorLookup": {
                "(?i).*cloud.*": "LightSteelBlue",
                "(?i).*rain.*": "LightGreen",
                "(?i).*storm.*": "DarkGreen",
                "(?i)overcast": "LightGrey",
                "Fair": "SkyBlue"
            },
     "x_colorLookup_about": "http://jfaden.net/HapiServerDemo/moreabout/extensions.html#colorLookup"

The lookup table is a list of regular expressions and then the web color name to use. See https://www.w3schools.com/colors/colors_names.asp for web color names. See https://regexr.com/ which is a tool for creating regular expressions. (It also shows that different languages use different syntax for regular expressions, for example its equivalent is /overcast/i .) Note the x_colorLookup_about doesn't point to anything, which is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions