timothyrenner / svl

A declarative language for dashboards and reports
https://timothyrenner.github.io/svl
MIT License
8 stars 1 forks source link

Tile Maps #69

Open timothyrenner opened 4 years ago

timothyrenner commented 4 years ago

It's time.

Add leaflet visualizations.

Proposed Syntax

1.

TILEMAP bigfoot
    GEOMETRY hexagon
    COLOR BY num_reports
    TILES "Stamen Toner"

Here GEOMETRY indicates a column with serialized geometries, and should support WKT or GeoJSON. TILES indicates which tile style 😎 to use, but has a default. COLOR BY works just like you'd expect, coloring the lines and polygon fills, unless either is explicitly declared (see "aesthetics" below).

2.

TILEMAP bigfoot
    LATITUDE lat
    LONGITUDE lon
    SPLIT BY classification
    TOOLTIP report_title

A second variant to be used if you just want to drop points on the map. LATITUDE and LONGITUDE are hopefully self explanatory. TOOLTIP shows which fields should be used for tooltip content. I see no reason why TOOLTIP can't be used multiple times.

Aesthetics

These should be adjustable, but I'm not sure what they'd look like syntactically yet.

Generically, they're grouped like this:

Open Questions

This is a very heavy add, with lots of new syntax and an entirely new Javascript / HTML / CSS component.

timothyrenner commented 4 years ago

Proposed Aesthetic Syntax

SIZE - column or value. Sets the point size for points, line width for lines and polygons. It's unclear how to scale this.

ALPHA - column or value. Sets the alpha value for points and lines. For polygons, sets the alpha of both the line and fill, effectively removing the outline.

COLOR - column or value. Sets the color for points and lines. For polygons, sets the color of both the line and fill. If the argument is a column, it's equivalent to COLOR BY.

FILL ALPHA - column or value. Sets the fill alpha for polygons. Ignored by lines and points. Overrides the ALPHA value if both are specified. For polygons if both are specified, effectively this means ALPHA controls the outline, and FILL ALPHA controls the fill.

FILL COLOR - column or value. Sets the fill color for polygons. Ignored by lines and points. Overrides the COLOR value if both are specified. For polygons if both are specified, effectively this means COLOR controls the outline and FILL COLOR controls the fill.

timothyrenner commented 4 years ago

Examples

Points colored by report classification with tooltips for the report titles.

TILEMAP bigfoot
    LATITUDE latitude
    LONGITUDE longitude
    SPLIT BY classification
    TOOLTIP report_title

Same thing, but with GEOMETRY.

TILEMAP bigfoot
    GEOMETRY location_point
    SPLIT BY classification
    TOOLTIP report_title

Lines with width proportional to a numerical value (I have no idea how to actually scale these values to a width but I'm gonna wing it).

TILEMAP bigfoot_paths
    GEOMETRY migration_paths
    SIZE number_of_sightings

Point size porportional to a numerical value.

TILEMAP bigfoot
    LATITUDE latitude
    LONGITUDE longitude
    SIZE number_of_sightings

Polygon line width proportional to a numeric value (I have no idea why this would be useful).

TILEMAP bigfoot_hexagons
    GEOMETRY hexagon
    SIZE number_of_sightings

... and that's all I can stand to do for now. More to come later.