Chart Units
Chart Units let you label a chart's axes with consistent unit names — USD, Tonnes, Visitors, Percent, and so on. The unit you pick appears alongside (or as) the axis title on the rendered chart, so readers immediately know what the numbers mean.
Units are stored as a standard WordPress taxonomy named Chart Units, attached to the Charts post type. The taxonomy is hierarchical: parent terms are groups (Money, Time, Length, …) and child terms are the units the user can actually pick (USD, Seconds, Meter, …). The plugin ships with a set of common groups and units out of the box, and you can add your own at any time.
Default groups
M Chart pre-populates these groups the first time the plugin runs:
| Group | Units |
|---|---|
| Time | Seconds, Minutes, Hours, Days, Weeks, Months, Quarter, Years, Decades, Centuries |
| Money | USD, EUR, GBP, JPY, CNY |
| Length | Inch, Foot, Yard, Mile, Millimeter, Centimeter, Meter, Kilometer |
| Weight | Tonnes, Tons, Kilograms, Grams, Milligrams, Pounds, Ounces |
| Other | Percent |
| Website/Traffic | Visitors, Unique Visitors, Clicks, Referrers, Active Users, Pages |
| Sales | Units, CPM |
You don't have to use any of these — they're just starting points. They can be renamed or deleted from the admin like any other WordPress term.
Adding new units
- In the WordPress admin, open Charts → Chart Units.
- To add a unit: fill in the
Namefield, pick the parent group from theParent Chart Unitdropdown, and clickAdd New Chart Unit. The slug can be left blank — WordPress derives it from the name. - To add a new group: fill in the
Namefield, leaveParent Chart Unitset toNone, and clickAdd New Chart Unit. A top-level term with no parent becomes a new group that other units can be nested under.
Group order
Groups appear in the chart Units dropdown alphabetically. Name them with that in mind if ordering matters.
Applying units to a chart
The unit pickers live in the Chart meta box on the chart edit screen, in the same row as each axis title field:
- Open a chart for editing.
- Find the
Vertical axis titleandHorizontal axis titlerows in the chart settings panel. - Each row has a
Unitsdropdown next to the title field. Pick the unit that matches the axis's values.
The dropdown lists every group as a disabled header (visual separator) followed by its child units. Pick a child unit — the parent groups themselves aren't selectable. Choose N/A to clear the unit.
When the chart renders:
- If you also filled in the axis title, the unit appears in parentheses after it: a chart with
Vertical axis title=YieldandUnits=Tonnes/hectarerenders the y-axis label as Yield (Tonnes/hectare). - If the axis title is blank, the unit name is the axis label.
Filtering and querying by unit
Because Chart Units is a standard WordPress taxonomy (slug m-chart-units), it works with WordPress's usual filtering and querying mechanisms — useful for surfacing "every chart on the site using X" without writing custom storage:
- Term archive URLs — each unit has a public archive at
/m-chart-units/<slug>/listing every published chart tagged with that unit. Link readers to e.g.https://example.com/m-chart-units/usd/to show all charts measured in US dollars. - Custom queries — pass a
tax_queryagainst them-chart-unitstaxonomy toWP_Query(orget_posts) to fetch charts by unit from theme templates, custom blocks, or admin reports. - REST API — the
/wp/v2/m-chartendpoint accepts?m-chart-units=<term_id>to filter the returned charts by unit. Useful for headless setups and external consumers.
Limits and gotchas
- Units only apply to chart types that have axes — bar, column, line, area, scatter, bubble, treemap (no axes; dropdown hidden), boxplot, violin, etc. On pie, doughnut, radar, radar area, and polar charts there are no x/y axes, so the
Unitsrow doesn't appear in the chart settings. - Custom units survive plugin updates — they're standard WordPress terms stored in your site's database.
- The unit name shown on the chart is whatever you type into the term's
Name. If you need different display text for one chart, the cleanest workaround is to leave Units set toN/Aand put the unit text directly into the axis title field. - Treemap renders the rectangles' value prefix/suffix from each row's data cell (e.g.,
$4500,2200kg), not from this taxonomy. The Units dropdown isn't shown for treemap charts.
