Graphina Documentation

Using SQL Builder to Fetch Dynamic Data for WordPress Charts

Introduction

In this guide, we’ll explore the fastest way to integrate dynamic charts in WordPress using SQL Builder with MySQL and PHP. Instead of manually updating data, you can leverage SQL queries to pull real-time information directly from your WordPress database.

We’ve previously discussed dynamic data and its sources—now, it’s time to put that knowledge into action. This tutorial will transform a static chart into a fully dynamic one using SQL Builder.


How to Use SQL Builder for Dynamic Charts

Step 1 – Select Your Chart

  • Open Graphina – WordPress Chart Plugin.
  • Choose the chart type where you want to display data (e.g., Line Chart).

Step 2 – Switch from Manual to Dynamic Data

  • Navigate to the chart data settings.
  • Change the data source from “Manual” to “Dynamic”.
  • At this stage, the chart might display “No Data Available”—this is expected because the data source hasn’t been selected yet.

Step 3 – Enable SQL Builder

  • In the Dynamic Data Options, select “SQL Builder” as the data source.
  • You will now see a text area where you can enter an SQL query.

Step 4 – Selecting a Table

  • Click on “Select Mode”, which allows you to choose a table.
  • A drop-down list of available WordPress database tables will appear.
  • Select a table from the list—the chart will instantly reflect the selected table’s data.

Step 5 – Writing and Executing SQL Queries

  • Write your SQL Query inside the text area. The query will execute automatically, updating the chart in real time.
  • The column list from your SQL query result will be available for X-Axis and Y-Axis selection.

Step 6 – Finalizing the Chart

  • Click on “External” under the SQL Builder options.
  • Choose a dataset from the dropdown (e.g., WordPress 2).
  • Edit your SQL Raw Query and select the desired column for the Y-axis.
  • The chart will now display live database-driven data.

Key Features & Notes

Supports Any WordPress Database Table – Fetch data from any table in your WordPress database.
Uppercase Column Names – Enable the setting for capitalized column names if needed.
Offset & Limit Control – Set to NULL if not required.
Instant Data Execution – SQL queries automatically update the chart upon execution.

By following these steps, you can seamlessly integrate dynamic charts in WordPress using SQL Builder, eliminating the need for manual data updates! 🚀