Git Product home page Git Product logo

vega / vega-lite Goto Github PK

View Code? Open in Web Editor NEW
4.5K 88.0 589.0 302.09 MB

A concise grammar of interactive graphics, built on Vega.

Home Page: https://vega.github.io/vega-lite/

License: BSD 3-Clause "New" or "Revised" License

JavaScript 0.97% CSS 0.63% HTML 0.97% Shell 0.51% TypeScript 96.91% Ruby 0.01%
visual-analysis visualization-grammar visualization vega charts declarative-language vega-lite plot

vega-lite's Introduction

Vega-Lite

npm version Build Status codecov code style: prettier JSDevlivr

Teaser

Vega-Lite provides a higher-level grammar for visual analysis that generates complete Vega specifications.

You can find more details, documentation, examples, usage instructions, and tutorials on the Vega-Lite website.

Try using Vega-Lite in the online Vega Editor.

Contributions are also welcome. Please see CONTRIBUTING.md for contribution and development guidelines and our Code of Conduct.

Read about future plans in our roadmap.

Team

The development of Vega-Lite is led by the alumni and members of the University of Washington Interactive Data Lab (UW IDL), including Kanit "Ham" Wongsuphasawat (now at Databricks), Dominik Moritz (now at CMU and Apple), Arvind Satyanarayan (now at MIT), and Jeffrey Heer (UW IDL).

Vega-Lite gets significant contributions from its community. Please see the contributors page for the full list of contributors.

Citing Vega-Lite

