plot
Mojo module 🡭
plot
Plot, the entry point of every chart: settings only, until a mark_*() call picks the mark and the chain becomes a Chart of that mark’s type (#828). Plot().mark_gantt() is a Chart[Gantt], and from there encode_gantt() exists and encode_categorical() does not, which the compiler says rather than render().
Each mark_*() setter builds the mark struct, applies the setter’s
own arguments to it or to the shared settings, and returns
Chart[<mark>](mark, settings, style). The one-call functions
(bar(), gantt(), …) go through the same setters and end in
_finished(), which applies the theme, size and titles.
Where the rest lives:
chart.mojo–Chart[M]andAnyChart, the type-erased chart that layers, facets and figures hold in one listmark_type.mojo– theMarkTypetrait every mark implementsmarks.mojo– one struct per mark, over the renderers and encoders in the mark packagesrendering.mojo–render(),render_svg(),render_pdf(),save()and the tight and accessible variants, generic over any chartlayers.mojo,facets.mojo,layout.mojo– composition overList[AnyChart]core/chart_settings.mojo–_ChartSettings, what every mark shares
This module exports only what it defines, Plot and _finished
(#825); scripts/check_import_direction.py keeps it so.
Adding a mark
- Its
Markconstant incore/mark.mojo,Self(<value>, "<NAME>"),Mark.COUNTone past it, and the constant in_every_mark()(tests/_mark_registry.mojo); the digest and backend sweeps walk that list. - Its struct in
marks.mojo: the columns it owns,renderover them, an override of eachencode_*()it accepts (the trait’s default refuses at compile time), and everyMarkTypeconstant – thesupports_*features and the drawing facts after them (straight_edged,continuous_path,layerable, …). They are required, so a missing one is a compile error rather than a list the new mark was left out of. - Its
mark_*()setter here, returningChart[<mark>]. - Its one-call function in its package, exported from
dataviz/__init__.mojo. - A representative chart in
tests/_mark_registry.mojo, thenpixi run digest-update. - An
ExamplePageinscripts/_example_docstrings.mojoand its entry inscripts/gen_example_docs.mojo, thenpixi run example.
Structs
Plot: The entry point: what a chart is before its mark is chosen.