• Stars
    star
    103
  • Rank 331,183 (Top 7 %)
  • Language
    JavaScript
  • License
    BSD 3-Clause "New...
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A grammar and recommender system for animated transitions in Vega/Vega-Lite

Gemini²

Gemini² extends Gemini to support keyframe-oriented animated transition between single-view Vega/Vega-Lite charts. This repository contains the source code of Gemini and Gemini².

Compile And Play Animated Transitions With The Gemini Grammar

<head>
  <script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
  <script src="https://cdn.jsdelivr.net/npm/vega-lite@4"></script>
  <script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
  <script src="https://d3js.org/d3.v6.min.js"></script>
  <script src="../gemini.web.js" ></script>

</head>
<body>
  <div id="view"></div>
  <script>

  const gemSpec = {
    "timeline": {
      "sync": [
        {"component": {"axis": "x"}, "timing": {"duration": 1000}},
        {"component": {"mark": "marks"}, "timing": {"duration": 1000}}
      ]
    }
  };
  const data = { values: [{"Hungry": 50, "Name": "Gemini"}, {"Hungry": 100, "Name": "Cordelia"}] };
  const sSpec = {
    data: data,
    mark: "bar",
    encoding: {
      x: { field: "Hungry", type: "quantitative"},
      y: { field: "Name", type: "nominal"}
    }
  }
  const eSpec = {
    data: data,
    mark: "bar",
    encoding: {
      x: { field: "Hungry", type: "quantitative"},
      y: { field: "Name", type: "nominal"}
    }
  }
  vegaEmbed("#view", sSpec, {renderer: "svg"})
  async function play() {
    let anim = await gemini.animate(sSpec, eSpec, gemSpec);
    await anim.play("#view")
  }

  </script>
</body>

Gemini APIs


Animate

# gemini.animate(start, end, spec) <>

Compile the Gemini spec for the transition between the start and end Vega visualizations to an Animation object.

Input

Parameter Type Description
start Object A Vega/Vega-Lite visualization spec* for the start state.
end Object A Vega/Vega-Lite visualization spec* for the end state.
spec Object A Gemini spec for the animation design.

*📢 Notes

  • The start/end visualizations should be Vega specifications having unique names on marks/axes/legend components.
  • The current version of Gemini only supports the single-view Vega charts, which contain no more than one x-axis and one y-axis.

See more details here.

Output

It returns a promise that triggers then with an animation object when it compiles successfully. The animation object can be played.

# gemini.animateSequence(chartSequence, animSpecs) <>

Compile the Gemini specs for the Vega chart sequence to an AnimationSequence object.

Input

Parameter Type Description
chartSequence Array An array Vega/Vega-Lite visualization specs. The compiled animation will uses them as keyframes.
animSpecs Array An array of Gemini animation specs for adjacent keyframes. For a sequence of N visualizations, N-1 Gemini specs are required.

Output

It returns a promise that triggers then with an animationSequence object when it compiles successfully. The animationSequence object can be played.

# animation.play(target) <>

Play the compiled animation at the place where the start Vega visualization is embedded.

Input

Parameter Type Description
target String A CSS selector string to select the target DOM. The start Vega visualization must be embedded at the target DOM.

Output

It returns a promise that triggers then when it completes the animation play. The promise has no success value.


Automate

# gemini.recommend(start, end, options) <>

Enumerates the candidate animation designs of the transition between the given two Vega visualizations in Gemini grammar. It sorts the candidates by their evaluated effectiveness.

Input

Parameter Type Description
start Object A Vega visualization spec for the start state.
end Object A Vega visualization spec for the end state.
options Object Options for the recommendations. See below.
let options = {
  stageN: ...,
  scales: {
    __scaleName__: { domainDimension: ... },
    ...
  },
  marks: {
    __markName__: { change: { data: [ ... ] } },
    ...
  },
  totalDuration: ...,
  includeMeta: ...
}
Property Type Description
stageN Integer The number of stages of the recommended animation design.(Default: 2)
totalDuration Number The total duration of the recommended animation design in milliseconds. (Default: 2000ms)
scales Object Set change.domainDimension of the scale(__scaleName__)'s corresponding axis component.
marks Object Set change.data of the corresponding mark component (__markName__). (Default: undefined which using the indices of the data as the join key.)
includeMeta Bool Include the meta information such as evaluated costs of each step and the whole design. (Default: false)

Output

It returns an array of objects ({spec: ...}), where spec is the Gemini spec.

# gemini.canRecommend(start, end, stageN) <>

Determine if the given inputs are valid to get recommendations.

Input

