A reply to myself.
VegaLite-datasets_from_values allows several sources.
I tried to apply it with:
def create_compare_graph(data_a, data_b, title, col) do
Vl.new(width: 500, height: 300, title: title)
|> Vl.data_from_values(a: data_a,
b: data_b,
only: ["day", party])
|> Vl.layers([
Vl.new()
|> Vl.data(name: "a")
|> Vl.mark(:line, color: "blue")
|> Vl.encode_field(:x, "day",
type: :quantitative,
title: "Day of the year"
)
|> Vl.encode_field(:y, party,
type: :quantitative,
scale: [domain: [0, 1]],
title: "Sentiment"),
Vl.new()
|> Vl.data(name: "b")
|> Vl.mark(:line, color: "red")
|> Vl.encode_field(:x, "day",
type: :quantitative,
title: "Day of the year")
|> Vl.encode_field(:y, party,
type: :quantitative,
scale: [domain: [0, 1]],
title: "Polls")
])
|> Vl.resolve(:scale, y: :independent)
end
end
Error:
expected valid tabular data, but got ... (*Desribes the dataframe*)
Edited: the error Because chcnage Vl.Data → Vl.data






















