{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"width": 800,
"autosize": {
"type": "fit",
"contains": "padding"
},
"description": "A candlestick chart inspired by an example in Protovis (http://mbostock.github.io/protovis/ex/candlestick.html)",
"data": {url: {
// Specify the time filter.
%timefield%: crypto.candle.openTime
// Apply dashboard context filters when set
%context%: true
// Which indexes to search
index: "crypto-*"
// The body element may contain "aggs" and "query" keys
body: {
aggs: {
time_buckets: {
date_histogram: {
// Use date histogram aggregation on @timestamp field
field: "crypto.candle.openTime"
// interval value will depend on the time filter
// Use an integer to set approximate bucket count
// interval: { %autointerval%: true }
"interval": "1h"
// Make sure we get an entire range, even if it has no data
// extended_bounds: {
// min: { %timefilter%: "min" }
// max: { %timefilter%: "max" }
// }
// Use this for linear (e.g. line, area) graphs
// Without it, empty buckets will not show up
min_doc_count: 1
}
}
}
// Speed up the response by only including aggregation results
size: 0
}
}},
"encoding": {
"x": {
"field": "key",
"type": "temporal",
"title": "Date",
"axis": {
"format": "%Y-%m-%dT%H:%M:%SZ",
"labelAngle": -45,
"title": "Date"
}
},
"y": {
"type": "quantitative",
field: "doc_count",
"scale": {"zero": false},
"axis": {"title": "Price"}
},
"color": {
"condition": {
"test": "datum.open < datum.close",
"value": "#06982d"
},
"value": "#ae1325"
}
},
"layer": [
{
"mark": "rule",
"encoding": {
"y": {"field": "crypto.candle.low"},
"y2": {"field": "crypto.candle.high"}
}
},
{
"mark": "bar",
"encoding": {
"y": {"field": "crypto.candle.open.max"},
"y2": {"field": "crypto.candle.close.max"}
}
}
]
}
Not sure I understand your data and query but if you want to start with the visualization first you can use the Vega Editor and hardcode the data.
I started it and did a basic design of what I think you are looking for. The hard part is doing the transformations/math to get the boxes in the right spot. Then you can conditionally color the boxes to be green or red.
That's the default example when you create a new visualization. The bottom format field is what I think you are looking for. Except yours would be like {"property": "aggs.time_buckets.buckets"}. Then you can reference the data like _source.crypto.candle.high
I have tried a few iterations with your example but I still was shown the error of
Infinite extent for field "_source.crypto.candle.openTime": [Infinity, -Infinity]
Infinite extent for field "_source.crypto.candle.openTime": [Infinity, -Infinity]
Infinite extent for field "_source.crypto.candle.low": [Infinity, -Infinity]
Infinite extent for field "_source.crypto.candle.high": [Infinity, -Infinity]
Infinite extent for field "_source.crypto.candle.open": [Infinity, -Infinity]
Infinite extent for field "_source.crypto.candle.close": [Infinity, -Infinity]
This is how It looks right now and how my query looks like. I will work more on this now I have a much bigger understanding of these tools. @aaron-nimocks thank you very much for your input!
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.