@article{2017-vega-lite,
  doi = {10.1109/tvcg.2016.2599030},
  year = {2017},
  author = {Arvind Satyanarayan and Dominik Moritz and Kanit Wongsuphasawat and Jeffrey Heer},
  title = {Vega-Lite: A Grammar of Interactive Graphics},
  journal = {{IEEE} Transactions on Visualization \& Computer Graphics (Proc. InfoVis)},
  url = {http://idl.cs.washington.edu/papers/vega-lite},
}

vega-lite's People

Contributors

akshatsh avatar amitkaps avatar arvind avatar bobocandys avatar chanwutk avatar chialingweng avatar dependabot-preview[bot] avatar dependabot[bot] avatar domoritz avatar greenkeeper[bot] avatar haldenl avatar hydrosquall avatar invokesus avatar jakevdp avatar jheer avatar joelostblom avatar kanitw avatar light-and-salt avatar lsh avatar marcprux avatar mattwchun avatar melissatdiamond avatar saba9 avatar sirahd avatar starry97 avatar swojit avatar willium avatar ydlamba avatar yhoonkim avatar yuhanlu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vega-lite's Issues

Column axis label are off.

{
  "marktype": "bar",
  "enc": {
    "x": {"name": "Cost__Total_$","type": "Q","aggr": "sum"},
    "y": {"name": "Effect__Amount_of_damage","type": "O"},
    "row": {"name": "Wildlife__Size","type": "O"},
    "col": {"name": "When__Phase_of_flight","type": "O"}
  },
  "cfg": {"dataUrl": "data/birdstrikes.json"}
}

vega_live_editor

there is no offset property …. we might need to create a group for this.

Error Management

throw error when

  • unsupported encoding is assigned to a particular mark type
  • we cannot load data #43
  • throw error if a variable field is not found.
  • throw error if timeUnit is used with non-T type.

Height Calculation is broken with binning

{
  "marktype": "point",
  "enc": {
    "x": {"name": "Cost__Total_$","type": "Q"},
    "y": {"name": "Cost__Repair","type": "O","bin": true},
    "color": {"name": "Effect__Amount_of_damage","type": "O"}
  },
  "cfg": {"dataUrl": "data/birdstrikes.json"}
}

screen shot 2014-12-09 at 10 22 45 am

——
Debugging Notes

Root cause is in setSize

Calculated Field

This is straightforward in vega, but need to introduce new syntax

Position of the x-axis for small multiples

{
  "marktype": "bar",
  "enc": {
    "x": {"name": "Cost__Total_$","type": "Q","aggr": "sum"},
    "y": {"name": "Effect__Amount_of_damage","type": "O"},
    "row": {"name": "Wildlife__Size","type": "O"}
  },
  "cfg": {"dataUrl": "data/birdstrikes.json"}
}

vegalite_ui

Fix Stacked Chart’s scale for small multiples

{
  "marktype": "bar",
  "enc": {
    "x": {"name": "Cost__Total_$","type": "Q","aggr": "sum"},
    "y": {"name": "Effect__Amount_of_damage","type": "O"},
    "row": {"name": "Wildlife__Size","type": "O"},
    "col": {"name": "When__Phase_of_flight","type": "O"},
    "color": {"name": "When__Time_of_day","type": "O"}
  },
  "cfg": {"dataUrl": "data/birdstrikes.json"}
}

get the following scale

vegalite_ui

Meanwhile, if we remove color

{
  "marktype": "bar",
  "enc": {
    "x": {"name": "Cost__Total_$","type": "Q","aggr": "sum"},
    "y": {"name": "Effect__Amount_of_damage","type": "O"},
    "row": {"name": "Wildlife__Size","type": "O"},
    "col": {"name": "When__Phase_of_flight","type": "O"}
  },
  "cfg": {"dataUrl": "data/birdstrikes.json"}
}

vegalite_ui

The scale is nicer.

Supporting labeling for all basic charts

Just always put numbers outside like I add 28, 55 below (same for all bars — I’m just adding this by hand so I added only the first two.)

vega_editor

  • try extending vega output for the “bar” example with another marks group for showing the label with some offset
  • modify the code (more details soon)
    • add label encoding channel to channel.ts and the schema
    • extend marks.ts

Remove small multiple axes spacing

{
  "marktype": "bar",
  "enc": {
    "x": {"name": "Cost__Total_$","type": "Q","aggr": "sum"},
    "y": {"name": "Effect__Amount_of_damage","type": "O"},
    "row": {"name": "Wildlife__Size","type": "O"},
    "col": {"name": "When__Phase_of_flight","type": "O"}
  },
  "cfg": {"dataUrl": "data/birdstrikes.json"}
}

vegalite_ui

Another case: (probably a different bug)

{
  "marktype": "bar",
  "enc": {
    "x": {"name": "Cost__Total_$","type": "Q","aggr": "sum"},
    "y": {"name": "Effect__Amount_of_damage","type": "O"},
    "col": {"name": "When__Phase_of_flight","type": "O"}
  },
  "cfg": {"dataUrl": "data/birdstrikes.json"}
}

vegalite_ui

Basic Table Support

For encoding = text, do not rotate x axis label.
But wrap / truncate text instead.

{
  "marktype": "text",
  "enc": {
    "x": {"name": "Major_Genre","type": "O"},
    "y": {"name": "Creative_Type","type": "O"},
    "text": {"name": "US_Gross","type": "Q","aggr": "avg"}
  },
  "cfg": {"dataUrl": "data/movies.json","cellHeight": "400","cellWidth": "400"}
}
  • make text doesn’t support x, y
  • remove padding for axes
  • adjust cell-size based on text
  • format number

Small Multiples Vertical Bar starts from top instead of bottom.

{
  "marktype": "bar",
  "enc": {
    "x": {"name": "Effect__Amount_of_damage","type": "O"},
    "y": {"name": "Cost__Total_$","type": "Q","aggr": "sum"},
    "row": {"name": "Cost__Other","type": "O"},
    "col": {"name": "When__Time_of_day","type": "O"},
    "color": {"name": "Wildlife__Size","type": "O"}
  },
  "cfg": {"dataUrl": "data/birdstrikes.json"}
}

screen shot 2014-12-01 at 10 54 44 am

Scale type

Some from linear, log, pow, sqrt, quantile, quantize, and threshold.

linear & log are probably the most important

Basic Support for Time Type

Currently, using T leads to Unrecognized interval error when I try point.x-year-T.

TODO

  • Parse Date
  • Discrete Binning (bin by "month", "year", "day", "date", "hour", "minute", “second” )
    • same month in different year are in the same bin.
  • custom scale for axis and legend names

"stack" control

  • whether to stack or not

By default would "auto" choose to stack based on mark (current behavior)
If true, stack regardless of mark type
If false, do not stack for any mark type

  • sortby

Chart Composition (Multiple X,Y s – layering / juxtaposition)

Common Refactor

  • distinguish between general model and a Single unit model
    • General model: produces scale, axis, legends
    • Single unit model: produces marks (and possibly others)
  • layout
  • data
  • facet
    • re-compile row and column to use facet
    • rewrite facet.ts

Sub-issues

  • layering #585
  • multiple x,y on the same axis
  • dual axes

Do I understand binning correctly?

I'm just trying to confirm the semantics of binning.

To create a histogram, we need to use the same column for x and y (y could also be another quantitative field) and choose to bin x and sum y (in some cases another aggregation might make sense). Also, we need to set the type of the binned field to O to fix the labels. I believe at some point we want to show labels that show the range and not hide groups with no values but we can leave that for later.

Vegalite atomically chooses a good bin size that optimizes for 1) not too many bins 2) nice bin widths (based on the base, usually 10). The only input to this binning function are the min and max.

