Skip to content

Commit

Permalink
add stacked_absolute to Gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshAusHessen committed Jun 5, 2024
1 parent 2204643 commit ec49c82
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/chart/gallery/bar_charts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ defmodule Contex.Gallery.BarCharts do
""")}
#{graph(title: "A simple stacked bar chart with absolute input values",
file: "bar_charts_plain_stacked_apsolute.sample",
info: "")}
"""
def plain(), do: 0
end
29 changes: 29 additions & 0 deletions lib/chart/gallery/bar_charts_plain_stacked_absolute.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
data = [
["January", 3500, 94, -3406],
["February", 3500, 842, -2658],
["March", 3500, 366, -3134],
["April", 4000, 660, -3340],
["May", 4000, 987, -3013],
["June", 4000, 788, -3212],
["July", 4000, 1630, -2370],
["August", 4000, 569, -3431],
["September", 4000, 855, -3145],
["November", 4500, 1001, -3499],
["December", 4000, 1562, -2438]
]

category_col = "Month"
series_cols = ["Income", "Savings", "Expenditure"]
test_data = Contex.Dataset.new(data, [category_col | series_cols])

options = [
mapping: %{category_col: category_col, value_cols: series_col},
type: :stacked_absolute,
data_labels: true,
orientation: :vertical,
colour_palette: ["009900", "003399", "990000"],
series_columns: series_cols
]

Contex.Plot.new(test_data, Contex.BarChart, 500, 400, options)
|> Contex.Plot.titles("Finances for a year", "")
1 change: 1 addition & 0 deletions test/gallery/bar_charts_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule ContexGalleryBarChartTest do
"bar_charts_plain.sample",
"bar_charts_plain_horizontal.sample",
"bar_charts_plain_stacked.sample",
"bar_charts_plain_stacked_absolute.sample",
"bar_charts_log_stacked.sample",
"bar_charts_log_stacked_auto_domain.sample"
]
Expand Down

0 comments on commit ec49c82

Please sign in to comment.