I'm by no means a coder and am trying to do something that I think should be relatively simple.
I have an index that has the following fields (plus others):
_source.name",
"_source['it_debt_applies']",
"_source['it_debt_asset_class']",
"_source['it_debt_comments']",
"_source['it_debt_cost_of_no_action']",
"_source['it_debt_current_version']",
"_source['it_debt_end_extended_support']",
"_source['it_debt_end_standard_support_date']",
"_source['it_debt_existing_support_level']",
"_source['it_debt_latest_version']",
"_source['it_debt_number_of_devices']",
"_source['it_debt_version_gap']"
I want to use a Vega timeline to chart them based on their "it_debt_end_standard_support_date" and "it_debt_end_extended_support".
The timeline I'm trying to use is this one:
the static code that they are using is:
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A timeline visualization of the lives of the first five U.S. presidents.",
"width": 500,
"height": 80,
"padding": 5,
"data": [
{
"name": "people",
"values": [
{
"label": "Washington",
"born": -7506057600000,
"died": -5366196000000,
"enter": -5701424400000,
"leave": -5453884800000
},
{
"label": "Adams",
"born": -7389766800000,
"died": -4528285200000,
"enter": -5453884800000,
"leave": -5327740800000
},
{
"label": "Jefferson",
"born": -7154586000000,
"died": -4528285200000,
"enter": -5327740800000,
"leave": -5075280000000
},
{
"label": "Madison",
"born": -6904544400000,
"died": -4213184400000,
"enter": -5075280000000,
"leave": -4822819200000
},
{
"label": "Monroe",
"born": -6679904400000,
"died": -4370518800000,
"enter": -4822819200000,
"leave": -4570358400000
}
]
},
{
"name": "events",
"format": {"type":"json", "parse":{"when":"date"}},
"values": [
{ "name":"Decl. of Independence", "when":"July 4, 1776" },
{ "name":"U.S. Constitution", "when":"3/4/1789" },
{ "name":"Louisiana Purchase", "when":"April 30, 1803" },
{ "name":"Monroe Doctrine", "when":"Dec 2, 1823" }
]
}
],
"scales": [
{
"name": "yscale",
"type": "band",
"range": [0, {"signal": "height"}],
"domain": {"data": "people", "field": "label"}
},
{
"name": "xscale",
"type": "time",
"range": "width",
"round": true,
"domain": {"data": "people", "fields": ["born", "died"]}
}
],
"axes": [
{"orient": "bottom", "scale": "xscale", "format": "%Y"}
],
"marks": [
{
"type": "text",
"from": {"data": "events"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "when"},
"y": {"value": -10},
"angle": {"value": -25},
"fill": {"value": "#000"},
"text": {"field": "name"},
"fontSize": {"value": 10}
}
}
},
{
"type": "rect",
"from": {"data": "events"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "when"},
"y": {"value": -8},
"width": {"value": 1},
"height": {"field": {"group": "height"}, "offset": 8},
"fill": {"value": "#888"}
}
}
},
{
"type": "text",
"from": {"data": "people"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "born"},
"y": {"scale": "yscale", "field": "label", "offset": -3},
"fill": {"value": "#000"},
"text": {"field": "label"},
"fontSize": {"value": 10}
}
}
},
{
"type": "rect",
"from": {"data": "people"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "born"},
"x2": {"scale": "xscale", "field": "died"},
"y": {"scale": "yscale", "field": "label"},
"height": {"value": 2},
"fill": {"value": "#557"}
}
}
},
{
"type": "rect",
"from": {"data": "people"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "enter"},
"x2": {"scale": "xscale", "field": "leave"},
"y": {"scale": "yscale", "field": "label", "offset":-1},
"height": {"value": 4},
"fill": {"value": "#e44"}
}
}
}
]
}
I've converted that to use the fields from my index, but for whatever reason it keeps complaining about an infinite extend for my date fields:
Here is my code:
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"padding": 5,
"config": {"background": "#f5f5f5"},
"data": [
{
"name": "source",
"url": {
"%context%": true,
"index": "test_XYZ_custom_itdebt",
"body": {"size": 10000}
},
"format": {"property": "hits.hits"},
"transform": [
{
"type": "filter",
"expr": "datum._source['it_debt_applies'] != null &&datum._source['it_debt_end_extended_support'] != null &&datum._source['it_debt_end_standard_support_date'] != null "
},
{
"type": "project",
"fields": [
"_source.name",
"_source['it_debt_applies']",
"_source['it_debt_asset_class']",
"_source['it_debt_comments']",
"_source['it_debt_cost_of_no_action']",
"_source['it_debt_current_version']",
"_source['it_debt_end_extended_support']",
"_source['it_debt_end_standard_support_date']",
"_source['it_debt_existing_support_level']",
"_source['it_debt_latest_version']",
"_source['it_debt_number_of_devices']",
"_source['it_debt_version_gap']"
],
"as": [
"Name",
"Applies",
"Asset_Class",
"Comments",
"Cost_Of_No_Action",
"Current_Version",
"End_Extended_Support",
"End_Standard_Support_Date",
"Existing_Support_Level",
"Latest_Version",
"Number_Of_Devices",
"Version_Gap"
]
}
]
},
{
"name": "events",
"format": {"type":"json", "parse":{"when":"date"}},
"values": [
{ "name":"Decl. of Independence", "when":"July 4, 1776" },
{ "name":"U.S. Constitution", "when":"3/4/1789" },
{ "name":"Louisiana Purchase", "when":"April 30, 1803" },
{ "name":"Monroe Doctrine", "when":"Dec 2, 1823" }
]
}
]
"scales": [
{
"name": "yscale",
"type": "band",
"range": [0, {"signal": "height"}],
"domain": {"data": "source", "field": "Name"}
},
{
"name": "xscale",
"type": "time",
"range": "width",
"round": true,
"domain": {"data": "source", "fields": ["End_Standard_Support_Date", "End_Extended_Support"]}
}
],
"axes": [
{"orient": "bottom", "scale": "xscale", "format": "%Y %M"}
],
"marks": [
{
"type": "text",
"from": {"data": "events"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "when"},
"y": {"value": -10},
"angle": {"value": -25},
"fill": {"value": "#000"},
"text": {"field": "name"},
"fontSize": {"value": 10}
}
}
},
{
"type": "text",
"from": {"data": "source"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "End_Standard_Support_Date"},
"y": {"scale": "yscale", "field": "Name", "offset": -3},
"fill": {"value": "#000"},
"text": {"field": "label"},
"fontSize": {"value": 10}
}
}
},
{
"type": "rect",
"from": {"data": "source"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "End_Standard_Support_Date"},
"x2": {"scale": "xscale", "field": "End_Extended_Support"},
"y": {"scale": "yscale", "field": "Name"},
"height": {"value": 2},
"fill": {"value": "#557"}
}
}
},
]
}
I know I'm missing something simple, any help would be appreciated.
Thanks in advance!