Skip to content

Latest commit

 

History

History
88 lines (69 loc) · 6.07 KB

IDEAS.org

File metadata and controls

88 lines (69 loc) · 6.07 KB

language

  • mostly everything in js?
  • interfaces in R/Python/Julia?

syntax

defaults could be specified as follows (should be specified in a JSON file, maybe extend Vega format?) for sharing we could store this file in a git repos (on github? http://fitzgen.github.io/github-api/)

list(
 lines=aplot(first_mapping=aes(x=year, y=life.expectancy, color=region),
  geom_line(data=WorldBank, size=4, first_mapping=aes(clickSelects=country)), # 4 pixels -- not passed through a scale.
  geom_tallrect(data=years), # needs year_xmax and year_xmin columns,
  # ignores aes(color) since there is no color column
  # aes(x) is plot-specific but aes(clickSelects) is layer-specific.
 points=aplot(first_mapping=aes(x=birth.rate, y=life.expectancy, color=region, size=population),
  # aes generate axes or guides.
  geom_point(data=WorldBank, showSelected(year), encode=vars(color, size)),
  # points always take x and y, this one also takes optional data color, size
  geom_text(data=WorldBank, showSelected(year, country), first_mapping=aes(label=country)), # takes x, y, label
  geom_text(data=years, showSelected(year), x=0.5, y=1, first_mapping=aes(label=sprintf("year = %d")))
 )
)

but minimally we just specify the data sets and maybe some common scales… actually we could specify just a href to the data set

animint(data=list(years=years, WorldBank=WorldBank),
        scales=list(region.colors=region.colors))

and then on the web page we could interactively define the linked plots by filling in the following 2 tables (1 for each plot).

scale=region.colors
datageomx=yeary=life.expectancystroke=regionfillstroke-widthopacitygrouplabelclickSelectsshowSelected
/<<
WorldBanklineencodedencodedencoded-41country-country[]
(not selected)---same-same0.5----
yearstallrectencoded-“black”“black”10.5--year[]
(not selected)---samesamesame0----

and for the scatterplot,

scale=region.colors
datageomx=birth.ratey=life.expectancystrokefill=regionsize=populationstroke-widthopacitylabelclickSelectsshowSelected
/<<
WorldBankcircleencodedencoded“black”encodedencoded11-country[year]
(not selected)---samesame-01/2---
WorldBanktextencodedencoded-“black”12-1country(none)[year, country]
yearstext0.51-“black”12-1yearLabel(none)[year]

The main idea is that there are two kinds of aesthetics:

  • some plot-specific, each need an axis/legend to decode: x, y, stroke, fill, size, stroke-width, opacity.
  • some geom-specific: clickSelects, showSelected, group, label.

size aesthetic controls <text style=”font-size: $(size)px”&gt; and &lt;circle r=”$(size*2)”>

x=year with geom line assumes that WorldBank has a year column and with geom tallrect looks for columns named year_min and year_max in years.

x, y, size have 3 kinds of values:

unit typexsizeconstant?
datayear 19961e8 people
canonical[0, 1]30px circle diameteryes
svgx=243 (px)r=15 (px)

but stroke-width, stroke, fill, opacity only have 2 kinds of values

unit typestrokeconstant?
dataregion Europe
svg“red”yes

if we specify constants for these aesthetics, they should be interpreted as canonical (x, y, size) or svg (stroke-width, stroke, fill, opacity) values.

scales take units from the first row and give units in the second row.