1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* functions for displaying chart
*
* @usedby tbl_chart.php
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Function to get html for pma_token and url_query
*
* @param string $url_query url query
*
* @return string
*/
function PMA_getHtmlForPmaTokenAndUrlQuery($url_query)
{
$htmlString = '<script type="text/javascript">'
. "pma_token = '" . $_SESSION[' PMA_token '] . "';"
. "url_query = '" . $url_query . "';"
. '</script>';
return $htmlString;
}
/**
* Function to get html for the chart type options
*
* @return string
*/
function PMA_getHtmlForChartTypeOptions()
{
$html = '<input type="radio" name="chartType" value="bar" id="radio_bar" />'
. '<label for ="radio_bar">' . _pgettext('Chart type', 'Bar') . '</label>'
. '<input type="radio" name="chartType" value="column" id="radio_column" />'
. '<label for ="radio_column">' . _pgettext('Chart type', 'Column')
. '</label>'
. '<input type="radio" name="chartType" value="line" id="radio_line"'
. ' checked="checked" />'
. '<label for ="radio_line">' . _pgettext('Chart type', 'Line') . '</label>'
. '<input type="radio" name="chartType" value="spline" id="radio_spline" />'
. '<label for ="radio_spline">' . _pgettext('Chart type', 'Spline')
. '</label>'
. '<input type="radio" name="chartType" value="area" id="radio_area" />'
. '<label for ="radio_area">' . _pgettext('Chart type', 'Area') . '</label>'
. '<span class="span_pie" style="display:none;">'
. '<input type="radio" name="chartType" value="pie" id="radio_pie" />'
. '<label for ="radio_pie">' . _pgettext('Chart type', 'Pie') . '</label>'
. '</span>'
. '<span class="span_timeline" style="display:none;">'
. '<input type="radio" name="chartType" '
. 'value="timeline" id="radio_timeline" />'
. '<label for ="radio_timeline">' . _pgettext('Chart type', 'Timeline')
. '</label>'
. '</span>'
. '<span class="span_scatter" style="display:none;">'
. '<input type="radio" name="chartType" '
. 'value="scatter" id="radio_scatter" />'
. '<label for ="radio_scatter">' . _pgettext('Chart type', 'Scatter')
. '</label>'
. '</span>'
. '<br /><br />';
return $html;
}
/**
* Function to get html for the bar stacked option
*
* @return string
*/
function PMA_getHtmlForStackedOption()
{
$html = '<span class="barStacked" style="display:none;">'
. '<input type="checkbox" name="barStacked" value="1"'
. ' id="checkbox_barStacked" />'
. '<label for ="checkbox_barStacked">' . __('Stacked') . '</label>'
. '</span>'
. '<br /><br />';
return $html;
}
/**
* Function to get html for the chart x axis options
*
* @param array $keys keys
* @param int &$yaxis y axis
*
* @return string
*/
function PMA_getHtmlForChartXAxisOptions($keys, &$yaxis)
{
$htmlString = '<div style="float:left; padding-left:40px;">'
. '<label for="select_chartXAxis">' . __('X-Axis:') . '</label>'
. '<select name="chartXAxis" id="select_chartXAxis">';
foreach ($keys as $idx => $key) {
if ($yaxis === null) {
$htmlString .= '<option value="' . htmlspecialchars($idx)
. '" selected="selected">' . htmlspecialchars($key) . '</option>';
$yaxis = $idx;
} else {
$htmlString .= '<option value="' . htmlspecialchars($idx) . '">'
. htmlspecialchars($key) . '</option>';
}
}
$htmlString .= '</select>';
return $htmlString;
}
/**
* Function to get html for chart series options
*
* @param array $keys keys
* @param array $fields_meta fields meta
* @param array $numeric_types numeric types
* @param int $yaxis y axis
* @param int $numeric_column_count numeric column count
*
* @return string
*/
function PMA_getHtmlForChartSeriesOptions($keys, $fields_meta, $numeric_types,
$yaxis, $numeric_column_count
) {
$htmlString = '<br />'
. '<label for="select_chartSeries">' . __('Series:') . '</label>'
. '<select name="chartSeries" id="select_chartSeries" multiple="multiple">';
foreach ($keys as $idx => $key) {
if (in_array($fields_meta[$idx]->type, $numeric_types)) {
if ($idx == $yaxis && $numeric_column_count > 1) {
$htmlString .= '<option value="' . htmlspecialchars($idx) . '">'
. htmlspecialchars($key) . '</option>';
} else {
$htmlString .= '<option value="' . htmlspecialchars($idx)
. '" selected="selected">' . htmlspecialchars($key)
. '</option>';
}
}
}
$htmlString .= '</select>';
return $htmlString;
}
/**
* Function to get html for date time columns
*
* @param array $keys keys
* @param array $fields_meta fields meta
*
* @return string
*/
function PMA_getHtmlForDateTimeCols($keys, $fields_meta)
{
$htmlString = '<input type="hidden" name="dateTimeCols" value="';
$date_time_types = array('date', 'datetime', 'timestamp');
foreach ($keys as $idx => $key) {
if (in_array($fields_meta[$idx]->type, $date_time_types)) {
$htmlString .= $idx . " ";
}
}
$htmlString .= '" />';
return $htmlString;
}
/**
* Function to get html for date time columns
*
* @param array $keys keys
* @param array $fields_meta fields meta
* @param array $numeric_types numeric types
*
* @return string
*/
function PMA_getHtmlForNumericCols($keys, $fields_meta, $numeric_types)
{
$htmlString = '<input type="hidden" name="numericCols" value="';
foreach ($keys as $idx => $key) {
if (in_array($fields_meta[$idx]->type, $numeric_types)) {
$htmlString .= $idx . " ";
}
}
$htmlString .= '" />';
return $htmlString;
}
/**
* Function to get html for the table axis label options
*
* @param int $yaxis y axis
* @param array $keys keys
*
* @return string
*/
function PMA_getHtmlForTableAxisLabelOptions($yaxis, $keys)
{
$htmlString = '<div style="float:left; padding-left:40px;">'
. '<label for="xaxis_label">' . __('X-Axis label:') . '</label>'
. '<input style="margin-top:0;" type="text" name="xaxis_label" id="xaxis_label"'
. ' value="'
. (($yaxis == -1) ? __('X Values') : htmlspecialchars($keys[$yaxis]))
. '" /><br />'
. '<label for="yaxis_label">' . __('Y-Axis label:') . '</label>'
. '<input type="text" name="yaxis_label" id="yaxis_label" value="'
. __('Y Values') . '" /><br />'
. '</div>';
return $htmlString;
}
/**
* Function to get html for the start row and number of rows options
*
* @param string $sql_query sql query
*
* @return string
*/
function PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query)
{
$htmlString = '<p style="clear:both;"> </p>'
. '<fieldset>'
. '<div>'
. '<label for="pos">' . __('Start row:') . '</label>'
. '<input type="text" name="pos" size="3" value="'
. $_SESSION['tmpval']['pos'] . '" />'
. '<label for="session_max_rows">'
. __('Number of rows:') . '</label>'
. '<input type="text" name="session_max_rows" size="3" value="'
. (($_SESSION['tmpval']['max_rows'] != 'all')
? $_SESSION['tmpval']['max_rows']
: $GLOBALS['cfg']['MaxRows'])
. '" />'
. '<input type="submit" name="submit" class="Go" value="' . __('Go')
. '" />'
. '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />'
. '</div>'
. '</fieldset>';
return $htmlString;
}
/**
* Function to get html for the chart area div
*
* @return string
*/
function PMA_getHtmlForChartAreaDiv()
{
$htmlString = '<p style="clear:both;"> </p>'
. '<div id="resizer" style="width:600px; height:400px;">'
. '<div id="querychart">'
. '</div>'
. '</div>';
return $htmlString;
}
/**
* Function to get html for displaying table chart
*
* @param string $url_query url query
* @param array $url_params url parameters
* @param array $keys keys
* @param array $fields_meta fields meta
* @param array $numeric_types numeric types
* @param int $numeric_column_count numeric column count
* @param string $sql_query sql query
*
* @return string
*/
function PMA_getHtmlForTableChartDisplay($url_query, $url_params, $keys,
$fields_meta, $numeric_types, $numeric_column_count, $sql_query
) {
// pma_token/url_query needed for chart export
$htmlString = PMA_getHtmlForPmaTokenAndUrlQuery($url_query);
$htmlString .= '<!-- Display Chart options -->'
. '<div id="div_view_options">'
. '<form method="post" id="tblchartform" action="tbl_chart.php" '
. 'class="ajax">'
. PMA_URL_getHiddenInputs($url_params)
. '<fieldset>'
. '<legend>' . __('Display chart') . '</legend>'
. '<div style="float:left; width:420px;">';
$htmlString .= PMA_getHtmlForChartTypeOptions();
$htmlString .= PMA_getHtmlForStackedOption();
$htmlString .= '<input type="text" name="chartTitle" value="'
. __('Chart title')
. '">'
. '</div>';
$yaxis = null;
$htmlString .= PMA_getHtmlForChartXAxisOptions($keys, $yaxis);
$htmlString .= PMA_getHtmlForChartSeriesOptions(
$keys, $fields_meta, $numeric_types, $yaxis, $numeric_column_count
);
$htmlString .= PMA_getHtmlForDateTimeCols($keys, $fields_meta);
$htmlString .= PMA_getHtmlForNumericCols($keys, $fields_meta, $numeric_types);
$htmlString .= '</div>';
$htmlString .= PMA_getHtmlForTableAxisLabelOptions($yaxis, $keys);
$htmlString .= PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query);
$htmlString .= PMA_getHtmlForChartAreaDiv();
$htmlString .= '</fieldset>'
. '</form>'
. '</div>';
return $htmlString;
}
?>
|