Skip to content

Instantly share code, notes, and snippets.

@nyurik
Created November 13, 2018 19:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyurik/c37a0ce6a5259109d8b3800986f1e38f to your computer and use it in GitHub Desktop.
Save nyurik/c37a0ce6a5259109d8b3800986f1e38f to your computer and use it in GitHub Desktop.
Kibana rotating cloropleth world map
{
$schema: https://vega.github.io/schema/vega/v3.json
padding: 10
config: {
kibana: {tooltips: false}
}
signals: [
{
name: rotation
value: 65
bind: {input: "range", min: -180, max: 180}
}
]
data: [
{
name: events
url: {
%context%: true
%timefield%: @timestamp
index: logstash-*
body: {
size: 0
aggs: {
by_country: {
terms: {
field: geoip.country_code2.keyword
size: 500
order: {_count: "desc"}
}
}
}
}
}
format: {property: "aggregations.by_country.buckets"}
}
{
name: sphere
values: [
{type: "Sphere"}
]
}
{
name: countries
url: {%type%: "emsfile", name: "World Countries"}
format: {property: "features"}
transform: [
{
type: formula
expr: datum.properties.iso2
as: countryCode
}
{
type: lookup
from: events
key: key
fields: ["countryCode"]
values: ["doc_count"]
as: ["count"]
}
]
}
]
projections: [
{
name: projection
scale: {signal: "min(width,height)/2*0.9"}
type: orthographic
translate: {signal: "[width/2, height/2]"}
rotate: [
{signal: "rotation"}
-20
0
]
}
]
scales: [
{
name: color
type: sqrt
domain: {data: "countries", field: "count"}
range: {scheme: "Reds"}
}
]
marks: [
{
type: shape
from: {data: "sphere"}
encode: {
update: {
fill: {value: "aliceblue"}
stroke: {value: "black"}
strokeWidth: {value: 1.5}
}
}
transform: [
{type: "geoshape", projection: "projection"}
]
}
{
type: shape
from: {data: "countries"}
encode: {
update: {
fill: {field: "count", scale: "color"}
stroke: {value: "black"}
strokeWidth: {value: 0.35}
tooltip: {
signal:
'''
{
title: datum.properties.name,
code: datum.countryCode,
count: datum.count,
}
'''
}
}
}
transform: [
{type: "geoshape", projection: "projection"}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment