Skip to content

Commit 38f4b03

Browse files
committed
Remove old label and grid line components
1 parent be4ae72 commit 38f4b03

1 file changed

Lines changed: 0 additions & 252 deletions

File tree

lib/plox.ex

Lines changed: 0 additions & 252 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ defmodule Plox do
88
alias Plox.Constants
99
alias Plox.Dimensions
1010
alias Plox.Scale
11-
alias Plox.XAxis
12-
alias Plox.YAxis
1311

1412
@doc """
1513
Entrypoint component for rendering graphs and plots.
@@ -36,256 +34,6 @@ defmodule Plox do
3634
"""
3735
end
3836

39-
@doc """
40-
X-axis labels along the bottom or top of the graph.
41-
42-
See `x_axis_label/1` for more details on the accepted attributes.
43-
"""
44-
@doc type: :component
45-
46-
attr :axis, XAxis, required: true
47-
attr :ticks, :any
48-
attr :step, :any
49-
attr :start, :any
50-
attr :rest, :global, include: ~w(gap rotation position) ++ Constants.svg_presentation_attrs()
51-
52-
slot :inner_block, required: true
53-
54-
def x_axis_labels(assigns) do
55-
~H"""
56-
<.x_axis_label
57-
:for={value <- Scale.values(@axis.scale, Map.take(assigns, [:ticks, :step, :start]))}
58-
axis={@axis}
59-
value={value}
60-
{@rest}
61-
>
62-
{render_slot(@inner_block, value)}
63-
</.x_axis_label>
64-
"""
65-
end
66-
67-
@doc """
68-
An X-axis label at the bottom or top of the graph.
69-
"""
70-
@doc type: :component
71-
72-
attr :axis, XAxis, required: true
73-
attr :value, :any, required: true
74-
attr :position, :atom, values: [:top, :bottom], default: :bottom
75-
attr :gap, :integer, default: 16
76-
attr :rotation, :integer, default: nil
77-
attr :"dominant-baseline", :any, default: nil
78-
attr :"text-anchor", :any, default: "middle"
79-
attr :rest, :global, include: Constants.svg_presentation_attrs()
80-
81-
slot :inner_block, required: true
82-
83-
def x_axis_label(%{position: :bottom} = assigns) do
84-
~H"""
85-
<text
86-
x={x = @axis[@value]}
87-
y={@axis.dimensions.height - @axis.dimensions.margin.bottom + @gap}
88-
dominant-baseline={assigns[:"dominant-baseline"] || "hanging"}
89-
text-anchor={assigns[:"text-anchor"]}
90-
transform={
91-
if @rotation,
92-
do:
93-
"rotate(#{@rotation}, #{x}, #{@axis.dimensions.height - @axis.dimensions.margin.bottom + @gap})"
94-
}
95-
{@rest}
96-
>
97-
{render_slot(@inner_block)}
98-
</text>
99-
"""
100-
end
101-
102-
def x_axis_label(%{position: :top} = assigns) do
103-
~H"""
104-
<text
105-
x={x = @axis[@value]}
106-
y={@axis.dimensions.margin.bottom - @gap}
107-
dominant-baseline={assigns[:"dominant-baseline"] || "text-bottom"}
108-
text-anchor={assigns[:"text-anchor"]}
109-
transform={
110-
if @rotation,
111-
do: "rotate(#{@rotation}, #{x}, #{@axis.dimensions.margin.bottom - @gap})"
112-
}
113-
{@rest}
114-
>
115-
{render_slot(@inner_block)}
116-
</text>
117-
"""
118-
end
119-
120-
@doc """
121-
Y-axis labels along the left or right side of the graph.
122-
123-
See `y_axis_label/1` for more details on the accepeted attributes.
124-
"""
125-
@doc type: :component
126-
127-
attr :axis, YAxis, required: true
128-
attr :ticks, :any
129-
attr :step, :any
130-
attr :start, :any
131-
attr :rest, :global, include: ~w(gap rotation position) ++ Constants.svg_presentation_attrs()
132-
133-
slot :inner_block, required: true
134-
135-
def y_axis_labels(assigns) do
136-
~H"""
137-
<.y_axis_label
138-
:for={value <- Scale.values(@axis.scale, Map.take(assigns, [:ticks, :step, :start]))}
139-
axis={@axis}
140-
value={value}
141-
{@rest}
142-
>
143-
{render_slot(@inner_block, value)}
144-
</.y_axis_label>
145-
"""
146-
end
147-
148-
@doc """
149-
A Y-axis label at the left or right side of the graph.
150-
"""
151-
@doc type: :component
152-
153-
attr :axis, YAxis, required: true
154-
attr :value, :any, required: true
155-
attr :position, :atom, values: [:left, :right], default: :left
156-
attr :gap, :integer, default: 16
157-
attr :rotation, :integer, default: nil
158-
attr :"dominant-baseline", :any, default: "middle"
159-
attr :"text-anchor", :any, default: nil
160-
attr :rest, :global, include: Constants.svg_presentation_attrs()
161-
162-
slot :inner_block, required: true
163-
164-
def y_axis_label(%{position: :left} = assigns) do
165-
~H"""
166-
<text
167-
x={@axis.dimensions.margin.left - @gap}
168-
y={y = @axis[@value]}
169-
dominant-baseline={assigns[:"dominant-baseline"]}
170-
text-anchor={assigns[:"text-anchor"] || "end"}
171-
transform={
172-
if @rotation,
173-
do: "rotate(#{@rotation}, #{@axis.dimensions.margin.left - @gap}, #{y})"
174-
}
175-
{@rest}
176-
>
177-
{render_slot(@inner_block)}
178-
</text>
179-
"""
180-
end
181-
182-
def y_axis_label(%{position: :right} = assigns) do
183-
~H"""
184-
<text
185-
x={@axis.dimensions.width - @axis.dimensions.margin.right + @gap}
186-
y={y = @axis[@value]}
187-
dominant-baseline={assigns[:"dominant-baseline"]}
188-
text-anchor={assigns[:"text-anchor"] || "start"}
189-
transform={
190-
if @rotation,
191-
do:
192-
"rotate(#{@rotation}, #{@axis.dimensions.width - @axis.dimensions.margin.right + @gap}, #{y})"
193-
}
194-
{@rest}
195-
>
196-
{render_slot(@inner_block)}
197-
</text>
198-
"""
199-
end
200-
201-
@doc """
202-
X-axis grid lines.
203-
"""
204-
@doc type: :component
205-
206-
attr :axis, XAxis, required: true
207-
attr :ticks, :any
208-
attr :step, :any
209-
attr :start, :any
210-
attr :rest, :global, include: Constants.svg_presentation_attrs()
211-
212-
def x_axis_grid_lines(assigns) do
213-
~H"""
214-
<.x_axis_grid_line
215-
:for={value <- Scale.values(@axis.scale, Map.take(assigns, [:ticks, :step, :start]))}
216-
axis={@axis}
217-
value={value}
218-
{@rest}
219-
/>
220-
"""
221-
end
222-
223-
@doc """
224-
A single X-axis grid line.
225-
"""
226-
@doc type: :component
227-
228-
attr :axis, XAxis, required: true
229-
attr :value, :any, required: true
230-
attr :top_overdraw, :integer, default: 0
231-
attr :bottom_overdraw, :integer, default: 0
232-
attr :rest, :global, include: Constants.svg_presentation_attrs()
233-
234-
def x_axis_grid_line(assigns) do
235-
~H"""
236-
<line
237-
x1={x = @axis[@value]}
238-
y1={@axis.dimensions.margin.top - @top_overdraw}
239-
x2={x}
240-
y2={@axis.dimensions.height - @axis.dimensions.margin.bottom + @bottom_overdraw}
241-
{@rest}
242-
/>
243-
"""
244-
end
245-
246-
@doc """
247-
Y-axis grid lines.
248-
"""
249-
@doc type: :component
250-
251-
attr :axis, YAxis, required: true
252-
attr :ticks, :any
253-
attr :step, :any
254-
attr :start, :any
255-
attr :rest, :global, include: Constants.svg_presentation_attrs()
256-
257-
def y_axis_grid_lines(assigns) do
258-
~H"""
259-
<.y_axis_grid_line
260-
:for={value <- Scale.values(@axis.scale, Map.take(assigns, [:ticks, :step, :start]))}
261-
axis={@axis}
262-
value={value}
263-
{@rest}
264-
/>
265-
"""
266-
end
267-
268-
@doc """
269-
A single Y-axis grid line.
270-
"""
271-
@doc type: :component
272-
273-
attr :axis, YAxis, required: true
274-
attr :value, :any, required: true
275-
attr :rest, :global, include: Constants.svg_presentation_attrs()
276-
277-
def y_axis_grid_line(assigns) do
278-
~H"""
279-
<line
280-
x1={@axis.dimensions.margin.left}
281-
y1={y = @axis[@value]}
282-
x2={@axis.dimensions.width - @axis.dimensions.margin.right}
283-
y2={y}
284-
{@rest}
285-
/>
286-
"""
287-
end
288-
28937
@doc """
29038
Draws a SVG `<polyline>` element connecting a series of points.
29139
"""

0 commit comments

Comments
 (0)