RFE 3141334: Reload icon
[phpmyadmin-themes.git] / tbl_chart.php
blobf4b8bd3adb3ce57ca88a2f033e753d3805a6d0dc
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'][] = 'pMap.js';
24 /**
25 * Runs common work
27 require './libraries/db_common.inc.php';
28 $url_params['goto'] = $cfg['DefaultTabDatabase'];
29 $url_params['back'] = 'sql.php';
32 * Import chart functions
34 require_once './libraries/chart.lib.php';
37 * Execute the query and return the result
39 $data = array();
41 $result = PMA_DBI_try_query($sql_query);
42 while ($row = PMA_DBI_fetch_assoc($result)) {
43 $data[] = $row;
46 // get settings if any posted
47 $chartSettings = array();
48 if (PMA_isValid($_REQUEST['chartSettings'], 'array')) {
49 $chartSettings = $_REQUEST['chartSettings'];
52 // get the chart and settings after chart generation
53 $chart = PMA_chart_results($data, $chartSettings);
55 if (!empty($chart)) {
56 $message = PMA_Message::success(__('Chart generated successfully.'));
58 else {
59 $message = PMA_Message::error(__('The result of this query can\'t be used for a chart. See [a@./Documentation.html#faq6_29@Documentation]FAQ 6.29[/a]'));
62 /**
63 * Displays top menu links
64 * We use db links because a chart is not necessarily on a single table
66 $num_tables = 0;
67 require_once './libraries/db_links.inc.php';
69 $url_params['db'] = $GLOBALS['db'];
70 $url_params['reload'] = 1;
72 /**
73 * Displays the page
76 <!-- Display Chart options -->
77 <div id="div_view_options">
78 <form method="post" action="tbl_chart.php">
79 <?php echo PMA_generate_common_hidden_inputs($url_params); ?>
80 <fieldset>
81 <legend><?php echo __('Display chart'); ?></legend>
83 <div style="float: right">
84 <?php echo $chart; ?>
85 </div>
87 <input type="hidden" name="sql_query" id="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
89 <table>
90 <tr><td><label for="width"><?php echo __("Width"); ?></label></td>
91 <td><input type="text" name="chartSettings[width]" id="width" value="<?php echo (isset($chartSettings['width']) ? htmlspecialchars($chartSettings['width']) : ''); ?>" /></td>
92 </tr>
94 <tr><td><label for="height"><?php echo __("Height"); ?></label></td>
95 <td><input type="text" name="chartSettings[height]" id="height" value="<?php echo (isset($chartSettings['height']) ? htmlspecialchars($chartSettings['height']) : ''); ?>" /></td>
96 </tr>
98 <tr><td><label for="titleText"><?php echo __("Title"); ?></label></td>
99 <td><input type="text" name="chartSettings[titleText]" id="titleText" value="<?php echo (isset($chartSettings['titleText']) ? htmlspecialchars($chartSettings['titleText']) : ''); ?>" /></td>
100 </tr>
102 <?php if ($chartSettings['type'] != 'pie' && $chartSettings['type'] != 'radar') { ?>
103 <tr><td><label for="xLabel"><?php echo __("X Axis label"); ?></label></td>
104 <td><input type="text" name="chartSettings[xLabel]" id="xLabel" value="<?php echo (isset($chartSettings['xLabel']) ? htmlspecialchars($chartSettings['xLabel']) : ''); ?>" /></td>
105 </tr>
107 <tr><td><label for="yLabel"><?php echo __("Y Axis label"); ?></label></td>
108 <td><input type="text" name="chartSettings[yLabel]" id="yLabel" value="<?php echo (isset($chartSettings['yLabel']) ? htmlspecialchars($chartSettings['yLabel']) : ''); ?>" /></td>
109 </tr>
110 <?php } ?>
112 <tr><td><label for="areaMargins"><?php echo __("Area margins"); ?></label></td>
113 <td>
114 <input type="text" name="chartSettings[areaMargins][]" size="2" value="<?php echo (isset($chartSettings['areaMargins'][0]) ? htmlspecialchars($chartSettings['areaMargins'][0]) : ''); ?>" />
115 <input type="text" name="chartSettings[areaMargins][]" size="2" value="<?php echo (isset($chartSettings['areaMargins'][1]) ? htmlspecialchars($chartSettings['areaMargins'][1]) : ''); ?>" />
116 <input type="text" name="chartSettings[areaMargins][]" size="2" value="<?php echo (isset($chartSettings['areaMargins'][2]) ? htmlspecialchars($chartSettings['areaMargins'][2]) : ''); ?>" />
117 <input type="text" name="chartSettings[areaMargins][]" size="2" value="<?php echo (isset($chartSettings['areaMargins'][3]) ? htmlspecialchars($chartSettings['areaMargins'][3]) : ''); ?>" />
118 </td>
119 </tr>
121 <?php if ($chartSettings['legend'] == true) { ?>
122 <tr><td><label for="legendMargins"><?php echo __("Legend margins"); ?></label></td>
123 <td>
124 <input type="text" name="chartSettings[legendMargins][]" size="2" value="<?php echo htmlspecialchars($chartSettings['legendMargins'][0]); ?>" />
125 <input type="text" name="chartSettings[legendMargins][]" size="2" value="<?php echo htmlspecialchars($chartSettings['legendMargins'][1]); ?>" />
126 <input type="text" name="chartSettings[legendMargins][]" size="2" value="<?php echo htmlspecialchars($chartSettings['legendMargins'][2]); ?>" />
127 <input type="text" name="chartSettings[legendMargins][]" size="2" value="<?php echo htmlspecialchars($chartSettings['legendMargins'][3]); ?>" />
128 </td>
129 </tr>
130 <?php } ?>
132 <tr><td><label for="type"><?php echo __("Type"); ?></label></td>
133 <td>
134 <input type="radio" name="chartSettings[type]" value="bar" <?php echo ($chartSettings['type'] == 'bar' ? 'checked' : ''); ?>><?php echo __('Bar'); ?>
135 <input type="radio" name="chartSettings[type]" value="line" <?php echo ($chartSettings['type'] == 'line' ? 'checked' : ''); ?>><?php echo __('Line'); ?>
136 <input type="radio" name="chartSettings[type]" value="radar" <?php echo ($chartSettings['type'] == 'radar' ? 'checked' : ''); ?>><?php echo __('Radar'); ?>
137 <?php if ($chartSettings['multi'] == false) { ?>
138 <input type="radio" name="chartSettings[type]" value="pie" <?php echo ($chartSettings['type'] == 'pie' ? 'checked' : ''); ?>><?php echo __('Pie'); ?>
139 <?php } ?>
140 </td>
141 </tr>
143 <?php if ($chartSettings['type'] == 'bar' && isset($chartSettings['multi']) && $chartSettings['multi'] == true) { ?>
144 <tr><td><label for="barType"><?php echo __("Bar type"); ?></label></td>
145 <td>
146 <input type="radio" name="chartSettings[barType]" value="stacked" <?php echo ($chartSettings['barType'] == 'stacked' ? 'checked' : ''); ?>><?php echo __('Stacked'); ?>
147 <input type="radio" name="chartSettings[barType]" value="multi" <?php echo ($chartSettings['barType'] == 'multi' ? 'checked' : ''); ?>><?php echo __('Multi'); ?>
148 </td>
149 </tr>
150 <?php } ?>
152 <tr><td><label for="continuous"><?php echo __("Continuous image"); ?></label></td>
153 <td>
154 <input type="checkbox" name="chartSettings[continuous]" id="continuous" <?php echo ($chartSettings['continuous'] == 'on' ? 'checked="checked"' : ''); ?>>
155 <?php echo PMA_showHint(PMA_sanitize(__('For compatibility reasons the chart image is segmented by default, select this to draw the whole chart in one image.'))) ?>
156 </td>
157 </tr>
159 <tr><td><label for="fontSize"><?php echo __("Font size"); ?></label></td>
160 <td><input type="text" name="chartSettings[fontSize]" id="fontSize" value="<?php echo (isset($chartSettings['fontSize']) ? htmlspecialchars($chartSettings['fontSize']) : ''); ?>" /></td>
161 </tr>
163 <?php if ($chartSettings['type'] == 'radar') { ?>
164 <tr><td colspan="2">
166 <?php echo __('When drawing a radar chart all values are normalized to a range [0..10].'); ?>
167 </p>
168 </td></tr>
169 <?php } ?>
171 <tr><td colspan="2">
173 <?php echo __('Note that not every result table can be put to the chart. See <a href="./Documentation.html#faq6_29" target="Documentation">FAQ 6.29</a>'); ?>
174 </p>
175 </td></tr>
177 </table>
179 </fieldset>
180 <fieldset class="tblFooters">
181 <input type="submit" name="displayChart" value="<?php echo __('Redraw'); ?>" />
182 </fieldset>
183 </form>
184 </div>
185 <?php
187 * Displays the footer
189 require_once './libraries/footer.inc.php';