我有一个按需要排序的图表,但似乎无法获得排名。我只想显示现有排序的前十名...... 例如,乔治将成为最后一个特工。
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"name": "data",
"values": [
{
"agent": "Connor",
"avg_score": "9.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.90000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.44",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Lily",
"avg_score": "8.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.80000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.34",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Jordan",
"avg_score": "7.5000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.75000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.29",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Jane",
"avg_score": "7.5000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.75000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.29",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Eagle",
"avg_score": "7.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.70000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.24",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Joe",
"avg_score": "5.0000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.50000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Evan",
"avg_score": "5.0000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.50000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "George",
"avg_score": "5.0000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "1.00000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.46",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Margaret",
"avg_score": "5.0000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "1.00000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.46",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Margaret",
"avg_score": "5.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.50000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Laura",
"avg_score": "4.0000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.80000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.26",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Evan",
"avg_score": "3.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.70000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.16",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Hunter",
"avg_score": "3.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.30000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.17",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Lily",
"avg_score": "3.0000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.60000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.06",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Jane",
"avg_score": "3.0000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.60000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.06",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Joe",
"avg_score": "2.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.50000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "George",
"avg_score": "2.5000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.25000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.22",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Jeff",
"avg_score": "2.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.50000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Hunter",
"avg_score": "2.0000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.40000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.14",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Jordan",
"avg_score": "1.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.30000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.24",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Leslie",
"avg_score": "1.5000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.15000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.32",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Leslie",
"avg_score": "1.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.30000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.24",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Laura",
"avg_score": "1.00000000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.10000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.37",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Eagle",
"avg_score": "1.00000000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.20000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.34",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Jeff",
"avg_score": "1.00000000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.10000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.37",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Connor",
"avg_score": "0.00000000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.00000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.54",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
}
]
},
"description": "",
"encoding": {
"y": {
"axis": {
"labels": true,
"tickBand": "center",
"tickOpacity": 0,
"title": ""
},
"field": "agent",
"sort": {"field": "AgentPercentage"},
"type": "nominal"
}
},
"height": {"step": 16},
"layer": [
{
"encoding": {
"tooltip": [
{"field": "AgentCalls", "title": "calls", "type": "quantitative"},
{
"field": "AvgAgtScore",
"title": "avg score",
"type": "quantitative"
},
{"field": "score_count", "title": "scores", "type": "quantitative"}
],
"x": {
"aggregate": "average",
"axis": null,
"field": "percentage",
"scale": {"domain": [0, 1]}
}
},
"mark": {"color": "#ddd", "tooltip": true, "type": "bar"},
"transform": [
{
"groupby": ["agent"],
"joinaggregate": [
{"as": "AvgAgtScore", "field": "avg_score", "op": "average"}
]
},
{
"groupby": ["agent"],
"joinaggregate": [
{"as": "AgentCalls", "field": "call_count", "op": "average"}
]
}
]
},
{
"encoding": {"text": {"field": "AgentPercentage", "format": ".2%"}},
"mark": {
"align": "left",
"tooltip": "the agent percentage",
"type": "text",
"x": 5
},
"transform": [
{
"groupby": ["agent"],
"joinaggregate": [
{"as": "AgentPercentage", "field": "percentage", "op": "average"}
]
}
]
},
{
"encoding": {
"color": {
"condition": {
"test": "datum['ScorePercentageCalc'] < 0",
"value": "red"
},
"value": "green"
},
"text": {
"field": "ScorePercentageCalc",
"format": ".2%",
"type": "quantitative"
},
"tooltip": [
{"field": "score_desc", "title": "description"},
{
"field": "ScorePercentage",
"format": ".2%",
"title": "avg score",
"type": "quantitative"
}
]
},
"mark": {
"align": "left",
"baseline": "middle",
"dx": 24,
"fontWeight": "bold",
"tooltip": "test",
"type": "text"
},
"transform": [
{
"groupby": ["agent"],
"joinaggregate": [
{
"as": "ScorePercentageCalc",
"field": "score_calc",
"op": "average"
}
]
},
{
"groupby": ["agent"],
"joinaggregate": [
{
"as": "ScorePercentage",
"field": "score_percentage",
"op": "average"
}
]
}
]
}
],
"title": "Bottom Agent Scores",
"width": 200
}
接受的答案工作得很好,下面是一个 Elixir 实现,它复制了该答案中的 json。我不知道你可以用这种方式组合变换[在 Elixir 中]。
def create_bottom_agent_score_chart(score_stats) do
data = Enum.map(score_stats, fn m -> Map.put(m, :score_desc, "diff from avg") end)
Vl.new(width: 200, height: [step: 16], title: "Bottom Agent Scores", description: "")
|> Vl.data_from_values(data, name: "data")
|> Vl.transform(
aggregate: [
[field: "percentage", op: :average, as: "AgentPercentage"],
[field: "call_count", op: :average, as: "AgentCalls"],
[field: "avg_score", op: :average, as: "AvgAgtScore"],
[field: "score_calc", op: :average, as: "ScorePercentageCalc"],
[field: "score_percentage", op: :average, as: "ScorePercentage"],
[field: "score_desc", op: :max, as: "score_desc"],
[field: "score_count", op: :sum, as: "Scores"]
],
groupby: ["agent"]
)
|> Vl.transform(
window: [
[
op: "rank",
as: "rank"
]
],
sort: [[field: "AgentPercentage", order: "ascending"]]
)
|> Vl.transform(filter: "datum.rank < 11")
|> Vl.encode_field(:y, "agent",
type: :nominal,
axis: [labels: true, tick_band: "center", tick_opacity: 0, title: ""],
# sort: [op: "max", field: "percentage", order: "ascending"],
sort: [field: "AgentPercentage", order: "ascending"]
)
|> Vl.layers([
Vl.new()
|> Vl.mark(:bar, tooltip: true, color: "#ddd")
|> Vl.encode(:tooltip, [
[field: "AgentCalls", type: :quantitative, title: "calls"],
[field: "AvgAgtScore", type: :quantitative, title: "avg score"],
[field: "Scores", type: :quantitative, title: "scores"]
])
|> Vl.encode_field(:x, "AgentPercentage",
# this agregate here is wierd, since the field is already averaged.
# but it won't work without it...
aggregate: :average,
scale: [domain: [0, 1]],
axis: nil
),
Vl.new()
|> Vl.mark(:text, align: "left", x: 5, tooltip: "the agent percentage")
|> Vl.encode_field(:text, "AgentPercentage", format: ".1%"),
Vl.new()
|> Vl.mark(:text,
align: "left",
baseline: "middle",
dx: 24,
font_weight: :bold,
tooltip: "test"
)
|> Vl.encode(:tooltip, [
[field: "score_desc", title: "description"],
[field: "ScorePercentage", type: :quantitative, title: "avg score", format: ".1%"]
])
|> Vl.encode_field(:text, "ScorePercentageCalc",
type: :quantitative,
format: ".1%"
)
|> Vl.encode(:color,
value: "green",
condition: [test: "datum['ScorePercentageCalc'] < 0", value: "red"]
)
])
|> Vl.to_spec()
|> Jason.encode!()
end
我建议一次性完成所有转换。您还复制了值,这就是为什么您的文本更加粗体(值一个放在另一个上)。
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"name": "data",
"values": [
{
"agent": "Connor",
"avg_score": "9.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.90000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.44",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Lily",
"avg_score": "8.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.80000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.34",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Jordan",
"avg_score": "7.5000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.75000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.29",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Jane",
"avg_score": "7.5000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.75000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.29",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Eagle",
"avg_score": "7.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.70000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.24",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Joe",
"avg_score": "5.0000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.50000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Evan",
"avg_score": "5.0000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.50000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "George",
"avg_score": "5.0000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "1.00000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.46",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Margaret",
"avg_score": "5.0000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "1.00000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.46",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Margaret",
"avg_score": "5.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.50000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Laura",
"avg_score": "4.0000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.80000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.26",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Evan",
"avg_score": "3.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.70000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.16",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Hunter",
"avg_score": "3.0000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.30000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.17",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Lily",
"avg_score": "3.0000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.60000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.06",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Jane",
"avg_score": "3.0000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.60000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "0.06",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Joe",
"avg_score": "2.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.50000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "George",
"avg_score": "2.5000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.25000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.22",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Jeff",
"avg_score": "2.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.50000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.04",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Hunter",
"avg_score": "2.0000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.40000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.14",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Jordan",
"avg_score": "1.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.30000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.24",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Leslie",
"avg_score": "1.5000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.15000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.32",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Leslie",
"avg_score": "1.5000000000000000",
"call_count": 2,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.30000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.24",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Laura",
"avg_score": "1.00000000000000000000",
"call_count": 1,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.10000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.37",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Eagle",
"avg_score": "1.00000000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.20000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.34",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
},
{
"agent": "Jeff",
"avg_score": "1.00000000000000000000",
"call_count": 2,
"label": "Negative Words",
"max_score": 10,
"percentage": "0.10000000000000000000",
"score_average": "4.6500000000000000",
"score_calc": "-0.37",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.46500000000000000000"
},
{
"agent": "Connor",
"avg_score": "0.00000000000000000000",
"call_count": 1,
"label": "Answer Time",
"max_score": 5,
"percentage": "0.00000000000000000000",
"score_average": "2.7000000000000000",
"score_calc": "-0.54",
"score_count": "2",
"score_desc": "diff from avg",
"score_percentage": "0.54000000000000000000"
}
]
},
"transform": [
{
"aggregate": [
{"op": "average", "field": "percentage", "as": "AgentPercentage"},
{"op": "average", "field": "score_calc", "as": "ScorePercentageCalc"},
{"op": "average", "field": "call_count", "as": "AgentCalls"}
],
"groupby": ["agent"]
},
{
"sort": [{"field": "AgentPercentage", "order": "ascending"}],
"window": [{"op": "rank", "as": "rank"}]
},
{"filter": "datum.rank < 11"}
],
"description": "",
"encoding": {
"y": {
"axis": {
"labels": true,
"tickBand": "center",
"tickOpacity": 0,
"title": ""
},
"field": "agent",
"sort": {"field": "AgentPercentage"},
"type": "nominal"
}
},
"height": {"step": 16},
"layer": [
{
"encoding": {
"tooltip": [
{"field": "AgentCalls", "title": "calls", "type": "quantitative"},
{
"field": "AgentPercentage",
"title": "avg score",
"type": "quantitative"
},
{"field": "score_count", "title": "scores", "type": "quantitative"}
],
"x": {
"axis": null,
"field": "AgentPercentage",
"type": "quantitative",
"scale": {"domain": [0, 1]}
}
},
"mark": {"color": "#ddd", "tooltip": true, "type": "bar"}
},
{
"encoding": {"text": {"field": "AgentPercentage", "format": ".2%"}},
"mark": {
"align": "left",
"tooltip": "the agent percentage",
"type": "text",
"x": 5
}
},
{
"encoding": {
"color": {
"condition": {
"test": "datum['ScorePercentageCalc'] < 0",
"value": "red"
},
"value": "green"
},
"text": {
"field": "ScorePercentageCalc",
"format": ".2%",
"type": "quantitative"
},
"tooltip": [
{"field": "score_desc", "title": "description"},
{
"field": "ScorePercentage",
"format": ".2%",
"title": "avg score",
"type": "quantitative"
}
]
},
"mark": {
"align": "left",
"baseline": "middle",
"dx": 24,
"fontWeight": "bold",
"tooltip": "test",
"type": "text"
}
}
],
"title": "Bottom Agent Scores",
"width": 200
}