Charts

New in version 3.4.0.

Since phpMyAdmin version 3.4.0, you can easily generate charts from a SQL query by clicking the “Display chart” link in the “Query results operations” area.

_images/query_result_operations.png

A window layer “Display chart” is shown in which you can customize the chart with the following options.

  • Chart type: Allows you choose the type of the chart. Supported types are bar charts, column charts, line charts, spline charts, area charts, pie charts and timeline charts (only the chart types applicable for current series selection are offered).
  • X-axis: Allows to choose the field for the main axis.
  • Series: Allows to choose series for the chart. You can choose multiple series.
  • Title: Allows specifying a title for the chart which is displayed above the chart.
  • X-axis and Y-axis labels: Allows specifying labels for axes.
  • Start row and number of rows: Allows generating charts only for a specified number of rows of the results set.

_images/chart.png

Chart implementation

Charts in phpMyAdmin are drawn using jqPlot jQuery library.

Examples

Pie chart

Query results for a simple pie chart can be generated with:

  1. SELECT 'Food' AS 'expense',
  2. 1250 AS 'amount' UNION
  3. SELECT 'Accommodation', 500 UNION
  4. SELECT 'Travel', 720 UNION
  5. SELECT 'Misc', 220

And the result of this query is:

expenseamount
Food1250
Accommodation500
Travel720
Misc220

Choosing expense as the X-axis and amount in series:

_images/pie_chart.png

Bar and column chart

Both bar charts and column chats support stacking. Upon selecting one of these types a checkbox is displayed to select stacking.

Query results for a simple bar or column chart can be generated with:

  1. SELECT
  2. 'ACADEMY DINOSAUR' AS 'title',
  3. 0.99 AS 'rental_rate',
  4. 20.99 AS 'replacement_cost' UNION
  5. SELECT 'ACE GOLDFINGER', 4.99, 12.99 UNION
  6. SELECT 'ADAPTATION HOLES', 2.99, 18.99 UNION
  7. SELECT 'AFFAIR PREJUDICE', 2.99, 26.99 UNION
  8. SELECT 'AFRICAN EGG', 2.99, 22.99

And the result of this query is:

titlerental_ratereplacement_cost
ACADEMY DINOSAUR0.9920.99
ACE GOLDFINGER4.9912.99
ADAPTATION HOLES2.9918.99
AFFAIR PREJUDICE2.9926.99
AFRICAN EGG2.9922.99

Choosing title as the X-axis and rental_rate and replacement_cost as series:

_images/column_chart.png

Scatter chart

Scatter charts are useful in identifying the movement of one or more variable(s) compared to another variable.

Using the same data set from bar and column charts section and choosing replacement_cost as the X-axis and rental_rate in series:

_images/scatter_chart.png

Line, spline and timeline charts

These charts can be used to illustrate trends in underlying data. Spline charts draw smooth lines while timeline charts draw X-axis taking the distances between the dates/time into consideration.

Query results for a simple line, spline or timeline chart can be generated with:

  1. SELECT
  2. DATE('2006-01-08') AS 'date',
  3. 2056 AS 'revenue',
  4. 1378 AS 'cost' UNION
  5. SELECT DATE('2006-01-09'), 1898, 2301 UNION
  6. SELECT DATE('2006-01-15'), 1560, 600 UNION
  7. SELECT DATE('2006-01-17'), 3457, 1565

And the result of this query is:

daterevenuecost
2016-01-0820561378
2006-01-0918982301
2006-01-151560600
2006-01-1734571565

_images/line_chart.png _images/spline_chart.png _images/timeline_chart.png