Complex Encodings: Icons

Concepts

The complex icons encodings section of a create dataset call provides fine-grained icon controls. The glyph can be set to icons, flags, text, and custom images through direct or mapped assignments.

Mappings from node/edge values to visual glyphs may be categorical, such as for mapping country names to flags, and continuous, such as for mapping wide score intervals to a few warning icons. By default, if a value is not defined by the mapping, no icon will be shown. Field other may be specified to define an alternative default mapping, such as showing a question mark. The same glyph can be applied to all elements by specifying an empty mapping with a default of choice.

Icon encodings are designed to work with other encodings. For example, icon encodings are often used alongside encodings for point colors, point sizes, and badges. Likewise, when used as a categorical mapping over a column named type, the legend will show the icon in its main area.

Default and current encodings

See primary discussion of default vs. current encodings.

Icons demo

Mapping categorical values to icon glyphs

{
    "name": "my graph",
    "metadata": {},
    "edge_encodings": { "bindings": {"source": "s", "destination": "d"} },
    "node_encodings": {
        "bindings": {"node": "n"},
        "complex": {
            "default": {
                "pointIconEncoding": {
                    "graphType": "point",
                    "encodingType": "icon",
                    "attribute": "type",
                    "variation": "categorical",
                    "mapping": {
                        "categorical": {
                            "fixed": {
                                "macbook": "laptop",
                                "mac": "server"
                            },
                            "other": "question"
                        }
                    }
                }
            }
        }
    }
}

Mapping categorical values to flags

{
    "name": "my graph",
    "metadata": {},
    "edge_encodings": { "bindings": {"source": "s", "destination": "d"} },
    "node_encodings": {
        "bindings": {"node": "n"},
        "complex": {
            "default": {
                "pointIconEncoding": {
                    "graphType": "point",
                    "encodingType": "icon",
                    "attribute": "type",
                    "variation": "categorical",
                    "mapping": {
                        "categorical": {
                            "fixed": {
                                "America": "flags-icon-us",
                                "Canada": "flags-icon-ca"
                            },
                            "other": "question"
                        }
                    }
                }
            }
        }
    }
}

Mapping categorical values to text

{
    "name": "my graph",
    "metadata": {},
    "edge_encodings": { "bindings": {"source": "s", "destination": "d"} },
    "node_encodings": {
        "bindings": {"node": "n"},
        "complex": {
            "default": {
                "pointIconEncoding": {
                    "graphType": "point",
                    "encodingType": "icon",
                    "attribute": "type",
                    "variation": "categorical",
                    "as_text": true,
                    "mapping": {
                        "categorical": {
                            "fixed": {
                                "America": "US",
                                "Canada": "CA"
                            }
                        }
                    }
                }
            }
        }
    }
}

Mapping categorical values to images that are external and embedded

