2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * handles creation of the chart
10 * do not import request variable into global scope
13 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
14 define('PMA_NO_VARIABLES_IMPORT', true);
20 require_once './libraries/common.inc.php';
22 $GLOBALS['js_include'][] = 'tbl_chart.js';
23 $GLOBALS['js_include'][] = 'highcharts/highcharts.js';
24 /* Files required for chart exporting */
25 $GLOBALS['js_include'][] = 'highcharts/exporting.js';
26 $GLOBALS['js_include'][] = 'canvg/canvg.js';
27 $GLOBALS['js_include'][] = 'canvg/rgbcolor.js';
32 if (strlen($GLOBALS['table'])) {
33 $url_params['goto'] = $cfg['DefaultTabTable'];
34 $url_params['back'] = 'tbl_sql.php';
35 require './libraries/tbl_common.php';
36 require './libraries/tbl_info.inc.php';
37 require './libraries/tbl_links.inc.php';
38 } elseif (strlen($GLOBALS['db'])) {
39 $url_params['goto'] = $cfg['DefaultTabDatabase'];
40 $url_params['back'] = 'sql.php';
41 require './libraries/db_common.inc.php';
42 require './libraries/db_info.inc.php';
44 $url_params['goto'] = $cfg['DefaultTabServer'];
45 $url_params['back'] = 'sql.php';
46 require './libraries/server_common.inc.php';
47 require './libraries/server_links.inc.php';
51 * Execute the query and return the result
55 $result = PMA_DBI_try_query($sql_query);
56 while ($row = PMA_DBI_fetch_assoc($result)) {
60 // get settings if any posted
61 $chartSettings = array();
62 if (PMA_isValid($_REQUEST['chartSettings'], 'array')) {
63 $chartSettings = $_REQUEST['chartSettings'];
66 $url_params['db'] = $GLOBALS['db'];
67 $url_params['reload'] = 1;
72 // pma_token/url_query needed for chart export
74 <script type
="text/javascript">
75 pma_token
= '<?php echo $_SESSION[' PMA_token
']; ?>';
76 url_query
= '<?php echo $url_query;?>';
78 <!-- Display Chart options
-->
79 <div id
="div_view_options">
80 <form method
="post" action
="tbl_chart.php">
81 <?php
echo PMA_generate_common_hidden_inputs($url_params); ?
>
83 <legend
><?php
echo __('Display chart'); ?
></legend
>
84 <div style
="float:left;">
85 <input type
="radio" name
="chartType" value
="bar"><?php
echo __('Bar'); ?
>
86 <input type
="radio" name
="chartType" value
="column"><?php
echo __('Column'); ?
>
87 <input type
="radio" name
="chartType" value
="line" checked
><?php
echo __('Line'); ?
>
88 <input type
="radio" name
="chartType" value
="spline"><?php
echo __('Spline'); ?
>
89 <input type
="radio" name
="chartType" value
="pie"><?php
echo __('Pie'); ?
>
90 <span
class="barStacked" style
="display:none;">
91 <input type
="checkbox" name
="barStacked" value
="1"><?php
echo __('Stacked'); ?
>
94 <input type
="text" name
="chartTitle" value
="<?php echo __('Chart title'); ?>">
95 <?php
$keys = array_keys($data[0]);
99 echo __('X-Axis:'); ?
> <select name
="chartXAxis">
102 foreach($keys as $idx=>$key) {
103 if($yaxis==-1 && ($idx==count($data[0])-1 ||
preg_match("/(date|time)/i",$key))) {
104 echo '<option value="'.$idx.'" selected>'.$key.'</option>';
107 echo '<option value="'.$idx.'">'.$key.'</option>';
113 <?php
echo __('Series:'); ?
>
114 <select name
="chartSeries">
115 <option value
="columns"><?php
echo __('The remaining columns'); ?
></option
>
117 foreach($keys as $idx=>$key) {
118 echo '<option>'.$key.'</option>';
127 <div style
="float:left; padding-left:40px;">
128 <?php
echo __('X-Axis label:'); ?
> <input style
="margin-top:0;" type
="text" name
="xaxis_label" value
="<?php echo ($yaxis==-1)?__('X Values'):$keys[$yaxis]; ?>"><br
>
129 <?php
echo __('Y-Axis label:'); ?
> <input type
="text" name
="yaxis_label" value
="<?php echo __('Y Values'); ?>">
131 <p style
="clear:both;"> 
;</p
>
132 <div id
="resizer" style
="width:600px; height:400px;">
133 <div id
="inner-resizer">
134 <div id
="querychart" style
="display:none;">
135 <?php
echo json_encode($data); ?
>
144 * Displays the footer
146 require_once './libraries/footer.inc.php';