Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Showcase] Simple Timeseries #3

Open
yesoreyeram opened this issue Oct 8, 2020 · 0 comments
Open

[Showcase] Simple Timeseries #3

yesoreyeram opened this issue Oct 8, 2020 · 0 comments

Comments

@yesoreyeram
Copy link
Owner

yesoreyeram commented Oct 8, 2020

Sample Data

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {
    "values": [
      {"Value": 27, "seriesName": "Server A", "Time": "2010"},
      {"Value": 48, "seriesName": "Server B", "Time": "2010"},
      {"Value": 27, "seriesName": "Server C", "Time": "2010"},
      {"Value": 39, "seriesName": "Server D", "Time": "2010"},
      {"Value": 32, "seriesName": "Server E", "Time": "2010"},
      {"Value": 23, "seriesName": "Server A", "Time": "2015"},
      {"Value": 38, "seriesName": "Server B", "Time": "2015"},
      {"Value": 11, "seriesName": "Server C", "Time": "2015"},
      {"Value": 39, "seriesName": "Server D", "Time": "2015"},
      {"Value": 12, "seriesName": "Server E", "Time": "2015"},
      {"Value": 37, "seriesName": "Server A", "Time": "2020"},
      {"Value": 28, "seriesName": "Server B", "Time": "2020"},
      {"Value": 17, "seriesName": "Server C", "Time": "2020"},
      {"Value": 19, "seriesName": "Server D", "Time": "2020"},
      {"Value": 52, "seriesName": "Server E", "Time": "2020"}
    ]
  },
}

Line chart 1

image

{
  "mark": "line",
  "encoding": {
    "y": {
      "field": "Value", 
      "type":"quantitative"
    },
    "x":{
      "field":"Time",
      "type":"temporal"
    },
    "color":{
      "field":"seriesName",
      "type":"nominal"
    }
  }
}

point chart

image

  "mark": "point",
  "encoding": {
    "y": {
      "field": "Value", 
      "type":"quantitative"
    },
    "x":{
      "field":"Time",
      "type":"temporal"
    },
    "color":{
      "field":"seriesName",
      "type":"nominal"
    }
  }

Point and line

image

{
  "layer":[
    { 
      "mark":"line"
    },
    { 
      "mark":"point"
    }
  ],
  "encoding": {
    "y": {
      "field": "Value", 
      "type":"quantitative"
    },
    "x":{
      "field":"Time",
      "type":"temporal"
    },
    "color":{
      "field":"seriesName",
      "type":"nominal"
    }
  }
}

Bar chart

image

