From e893800d2c46c9054ec1824fd691944f6e457fab Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Wed, 27 Nov 2024 14:59:35 +0000 Subject: [PATCH] Add chart for count by artist --- music_library.livemd | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/music_library.livemd b/music_library.livemd index bdb85ed8..6d94f76a 100644 --- a/music_library.livemd +++ b/music_library.livemd @@ -3,7 +3,8 @@ ```elixir Mix.install([ {:kino_db, "~> 0.2.10"}, - {:exqlite, "~> 0.23.0"} + {:exqlite, "~> 0.23.0"}, + {:kino_vega_lite, "~> 0.1.11"} ]) ``` @@ -23,10 +24,10 @@ opts = [ ### Count of records per artist - + ```elixir -result = +count_by_artist = Exqlite.query!( conn, ~S""" @@ -42,10 +43,10 @@ result = ### Count of records by genre - + ```elixir -result2 = +count_by_genre = Exqlite.query!( conn, ~S""" @@ -59,3 +60,13 @@ result2 = [] ) ``` + + + +```elixir +VegaLite.new(width: 600, title: "Count by genre") +|> VegaLite.data_from_values(count_by_genre, only: ["c", "value"]) +|> VegaLite.mark(:bar) +|> VegaLite.encode_field(:x, "c", type: :quantitative) +|> VegaLite.encode_field(:y, "value", type: :nominal) +```