{
    "name": "my graph",
    "metadata": {},
    "edge_encodings": { "bindings": {"source": "s", "destination": "d"} },
    "node_encodings": {
        "bindings": {"node": "n"},
        "complex": {
            "default": {
                "pointIconEncoding": {
                    "graphType": "point",
                    "encodingType": "icon",
                    "attribute": "type",
                    "variation": "categorical",
                    "mapping": {
                        "categorical": {
                            "fixed": {
                                "mac": "https://cdn.mos.cms.futurecdn.net/a89992626a0bf98e5f9030af8584b26e-970-80.jpg.webp",
                                "macbook": "data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzMwMHB4JyB3aWR0aD0nMzAwcHgnICBmaWxsPSIjMDAwMDAwIiB4bWxuczp4PSJodHRwOi8vbnMuYWRvYmUuY29tL0V4dGVuc2liaWxpdHkvMS4wLyIgeG1sbnM6aT0iaHR0cDovL25zLmFkb2JlLmNvbS9BZG9iZUlsbHVzdHJhdG9yLzEwLjAvIiB4bWxuczpncmFwaD0iaHR0cDovL25zLmFkb2JlLmNvbS9HcmFwaHMvMS4wLyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDEwMCAxMDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxzd2l0Y2g+PGZvcmVpZ25PYmplY3QgcmVxdWlyZWRFeHRlbnNpb25zPSJodHRwOi8vbnMuYWRvYmUuY29tL0Fkb2JlSWxsdXN0cmF0b3IvMTAuMC8iIHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjwvZm9yZWlnbk9iamVjdD48ZyBpOmV4dH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Q2LjU5NSwzOS40Nyw0Ni41OTV6Ij48L3BhdGg+PC9nPjxnPjxnPjxsaW5lIHgxPSI0MC45MjciIHkxPSIzNC43MDMiIHgyPSIzOC4zMyIgeTI9IjQxLjA3MyI+PC9saW5lPjwvZz48Zz48cGF0aCBkPSJNNDAuOTI3LDM0LjcwM2MwLDAsMC4xMDMsMC4xNTcsMC4yMTUsMC40MDdjMC4xMTcsMC4yNSwwLjI0MiwwLjU5MiwwLjMzMiwwLjk3N2MwLjE3OSwwLjc3LDAuMTI5LDEuNjc4LTAuMTkzLDIuNDc1ICAgICAgIGMtMC4zMjIsMC43OTgtMC45MiwxLjQ4Mi0xLjU4NywxLjkwN2MtMC4zMzQsMC4yMTItMC42NjQsMC4zNjgtMC45MjMsMC40NjVjLTAuMjU2LDAuMDk5LTAuNDQxLDAuMTQtMC40NDEsMC4xNCAgICAgICBzLTAuMTA0LTAuMTU4LTAuMjE3LTAuNDA4Yy0wLjExOC0wLjI1MS0wLjI0NS0wLjU5My0wLjMzNS0wLjk3OGMtMC4xOC0wLjc3MS0wLjEyOC0xLjY3OCwwLjE5OS0yLjQ3MyAgICAgICBjMC4zMjYtMC43OTcsMC45MjYtMS40OCwxLjU5Mi0xLjkwNWMwLjMzMy0wLjIxMywwLjY2Mi0wLjM2OSwwLjkyLTAuNDY3QzQwLjc0MywzNC43NDMsNDAuOTI3LDM0LjcwMyw0MC45MjcsMzQuNzAzeiI+PC9wYXRoPjwvZz48L2c+PC9nPjwvZz48L3N3aXRjaD48L3N2Zz4="
                            },
                            "other": "question"
                        }
                    }
                }
            }
        }
    }
}

Mapping continuous values to icons

{
    "name": "my graph",
    "metadata": {},
    "edge_encodings": { "bindings": {"source": "s", "destination": "d"} },
    "node_encodings": {
        "bindings": {"node": "n"},
        "complex": {
            "default": {
                "pointIconEncoding": {
                    "graphType": "point",
                    "encodingType": "icon",
                    "attribute": "score",
                    "variation": "continuous",
                    "mapping": {
                        "continuous": {
                            "bins": [
                                [20, 'info'],
                                [80, 'exclamation-circle'],
                                [null, 'exclamation-triangle']
                            ],
                            "other": "question"
                        }
                    }
                }
            }
        }
    }
}

Complex icons encodings schema

Structure

Note the syntax switch from node to point:
{
    ["node_encodings" | "edge_encodings"]: {
        "complex": {
            ["default" | "current"]: {
                "(point|edge)IconEncoding": {
                    "graphType": "point" | "edge",
                    "encodingType": "icon",
                    "attribute": String,
                    ?"asText": Boolean,
                    ...( FixedMapping<Glyph> | ContinuousMapping<Glyph> )
                }
            }
        }
    }
}

Mapping: Categorical<T>

Map specific values, with an optional default:
{
    ?"attribute": String
    "variation": "categorical",
    "mapping": {
        "categorical": {
            "fixed": {
                [String]: T
            },
            ?"other": T
        }
    }
}

Mapping: Continuous<T>

Map value ranges, with optional comparator and default. If the last value range bin specifics null for the comparator, values above the previous sentinels will map to the last bin. This enables mapping unexpectedly high values to the last bin, while null values may be handled separately via an other mapping.
{
    ?"attribute": String,
    "variation": "continuous",
    "mapping": {
        "continuous": {
            "bins": [
                [Comparable | null, T]
            ],
            ?"other": T
        }
    }
}

Glyphs

Glyphs are automatically inferred based on their string value: To use uninterpreted text values, disable glyph inference by setting "asText": true