Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colorLookup to assign colors to nominal data #2

Open
jbfaden opened this issue Dec 1, 2021 · 2 comments
Open

colorLookup to assign colors to nominal data #2

jbfaden opened this issue Dec 1, 2021 · 2 comments

Comments

@jbfaden
Copy link
Collaborator

jbfaden commented Dec 1, 2021

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.

@jbfaden
Copy link
Collaborator Author

jbfaden commented Dec 1, 2021

Note Jon's MMS group at UNH requested that Autoplot color data based on data values, for example to mark points as red because a sensor has reported data outside nominal values. In this case instead of regular expressions and nominal data, we could have something like:

    "x_colorLookup": {
           ".gt(50)": "Red",
           ".gt(40).and(le(50))": "Yellow",
           ".le(40)": "Green"
    }

But it might be better to have nominal labels for these as well (ERROR,WARNING,info).

@jbfaden
Copy link
Collaborator Author

jbfaden commented Dec 1, 2021

Another use case for this would be to display the data in a spreadsheet, where the cell background color is picked using the lookup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant