Created
February 7, 2018 01:15
-
-
Save tsgkdt/c2a0667813d3927df4aa0503a6d43ed7 to your computer and use it in GitHub Desktop.
Kibana6.2.0で追加されたVega用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v2.json", | |
"title": "日経平均株価の推移", | |
"width": 1024, | |
"data": { | |
"url": { | |
"index": "stock", | |
"%context%": true, | |
"%timefield%": "timestamp", | |
"body": { | |
"aggs": { | |
"time_buckets": { | |
"date_histogram": { | |
"field": "timestamp", | |
"interval": "1d", | |
"extended_bounds": { | |
"min": {"%timefilter%": "min"}, | |
"max": {"%timefilter%": "max"} | |
}, | |
"min_doc_count": 0 | |
}, | |
"aggs": { | |
"high_value": {"avg": {"field": "high_value"}}, | |
"low_value": {"avg": {"field": "low_value"}}, | |
"end_value": {"avg": {"field": "end_value"}}, | |
"start_value": {"avg": {"field": "start_value"}}, | |
"moving": { | |
"moving_avg": { | |
"buckets_path": "moving_end", | |
"model": "simple", | |
"window": 25, | |
"settings": {} | |
} | |
}, | |
"moving_end": {"avg": {"field": "end_value"}} | |
} | |
} | |
} | |
}, | |
"size": 0 | |
}, | |
"format": {"property": "aggregations.time_buckets.buckets"} | |
}, | |
"transform": [ | |
{ | |
"calculate": "datum.start_value.value < datum.end_value.value", | |
"as": "isIncrease" | |
} | |
], | |
"layer": [ | |
{ | |
"mark": "rule", | |
"encoding": { | |
"x": { | |
"field": "key", | |
"type": "temporal", | |
"timeUnit": "yearmonthdate", | |
"axis": {"format": "%m/%d", "title": "月/日"} | |
}, | |
"y": { | |
"field": "low_value.value", | |
"type": "quantitative", | |
"scale": {"zero": false}, | |
"axis": {"title": ""} | |
}, | |
"y2": { | |
"field": "high_value.value", | |
"type": "quantitative" | |
}, | |
"color": { | |
"field": "isIncrease", | |
"type": "nominal", | |
"scale": {"range": ["#ae1325", "#06982d"]}, | |
"legend": null | |
} | |
} | |
}, | |
{ | |
"mark": "bar", | |
"encoding": { | |
"x": { | |
"field": "key", | |
"type": "temporal", | |
"timeUnit": "yearmonthdate" | |
}, | |
"y": { | |
"field": "start_value.value", | |
"type": "quantitative" | |
}, | |
"y2": { | |
"field": "end_value.value", | |
"type": "quantitative" | |
}, | |
"size": {"value": 5}, | |
"color": { | |
"field": "isIncrease", | |
"type": "nominal", | |
"legend": null | |
} | |
} | |
}, | |
{ | |
"mark": { | |
"type":"line", | |
"interpolate": "cardinal" | |
}, | |
"encoding": { | |
"x": { | |
"field": "key", | |
"timeUnit": "yearmonthdate", | |
"axis": {"format": "%m/%d", "title": "月/日"} | |
}, | |
"y": { | |
"field": "moving_end.value", | |
"type": "quantitative" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment