Adding composer lock for 4.9.8
[phpmyadmin.git] / doc / charts.rst
blob4896d9d794d80d744a75bcf1de6bd4d4019cd389
1 .. _charts:
3 Charts
4 ======
6 .. versionadded:: 3.4.0
8 Since phpMyAdmin version 3.4.0, you can easily generate charts from a SQL query
9 by clicking the "Display chart" link in the "Query results operations" area.
11 .. image:: images/query_result_operations.png
13 A window layer "Display chart" is shown in which you can customize the chart with the following options.
15 -   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).
16 -   X-axis: Allows to choose the field for the main axis.
17 -   Series: Allows to choose series for the chart. You can choose multiple series.
18 -   Title: Allows specifying a title for the chart which is displayed above the chart.
19 -   X-axis and Y-axis labels: Allows specifying labels for axes.
20 -   Start row and a number of rows: Allows generating charts only for a specified number of rows of the results set.
22 .. image:: images/chart.png
24 Chart implementation
25 --------------------
27 Charts in phpMyAdmin are drawn using `jqPlot <http://www.jqplot.com/>`_ jQuery library.
29 Examples
30 --------
32 Pie chart
33 +++++++++
35 Query results for a simple pie chart can be generated with:
37 .. code-block:: mysql
39     SELECT 'Food' AS 'expense',
40        1250 AS 'amount' UNION
41     SELECT 'Accommodation', 500 UNION
42     SELECT 'Travel', 720 UNION
43     SELECT 'Misc', 220
45 And the result of this query is:
47 +---------------+--------+
48 | expense       | amount |
49 +===============+========+
50 | Food          | 1250   |
51 +---------------+--------+
52 | Accommodation | 500    |
53 +---------------+--------+
54 | Travel        | 720    |
55 +---------------+--------+
56 | Misc          | 220    |
57 +---------------+--------+
59 Choosing expense as the X-axis and amount in series:
61 .. image:: images/pie_chart.png
63 Bar and column chart
64 ++++++++++++++++++++
66 Both bar charts and column chats support stacking. Upon selecting one of these types a checkbox is displayed to select stacking.
68 Query results for a simple bar or column chart can be generated with:
70 .. code-block:: mysql
72     SELECT
73        'ACADEMY DINOSAUR' AS 'title',
74        0.99 AS 'rental_rate',
75        20.99 AS 'replacement_cost' UNION
76     SELECT 'ACE GOLDFINGER', 4.99, 12.99 UNION
77     SELECT 'ADAPTATION HOLES', 2.99, 18.99 UNION
78     SELECT 'AFFAIR PREJUDICE', 2.99, 26.99 UNION
79     SELECT 'AFRICAN EGG', 2.99, 22.99
81 And the result of this query is:
83 +------------------+--------------+-------------------+
84 | title            | rental_rate  | replacement_cost  |
85 +==================+==============+===================+
86 | ACADEMY DINOSAUR | 0.99         | 20.99             |
87 +------------------+--------------+-------------------+
88 | ACE GOLDFINGER   | 4.99         | 12.99             |
89 +------------------+--------------+-------------------+
90 | ADAPTATION HOLES | 2.99         | 18.99             |
91 +------------------+--------------+-------------------+
92 | AFFAIR PREJUDICE | 2.99         | 26.99             |
93 +------------------+--------------+-------------------+
94 | AFRICAN EGG      | 2.99         | 22.99             |
95 +------------------+--------------+-------------------+
97 Choosing title as the X-axis and rental_rate and replacement_cost as series:
99 .. image:: images/column_chart.png
101 Scatter chart
102 +++++++++++++
104 Scatter charts are useful in identifying the movement of one or more variable(s) compared to another variable.
106 Using the same data set from bar and column charts section and choosing replacement_cost as the X-axis and rental_rate in series:
108 .. image:: images/scatter_chart.png
110 Line, spline and timeline charts
111 ++++++++++++++++++++++++++++++++
113 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.
115 Query results for a simple line, spline or timeline chart can be generated with:
117 .. code-block:: mysql
119     SELECT
120        DATE('2006-01-08') AS 'date',
121        2056 AS 'revenue',
122        1378 AS 'cost' UNION
123     SELECT DATE('2006-01-09'), 1898, 2301 UNION
124     SELECT DATE('2006-01-15'), 1560, 600 UNION
125     SELECT DATE('2006-01-17'), 3457, 1565
127 And the result of this query is:
129 +------------+---------+------+
130 | date       | revenue | cost |
131 +============+=========+======+
132 | 2016-01-08 | 2056    | 1378 |
133 +------------+---------+------+
134 | 2006-01-09 | 1898    | 2301 |
135 +------------+---------+------+
136 | 2006-01-15 | 1560    | 600  |
137 +------------+---------+------+
138 | 2006-01-17 | 3457    | 1565 |
139 +------------+---------+------+
141 .. image:: images/line_chart.png
142 .. image:: images/spline_chart.png
143 .. image:: images/timeline_chart.png