M ChartM Chart
Users
Pro
Developers
Download
GitHub
Users
Pro
Developers
Download
GitHub
  • M Chart Pro

    • M Chart Pro
    • External Data Sources
    • MySQL Data Sources
    • Smart Data Selection
    • Annotations
    • Theme Builder
    • Display as Table
    • Creating a Google Service Account
    • Creating a Google Fonts API Key
    • Adobe Fonts (Typekit) Setup

External Data Sources

External Data Sources let a chart pull its data from somewhere else instead of being typed into the spreadsheet by hand. Use this when your numbers live in a Google Sheet, a CSV file somewhere on the web, a MySQL database, or another chart on your site, and you want the chart to keep itself up to date. Developer notes for data sources are in M Chart Pro for developers.

External Data Sources panel on the chart edit screen

Overview

There are five source types:

  • Google Sheets — connect a chart to a sheet by URL.
  • Remote CSV — connect a chart to one or more CSV files served over http:// or https://.
  • Another Chart — copy the data of another published chart on this site.
  • Local MySQL — run read-only SQL queries against the WordPress database itself.
  • Remote MySQL — run read-only SQL queries against another MySQL server.

The MySQL sources have their own page — including their administrator-only security model — at MySQL Data Sources.

Once a chart is connected, it re-fetches data on demand (a Sync Now button) and on a schedule. While External Data is active, the chart's spreadsheet is locked for direct editing — every successful sync overwrites whatever is in it.

Setup

Cache period default

Open Charts → Settings. Under the External Data section you'll find Default Cache Period — the schedule charts use when they don't override it themselves. Choices range from 30 minutes to 3 days. The default is 1 day.

Google Sheets service account

A Google service account is needed to read private Google Sheets. This is a one-time, plugin-wide setup. Public sheets work without it.

  1. Create a Google service account and download its JSON key file.
  2. On Charts → Settings, find the Google Sheets — Service Account section. Paste the entire contents of the JSON key file into the Service Account textarea.
  3. Save the settings page.
  4. The section now shows the service account's email address, with a Copy button next to it.
  5. In Google Sheets, share each sheet you want M Chart to read with that email address. Viewer access is enough.

To remove or replace the credentials, click Clear Service Account. The textarea reappears so you can paste a new JSON. Until you do, private sheets won't sync.

Tips

There is no "Test Connection" button. The first time you sync a chart against a private sheet, a successful sync confirms the service account is working.

Connecting a chart to an external source

  1. Open the chart in the WordPress editor.
  2. In the Spreadsheet meta box, switch the Use External Data toggle on.
  3. Pick Google Sheets, Remote CSV, Another Chart, Local MySQL, or Remote MySQL from the Source menu.
  4. Fill in the source-specific fields (see below).
  5. Save the post.

Warning

While External Data is active the spreadsheet inside the meta box is read-only. Each successful sync overwrites it — including sheet count, sheet names, and every cell. Anything you typed in by hand before connecting will be replaced.

Turning Use External Data back off clears all source state for that chart — URLs, tab selections, and sync history are reset.

Cleaning up synced data

Since the spreadsheet can't be edited while External Data is active, use Smart Data Selection to keep junk rows or columns from the source out of the chart. For sources that grow over time, use Auto mode or turn on manual mode's Automatically include new rows and columns option.

Using a CSV source

Paste a public CSV URL into the CSV URL field and give it a name. The URL must use http:// or https://; URLs that need a login or API key are not supported.

For single-sheet chart types, you can connect one CSV URL. For multi-sheet chart types you can connect up to 25 URLs. Each URL becomes one data set in the chart. Use the Add CSV URL button to add another row, and the X icon to remove one.

The CSV format is the same as M Chart's built-in CSV Import, and uses the delimiter set in Charts → Settings → CSV. Keep your header row in the file. M Chart treats the first row and column as labels, like a manually-imported CSV. Short rows are padded to the width of the longest row. Quotes and backslashes in cells are kept as typed.

A View button appears next to a valid URL so you can open it in a new tab to confirm it returns CSV.

Using a Google Sheets source

Paste the share URL of a Google Sheet into the Google Sheets URL field — anything that looks like https://docs.google.com/spreadsheets/d/… will work. The View button opens the sheet in a new tab.

If the sheet is private, share it with the service account email shown on the M Chart settings page. Viewer permission is enough.

If the sheet is public ("Anyone with the link → Viewer"), it can be read without a service account. Tab listing and selection does not work in this mode, so a service account is recommended.

When the sheet has more than one tab, a tab selector appears:

  • On a single-sheet chart type, you'll see radio buttons — pick the one tab you want to use.
  • On a multi-sheet chart type, you'll see checkboxes — each selected tab becomes one data set in the chart.

The whole tab is read every time. There is no cell-range selector.

Tips

If you don't have a service account configured, a yellow warning appears at the top of the Google Sheets tab. You can ignore it and use a publicly-shared sheet; you just won't get tab selection or private-sheet access.

Using another chart as the source

Pick Another Chart from the Source menu to copy the data of another published chart on this site. The Source chart field searches charts by title. Open it to see the first few charts, type to narrow the list, and scroll to the end to load more. The chart you are editing is not offered. A View button opens the source chart's edit screen in a new tab.

