added japanese language
[openemr.git] / phpmyadmin / libraries / tbl_chart.lib.php
blob4453f0a1afbd4e5f12ee3841790f2326104471ab
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * functions for displaying chart
7 * @usedby tbl_chart.php
9 * @package PhpMyAdmin
11 if (! defined('PHPMYADMIN')) {
12 exit;
15 /**
16 * Function to get html for pma_token and url_query
18 * @param string $url_query url query
20 * @return string
22 function PMA_getHtmlForPmaTokenAndUrlQuery($url_query)
24 $htmlString = '<script type="text/javascript">'
25 . "pma_token = '" . $_SESSION[' PMA_token '] . "';"
26 . "url_query = '" . $url_query . "';"
27 . '</script>';
28 return $htmlString;
31 /**
32 * Function to get html for the chart type options
34 * @return string
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')
42 . '</label>'
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')
48 . '</label>'
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>'
54 . '</span>'
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')
59 . '</label>'
60 . '</span>'
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')
65 . '</label>'
66 . '</span>'
67 . '<br /><br />';
69 return $html;
72 /**
73 * Function to get html for the bar stacked option
75 * @return string
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>'
83 . '</span>'
84 . '<br /><br />';
86 return $html;
89 /**
90 * Function to get html for the chart x axis options
92 * @param array $keys keys
93 * @param int &$yaxis y axis
95 * @return string
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>';
107 $yaxis = $idx;
108 } else {
109 $htmlString .= '<option value="' . htmlspecialchars($idx) . '">'
110 . htmlspecialchars($key) . '</option>';
113 $htmlString .= '</select>';
115 return $htmlString;
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
128 * @return string
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>';
142 } else {
143 $htmlString .= '<option value="' . htmlspecialchars($idx)
144 . '" selected="selected">' . htmlspecialchars($key)
145 . '</option>';
149 $htmlString .= '</select>';
150 return $htmlString;
154 * Function to get html for date time columns
156 * @param array $keys keys
157 * @param array $fields_meta fields meta
159 * @return string
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 .= '" />';
173 return $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
183 * @return string
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 .= '" />';
195 return $htmlString;
199 * Function to get html for the table axis label options
201 * @param int $yaxis y axis
202 * @param array $keys keys
204 * @return string
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"'
211 . ' value="'
212 . (($yaxis == -1) ? __('X Values') : htmlspecialchars($keys[$yaxis]))
213 . '" /><br />'
214 . '<label for="yaxis_label">' . __('Y-Axis label:') . '</label>'
215 . '<input type="text" name="yaxis_label" id="yaxis_label" value="'
216 . __('Y Values') . '" /><br />'
217 . '</div>';
219 return $htmlString;
223 * Function to get html for the start row and number of rows options
225 * @param string $sql_query sql query
227 * @return string
229 function PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query)
231 $htmlString = '<p style="clear:both;">&nbsp;</p>'
232 . '<fieldset>'
233 . '<div>'
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'])
243 . '" />'
244 . '<input type="submit" name="submit" class="Go" value="' . __('Go')
245 . '" />'
246 . '<input type="hidden" name="sql_query" value="'
247 . htmlspecialchars($sql_query) . '" />'
248 . '</div>'
249 . '</fieldset>';
251 return $htmlString;
255 * Function to get html for the chart area div
257 * @return string
259 function PMA_getHtmlForChartAreaDiv()
261 $htmlString = '<p style="clear:both;">&nbsp;</p>'
262 . '<div id="resizer" style="width:600px; height:400px;">'
263 . '<div id="querychart">'
264 . '</div>'
265 . '</div>';
267 return $htmlString;
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
281 * @return string
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" '
291 . 'class="ajax">'
292 . PMA_URL_getHiddenInputs($url_params)
293 . '<fieldset>'
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="'
300 . __('Chart title')
301 . '">'
302 . '</div>';
303 $yaxis = null;
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>'
318 . '</form>'
319 . '</div>';
321 return $htmlString;