I am working with two versions of a Vega Detail/Overview (Area Chart) Visualization.
They both have the same dropdowns that are used to filter the data:
"signals": [
{ "name": "detailDomain" },
{ "name": "regionFilter", "value": "EMEA",
"bind": {"input": "select", "options": ["AMER", "EMEA", "APAC"]} },
{ "name": "acctypeFilter", "value": "StrategyAccount",
"bind": {"input": "select", "options": ["StrategyAccount", "Strategy", "Account"]} }
],
The data source of the version where filtering works:
"data": [
{
"name": "sp500",
"values": [
{"account":"XXXXXX","price":-1.387814312978290e+004,"acctype":"Account","region":"APAC"},
{"account":"YYYYY","price":0.000000000000000e+000,"acctype":"Account","region":"APAC"},
{"account":"ZZZZZ","price":-6.588935784852400e+005,"acctype":"Account","region":"APAC"},
{"account":"X1X1X1","price":8.863933226918270e+005,"acctype":"Account","region":"APAC"},
{"account":"Z2Z2Z2","price":-3.314336740809040e+005,"acctype":"Account","region":"APAC"},
# . etc, etc,
#
]
},
The data source of the version where filtering does not work:
"data": [
{
"name": "sp500",
url: {
%context%: true
%timefield%: @timestamp
index: mgpnlquery*
body: {
size: 1000
_source: ["@timestamp", "price", "account", "acctype", "region" ]
}
}
"format": { "property": "hits.hits" }
},
# Here are the data filters:
{
"name": "byAccType",
"source": "sp500",
"transform": [
{"type": "filter", "expr": "datum.acctype == acctypeFilter"}
]
},
{
"name": "byFilter",
"source": "byAccType",
"transform": [
{"type": "filter", "expr": "datum.region == regionFilter"}
]
}
],
The "byFilter" data set works in the inline data version, but results in blank data in the index data version shown below: (Note - substituting "sp500" for "byFilter" will make the (unfiltered) display work). I am suspecting that the Transform / Filter behaves differently for inline data vs. index data.)
"marks": [
{
"type": "group",
"name": "detail",
"encode": {
"enter": {
"height": {"value": 390},
"width": {"value": 1700}
}
},
"scales": [
{
"name": "xDetail",
"type": "point",
"range": "width",
"domain": {"data": "byFilter", "field": "_source.account"}
"domainRaw": {"signal": "detailDomain"}
},
{
"name": "yDetail",
"type": "linear",
"range": [390, 0],
"domain": {"data": "byFilter", "field": "_source.price"},
"nice": true, "zero": true
}
],
"axes": [
{"orient": "bottom", "scale": "xDetail", "grid": "true", "labelOverlap": true,
"title": "Accounts"},
{"orient": "left", "scale": "yDetail", "grid": "true",
"title": "PnL"}
],
"marks": [
{
"type": "group",
"encode": {
"enter": {
"height": {"field": {"group": "height"}},
"width": {"field": {"group": "width"}},
"clip": {"value": true}
}
},
"marks": [
{
"type": "area",
"from": {"data": "byFilter"},
"encode": {
"update": {
"x": {"scale": "xDetail", "field": "_source.account"},
"y": {"scale": "yDetail", "field": "_source.price"},
"y2": {"scale": "yDetail", "value": 0},
"fill": {"value": "steelblue"}
}
}
}
]
}
]
},
This is what the index data looks like:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 23870,
"max_score" : 1.0,
"hits" : [
{
"_index" : "mgpnlquery-2019.04.03",
"_type" : "doc",
"_id" : "IyX84mkBLZb84o2j7mwW",
"_score" : 1.0,
"_source" : {
"region" : "APAC",
"price" : -2071.39358048752,
"@version" : "1",
"tags" : [
"PnlQuery2"
],
"@timestamp" : "2019-04-03T11:37:00.592Z",
"type" : "PnlQuery2",
"account" : "ZZZZZ",
"acctype" : "StrategyAccount"
}
},
{
"_index" : "mgpnlquery-2019.04.03",
"_type" : "doc",
"_id" : "JSX84mkBLZb84o2j7mwX",
"_score" : 1.0,
"_source" : {
"region" : "APAC",
"price" : 5640.71772310075,
"@version" : "1",
"tags" : [
"PnlQuery2"
],
"@timestamp" : "2019-04-03T11:37:00.591Z",
"type" : "PnlQuery2",
"account" : "ZZZZ",
"acctype" : "StrategyAccount"
}
},
{
"_index" : "mgpnlquery-2019.04.03",