require('lx')

Plotting the first point w/ the Vega ecosystem.

João Palmeiro | @joaompalmeiro | Research Intern @Feedzai

Agenda

  1. Framing
  2. Vega
  3. Examples
  4. Feedzai Charting Library KO
  5. Next steps?

Let's see code!

Bar chart


                {
                  "data": {
                    "url": ".../operations.csv",
                    "name": "operations"
                  }
                }
              

Bar chart


                {
                  "data": {
                    "url": ".../operations.csv",
                    "name": "operations"
                  },
                  "mark": {
                    "type": "bar", 
                    "color": "#f2af29"
                  }
                }
              

Bar chart


                  ...
                  "mark": {
                    "type": "bar", 
                    "color": "#f2af29"
                  },
                  "encoding": {
                    "x": {
                      "field": "emoji",
                      "type": "ordinal",
                      "axis": {
                        "title": "Sector", 
                        "labelAngle": 0
                      }
                    }
                  }
                }
              

Bar chart


                  ...
                  "encoding": {
                    "x": {
                      "field": "emoji",
                      "type": "ordinal",
                      "axis": {
                        "title": "Sector", 
                        "labelAngle": 0
                      },
                    },
                    "y": {
                      "field": "amount",
                      "type": "quantitative",
                      "axis": {
                        "title": "Amount (EUR)", 
                        "format": ".2s"
                      }
                    }
                  }
                }
              

Bar chart


                  ...
                  "encoding": {
                    "x": {
                      "field": "emoji",
                      "type": "ordinal",
                      "axis": {
                        "title": "Sector", 
                        "labelAngle": 0
                      },
                      "sort": {
                        "op": "count", 
                        "field": "amount", 
                        "order": "ascending"
                      }
                    },
                    ...
              

Bar chart


                  ...
                  "layer": [
                    {
                      "mark": {
                        "type": "bar", 
                        "color": "#f2af29"
                      },
                    },
                    {
                      "mark": {
                        "type": "text", 
                        "yOffset": -5
                      },
                      "encoding": {
                        "text": {
                          "field": "amount", 
                          "type": "quantitative", 
                          "format": ".2s"
                        }
                      ...
              

Bar chart


                  ...
                  "layer": [
                    {
                      "mark": {
                        "type": "bar", 
                        "color": "#f2af29"
                      },
                      "encoding": {
                        "tooltip": {
                          "field": "sector", 
                          "type": "ordinal"
                        }
                      }
                    ...
              

Bar chart


                  ...
                  "layer": [
                    {
                      "selection": {
                        "select": {
                          "type": "multi"
                        }
                      },
                      ...
                      "encoding": {
                        "fillOpacity": {
                          "condition": {
                            "selection": "select", 
                            "value": 1
                          },
                          "value": 0.3
                        },
                        ...
              

Bar chart ✔️

Lifecycle Methods Wrapping


            class Histogram extends React.Component {
              constructor(props) {
                  super(props);
                  this.histogramRef = React.createRef();
              }

              componentDidMount() {
                  this._createView();
              }
              componentDidUpdate() {
                  this._updateView();
              }
              componentWillUnmount() {
                  this._clearView();
              }
          
              render() {
                  return <div ref={this.histogramRef} />;
              }
            }