Repository navigation
Blocks Chart
Block name: designsetgo/chart
Version: 1.0.0
Category: DesignSetGo
Keywords: chart, graph, data, bar, donut, statistics
The Chart Block renders bar, line, and donut charts as inline SVG — no charting library, no frontend JavaScript. Data can be typed in by hand or pulled live from a post meta field, so the same chart can show different numbers per post in a query loop.
Key Features:
- Bar, line, and donut chart types, drawn as a single server-rendered SVG
- Manual data entry or a post meta field (
dataSource) holding a JSON array of{label, value}rows - Per-series colors, with theme-palette fallbacks
- Optional value labels, legend, and gridlines
- Prefix/suffix and thousands-grouping for every printed value
- Always emits a visually-hidden data table — this is the accessible, screen-reader and search-engine version of the chart, not a fallback
- Server-rendered (
render.php): the editor preview and the frontend markup are produced by the same PHP, via<ServerSideRender>
- Insert the Chart block (Design category).
- Choose a Chart type: Bar, Line, or Donut.
- Leave Data source as "Enter data" and add rows with the Add row button, or switch it to "Post meta field" and enter a meta key.
- Set colors per series from the Color panel (Series), and adjust height, legend, grid, and value formatting under Style.
-
Chart type: Bar, Line, or Donut (
chartType, defaultbar). Donut hides the Legend/Grid toggles below because a donut has no axis. -
Description: Optional text (
label) read by screen readers as the data table's<caption>. -
Data source: "Enter data" (
manual) or "Post meta field" (meta) (dataSource).- Data (manual only): row-by-row editor — Label + numeric Value per row, with Add row / Remove row.
-
Meta key (meta only): the post meta key (
metaKey) to read. The field must hold a JSON array of{label, value}objects (or an already-decoded PHP array in that shape). UsespostIdfrom block context, so it works inside a query loop and reads the current item's post, not the block's own post.
-
Height: 80–800px (
height, default 240). -
Legend: Show/hide the legend (
showLegend, defaulttrue). Hidden for donut charts only when every category name is already drawn on the axis; otherwise the toggle is unavailable because the legend is the only sighted route from a mark to its category. -
Values: Show/hide value labels on bars/points, or share-of-total labels on donut slices (
showValues, defaulttrue). -
Grid: Show/hide horizontal gridlines and axis tick labels (
showGrid, defaulttrue). Not available for donut. -
Value prefix / Value suffix: Text added before/after every printed value (
valuePrefix,valueSuffix), e.g.$or%. On a donut, slice labels are always a share of the total and never take the prefix/suffix. -
Group thousands: Adds thousands separators, e.g.
1,234,567(groupThousands, defaultfalse).
A Series dropdown in the sidebar's Color panel exposes one color control per data row (up to 6 slots when the source is post meta, since the actual rows aren't known until render). Colors are positional — setting series 2's color never shifts series 1 or 3. Unset series fall back to a 4-color theme palette (--wp--preset--color--primary/secondary/tertiary/accent, cycling if there are more series than colors).
Anchor, align: wide|full, spacing (margin, padding), typography (font size, font family), and background/text color are available through the standard sidebar panels.
- Rows must have a numeric
value; rows without one are dropped silently. - A hard cap (
designsetgo_chart_max_rowsfilter, default 200) limits how many rows are drawn, regardless of source. Beyond the cap, the chart draws only the first 200 rows and the data table's caption discloses the true row count (e.g. "Showing the first 200 of 340 rows"). - A donut chart additionally drops rows with a value of zero or less — a negative can't be a positive share of a total, so those rows are removed from the plot, legend, and data table together rather than being misrepresented in one of them.
- Post-meta reads honor the same visibility gates as Block Bindings: protected meta keys are never read, and a private or password-protected post's meta is withheld unless the current user can read that post.
- The
<svg>itself isaria-hidden="true"withrole="presentation"— it carries no accessible information of its own. - A
<table class="screen-reader-text">is always rendered alongside it, listing every row's label and formatted value. This table, not the SVG, is the chart's accessible representation, and it is what search engines and screen readers see. - Color is never the only channel identifying a series: every series appears in the legend (when shown) and in the data table.
- Custom colors accept raw CSS (including
var()references) but are run through a strict character allowlist that rejects anything that could break out of astyleattribute (e.g.;,url(,expression().
-
Icon (
designsetgo/icon) — see ICON.md for the icon library the plugin uses elsewhere; the Chart block does not use icons itself. -
Progress Bar (
designsetgo/progress-bar) — see PROGRESS-BAR.md for a single-value alternative when a full chart is more than the data needs.
- Fully dynamic:
save()is not used (the block has nosave.js);render.phpis the single source of truth for both the editor preview (viaServerSideRender) and the frontend, so there is no JS/PHP geometry to keep in sync. - Geometry (scaling, axis ticks, arc math) lives in
chart-geometry.php; data resolution and the accessible table inchart-data.php; color/palette resolution inchart-colors.php. - Covered by
tests/phpunit/chart-geometry-test.php,tests/phpunit/chart-render-test.php, and Jest tests undertests/unit/blocks/chart-*.test.js. - See 2026-08-16-chart-block.md for the original implementation plan (architecture rationale for going server-rendered).
Auto-generated from
docs/blocks/CHART.md. To update, edit the source file and changes will sync on next push to main.
- Accordion
- Advanced Heading
- Blobs
- Breadcrumbs
- Card
- Chart
- Comparison Table
- Countdown Timer
- Counter Group
- Divider
- Dynamic Image
- Fifty Fifty
- Flip Card
- Form Builder
- Grid
- Hotspot
- Icon
- Icon Button
- Icon List
- Image Accordion
- Map
- Modal
- Modal Api Reference
- Modal Auto Triggers
- Modal Fse Compatibility
- Modal Gallery Navigation
- Modal Trigger
- Pill
- Product Categories Grid
- Product Showcase Hero
- Progress Bar
- Query
- Query Filter
- Query Group Header
- Query No Results
- Query Pagination
- Query Results
- Row
- Scroll Accordion
- Scroll Marquee
- Scroll Slides
- Section
- Section Divider
- Slider
- Star Rating
- Sticky Sections
- Table Of Contents
- Tabs
- Text Path
- Timeline
- Background Video
- Block Animations
- Clickable Group
- Conditional Visibility
- Custom Css
- Draft Mode
- Dynamic Tags
- Expanding Background
- Grid Mobile Order
- Grid Span
- Hover Effects
- Max Width
- Responsive Visibility
- Reveal Control
- Scroll Parallax
- Sticky Header
- Style Binding
- Svg Patterns
- Text Alignment Inheritance
- Text Reveal
- Abilities Api
- Abilities Api Guide
- Block Bindings
- Draft Mode Api
- Form Webhooks
- Generation Contract
- Interactive Blocks
- Layout Flexibility
- Markdown Content Negotiation
- Rest Api Reference
- Wp Cli Reference
- Ai Assisted Development
- Best Practices Summary
- Block Controls Organization
- Block Development Best Practices Comprehensive
- Block Exclusion Guide
- Deploying To Wordpress Org
- Design System
- 2026 04 16 Blocks Editor Ux Design
- 2026 04 17 Theme 3 Inspector Ia
- 2026 04 21 Query Block Onboarding
- 2026 04 21 Query Capable Layout Blocks Design
- 2026 04 27 Block Roadmap Ideas
- 2026 07 01 Shape Divider Theme Inheritance
- 2026 07 02 Icon Block Dynamic Render Pilot
- 2026 07 06 Section Divider Block Design
- 2026 07 06 Section Style Variations Fse Design
- 2026 07 06 Section Styles Editor Preview
- 2026 07 07 Row Grid Overlay Hover Parity Design
- 2026 07 21 Conditional And Dup Label Sourcing
- 2026 07 23 Theme Block Type Animation Defaults
- 2026 08 16 Chart Block
- 2026 08 16 Greenshift Gap Roadmap
- 2026 08 17 Woocommerce Surface
- 2026 08 24 Loop Carousel
- 2026 08 24 Star Rating Block
- 2026 09 17 Abilities Drift Prevention
- 2026 09 17 Abilities Drift Prevention Implementation
- 2026 09 29 Existing User Regression Fixes
- 2026 09 29 Release Preflight Fixes
- Readme
- 2026 07 02 Block Authorability Audit
- 2026 09 29 Regression Fixes
- 2026 09 29 Release 2.9.0
- 2026 09 29 Release Fixes
- 2026 10 19 Bug Hunt
- 2026 10 20 Bug Hunt Round 2