diff --git a/lib/microwaveprop_web/live/path_live.ex b/lib/microwaveprop_web/live/path_live.ex index 203b4d30..54f6c384 100644 --- a/lib/microwaveprop_web/live/path_live.ex +++ b/lib/microwaveprop_web/live/path_live.ex @@ -890,22 +890,22 @@ defmodule MicrowavepropWeb.PathLive do {Phoenix.HTML.raw(@trend)} - - <%= for s <- [0, 50, 100] do %> - <% y = 6 + (100 - s) / 100 * 70 %> + + <%= for s <- [0, 25, 50, 75, 100] do %> + <% y = 20 + (100 - s) / 100 * 185 %> <%= for pt <- @points do %> - + <% end %> x = if n <= 1 do - 161 + 617 else - 28 + i / (n - 1) * 266 + 55 + i / (n - 1) * 1125 end - y = 6 + (100 - p.score) / 100 * 70 + y = 20 + (100 - p.score) / 100 * 185 %{ x: Float.round(x * 1.0, 2), @@ -1041,10 +1041,10 @@ defmodule MicrowavepropWeb.PathLive do n = length(points) indices = - if n <= 3 do - Enum.to_list(0..(n - 1)) - else - [0, div(n - 1, 2), n - 1] + cond do + n <= 1 -> [0] + n <= 7 -> Enum.to_list(0..(n - 1)) + true -> label_indices(n, 7) end Enum.map(indices, fn i -> @@ -1053,6 +1053,14 @@ defmodule MicrowavepropWeb.PathLive do end) end + defp label_indices(n, target) do + step = (n - 1) / (target - 1) + + 0..(target - 1) + |> Enum.map(fn k -> round(k * step) end) + |> Enum.uniq() + end + attr :label, :string, required: true attr :value, :any, required: true attr :unit, :string, required: true