2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * functions for displaying chart
7 * @usedby tbl_chart.php
11 if (! defined('PHPMYADMIN')) {
16 * Function to get html for pma_token and url_query
18 * @param string $url_query url query
22 function PMA_getHtmlForPmaTokenAndUrlQuery($url_query)
24 $htmlString = '<script type="text/javascript">'
25 . "pma_token = '" . $_SESSION[' PMA_token '] . "';"
26 . "url_query = '" . $url_query . "';"
32 * Function to get html for the chart type options
36 function PMA_getHtmlForChartTypeOptions()
38 $html = '<input type="radio" name="chartType" value="bar" id="radio_bar" />'
39 . '<label for ="radio_bar">' . _pgettext('Chart type', 'Bar') . '</label>'
40 . '<input type="radio" name="chartType" value="column" id="radio_column" />'
41 . '<label for ="radio_column">' . _pgettext('Chart type', 'Column')
43 . '<input type="radio" name="chartType" value="line" id="radio_line"'
44 . ' checked="checked" />'
45 . '<label for ="radio_line">' . _pgettext('Chart type', 'Line') . '</label>'
46 . '<input type="radio" name="chartType" value="spline" id="radio_spline" />'
47 . '<label for ="radio_spline">' . _pgettext('Chart type', 'Spline')
49 . '<input type="radio" name="chartType" value="area" id="radio_area" />'
50 . '<label for ="radio_area">' . _pgettext('Chart type', 'Area') . '</label>'
51 . '<span class="span_pie" style="display:none;">'
52 . '<input type="radio" name="chartType" value="pie" id="radio_pie" />'
53 . '<label for ="radio_pie">' . _pgettext('Chart type', 'Pie') . '</label>'
55 . '<span class="span_timeline" style="display:none;">'
56 . '<input type="radio" name="chartType" '
57 . 'value="timeline" id="radio_timeline" />'
58 . '<label for ="radio_timeline">' . _pgettext('Chart type', 'Timeline')
67 * Function to get html for the bar stacked option
71 function PMA_getHtmlForStackedOption()
73 $html = '<span class="barStacked">'
74 . '<input type="checkbox" name="barStacked" value="1"'
75 . ' id="checkbox_barStacked" />'
76 . '<label for ="checkbox_barStacked">' . __('Stacked') . '</label>'
84 * Function to get html for the chart x axis options
86 * @param array $keys keys
87 * @param int &$yaxis y axis
91 function PMA_getHtmlForChartXAxisOptions($keys, &$yaxis)
93 $htmlString = '<div style="float:left; padding-left:40px;">'
94 . '<label for="select_chartXAxis">' . __('X-Axis:') . '</label>'
95 . '<select name="chartXAxis" id="select_chartXAxis">';
97 foreach ($keys as $idx => $key) {
98 if ($yaxis === null) {
99 $htmlString .= '<option value="' . htmlspecialchars($idx)
100 . '" selected="selected">' . htmlspecialchars($key) . '</option>';
103 $htmlString .= '<option value="' . htmlspecialchars($idx) . '">'
104 . htmlspecialchars($key) . '</option>';
107 $htmlString .= '</select>';
114 * Function to get html for chart series options
116 * @param array $keys keys
117 * @param array $fields_meta fields meta
118 * @param array $numeric_types numeric types
119 * @param int $yaxis y axis
120 * @param int $numeric_column_count numeric column count
124 function PMA_getHtmlForChartSeriesOptions($keys, $fields_meta, $numeric_types,
125 $yaxis, $numeric_column_count
127 $htmlString = '<br />'
128 . '<label for="select_chartSeries">' . __('Series:') . '</label>'
129 . '<select name="chartSeries" id="select_chartSeries" multiple="multiple">';
131 foreach ($keys as $idx => $key) {
132 if (in_array($fields_meta[$idx]->type
, $numeric_types)) {
133 if ($idx == $yaxis && $numeric_column_count > 1) {
134 $htmlString .= '<option value="' . htmlspecialchars($idx) . '">'
135 . htmlspecialchars($key) . '</option>';
137 $htmlString .= '<option value="' . htmlspecialchars($idx)
138 . '" selected="selected">' . htmlspecialchars($key)
143 $htmlString .= '</select>';
148 * Function to get html for date time columns
150 * @param array $keys keys
151 * @param array $fields_meta fields meta
155 function PMA_getHtmlForDateTimeCols($keys, $fields_meta)
157 $htmlString = '<input type="hidden" name="dateTimeCols" value="';
159 $date_time_types = array('date', 'datetime', 'timestamp');
160 foreach ($keys as $idx => $key) {
161 if (in_array($fields_meta[$idx]->type
, $date_time_types)) {
162 $htmlString .= $idx . " ";
165 $htmlString .= '" />';
171 * Function to get html for the table axis label options
173 * @param int $yaxis y axis
174 * @param array $keys keys
178 function PMA_getHtmlForTableAxisLabelOptions($yaxis, $keys)
180 $htmlString = '<div style="float:left; padding-left:40px;">'
181 . '<label for="xaxis_label">' . __('X-Axis label:') . '</label>'
182 . '<input style="margin-top:0;" type="text" name="xaxis_label" id="xaxis_label"'
184 . (($yaxis == -1) ?
__('X Values') : htmlspecialchars($keys[$yaxis]))
186 . '<label for="yaxis_label">' . __('Y-Axis label:') . '</label>'
187 . '<input type="text" name="yaxis_label" id="yaxis_label" value="'
188 . __('Y Values') . '" /><br />'
195 * Function to get html for the start row and number of rows options
197 * @param string $sql_query sql query
201 function PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query)
203 $htmlString = '<p style="clear:both;"> </p>'
206 . '<label for="pos">' . __('Start row:') . '</label>'
207 . '<input type="text" name="pos" size="3" value="'
208 . $_SESSION['tmpval']['pos'] . '" />'
209 . '<label for="session_max_rows">'
210 . __('Number of rows:') . '</label>'
211 . '<input type="text" name="session_max_rows" size="3" value="'
212 . (($_SESSION['tmpval']['max_rows'] != 'all')
213 ?
$_SESSION['tmpval']['max_rows']
214 : $GLOBALS['cfg']['MaxRows'])
216 . '<input type="submit" name="submit" class="Go" value="' . __('Go')
218 . '<input type="hidden" name="sql_query" value="'
219 . htmlspecialchars($sql_query) . '" />'
227 * Function to get html for the chart area div
231 function PMA_getHtmlForChartAreaDiv()
233 $htmlString = '<p style="clear:both;"> </p>'
234 . '<div id="resizer" style="width:600px; height:400px;">'
235 . '<div id="querychart">'
243 * Function to get html for displaying table chart
245 * @param string $url_query url query
246 * @param array $url_params url parameters
247 * @param array $keys keys
248 * @param array $fields_meta fields meta
249 * @param array $numeric_types numeric types
250 * @param int $numeric_column_count numeric column count
251 * @param string $sql_query sql query
255 function PMA_getHtmlForTableChartDisplay($url_query, $url_params, $keys,
256 $fields_meta, $numeric_types, $numeric_column_count, $sql_query
258 // pma_token/url_query needed for chart export
259 $htmlString = PMA_getHtmlForPmaTokenAndUrlQuery($url_query);
260 $htmlString .= '<!-- Display Chart options -->'
261 . '<div id="div_view_options">'
262 . '<form method="post" id="tblchartform" action="tbl_chart.php" '
264 . PMA_URL_getHiddenInputs($url_params)
266 . '<legend>' . __('Display chart') . '</legend>'
267 . '<div style="float:left; width:420px;">';
268 $htmlString .= PMA_getHtmlForChartTypeOptions();
269 $htmlString .= PMA_getHtmlForStackedOption();
271 $htmlString .= '<input type="text" name="chartTitle" value="'
276 $htmlString .= PMA_getHtmlForChartXAxisOptions($keys, $yaxis);
277 $htmlString .= PMA_getHtmlForChartSeriesOptions(
278 $keys, $fields_meta, $numeric_types, $yaxis, $numeric_column_count
280 $htmlString .= PMA_getHtmlForDateTimeCols($keys, $fields_meta);
281 $htmlString .= '</div>';
283 $htmlString .= PMA_getHtmlForTableAxisLabelOptions($yaxis, $keys);
284 $htmlString .= PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query);
286 $htmlString .= PMA_getHtmlForChartAreaDiv();
288 $htmlString .= '</fieldset>'