Hello expert,
I need your help to find the error, i tried to find out but i didnt got it. Thanks in advance...
` {
$schema: https://vega.github.io/schema/vega-lite/v5.json
data: {
url: {
%context%: true
%timefield%: timestamp
index: terrena_1
body: {
size: 0
aggs: {
month_date_histogram_of_timestamp: {
date_histogram: {field: "timestamp", calendar_interval: "month"}
aggs: {
sum_of_Jobsize: {
sum: {field: "Job_Size_(GB)"}
}
serial_diff_of_sum_of_Jobsize: {
serial_diff: {buckets_path: "sum_of_Jobsize", lag: 1}
}
}
}
}
}
}
format: {
property: aggregations.month_date_histogram_of_timestamp.buckets
}
}
transform: [
{
window: [
{
op: lead
field: key_as_string
offset: 1
as: next_lead
}
]
}
{
calculate: "datum.sum_of_Jobsize.value",
as: "sum"
}
{
calculate: "datum.key_as_string",
as: "lead"
}
{
calculate: datum.serial_diff_of_sum_of_Jobsize != null ? datum.sum - datum.serial_diff_of_sum_of_Jobsize.value : 0
as: previous_sum
}
{
calculate: datum.serial_diff_of_sum_of_Jobsize != null ? datum.serial_diff_of_sum_of_Jobsize.value :datum.sum
as: amount
}
{
calculate: (datum.serial_diff_of_sum_of_Jobsize != null && datum.amount (GB > 0 ? '+' : '') + datum.amount
as: text_amount
}
{
calculate: (datum.sum + datum.previous_sum) / 2
as: center
}
{
calculate: datum.sum < datum.previous_sum ? datum.sum : ''
as: sum_dec
}
{
calculate: datum.sum > datum.previous_sum ? datum.sum : ''
as: sum_inc
}
]
encoding: {
x: {
field: key_as_string
type: ordinal
sort: null
axis: {labelAngle: 0, title: "Months"}
}
}
layer: [
{
mark: {type: "bar", size: 45}
encoding: {
y: {field: "previous_sum", type: "quantitative", title: "Job Size"}
y2: {field: "sum"}
color: {
condition: [
{
test: datum.serial_diff_of_sum_of_Jobsize == null
value: "#f7e0b6"
}
{test: "datum.sum < datum.previous_sum", value: "#f78a64"}
]
value: "#93c4aa"
}
}
}
{
mark: {
type: rule
opacity: 1
color: "#404040"
strokeWidth: 2
xOffset: -22.5
x2Offset: 22.5
}
encoding: {
x2: {field: "next_lead"}
y: {field: "sum", type: "quantitative"}
}
}
{
mark: {type: "text", dy: -4, baseline: "bottom"}
encoding: {
y: {field: "sum_inc", type: "quantitative"}
text: {field: "sum_inc", type: "nominal"}
}
}
{
mark: {type: "text", dy: 4, baseline: "top"}
encoding: {
y: {field: "sum_dec", type: "quantitative"}
text: {field: "sum_dec", type: "nominal"}
}
}
{
mark: {type: "text", fontWeight: "bold", baseline: "middle"}
encoding: {
y: {field: "center", type: "quantitative"}
text: {field: "text_amount", type: "nominal"}
color: {
condition: [
{
test: datum.serial_diff_of_sum_of_Jobsize == null
value: "#725a30"
}
]
value: white
}
}
}
]
config: {
text: {fontWeight: "bold", color: "#404040"}
}
}
`