Make PMA_DBI_getCompatibilities() aware of Drizzle - it doesn't have SQL_MODE
[phpmyadmin.git] / tbl_chart.php
blob817a8ead7ef1e5590b60d0bd0d7da00d9a60c8f8
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * handles creation of the chart
6 * @package phpMyAdmin
7 */
9 /**
10 * do not import request variable into global scope
11 * @ignore
13 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
14 define('PMA_NO_VARIABLES_IMPORT', true);
17 /**
20 require_once './libraries/common.inc.php';
22 $GLOBALS['js_include'][] = 'tbl_chart.js';
23 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
24 /* Files required for chart exporting */
25 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
26 $GLOBALS['js_include'][] = 'canvg/canvg.js';
27 $GLOBALS['js_include'][] = 'canvg/rgbcolor.js';
29 /**
30 * Runs common work
32 if (strlen($GLOBALS['table'])) {
33 $url_params['goto'] = $cfg['DefaultTabTable'];
34 $url_params['back'] = 'tbl_sql.php';
35 require './libraries/tbl_common.php';
36 require './libraries/tbl_info.inc.php';
37 require './libraries/tbl_links.inc.php';
38 } elseif (strlen($GLOBALS['db'])) {
39 $url_params['goto'] = $cfg['DefaultTabDatabase'];
40 $url_params['back'] = 'sql.php';
41 require './libraries/db_common.inc.php';
42 require './libraries/db_info.inc.php';
43 } else {
44 $url_params['goto'] = $cfg['DefaultTabServer'];
45 $url_params['back'] = 'sql.php';
46 require './libraries/server_common.inc.php';
47 require './libraries/server_links.inc.php';
51 * Execute the query and return the result
53 $data = array();
55 $result = PMA_DBI_try_query($sql_query);
56 while ($row = PMA_DBI_fetch_assoc($result)) {
57 $data[] = $row;
60 // get settings if any posted
61 $chartSettings = array();
62 if (PMA_isValid($_REQUEST['chartSettings'], 'array')) {
63 $chartSettings = $_REQUEST['chartSettings'];
66 $url_params['db'] = $GLOBALS['db'];
67 $url_params['reload'] = 1;
69 /**
70 * Displays the page
72 // pma_token/url_query needed for chart export
74 <script type="text/javascript">
75 pma_token = '<?php echo $_SESSION[' PMA_token ']; ?>';
76 url_query = '<?php echo $url_query;?>';
77 </script>
78 <!-- Display Chart options -->
79 <div id="div_view_options">
80 <form method="post" action="tbl_chart.php">
81 <?php echo PMA_generate_common_hidden_inputs($url_params); ?>
82 <fieldset>
83 <legend><?php echo __('Display chart'); ?></legend>
84 <div style="float:left;">
85 <input type="radio" name="chartType" value="bar"><?php echo __('Bar'); ?>
86 <input type="radio" name="chartType" value="column"><?php echo __('Column'); ?>
87 <input type="radio" name="chartType" value="line" checked><?php echo __('Line'); ?>
88 <input type="radio" name="chartType" value="spline"><?php echo __('Spline'); ?>
89 <input type="radio" name="chartType" value="pie"><?php echo __('Pie'); ?>
90 <span class="barStacked" style="display:none;">
91 <input type="checkbox" name="barStacked" value="1"><?php echo __('Stacked'); ?>
92 </span>
93 <br>
94 <input type="text" name="chartTitle" value="<?php echo __('Chart title'); ?>">
95 <?php $keys = array_keys($data[0]);
96 $yaxis=-1;
97 if(count($keys)>1) {
98 echo '<br>';
99 echo __('X-Axis:'); ?> <select name="chartXAxis">
100 <?php
102 foreach($keys as $idx=>$key) {
103 if($yaxis==-1 && ($idx==count($data[0])-1 || preg_match("/(date|time)/i",$key))) {
104 echo '<option value="'.$idx.'" selected>'.$key.'</option>';
105 $yaxis=$idx;
106 } else {
107 echo '<option value="'.$idx.'">'.$key.'</option>';
112 </select><br>
113 <?php echo __('Series:'); ?>
114 <select name="chartSeries">
115 <option value="columns"><?php echo __('The remaining columns'); ?></option>
116 <?php
117 foreach($keys as $idx=>$key) {
118 echo '<option>'.$key.'</option>';
121 </select>
122 <?php
126 </div>
127 <div style="float:left; padding-left:40px;">
128 <?php echo __('X-Axis label:'); ?> <input style="margin-top:0;" type="text" name="xaxis_label" value="<?php echo ($yaxis==-1)?__('X Values'):$keys[$yaxis]; ?>"><br>
129 <?php echo __('Y-Axis label:'); ?> <input type="text" name="yaxis_label" value="<?php echo __('Y Values'); ?>">
130 </div>
131 <p style="clear:both;">&nbsp;</p>
132 <div id="resizer" style="width:600px; height:400px;">
133 <div id="inner-resizer">
134 <div id="querychart" style="display:none;">
135 <?php echo json_encode($data); ?>
136 </div>
137 </div>
138 </div>
139 </fieldset>
140 </form>
141 </div>
142 <?php
144 * Displays the footer
146 require_once './libraries/footer.inc.php';