screen shot 2014-12-12 at 17 22 19

sqlite> select cast((Cost__Repair-25000)/500000 as int)*500000, sum(Cost__Repair) from birdstrikes_json group by cast((Cost__Repair-25000)/500000 as int);
0|9227604
500000|5519778
1500000|2762200
1500000|1715077
3000000|6390178
3500000|3644483
7000000|7043545

Choosing two ordinals only makes sense if we also add alpha, size, or a color scale to show the count (without a field). As an alternative, we could use the sum, max, ... of the quantitative scale to map to the alpha, size, or color. But it will never make sense to use another field that we haven't used (?).

screen shot 2014-12-12 at 17 40 50

screen shot 2014-12-12 at 17 47 30

What I'm trying to understand is what the limitations are and what things we can propagate automatically (or disable in the interface). I'm not yet seeing the generalized rules but will think more about this.

Test Suite

  • test.js — run test case. Throw error / create output html page to show mismatches.
  • gen.js — generate vega specs based on input in /vega/ and output to /vegalite or add test case (given an encoding, automatically create files in /vega and /vegalite with appropriate names

Support sorting (for interactions)

apply sort transform first (and then use “index” to sort axis)??

  • It would be also nice to be able to control order of line group
    for example, we can we encoding time along the line

By default, scatter plots should use opacity

Otherwise marks are unreadable.

Is there a story for changing the visualization depending on the data? I imagine that it would be great to change for example the color mapping if there are negative values. Or use a log scale if the data has only few large values.

UI Improvements

  • editor mode (paste a code to update the UI based on the input vegalite code.) 12b8123
  • transpose (button for swapping X,Y encodings) 2e4b4df

Control

  • split function into aggregate functions and non-aggregate functions @kanitw

  • agg: min, max, avg

  • non-agg: math functions, bin

  • Drag & Drop to swap encoding

  • Add better UI for adjusting common defaults?
    This could be toggle-able panel appearing beneath the encoding shelves

    Add slider to set default opacity
    Add slider for default point size
    Add x/y axis controls (zero, reverse, log)
    Default font, size controls

Prevent Errors

  • disable unsupported encoding based on the selected mark types.
  • Hide unsupported type based on data column & encoding type.
  • Hide unsupported functions based on data column & encoding type.
  • prevent casting to ordinal with binning ?

Productivity

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.