Skip to content

Commit b40687d

Browse files
committed
chore: Ensure non-deterministic map key order doesn't break things
1 parent 2c84858 commit b40687d

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

lib/chart/mapping.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ defmodule Contex.Mapping do
152152
:ok
153153

154154
mappings ->
155-
mapping_string = Enum.map_join(mappings, ", ", &"\"#{&1}\"")
155+
mapping_string =
156+
mappings
157+
|> Enum.sort()
158+
|> Enum.map_join(", ", &"\"#{&1}\"")
159+
156160
raise "Required mapping(s) #{mapping_string} not included in column map."
157161
end
158162
end

test/contex_bar_chart_test.exs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,9 @@ defmodule ContexBarChartTest do
232232
[51.429, 58.0, 61.0, 68.571],
233233
[68.571, 58.0, 61.0, 0.0]
234234
] ==
235-
Stream.map(rects_map, &Map.delete(&1, :title))
236-
|> Stream.map(&Enum.unzip/1)
237-
|> Stream.map(fn value ->
238-
elem(value, 1)
239-
end)
240-
|> Enum.map(fn value ->
241-
Enum.map(value, string_to_rounded_float)
235+
Enum.map(rects_map, fn rect ->
236+
[rect.height, rect.width, rect.x, rect.y]
237+
|> Enum.map(string_to_rounded_float)
242238
end)
243239

244240
assert ["10", "20", "30", "40"] ==

test/contex_continuous_log_scale_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ defmodule ContinuousLogScaleTest do
99
test "defaults" do
1010
assert %Contex.ContinuousLogScale{
1111
custom_tick_formatter: nil,
12-
domain: {0.0, 1.0},
12+
domain: {+0.0, 1.0},
1313
tick_positions: [
14-
0.0,
14+
+0.0,
1515
0.1,
1616
0.2,
1717
_,

test/contex_gantt_chart_test.exs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,9 @@ defmodule ContexGanttChartTest do
204204
[28.0, 15.0, 51.25, 61.0],
205205
[28.0, 30.0, 81.25, 91.0]
206206
] ==
207-
Stream.map(rects_map, &Enum.unzip/1)
208-
|> Stream.map(fn value ->
209-
elem(value, 1)
210-
end)
211-
|> Enum.map(fn value ->
212-
Enum.map(value, string_to_rounded_float)
207+
Enum.map(rects_map, fn rect ->
208+
[rect.height, rect.width, rect.x, rect.y]
209+
|> Enum.map(string_to_rounded_float)
213210
end)
214211

215212
labels =

test/contex_scale_utils_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ defmodule ScaleUtilsTest do
88
test "with fixed intervals" do
99
assert %{
1010
display_decimals: 0,
11-
ticks: [0.0, 20.0, 40.0, 60.0, 80.0, 100.0],
12-
nice_domain: {0.0, 100.0}
11+
ticks: [+0.0, 20.0, 40.0, 60.0, 80.0, 100.0],
12+
nice_domain: {+0.0, 100.0}
1313
} =
1414
ScaleUtils.compute_nice_settings(
1515
0,
@@ -23,7 +23,7 @@ defmodule ScaleUtilsTest do
2323
assert %{
2424
display_decimals: 0,
2525
ticks: [0, 10, 50],
26-
nice_domain: {0.0, 80.0}
26+
nice_domain: {+0.0, 80.0}
2727
} =
2828
ScaleUtils.compute_nice_settings(
2929
0,

0 commit comments

Comments
 (0)