Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/contexsample_web/live/barchart.ex
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ defmodule ContexSampleWeb.BarChartLive do
data = 1..categories
|> Enum.map(fn cat ->
series_data = for _ <- 1..series do
random_within_range(10.0, 100.0)
if options.type == :stacked_absolute do
random_within_range(-10.0, 100.0)
else
random_within_range(10.0, 100.0)
end
end
["Category #{cat}" | series_data]
end)
Expand Down
3 changes: 2 additions & 1 deletion lib/contexsample_web/live/shared.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule ContexSampleWeb.Shared do
def colour_options(), do: simple_option_list(~w(default themed custom warm pastel nil))
def yes_no_options(), do: simple_option_list(~w(yes no))
def legend_options(), do: simple_option_list(~w(legend_none legend_right legend_top legend_bottom))
def chart_type_options(), do: simple_option_list(~w(stacked grouped))
def chart_type_options(), do: simple_option_list(~w(stacked stacked_absolute grouped))
def chart_orientation_options(), do: simple_option_list(~w(vertical horizontal))


Expand Down Expand Up @@ -89,6 +89,7 @@ defmodule ContexSampleWeb.Shared do
defp update_type(options, raw) do
case raw do
"stacked" -> Map.put(options, :type, :stacked)
"stacked_absolute" -> Map.put(options, :type, :stacked_absolute)
"grouped" -> Map.put(options, :type, :grouped)
_-> Map.put(options, :type, raw)
end
Expand Down