API Reference
Mojo package 🡭
dataviz_mojo
This package’s public surface: everything a caller is meant to import, re-exported here so from dataviz_mojo import bar, Plot, Theme works without anyone needing to know which file inside the package a given name actually lives in.
That indirection matters most for the one-call convenience functions
(bar, scatter, pie, …): each one lives in its mark’s file,
next to that mark’s rendering code (see plot.mojo’s module
docstring, its “one-call convenience functions” section, for the rule
and why), so their real module paths – dataviz_mojo.bar.bar,
dataviz_mojo.arc.pie – are an internal layout detail that would be
noisy and surprising to import directly. Import them from the package,
not from the file.
Every name below is listed explicitly – a deliberate, considered
addition to this package’s public surface – with one exception:
colors.mojo’s ~148 CSS-named Color constants (from dataviz_mojo. colors import *, the one wildcard import in this file). Those aren’t
individually-designed features to enumerate one by one, just a single
fixed, already-standard vocabulary (see that file’s docstring) –
listing RED, BLUE, CORNFLOWERBLUE, … by hand here would be
pure noise a spec already settled, not documentation of a real choice
made in this package.
Modules
arcarc_diagrambarbeeswarmboxbulletbumpcalendar_heatmapcandlestickchordcolor_scale: ColorScale – maps a continuous data domain onto a color gradient, for data-driven color encoding (Plot.encode(color=...)). Shares its stop-interpolation logic withcanvas_mojo.gradient’sLinearGradient/RadialGradientvia that module’s_color_at_t/_GradientStop– identical math (bracket the two nearest stops, linearly interpolate), only the projection differs: those two project a pixel position (an axis, or a radial distance) onto [0, 1]; this one projects a data value onto [0, 1] via a plain domain, the same domain-to-[0,1] ideaLinearScaleuses for position, generalized to color instead of a pixel coordinate.colors: Named colors – the full CSS Color Module Level 3 / X11 “extended color keywords” list (https://www.w3.org/TR/css-color-3/#svg-color), plusREBECCAPURPLE(added in Level 4, but universally bundled alongside the rest of this list by every implementation of “the CSS named colors” in practice, not just formally part of Level 3), asColorconstants:Theme(mark_color=CORNFLOWERBLUE)instead of hand-typingTheme(mark_color=Color(100, 149, 237))(see #10 – “make ‘green’ and similar colors just available to specify”). Each name is the CSS keyword itself, uppercased, with no separators added (CORNFLOWERBLUE, notCORNFLOWER_BLUE) – that keeps every name a direct, greppable match for the CSS spec/any color picker a caller already knows the keyword from, rather than a second, dataviz_mojo- specific spelling to remember. Both spellings CSS itself standardizes (GRAY/GREY,DARKGRAY/DARKGREY,DIMGRAY/DIMGREY,LIGHTGRAY/LIGHTGREY,LIGHTSLATEGRAY/LIGHTSLATEGREY,SLATEGRAY/SLATEGREY) are both included, each the identicalColorvalue under both names – picking one and dropping the other would just be a different, equally arbitrary standard.corrplotedges: The shared edge-list core behind the network family (Mark.CHORD/ARC_DIAGRAM/GRAPH/SANKEY): every one of those marks reads the same three columns fromPlot.encode_chord()– afromname, atoname and a magnitude per row – and every one needs the same two answers about them before any mark-specific layout (a ring sector, an arc, a node circle, a column) can be computed: are the columns well-formed, and where does each endpoint sit in the node domain.effect_scatterfunnelganttgaugegraphgrouped_barheatmaphierarchy: The shared tree-indexing core behind the hierarchy family (Mark.SUNBURST/TREE/TREEMAP): every one of those marks needs the exact same three answers aboutPlot.encode_hierarchy()’s flatids/parent_ids/valuesrows – who is whose child, how deep is each node, and what’s each node’s subtree total – before any mark-specific layout (a ring sector, a node position, a rectangle) can be computed. Shared by all three callers.histogramlollipopmarimekkomark: The geometric primitive a data row becomes – the grammar-of- graphicsmarkconcept. Follows the same small-struct-with-comptime- constants-and-__eq__pattern canvas_mojo.FillRule/canvas_mojo.TextAlign use, not a distinct enum mechanism.nightingaleordinal_scale: OrdinalScale – maps a fixed-order list of discrete categories onto evenly spaced pixel bands, the standard “band scale” every bar-chart- style categorical axis needs (matches d3’sscaleBandin spirit: onepaddingfraction, applied as an equal gap on both sides of every band, not separate inner/outer padding knobs).output_format: The file formatsave()(this module’s siblingplot.mojo) writes when a caller hands it aPlotand a path, rather than picking acanvas_mojobackend by hand. Follows the same small-struct-with- comptime-constants-and-__eq__patternMark(mark.mojo) and canvas_mojo’sFillRule/TextAlignuse, not a distinct enum mechanism.parallelplot: Plot – the fluent builder for this package’s first vertical slice: basic X-Y plots (scatter via Mark.POINT, line via Mark.LINE). Data is plain columnarList[Float64]/List[String], passed toencode()/encode_categorical()directly – a 1-D array is all any chart type here needs; a named-columnTableabstraction was built and then removed (see the wiki’s Changelog) once it turned out to add a second way to do the same thing without a concrete need for named-column lookup driving it.polarpolar_barpopulation_pyramidpunchcardradarradialbarridgelinesankeyscale: LinearScale – maps a continuous data domain onto a pixel range, and picks “nice” tick positions within that domain for axis labeling. This is the piece canvas_mojo.geometry.Transform2D’s docstring already named as deferred here:scale()/translate()below compute exactly the slope/intercept Transform2D’s affine map takes, so Plot builds one Transform2D from an x-scale and a y-scale (with the y-scale’s range reversed – pixel y increases downward, data y conventionally increases upward, the same “negative scale_y” trick Transform2D’s docstring documents) rather than reimplementing the linear map here.single_axisspan_chartstacked_barstreamgraphsunbursttheme: Visual defaults for a Plot – colors, sizes, margins – kept as one small struct with sensible defaults rather than a dozen optional parameters scattered across Plot’s builder methods. This is deliberately the one place in this early vertical slice that borrows ECharts’ “config object” ergonomics (a bundle of display knobs) rather than the grammar-of-graphics vocabulary the rest of dataviz follows – appropriate here specifically because a theme isn’t part of the data grammar (it doesn’t change what a mark or scale means), just how it looks.treetreemapviolinwaterfall