Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mindok committed Dec 29, 2023
1 parent 964298d commit 7d9c7b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 2 additions & 4 deletions lib/chart/gallery/ohlc_charts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ defmodule Contex.Gallery.OHLCCharts do
#{graph(title: "A simple candle OHLC chart",
file: "ohlc_candle.sample"
)}
file: "ohlc_candle.sample")}
#{graph(title: "A simple tick OHLC chart",
file: "ohlc_tick.sample"
)}
file: "ohlc_tick.sample")}
"""
Expand Down
18 changes: 11 additions & 7 deletions lib/chart/ohlc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule Contex.OHLC do
:options,
:x_scale,
:y_scale,
transforms: %{},
transforms: %{}
]

@required_mappings [
Expand Down Expand Up @@ -71,7 +71,6 @@ defmodule Contex.OHLC do

@type t() :: %__MODULE__{}


@doc """
Create a new `OHLC` struct from Dataset.
Expand Down Expand Up @@ -133,7 +132,7 @@ defmodule Contex.OHLC do
Keyword.get(options, key)
end

@doc false
@doc false
def to_svg(%__MODULE__{} = plot, plot_options) do
plot = prepare_scales(plot)
x_scale = plot.x_scale
Expand Down Expand Up @@ -288,12 +287,18 @@ defmodule Contex.OHLC do
{min, max} = Dataset.column_extents(dataset, column)

TimeScale.new()
|> TimeScale.domain(min, max)
|> Scale.set_range(r_min, r_max)
|> TimeScale.domain(min, max)
|> Scale.set_range(r_min, r_max)
end

defp prepare_y_scale(%__MODULE__{dataset: dataset, mapping: mapping} = plot) do
y_col_names = [mapping.column_map[:open], mapping.column_map[:high], mapping.column_map[:low], mapping.column_map[:close]]
y_col_names = [
mapping.column_map[:open],
mapping.column_map[:high],
mapping.column_map[:low],
mapping.column_map[:close]
]

height = get_option(plot, :height)
custom_y_scale = get_option(plot, :custom_y_scale)

Expand Down Expand Up @@ -330,5 +335,4 @@ defmodule Contex.OHLC do
combiner.(acc_extents, inner_extents)
end)
end

end

0 comments on commit 7d9c7b6

Please sign in to comment.