Closed travelmassive closed 1 year ago
That's awesome thanks Ian. When I get a chance, I'll add them to the context-samples project - anything that helps get developers productive quickly is really appreciated!
Here's one more example, a stacked bar chart.
(The stacked bar chart took me the longest to figure out how to generate, so this would be helpful example in the docs).
data = [
["Tiktok", 4.7, 3],
["Twitter", 6.7, 2],
["YouTube", 5.2, 5],
["Blog/Website", 7, 8],
["Instagram", 10.5, 7]
]
series_cols = ["Series 1", "Series 2"]
test_data = Contex.Dataset.new(data, ["Category" | series_cols])
options = [
mapping: %{category_col: "Category", value_cols: ["Series 1", "Series 2"]},
type: :stacked,
data_labels: true,
orientation: :vertical,
colour_palette: ["4c4bdc", "c13584"],
series_columns: series_cols
]
Contex.Plot.new(test_data, Contex.BarChart, 500, 400, options)
|> Contex.Plot.titles("Combined Reach of Brand + Individuals (M)", "")
|> Contex.Plot.axis_labels("", "")
|> Contex.Plot.plot_options(%{})
|> Contex.Plot.to_svg()
Closed with PR #83 - ExDocs now has a number of gallery modules (thanks to @l3nz ) where sample code is used to automatically generate the SVG output that is embedded in the docs. Currently not released, but you can access from GitHub master, then run mix docs
to generate the docs locally.
Thanks for the samples!
Thanks for creating a fantastic library for Elixir!
I'm currently using Contex for:
I recently needed to develop a few "one off" charts for a static marketing page, and decided to try Contex for that too. However I struggled a little bit to find straight up example code for some of the charts. As a new user of the library, it took me a little longer than usual to get started as I was trying to hunt down some simple copy-paste examples that could work out of the box.
Anyway, I eventually made a couple of charts and thought I'd share the code in case you wanted to add more examples to help other users. Alternatively, I could put this in a gist. Sorry if I've put this in the wrong place!
Cheers, Ian