Parameter Type Description
start Object A Vega/Vega-Lite visualization spec for the start state.
end Object A Vega/Vega-Lite visualization spec for the end state.
stageN Number The number of stages for recommendations.

Output

{
  "result": false, // boolean. true: Gemini can recommend, false: cannot
  "reason": ... // string or undefined when result===true.
}

# gemini.recommendForSeq(sequence, options) <>

Enumerates the candidate animation designs of given Vega/Vega-Lite visualization sequence (keyfreame sequence). It sorts the candidates by their evaluated effectiveness.

Input

Parameter Type Description
sequence Array An Vega/Vega-Lite visualization array.
options Object Options for the recommendations. Same as the .recommend's options.

Output

{
  "specs": [ {"spec": geminiSpec, ... }, ...],
  "cost": Number //total complexity of the gemini specs
}

# gemini.canRecommendForSeq(sequence) <>

Determine if the given inputs are valid to get recommendations.

Input

Parameter Type Description
sequence Array An array of Vega/Vega-Lite visualization specs.

Output

{
  "result": false, // boolean. true: Gemini can recommend, false: cannot
  "reason": ... // string or undefined when result===true.
}

# gemini.recommendKeyframes(start, end, keyframeM) <>

By leveraging GraphScape, it enumerates the candidate keyframe sequences (Vega-Lite visualization sequences) for given start and end Vega-Lite charts. It sorts the candidates by their evaluated effectiveness.

Input

Parameter Type Description
start Object A Vega-Lite visualization spec for the start state.
end Object A Vega-Lite visualization spec for the end state.
keyframeM Number The number of sub-transitions between adjacent keyframes. For example, keyframeM=2 means to 3 keyframes per sequence. If it is undefined, it returns all possible keyframe sequences with key-value pair.

Output

If keyframeM is specified, it returns a path array (Array<Path>). If not, it returns object having possible keyframeMs and corresponding paths as keys and values({ "1": Array<Path>, "2": ..., ...})

Each Path has these properties:

{
  "sequence": [startChart, ..., endChart ],
  // The partition of the edit operations from the start and the end.
  "editOpPartition": [editOpArray1, ..., editOpArrayM],

  "eval": {
    // GraphScape's heuristic evaluation score for this path. Higher means better.
    "score": 1, //Number
    "satisfiedRules": ... // The reasons for the scores.
  }
}

# gemini.canRecommendKeyframes(start, end) <>

Determine if the given inputs are valid to get recommendations.

Input

Parameter Type Description
start Object A Vega/Vega-Lite visualization spec for the start state.
end Object A Vega/Vega-Lite visualization spec for the end state.

Output

{
  "result": false, // boolean. true: Gemini can recommend, false: cannot
  "reason": ... // string or undefined when result===true.
}

# gemini.recommendWithPath(start, end, option) <>

Enumerates the candidate keyframe sequences (Vega-Lite visualization sequences) with Gemini animation specs for given start and end Vega-Lite charts. It sorts the candidates by their evaluated effectiveness.

Input

Parameter Type Description
start Object A Vega-Lite visualization spec for the start state.
end Object A Vega-Lite visualization spec for the end state.
option Object Options for the recommendations. Same as the .recommend's options.

Output

It returns object with the number of sub-transitions and corresponding recommendations for each Path as keys and values:

{
  "1": [ {"path": path_1_1, "recommendations": recomsForPath_1_1}, ...],
  "2": [ {"path": path_2_1, "recommendations": recomsForPath_2_1}, ...],
  ...
}

Utility

# gemini.vl2vg4gemini(vlSpec) <>

Compile the given vega-lite spec to the vega spec with the necessary information for Gemini, such as each component's name.

Cite us!

If you use Gemini in published research, please cite these papers: 1, TBD.

More Repositories

1

visualization-curriculum

A data visualization curriculum of interactive notebooks.
Jupyter Notebook
1,275
star
2

arquero

Query processing and transformation of array-backed data tables.
JavaScript
1,251
star
3

mosaic

An extensible framework for linking databases and interactive views.
JavaScript
688
star
4

draco

Visualization Constraints and Weight Learning
TypeScript
222
star
5

d3-tutorials

D3 Tutorials for CSE512 Data Visualization Course at University of Washington
HTML
170
star
6

imMens

Real-Time Visual Querying of Big Data
HTML
168
star
7

living-papers

Authoring tools for scholarly communication. Create interactive web pages or formal research papers from markdown source.
TeX
128
star
8

termite-data-server

Data Server for Topic Models
Python
120
star
9

errudite

An Interactive Tool for Scalable and Reproducible Error Analysis.
Python
104
star
10

vsup