{
 "layer":[
    { 
      "mark":"bar"
    }
  ],
  "encoding": {
    "y": {
      "field": "Value", 
      "type":"quantitative"
    },
    "x":{
      "field":"Time",
      "type":"temporal"
    },
    "color":{
      "field":"seriesName",
      "type":"nominal"
    }
  }

Horizontal bar chart

image

{
 "layer":[
    { 
      "mark":"bar"
    }
  ],
  "encoding": {
    "x": {
      "field": "Value", 
      "type":"quantitative"
    },
    "y":{
      "field":"Time",
      "type":"temporal"
    },
    "color":{
      "field":"seriesName",
      "type":"nominal"
    }
  }
}

Horizontal bar chart with year as column

image

{
"mark": "bar",
  "encoding": {
    "y": {
      "field": "seriesName", "type": "nominal"
    },
    "x":{
      "field":"Value",
      "type":"quantitative"
    },
    "color":{
      "field":"Time",
      "type":"nominal"
    }
  }

Stacked area chart

image

{
  "mark": "area",
  "encoding": {
    "x": {
      "field": "seriesName", "type": "nominal"
    },
    "y":{
      "field":"Value",
      "type":"quantitative"
    },
    "color":{
      "field":"Time",
      "type":"nominal"
    }
  }
}

Horizontal bar chart with year as y axis

image

{
  "mark": "bar",
  "encoding": {
    "y": {
      "field":"Time",
      "type":"nominal"
    },
    "x":{
      "field":"Value",
      "type":"quantitative"
    },
    "color":{
      "field": "seriesName", 
      "type": "nominal"
    }
  }
}

Max of each server

image

{
"mark": "bar",
  "encoding": {
    "y": {
      "field":"seriesName",
      "type":"nominal"
    },
    "x":{
      "field":"Value",
      "type":"quantitative",
      "aggregate":"max"
    }
  }

Max of each year

image

{
   "mark": "bar",
  "encoding": {
    "y": {
      "field":"Time",
      "type":"nominal"
    },
    "x":{
      "field":"Value",
      "type":"quantitative",
      "aggregate":"max"
    }
  }
}

Bucketing

image

{
"layer":[
    { 
      "mark":"circle"
    }
  ],
  "encoding": {
    "x": {
      "field": "Value", 
      "type":"quantitative"
    },
    "color":{
      "field":"seriesName",
      "type":"nominal"
    }
  }
}

Heat map

image

"mark": "bar",
  "encoding": {
    "x": {
      "field":"Time",
      "type":"nominal"
    },
    "y":{
      "field":"seriesName",
      "type":"nominal"
    },
    "color":{
      "field":"Value",
      "type":"quantitative"
    }
  }
}

Heatmap 2

image

{
 "mark": "bar",
  "encoding": {
    "x": {
      "field":"Time",
      "type":"nominal"
    },
    "y":{
      "field":"seriesName",
      "type":"nominal"
    },
    "color":{
      "field":"Value",
      "type":"quantitative",
      "scale": {"range": ["lightgreen", "red"]}
    }
  }
}

Heatmap 3

image

{
"mark": "circle",
  "encoding": {
    "x": {
      "field":"Time",
      "type":"nominal"
    },
    "y":{
      "field":"seriesName",
      "type":"nominal"
    },
    "size":{
      "value": 120
    },
    "color":{
      "legend":null,
      "field":"Value",
      "type":"quantitative",
      "scale": {"range": ["lightgreen", "red"]}
    }
  }
}

Simple pie chart with mean of each server

image

{
      "mark": "arc",
      "encoding": {
        "theta": {"field": "Value", "type": "quantitative", "aggregate":"mean"},
        "color": {"field": "seriesName", "type": "nominal"}
      }
    }

image

{
      "mark": "arc",
      "encoding": {
        "radius": {"field": "Value", "type": "quantitative", "aggregate":"mean"},
        "color": {"field": "seriesName", "type": "nominal"}
      }
    }

Box Plot

image

{
  "mark": {"type": "boxplot", "extent": "min-max"},
  "encoding": {
    "y": {"field": "seriesName", "type": "nominal"},
    "color":{
      "field":"seriesName"
    },
    "x": {
      "field": "Value",
      "type": "quantitative",
      "scale": {"zero": false, "domainMin": 0}
    }
  }
}

Average and individual metrics

image

{
 "layer":[
    {
      "mark":"line",
      "encoding":{
        "x":{ "field":"Time", "type":"temporal" },
        "y":{ "field":"Value", "type":"quantitative", "aggregate":"average" },
        "color":{ "value":"green" }
      }
    },
    {
      "mark":"line",
      "encoding":{
        "x":{ "field":"Time", "type":"temporal" },
        "y":{ "field":"Value", "type":"quantitative", "aggregate":"min" },
        "color":{ "value":"lightgreen" }
      }
    },
    {
      "mark":"line",
      "encoding":{
        "x":{ "field":"Time", "type":"temporal" },
        "y":{ "field":"Value", "type":"quantitative", "aggregate":"max" },
        "color":{ "value":"darkgreen" }
      }
    },
    {
      "mark": {
        "type":"point",
        "opacity":0.5
      },
      "encoding":{
        "x":{ "field":"Time", "type":"temporal" },
        "y":{ "field":"Value", "type":"quantitative" },
        "color":{ "field":"seriesName", "type": "nominal" }
      }
    }
  ]
}

Horizontal stacked bar chart

image

{
"mark": "bar",
  "encoding": {
    "x": {
      "field":"seriesName",
      "type":"nominal",
      "title":null
    },
    "column": {
      "field": "Time", 
      "type": "ordinal"
    },
    "y":{
      "field":"Value",
      "type":"quantitative",
      "title":"Value"
    },
    "color":{
      "field": "seriesName"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant