@@ -242,16 +242,18 @@ defmodule Matplotex.Figure.Areal.BarChart do
242242 defp capture_stacked ( to_capture , captured , dataset , bly ) do
243243 to_capture
244244 |> Enum . map ( fn point ->
245- calculate_point ( point , bly )
245+ format_point ( point , bly )
246246 end )
247247 |> capture ( captured , dataset )
248248 end
249249
250- defp calculate_point ( { x , y } , _bly ) when is_list ( y ) do
251- { { x , Enum . sum ( y ) } , y |> tl ( ) |> Enum . sum ( ) }
252- end
250+ defp format_point ( { { _x , _y } , _y_bottom } = point , _bly ) , do: point
251+ # sum_of_tail = y |> Enum.sort()|>tl()|>Enum.sum
252+ # sum_of_second_tail = y|>tl()|>tl()|>Enum.sum()
253+ # {{x, y|>Enum.max()|>Kernel.-(sum_of_tail)}, y|>tl()|>Enum.max()|> Kernel.-(sum_of_second_tail)}
254+ # end
253255
254- defp calculate_point ( { x , y } , bly ) do
256+ defp format_point ( { x , y } , bly ) do
255257 { { x , y } , bly }
256258 end
257259 defp hypox ( y ) do
@@ -288,13 +290,16 @@ defmodule Matplotex.Figure.Areal.BarChart do
288290 end
289291
290292 defp transform_with_bottom ( x , y , xlim , ylim , width , height , transition ) when is_list ( y ) do
291- transformed = Enum . map ( y , fn y_with_bottom ->
292- transformation ( x , y_with_bottom , xlim , ylim , width , height , transition )
293- |> Algebra . flip_y_coordinate ( )
294- end )
295- |> Enum . unzip ( )
296-
297- { transformed |> elem ( 0 ) |> hd , transformed |> elem ( 1 ) }
293+ # transformed = Enum.map(y, fn y_with_bottom ->
294+ # transformation(x, y_with_bottom, xlim, ylim, width, height, transition)
295+ # |> Algebra.flip_y_coordinate()
296+ # end)
297+ # |>Enum.unzip()
298+ y_top = Enum . sum ( y )
299+ y_bottom = y |> tl ( ) |> Enum . sum ( )
300+ transformed = transformation ( x , y_top , xlim , ylim , width , height , transition ) |> Algebra . flip_y_coordinate ( )
301+ { _ , transformed_y_bottom } = transformation ( x , y_bottom , xlim , ylim , width , height , transition ) |> Algebra . flip_y_coordinate ( )
302+ { transformed , transformed_y_bottom }
298303 end
299304
300305 defp transform_with_bottom ( x , y , xlim , ylim , width , height , transition ) do
0 commit comments