-
Notifications
You must be signed in to change notification settings - Fork 6
Start of a Philosophical Rewrite for Version 1.0.0 #21
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
Open
nkyllonen
wants to merge
23
commits into
main
Choose a base branch
from
philosophical-rewrite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d40df11
Add Phoenix Playground demo file
nkyllonen 49f6ff1
Handle scale value conversions with Axes + Separate out Dimensions
doughsay 5248c28
Update DateTimeScale + Add basic tests
doughsay 7018fd0
Change points_plot to circles + Update icon SVG
nkyllonen 5a85816
Implement Access and Enumberable protocols for Datasets
doughsay e765b3b
Fetch padding from dimensions options instead of margin (#14)
krainboltgreene 5733d69
Update demo with new example graph
nkyllonen 8dd415e
Add logo example graph + Add animated example graph
nkyllonen b56fc77
Update README and add migration_guide
nkyllonen 26b9a9a
Rename line_points to polyline and pass list of tuples for points
nkyllonen a35760b
Update demo files with new polyline component
nkyllonen 211078b
Simplify the way we generate multiple values from datasets (#18)
doughsay 076be76
Add docs to points and values + Update demo_live
nkyllonen a2fc0ef
Refactor Axis protocol and add Axis using macro so that axes can be a…
doughsay 19ca435
Update step_polyline to follow polyline component
nkyllonen 4c0bdd5
Remove unneeded marker components + Update docs and animated demo
nkyllonen 7772660
Organize demos and migration guide into subfolders
nkyllonen 28902b5
Update tests and docs (#20)
nkyllonen eb5a79f
Bump Erlang and Elixir versions for CI
nkyllonen fa122b3
Update docs to present better in HexDocs
nkyllonen c75dd9f
Run CI against more elixir/OTP versions (#22)
doughsay bc62321
Update CI to only push to main
nkyllonen 010a6d5
Small cleanups + Fix incorrect migration guide example
nkyllonen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Plox Migration Guide (0.2.0 to X.X.X) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving this generic for now, but this should be |
||
|
|
||
| Plox has gone through a major philosophical rewrite since its initial publication. This | ||
| guide will help users convert their current Plox graphs over to the new approach. | ||
|
|
||
| ## Example of 0.2.0 usage | ||
|
|
||
| 1. Set up data, scales, and dataset: | ||
|
|
||
| ```elixir | ||
| data = [ | ||
| %{date: ~D[2023-08-01], value: 35.0}, | ||
| %{date: ~D[2023-08-02], value: 60.0}, | ||
| %{date: ~D[2023-08-03], value: 65.0}, | ||
| %{date: ~D[2023-08-04], value: 10.0}, | ||
| %{date: ~D[2023-08-05], value: 50.0} | ||
| ] | ||
|
|
||
| date_scale = date_scale(Date.range(~D[2023-08-01], ~D[2023-08-05])) | ||
| number_scale = number_scale(0.0, 80.0) | ||
|
|
||
| dataset = | ||
| dataset(data, | ||
| x: {date_scale, & &1.date}, | ||
| y: {number_scale, & &1.value} | ||
| ) | ||
| ``` | ||
|
|
||
| 2. Build a `Plox.Graph` struct: | ||
|
|
||
| ```elixir | ||
| example_graph = | ||
| to_graph( | ||
| scales: [date_scale: date_scale, number_scale: number_scale], | ||
| datasets: [dataset: dataset] | ||
| ) | ||
| ``` | ||
|
|
||
| 3. Render the `Plox.Graph` within your HEEx template: | ||
|
|
||
| ```html | ||
| <.graph :let={graph} id="example_graph" for={@example_graph} width="800" height="250"> | ||
| <.x_axis :let={date} scale={graph[:date_scale]}> | ||
| {Calendar.strftime(date, "%-m/%-d")} | ||
| </.x_axis> | ||
|
|
||
| <.y_axis :let={value} scale={graph[:number_scale]} ticks={5}> | ||
| {value} | ||
| </.y_axis> | ||
|
|
||
| <.line_plot dataset={graph[:dataset]} color="#EC7E16" /> | ||
|
|
||
| <.points_plot dataset={graph[:dataset]} color="#EC7E16" /> | ||
| </.graph> | ||
| ``` | ||
|
|
||
| ## Example of X.X.X usage | ||
|
|
||
| 1. Set up data, dimensions, axes, and dataset: | ||
|
|
||
| ```elixir | ||
| data = [ | ||
| %{date: ~D[2023-08-01], value: 35.0}, | ||
| %{date: ~D[2023-08-02], value: 60.0}, | ||
| %{date: ~D[2023-08-03], value: 65.0}, | ||
| %{date: ~D[2023-08-04], value: 10.0}, | ||
| %{date: ~D[2023-08-05], value: 50.0} | ||
| ] | ||
|
|
||
| # Instead of passing the height and width via the `graph` component, | ||
| # create Dimensions and pass them to each Axis | ||
| dimensions = Plox.Dimensions.new(800, 250) | ||
|
|
||
| # Instead of creating separate Scales, we need them when creating our Axes | ||
| x_axis = Plox.XAxis.new( | ||
| Plox.DateScale.new(Date.range(~D[2023-08-01], ~D[2023-08-05])), | ||
| dimensions | ||
| ) | ||
|
|
||
| y_axis = Plox.YAxis.new(Plox.NumberScale.new(0.0, 80.0), dimensions) | ||
|
|
||
| # Create a Dataset with our Axes | ||
| dataset = | ||
| Plox.Dataset.new(data, | ||
| x: {x_axis, & &1.date}, | ||
| y: {y_axis, & &1.value} | ||
| ) | ||
| ``` | ||
|
|
||
| 2. Render the `graph` component within your HEEx template: | ||
|
|
||
| ```html | ||
| <.graph id="example_graph" dimensions={@dimensions}> | ||
| <!-- Render axis labels and lines individually --> | ||
| <.x_axis_labels :let={date} axis={@x_axis}> | ||
| {Calendar.strftime(date, "%-m/%-d")} | ||
| </.x_axis_labels> | ||
|
|
||
| <.y_axis_labels :let={value} axis={@y_axis} ticks={5}> | ||
| {value} | ||
| </.y_axis_labels> | ||
|
|
||
| <.x_axis_grid_lines axis={@x_axis} stroke="#D3D3D3" /> | ||
| <.y_axis_grid_lines axis={@y_axis} ticks={5} stroke="#D3D3D3" /> | ||
|
|
||
| <!-- Use the `points/2` helper to generate a list of {x, y} tuples from our Dataset --> | ||
| <.polyline points={points(@dataset[:x], @dataset[:y])} stroke="#EC7E16" stroke-width={2} /> | ||
|
|
||
| <!-- Pass all the `x` values and the `y` values to render circles at each datapoint --> | ||
| <.circle cx={@dataset[:x]} cy={@dataset[:y]} r={3} fill="#EC7E16" /> | ||
| </.graph> | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We'll change this later to
1.0.0✨ when this rewrite is ready! 🤩 (not ready yet)