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')
61 . '<span class="span_scatter" style="display:none;">'
62 . '<input type="radio" name="chartType" '
63 . 'value="scatter" id="radio_scatter" />'
64 . '<label for ="radio_scatter">' . _pgettext('Chart type', 'Scatter')
73 * Function to get html for the bar stacked option
77 function PMA_getHtmlForStackedOption()
79 $html = '<span class="barStacked" style="display:none;">'
80 . '<input type="checkbox" name="barStacked" value="1"'
81 . ' id="checkbox_barStacked" />'
82 . '<label for ="checkbox_barStacked">' . __('Stacked') . '</label>'
90 * Function to get html for the chart x axis options
92 * @param array $keys keys
93 * @param int &$yaxis y axis
97 function PMA_getHtmlForChartXAxisOptions($keys, &$yaxis)
99 $htmlString = '<div style="float:left; padding-left:40px;">'
100 . '<label for="select_chartXAxis">' . __('X-Axis:') . '</label>'
101 . '<select name="chartXAxis" id="select_chartXAxis">';
103 foreach ($keys as $idx => $key) {
104 if ($yaxis === null) {
105 $htmlString .= '<option value="' . htmlspecialchars($idx)
106 . '" selected="selected">' . htmlspecialchars($key) . '</option>';
109 $htmlString .= '<option value="' . htmlspecialchars($idx) . '">'
110 . htmlspecialchars($key) . '</option>';
113 $htmlString .= '</select>';
120 * Function to get html for chart series options
122 * @param array $keys keys
123 * @param array $fields_meta fields meta
124 * @param array $numeric_types numeric types
125 * @param int $yaxis y axis
126 * @param int $numeric_column_count numeric column count
130 function PMA_getHtmlForChartSeriesOptions($keys, $fields_meta, $numeric_types,
131 $yaxis, $numeric_column_count
133 $htmlString = '<br />'
134 . '<label for="select_chartSeries">' . __('Series:') . '</label>'
135 . '<select name="chartSeries" id="select_chartSeries" multiple="multiple">';
137 foreach ($keys as $idx => $key) {
138 if (in_array($fields_meta[$idx]->type
, $numeric_types)) {
139 if ($idx == $yaxis && $numeric_column_count > 1) {
140 $htmlString .= '<option value="' . htmlspecialchars($idx) . '">'
141 . htmlspecialchars($key) . '</option>';
143 $htmlString .= '<option value="' . htmlspecialchars($idx)
144 . '" selected="selected">' . htmlspecialchars($key)
149 $htmlString .= '</select>';
154 * Function to get html for date time columns
156 * @param array $keys keys
157 * @param array $fields_meta fields meta
161 function PMA_getHtmlForDateTimeCols($keys, $fields_meta)
163 $htmlString = '<input type="hidden" name="dateTimeCols" value="';
165 $date_time_types = array('date', 'datetime', 'timestamp');
166 foreach ($keys as $idx => $key) {
167 if (in_array($fields_meta[$idx]->type
, $date_time_types)) {
168 $htmlString .= $idx . " ";
171 $htmlString .= '" />';
177 * Function to get html for date time columns
179 * @param array $keys keys
180 * @param array $fields_meta fields meta
181 * @param array $numeric_types numeric types
185 function PMA_getHtmlForNumericCols($keys, $fields_meta, $numeric_types)
187 $htmlString = '<input type="hidden" name="numericCols" value="';
188 foreach ($keys as $idx => $key) {
189 if (in_array($fields_meta[$idx]->type
, $numeric_types)) {
190 $htmlString .= $idx . " ";
193 $htmlString .= '" />';
199 * Function to get html for the table axis label options
201 * @param int $yaxis y axis
202 * @param array $keys keys
206 function PMA_getHtmlForTableAxisLabelOptions($yaxis, $keys)
208 $htmlString = '<div style="float:left; padding-left:40px;">'
209 . '<label for="xaxis_label">' . __('X-Axis label:') . '</label>'
210 . '<input style="margin-top:0;" type="text" name="xaxis_label" id="xaxis_label"'
212 . (($yaxis == -1) ?
__('X Values') : htmlspecialchars($keys[$yaxis]))
214 . '<label for="yaxis_label">' . __('Y-Axis label:') . '</label>'
215 . '<input type="text" name="yaxis_label" id="yaxis_label" value="'
216 . __('Y Values') . '" /><br />'
223 * Function to get html for the start row and number of rows options
225 * @param string $sql_query sql query
229 function PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query)
231 $htmlString = '<p style="clear:both;"> </p>'
234 . '<label for="pos">' . __('Start row:') . '</label>'
235 . '<input type="text" name="pos" size="3" value="'
236 . $_SESSION['tmpval']['pos'] . '" />'
237 . '<label for="session_max_rows">'
238 . __('Number of rows:') . '</label>'
239 . '<input type="text" name="session_max_rows" size="3" value="'
240 . (($_SESSION['tmpval']['max_rows'] != 'all')
241 ?
$_SESSION['tmpval']['max_rows']
242 : $GLOBALS['cfg']['MaxRows'])
244 . '<input type="submit" name="submit" class="Go" value="' . __('Go')
246 . '<input type="hidden" name="sql_query" value="'
247 . htmlspecialchars($sql_query) . '" />'
255 * Function to get html for the chart area div
259 function PMA_getHtmlForChartAreaDiv()
261 $htmlString = '<p style="clear:both;"> </p>'
262 . '<div id="resizer" style="width:600px; height:400px;">'
263 . '<div id="querychart">'
271 * Function to get html for displaying table chart
273 * @param string $url_query url query
274 * @param array $url_params url parameters
275 * @param array $keys keys
276 * @param array $fields_meta fields meta
277 * @param array $numeric_types numeric types
278 * @param int $numeric_column_count numeric column count
279 * @param string $sql_query sql query
283 function PMA_getHtmlForTableChartDisplay($url_query, $url_params, $keys,
284 $fields_meta, $numeric_types, $numeric_column_count, $sql_query
286 // pma_token/url_query needed for chart export
287 $htmlString = PMA_getHtmlForPmaTokenAndUrlQuery($url_query);
288 $htmlString .= '<!-- Display Chart options -->'
289 . '<div id="div_view_options">'
290 . '<form method="post" id="tblchartform" action="tbl_chart.php" '
292 . PMA_URL_getHiddenInputs($url_params)
294 . '<legend>' . __('Display chart') . '</legend>'
295 . '<div style="float:left; width:420px;">';
296 $htmlString .= PMA_getHtmlForChartTypeOptions();
297 $htmlString .= PMA_getHtmlForStackedOption();
299 $htmlString .= '<input type="text" name="chartTitle" value="'
304 $htmlString .= PMA_getHtmlForChartXAxisOptions($keys, $yaxis);
305 $htmlString .= PMA_getHtmlForChartSeriesOptions(
306 $keys, $fields_meta, $numeric_types, $yaxis, $numeric_column_count
308 $htmlString .= PMA_getHtmlForDateTimeCols($keys, $fields_meta);
309 $htmlString .= PMA_getHtmlForNumericCols($keys, $fields_meta, $numeric_types);
310 $htmlString .= '</div>';
312 $htmlString .= PMA_getHtmlForTableAxisLabelOptions($yaxis, $keys);
313 $htmlString .= PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query);
315 $htmlString .= PMA_getHtmlForChartAreaDiv();
317 $htmlString .= '</fieldset>'