Translation update done using Pootle.
[phpmyadmin-themes.git] / tbl_chart.php
blob0e9ed404925496cc4a5b3b9ef75925b70da9997e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * handles creation of the chart
6 * @version $Id$
7 * @package phpMyAdmin
8 */
10 /**
11 * do not import request variable into global scope
12 * @ignore
14 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
15 define('PMA_NO_VARIABLES_IMPORT', true);
18 /**
21 require_once './libraries/common.inc.php';
23 $GLOBALS['js_include'][] = 'pMap.js';
25 /**
26 * Runs common work
28 require './libraries/db_common.inc.php';
29 $url_params['goto'] = $cfg['DefaultTabDatabase'];
30 $url_params['back'] = 'sql.php';
33 * Import chart functions
35 require_once './libraries/chart.lib.php';
38 * Execute the query and return the result
40 $data = array();
42 $result = PMA_DBI_try_query($sql_query);
43 while ($row = PMA_DBI_fetch_assoc($result)) {
44 $data[] = $row;
47 // get settings if any posted
48 $chartSettings = array();
49 if (PMA_isValid($_REQUEST['chartSettings'], 'array')) {
50 $chartSettings = $_REQUEST['chartSettings'];
53 // get the chart and settings after chart generation
54 $chart = PMA_chart_results($data, $chartSettings);
56 if (!empty($chart)) {
57 $message = PMA_Message::success(__('Chart generated successfully.'));
59 else {
60 $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]'));
63 /**
64 * Displays top menu links
65 * We use db links because a chart is not necessarily on a single table
67 $num_tables = 0;
68 require_once './libraries/db_links.inc.php';
70 $url_params['db'] = $GLOBALS['db'];
71 $url_params['reload'] = 1;
73 /**
74 * Displays the page
77 <!-- Display Chart options -->
78 <div id="div_view_options">
79 <form method="post" action="tbl_chart.php">
80 <?php echo PMA_generate_common_hidden_inputs($url_params); ?>
81 <fieldset>
82 <legend><?php echo __('Display chart'); ?></legend>
84 <div style="float: right">
85 <?php echo $chart; ?>
86 </div>
88 <input type="hidden" name="sql_query" id="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
90 <table>
91 <tr><td><label for="width"><?php echo __("Width"); ?></label></td>
92 <td><input type="text" name="chartSettings[width]" id="width" value="<?php echo (isset($chartSettings['width']) ? htmlspecialchars($chartSettings['width']) : ''); ?>" /></td>
93 </tr>
95 <tr><td><label for="height"><?php echo __("Height"); ?></label></td>
96 <td><input type="text" name="chartSettings[height]" id="height" value="<?php echo (isset($chartSettings['height']) ? htmlspecialchars($chartSettings['height']) : ''); ?>" /></td>
97 </tr>
99 <tr><td><label for="titleText"><?php echo __("Title"); ?></label></td>
100 <td><input type="text" name="chartSettings[titleText]" id="titleText" value="<?php echo (isset($chartSettings['titleText']) ? htmlspecialchars($chartSettings['titleText']) : ''); ?>" /></td>
101 </tr>
103 <?php if ($chartSettings['type'] != 'pie' && $chartSettings['type'] != 'radar') { ?>
104 <tr><td><label for="xLabel"><?php echo __("X Axis label"); ?></label></td>
105 <td><input type="text" name="chartSettings[xLabel]" id="xLabel" value="<?php echo (isset($chartSettings['xLabel']) ? htmlspecialchars($chartSettings['xLabel']) : ''); ?>" /></td>
106 </tr>
108 <tr><td><label for="yLabel"><?php echo __("Y Axis label"); ?></label></td>
109 <td><input type="text" name="chartSettings[yLabel]" id="yLabel" value="<?php echo (isset($chartSettings['yLabel']) ? htmlspecialchars($chartSettings['yLabel']) : ''); ?>" /></td>
110 </tr>
111 <?php } ?>
113 <tr><td><label for="areaMargins"><?php echo __("Area margins"); ?></label></td>
114 <td>
115 <input type="text" name="chartSettings[areaMargins][]" size="2" value="<?php echo (isset($chartSettings['areaMargins'][0]) ? htmlspecialchars($chartSettings['areaMargins'][0]) : ''); ?>" />
116 <input type="text" name="chartSettings[areaMargins][]" size="2" value="<?php echo (isset($chartSettings['areaMargins'][1]) ? htmlspecialchars($chartSettings['areaMargins'][1]) : ''); ?>" />
117 <input type="text" name="chartSettings[areaMargins][]" size="2" value="<?php echo (isset($chartSettings['areaMargins'][2]) ? htmlspecialchars($chartSettings['areaMargins'][2]) : ''); ?>" />
118 <input type="text" name="chartSettings[areaMargins][]" size="2" value="<?php echo (isset($chartSettings['areaMargins'][3]) ? htmlspecialchars($chartSettings['areaMargins'][3]) : ''); ?>" />
119 </td>
120 </tr>
122 <?php if ($chartSettings['legend'] == true) { ?>
123 <tr><td><label for="legendMargins"><?php echo __("Legend margins"); ?></label></td>
124 <td>
125 <input type="text" name="chartSettings[legendMargins][]" size="2" value="<?php echo htmlspecialchars($chartSettings['legendMargins'][0]); ?>" />
126 <input type="text" name="chartSettings[legendMargins][]" size="2" value="<?php echo htmlspecialchars($chartSettings['legendMargins'][1]); ?>" />
127 <input type="text" name="chartSettings[legendMargins][]" size="2" value="<?php echo htmlspecialchars($chartSettings['legendMargins'][2]); ?>" />
128 <input type="text" name="chartSettings[legendMargins][]" size="2" value="<?php echo htmlspecialchars($chartSettings['legendMargins'][3]); ?>" />
129 </td>
130 </tr>
131 <?php } ?>
133 <tr><td><label for="type"><?php echo __("Type"); ?></label></td>
134 <td>
135 <input type="radio" name="chartSettings[type]" value="bar" <?php echo ($chartSettings['type'] == 'bar' ? 'checked' : ''); ?>><?php echo __('Bar'); ?>
136 <input type="radio" name="chartSettings[type]" value="line" <?php echo ($chartSettings['type'] == 'line' ? 'checked' : ''); ?>><?php echo __('Line'); ?>
137 <input type="radio" name="chartSettings[type]" value="radar" <?php echo ($chartSettings['type'] == 'radar' ? 'checked' : ''); ?>><?php echo __('Radar'); ?>
138 <?php if ($chartSettings['multi'] == false) { ?>
139 <input type="radio" name="chartSettings[type]" value="pie" <?php echo ($chartSettings['type'] == 'pie' ? 'checked' : ''); ?>><?php echo __('Pie'); ?>
140 <?php } ?>
141 </td>
142 </tr>
144 <?php if ($chartSettings['type'] == 'bar' && isset($chartSettings['multi']) && $chartSettings['multi'] == true) { ?>
145 <tr><td><label for="barType"><?php echo __("Bar type"); ?></label></td>
146 <td>
147 <input type="radio" name="chartSettings[barType]" value="stacked" <?php echo ($chartSettings['barType'] == 'stacked' ? 'checked' : ''); ?>><?php echo __('Stacked'); ?>
148 <input type="radio" name="chartSettings[barType]" value="multi" <?php echo ($chartSettings['barType'] == 'multi' ? 'checked' : ''); ?>><?php echo __('Multi'); ?>
149 </td>
150 </tr>
151 <?php } ?>
153 <tr><td><label for="continuous"><?php echo __("Continuous image"); ?></label></td>
154 <td>
155 <input type="checkbox" name="chartSettings[continuous]" id="continuous" <?php echo ($chartSettings['continuous'] == 'on' ? 'checked="checked"' : ''); ?>>
156 <?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.'))) ?>
157 </td>
158 </tr>
160 <tr><td><label for="fontSize"><?php echo __("Font size"); ?></label></td>
161 <td><input type="text" name="chartSettings[fontSize]" id="fontSize" value="<?php echo (isset($chartSettings['fontSize']) ? htmlspecialchars($chartSettings['fontSize']) : ''); ?>" /></td>
162 </tr>
164 <?php if ($chartSettings['type'] == 'radar') { ?>
165 <tr><td colspan="2">
167 <?php echo __('When drawing a radar chart all values are normalized to a range [0..10].'); ?>
168 </p>
169 </td></tr>
170 <?php } ?>
172 <tr><td colspan="2">
174 <?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>'); ?>
175 </p>
176 </td></tr>
178 </table>
180 </fieldset>
181 <fieldset class="tblFooters">
182 <input type="submit" name="displayChart" value="<?php echo __('Redraw'); ?>" />
183 </fieldset>
184 </form>
185 </div>
186 <?php
188 * Displays the footer
190 require_once './libraries/footer.inc.php';