You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/matplotex.ex
+45Lines changed: 45 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,51 @@ defmodule Matplotex do
114
114
## `M.show/1`
115
115
After creating a figure using the functions provided, call M.show/1 to generate and display the final SVG representation of the plot. The show/1 function will convert the Matplotex.Figure data into a valid SVG string.
116
116
117
+
## Matplotex.Figure.Areal behaviour
118
+
Matplotex goes beyond basic chart generation, offering a user-friendly interface for creating custom plots. It leverages two key behaviors: Matplotex.Figure.Areal and Matplotex.Element. The Areal module handles the underlying linear transformations, abstracting away unnecessary complexity. Users can seamlessly integrate SVG strings by defining structs that implement the Element behavior. Mapping data series to these elements is then achieved through the Matplotex.Figure.Areal behavior, making it a compelling tool for custom visualization.
defp materialize_chart_elements(%Figure{axes: %__MODULE__{elements: elements}}) do
147
+
elements ++ [%CustomElement{}]
148
+
end
149
+
```
150
+
* Figure: A common struct used by all chart APIs in the library, serving as both input and output for consistent handling.
151
+
152
+
* Axes: A struct containing all chart-specific information.
153
+
154
+
* Dataset: A modular data input structure. The axes struct expects a list of %Dataset{} structs for converting data points into their SVG element equivalents.
155
+
156
+
* Custom Elements: The materializer function's primary role is to generate a list of structs that implement the Matplotex.Element behavior. This enables the SVG generator to produce the appropriate tags for custom visualizations
157
+
158
+
### Matplotex.Element behaviour
159
+
160
+
The Matplotex.Element behavior defines a callback function, assemble/1, which takes a struct as input and returns its corresponding SVG tag as a string. The assemble/1 function is responsible for interpolating the struct's values into the SVG element.
0 commit comments