Last active
December 19, 2015 12:29
-
-
Save mamchenkov/5955343 to your computer and use it in GitHub Desktop.
Quick and easy way to have multiple configurations for things like charts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$charts = array( | |
'live1-ajax-total-count' => array( | |
'type' => 'line', | |
'title' => 'LIVE1 Total Count (ajax)', | |
'sql' => 'select .... ', | |
'callback' => 'minute_counts', | |
), | |
'live2-ajax-total-count' => array( | |
'type' => 'line', | |
'title' => 'LIVE2 Total Count (ajax)', | |
'sql' => 'select .... ', | |
'callback' => 'minute_counts', | |
), | |
); | |
function get_chart($chart_id) { | |
if (!empty($charts[$chart_id])) { | |
$data = mysql_query($charts[$chart_id]['sql']); | |
$data = call_user_func($charts[$chart_id]['callback'], $data); | |
return $data; | |
} | |
} | |
function get_charts() { | |
return array_keys($charts); | |
} | |
function minute_counts($data) { | |
// Data expectation: | |
// array('minute' => count); | |
// return json array | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment