Skip to content

Conversation

@doughsay
Copy link
Contributor

@doughsay doughsay commented Jul 9, 2025

My proposal for a "value generator" function (with simple helper points). The idea is that many graphing components are going to need to generate values from datasets. Sometimes you want to do this internal to the library (see the circle component). Sometimes you want to let the user use the value generator directly (see the polyline example in the phoenix playground). I think this is simple and elegant. Thoughts?

Comment on lines +103 to +105
<.polyline points={points(@dataset1[:x], @dataset1[:y])} stroke="orange" stroke-width="2" />
<.polyline points={points(@dataset2[:x], @dataset2[:y])} stroke="blue" stroke-width="2" />
<.polyline points={points(@dataset3[:x], @dataset3[:y])} stroke="green" stroke-width="2" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of the value generator being used outside the library.

Comment on lines +380 to +386
:for={{cx, cy, r, fill, stroke, stroke_width} <- values([@cx, @cy, @r, @fill, @stroke, assigns[:"stroke-width"]])}
cx={cx}
cy={cy}
r={r}
fill={fill}
stroke={stroke}
stroke-width={stroke_width}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of the value generator being used internal to the library

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa 😮

Comment on lines +406 to +408
def points(x, y) do
values([x, y])
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiniest function ever 😆

|> Enum.uniq()

case datasets do
defp validate_zero_or_one_dataset(data) do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little silly, but now that circle isn't using this directly, I would like to move this below values/1 since that is where it's being used.

@nkyllonen nkyllonen merged commit b3d300a into gridpoint-com:philosophical-rewrite Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants