charts.rst.txt 4.6 KB

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