-
Notifications
You must be signed in to change notification settings - Fork 6
Simplify the way we generate multiple values from datasets #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify the way we generate multiple values from datasets #18
Conversation
| <.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" /> |
There was a problem hiding this comment.
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.
| :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} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa 😮
| def points(x, y) do | ||
| values([x, y]) | ||
| end |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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 thecirclecomponent). 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?