Picking a chart syncs right away. Every sheet of the source chart, with its name, is copied and replaces this chart's sheets. A sheet with no name becomes Sheet 1, Sheet 2, and so on. When this chart's type uses one sheet and the source has several, a badge reads "The source chart has more than one sheet; this chart type uses the first one only."

If the source chart uses Smart Data Selection in Manual mode, the rows and columns its author excluded are left out of the copy. In Auto mode the full grid is copied. This chart can apply its own Smart Data Selection on top.

Keeping the copy current

Saving the source chart in the editor pushes its data to every chart that uses it. The push runs through WP-Cron, so it depends on cron running on your site. When the source chart has an External Data source of its own, each of its syncs pushes too. The Refresh schedule and Sync Now also work for this source, so the chart updates even when a push is missed.

A push updates the saved data only. The dependent chart's image version is re-created the next time that chart is saved in the editor.

Chains work: chart A can feed chart B, which feeds chart C. A chart cannot use itself, or any chart that depends on it, as its source. Picking one gives the error "A chart cannot use itself, or a chart that depends on it, as its source."

When the source chart changes

When the source chart is unpublished, trashed, or given a password, the charts that use it keep their last copied data and show a sync error. Publishing it again pushes the data once more. Deleting the source chart for good leaves its dependents with their last data and a failing sync. Nothing on the source chart shows which charts use it, so check before deleting.

Sources are limited to charts on the same site. A chart that is displayed as a table can be a source, and can use one.

Syncing

Manual sync

Click Sync Now next to the Refresh dropdown. The button changes to Syncing… while it runs. When it finishes, the status icon updates:

  • A clock icon means the last sync succeeded — hover to see when.
  • A warning triangle means the last sync failed — hover to read the error message.

Automatic sync while editing

Editing the URL or changing a Google Sheets tab selection automatically triggers a sync about half a second after you stop typing. There is no button to click.

MySQL sources are the exception — queries never run automatically while editing. See Syncing on the MySQL page.

Scheduled sync

Each chart has its own Refresh dropdown that overrides the global cache period for just that chart. Options match the global setting (30 minutes through 3 days).

Scheduled syncs use WordPress's built-in cron, which fires when someone visits your site. Sites with very little traffic may not refresh on time unless a real system cron is configured to drive WP-Cron. If a scheduled sync fails, the chart keeps showing the last good data and the next sync is still booked.

Status indicators

The Charts list table has a Sync column that shows one of:

  • OK — the last sync succeeded
  • Error — the last sync failed (hover for the message)
  • Never — the chart has External Data enabled but has not synced yet
  • — — the chart is not using External Data

The chart edit screen shows the same OK / Error status next to the Sync Now button.

Troubleshooting

Error messageWhat to do
Could not extract a Sheet ID from the provided URLPaste a real Google Sheets share URL.
Google Sheets returned HTTP …; the sheet may not be publicly accessibleShare the sheet with the service account email, or set sharing to "Anyone with the link".
Google Sheets API returned an errorConfirm the sheet is shared with the service account email and that the URL is correct.
The requested sheet tab could not be foundThe tab was renamed or deleted in Google Sheets. Re-pick a tab.
No service account credentials configuredPaste your service account JSON in Charts → Settings.
Could not parse the service account private keyRe-download the JSON key from Google Cloud Console and paste it again.
CSV fetch returned HTTP …The URL is wrong or the source is offline. Verify the URL loads in a browser.
CSV file was emptyThe URL responded successfully but returned nothing. Check that the source is actually producing CSV.
No source chart selected for this chart.Pick a chart in the Source chart field.
A chart cannot use itself, or a chart that depends on it, as its source.Pick a chart that does not take its data from this one.
The source chart could not be found or is not published.Publish the source chart again, or pick another one.
The source chart is password protected and cannot be used as a source.Remove the password from the source chart, or pick another one.

Limits and gotchas

  • A chart can connect up to 25 CSV URLs.
  • Every external fetch has a 15-second timeout. Slow sources may not finish in time. Copies from another chart are local and have no timeout.
  • Saving a source chart pushes its data to at most 100 dependent charts at a time. Charts past that limit update on their own Refresh schedule.
  • A chain of charts feeding charts can be at most 100 charts deep.
  • Another Chart sources are limited to charts on the same site.
  • Nothing on a source chart shows which charts use it. Deleting it leaves those charts with their last data and a failing sync.
  • Turning Use External Data off clears all source state for that chart — URLs, tab selections, and sync history.
  • On WordPress multisite, each subsite needs its own service account JSON.
  • Duplicating a chart copies its External Data configuration. Both copies will sync independently against the same source.
  • Very large sheets or CSV files may be slow to fetch and parse, and can hit your site's PHP memory limit.
  • Sites with no traffic and no system cron won't auto-refresh on schedule. Use Sync Now to refresh manually, or set up a real cron entry.
  • If Smart Data Selection is in manual mode without Automatically include new rows and columns, rows or columns added by a sync stay out of the chart until you review the selections.
Last Updated: 11/7/26, 6:48 PM
Contributors: Jamie Poitra
Prev
M Chart Pro
Next
MySQL Data Sources