Code for generating Value-Suppressing Uncertainty Palettes for use in D3 charts.
JavaScript
77
star
11

latent-space-cartography

Visual analysis of vector space embeddings
HTML
74
star
12

setcola

High-Level Constraints for Graph Layout
JavaScript
72
star
13

boba

Specifying and executing multiverse analysis
Python
62
star
14

termite-visualizations

[development moved to termite-data-server]
Python
61
star
15

rev

REV: Reverse-Engineering Visualizations
Python
60
star
16

graphscape

A directed graph model of the visualization design space, using Vega-Lite.
JavaScript
58
star
17

fast-kde

Fast, approximate Gaussian kernel density estimation.
JavaScript
56
star
18

bayesian-surprise

Bayesian Weighting for De-Biasing Thematic Maps
TeX
54
star
19

gestrec

A JavaScript implementation of the Protractor gesture recognizer.
JavaScript
36
star
20

perceptual-kernels

Data & source code for the perceptual kernels study
HTML
33
star
21

ellipsis

Visualization Storytelling Components
JavaScript
31
star
22

visual-embedding

Data & source code for the visual embedding model
MATLAB
31
star
23

boba-visualizer

A visual analysis tool for exploring multiverse outcomes
JavaScript
31
star
24

papers-vsup

Visualize uncertainty
TeX
27
star
25

arquero-sql

Database backend support for Arquero
JavaScript
24
star
26

color-naming-in-different-languages

JavaScript
24
star
27

arquero-worker

Worker thread support for Arquero.
JavaScript
22
star
28

living-papers-template

A Living Papers article starter template.
22
star
29

mosaic-framework-example

Using Mosaic and DuckDB within Observable Framework
TypeScript
22
star
30

dziban

Context-Aware, Recommender-Powered Visualization Authoring
Jupyter Notebook
21
star
31

draco-vis

Draco on the web
TypeScript
18
star
32

flechette

Fast, lightweight access to Apache Arrow data.
JavaScript
18
star
33

diagnostics

Topic Model Diagnostics
JavaScript
14
star
34

vegaserver

A simple node server that renders vega specs to SVG or PNG.
JavaScript
13
star
35

visual-encoding-effectiveness-data

Supplement material for "Assessing Effects of Task and Data Distribution on the Effectiveness of Visual Encodings".
JavaScript
13
star
36

divi

Automatically interact with SVG charts.
JavaScript
10
star
37

quantitative-color-data

Data for quantitative colormap study
R
10
star
38

citation-query

Retrieve paper citatation data from doi.org and Semantic Scholar.
JavaScript
10
star
39

arquero-arrow

Arrow serialization support for Arquero.
JavaScript
9
star
40

verp

The VERP Explorer
JavaScript
8
star
41

termite-stm

[development moved to termite-data-server]
Python
8
star
42

code-augmentation

Code augmentation editor
JavaScript
7
star
43

aggregate-animation-data

Supplement material for "Designing Animated Transitions to Convey Aggregate Operations"
JavaScript
7
star
44

vega-dataflow

Reactive dataflow processing.
JavaScript
7
star
45

trend-bias

Experiments on trend-fitting
TeX
6
star
46

termite-treetm

[development moved to termite-data-server]
Python
6
star
47

flights-arrow

Flight Dataset as Apache Arrow in Different Sizes
6
star
48

living-papers-paper

The UIST'23 Living Papers research paper and supplemental material.
JavaScript
5
star
49

fast-kde-benchmarks

Research archive of methods and benchmarks for fast, approximate Gaussian kernel density estimation.
JavaScript
5
star
50

gemini-supplemental-material

Supplemental material for "Gemini: A Grammar and Recommender System for Animated Transitions in Statistical Graphics"
HTML
5
star
51

uwdata.github.io

UW Interactive Data Lab web page
Svelte
5
star
52

palette-analyzer

Analyzes the local and global distances in [RGB, LAB, UCS, Color Names] model, given a palette.
HTML
5
star
53

draco-learn

Learning Weights for Draco
Python
4
star
54

draco-editor

The Draco Online Editor
CSS
4
star
55

datalib

We've moved! Please see https://github.com/vega/datalib
3
star
56

file-cache

File-based cache for JSON-serializable data.
JavaScript
3
star
57

istc-explorer

JavaScript
2
star
58

draco-analysis

Notebooks for Draco
Jupyter Notebook
2
star
59

draco-tools

Tools for Draco
JavaScript
2
star
60

living-papers-examples

Example Living Papers Articles
JavaScript
2
star
61

draco-tuner

An interactive application to modify Draco's knowledge base
TypeScript
1
star