charts — phpmyadmin 5.2.0 documentation-尊龙登录

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 to choose the type of 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 a 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 jquery library.

examples

pie chart

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

select 'food' as 'expense',
   1250 as 'amount' union
select 'accommodation', 500 union
select 'travel', 720 union
select 'misc', 220

and the result of this query is:

expense

amount

food

1250

accommodation

500

travel

720

misc

220

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:

select
   'academy dinosaur' as 'title',
   0.99 as 'rental_rate',
   20.99 as 'replacement_cost' union
select 'ace goldfinger', 4.99, 12.99 union
select 'adaptation holes', 2.99, 18.99 union
select 'affair prejudice', 2.99, 26.99 union
select 'african egg', 2.99, 22.99

and the result of this query is:

title

rental_rate

replacement_cost

academy dinosaur

0.99

20.99

ace goldfinger

4.99

12.99

adaptation holes

2.99

18.99

affair prejudice

2.99

26.99

african egg

2.99

22.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:

select
   date('2006-01-08') as 'date',
   2056 as 'revenue',
   1378 as 'cost' union
select date('2006-01-09'), 1898, 2301 union
select date('2006-01-15'), 1560, 600 union
select date('2006-01-17'), 3457, 1565

and the result of this query is:

date

revenue

cost

2016-01-08

2056

1378

2006-01-09

1898

2301

2006-01-15

1560

600

2006-01-17

3457

1565

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