mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
Merge branch 'feature-650' into feature-407rm
This commit is contained in:
commit
8b41fbf512
@ -23,12 +23,18 @@ if [ -z "$ONE_LOCATION" ]; then
|
|||||||
SUNSTONE_LOCK_FILE=/var/lock/one/.sunstone.lock
|
SUNSTONE_LOCK_FILE=/var/lock/one/.sunstone.lock
|
||||||
SUNSTONE_LOG=/var/log/one/sunstone.log
|
SUNSTONE_LOG=/var/log/one/sunstone.log
|
||||||
SUNSTONE_CONF=/etc/one/sunstone-server.conf
|
SUNSTONE_CONF=/etc/one/sunstone-server.conf
|
||||||
|
ONEMONITOR_CMD=/usr/lib/one/sunstone/share/OneMonitor/runOneMonitor.sh
|
||||||
|
HOST_LOG_FOLDER=/var/log/one/OneMonitor/host
|
||||||
|
VM_LOG_FOLDER=/var/log/one/OneMonitor/vm
|
||||||
else
|
else
|
||||||
SUNSTONE_PID=$ONE_LOCATION/var/sunstone.pid
|
SUNSTONE_PID=$ONE_LOCATION/var/sunstone.pid
|
||||||
SUNSTONE_SERVER=$ONE_LOCATION/lib/sunstone/config.ru
|
SUNSTONE_SERVER=$ONE_LOCATION/lib/sunstone/config.ru
|
||||||
SUNSTONE_LOCK_FILE=$ONE_LOCATION/var/.sunstone.lock
|
SUNSTONE_LOCK_FILE=$ONE_LOCATION/var/.sunstone.lock
|
||||||
SUNSTONE_LOG=$ONE_LOCATION/var/sunstone.log
|
SUNSTONE_LOG=$ONE_LOCATION/var/sunstone.log
|
||||||
SUNSTONE_CONF=$ONE_LOCATION/etc/sunstone-server.conf
|
SUNSTONE_CONF=$ONE_LOCATION/etc/sunstone-server.conf
|
||||||
|
ONEMONITOR_CMD=$ONE_LOCATION/lib/sunstone/share/OneMonitor/runOneMonitor.sh
|
||||||
|
HOST_LOG_FOLDER=$ONE_LOCATION/var/OneMonitor/host
|
||||||
|
VM_LOG_FOLDER=$ONE_LOCATION/var/OneMonitor/vm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
@ -84,6 +90,24 @@ start()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "sunstone-server listening on $HOST:$PORT"
|
echo "sunstone-server listening on $HOST:$PORT"
|
||||||
|
|
||||||
|
# Start the monitoring app
|
||||||
|
if [ ! -d $HOST_LOG_FOLDER ]
|
||||||
|
then
|
||||||
|
mkdir -p $HOST_LOG_FOLDER
|
||||||
|
[[ $? -ne 0 ]] && ( echo "Error creating host log directory"; exit 1 )
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $VM_LOG_FOLDER ]
|
||||||
|
then
|
||||||
|
mkdir -p $VM_LOG_FOLDER
|
||||||
|
[[ $? -ne 0 ]] && ( echo "Error creating vm log directory"; exit 1 )
|
||||||
|
fi
|
||||||
|
|
||||||
|
$ONEMONITOR_CMD $MONITORING_INTERVAL $HOST_LOG_FOLDER $VM_LOG_FOLDER &>/dev/null &
|
||||||
|
|
||||||
|
[[ $? -ne 0 ]] && ( echo "Error launching monitoring daemon"; exit 1 )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -102,6 +126,8 @@ stop()
|
|||||||
# Remove pid files
|
# Remove pid files
|
||||||
rm -f $SUNSTONE_LOCK_FILE &> /dev/null
|
rm -f $SUNSTONE_LOCK_FILE &> /dev/null
|
||||||
|
|
||||||
|
killall $ONEMONITOR_CMD
|
||||||
|
|
||||||
echo "sunstone-server stopped"
|
echo "sunstone-server stopped"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
require 'OpenNebulaJSON'
|
require 'OpenNebulaJSON'
|
||||||
include OpenNebulaJSON
|
include OpenNebulaJSON
|
||||||
|
|
||||||
|
require 'OneMonitorClient'
|
||||||
|
|
||||||
class SunstoneServer
|
class SunstoneServer
|
||||||
def initialize(username, password)
|
def initialize(username, password)
|
||||||
# TBD one_client_user(name) from CloudServer
|
# TBD one_client_user(name) from CloudServer
|
||||||
@ -223,7 +225,6 @@ class SunstoneServer
|
|||||||
# The VM host and its VNC port
|
# The VM host and its VNC port
|
||||||
host = resource['HISTORY/HOSTNAME']
|
host = resource['HISTORY/HOSTNAME']
|
||||||
vnc_port = resource['TEMPLATE/GRAPHICS/PORT']
|
vnc_port = resource['TEMPLATE/GRAPHICS/PORT']
|
||||||
|
|
||||||
# The noVNC proxy_port
|
# The noVNC proxy_port
|
||||||
proxy_port = config[:vnc_proxy_base_port].to_i + vnc_port.to_i
|
proxy_port = config[:vnc_proxy_base_port].to_i + vnc_port.to_i
|
||||||
|
|
||||||
@ -262,6 +263,37 @@ class SunstoneServer
|
|||||||
return [200, nil]
|
return [200, nil]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
def get_log(params)
|
||||||
|
resource = params[:resource]
|
||||||
|
id = params[:id]
|
||||||
|
id = "global" unless id
|
||||||
|
columns = params['monitor_resources'].split(',')
|
||||||
|
history_length = params['history_length']
|
||||||
|
|
||||||
|
log_file_folder = case resource
|
||||||
|
when "vm","VM"
|
||||||
|
VM_LOG_FOLDER
|
||||||
|
when "host","HOST"
|
||||||
|
HOST_LOG_FOLDER
|
||||||
|
end
|
||||||
|
|
||||||
|
monitor_client = OneMonitorClient.new(id,log_file_folder)
|
||||||
|
return monitor_client.get_data_for_id(id,columns,history_length).to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -55,17 +55,16 @@ table#dashboard_table tr {
|
|||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#dashboard_table td{
|
table#dashboard_table > tbody > tr > td{
|
||||||
width:50%;
|
width:50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.panel {
|
div.panel {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
padding:0;
|
padding:0;
|
||||||
width:80%;
|
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
border: 1px #ddd solid;
|
border: 1px #ddd solid;
|
||||||
min-height: 110px;
|
min-height: 50px;
|
||||||
-webkit-border-radius: 3px;
|
-webkit-border-radius: 3px;
|
||||||
-moz-border-radius: 3px;
|
-moz-border-radius: 3px;
|
||||||
-moz-box-shadow: 5px 5px 5px #888;
|
-moz-box-shadow: 5px 5px 5px #888;
|
||||||
@ -77,6 +76,8 @@ div.panel h3 {
|
|||||||
border: 0;
|
border: 0;
|
||||||
padding:5px 10px 5px 10px;
|
padding:5px 10px 5px 10px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
background-color: #353735;
|
background-color: #353735;
|
||||||
-webkit-border-radius: 3px 3px 0 0;
|
-webkit-border-radius: 3px 3px 0 0;
|
||||||
-moz-border-radius: 3px 3px 0 0;
|
-moz-border-radius: 3px 3px 0 0;
|
||||||
@ -105,7 +106,7 @@ div.panel_info table.info_table tr {
|
|||||||
border: 0;
|
border: 0;
|
||||||
border-bottom: 1px dotted #ccc;
|
border-bottom: 1px dotted #ccc;
|
||||||
}
|
}
|
||||||
div.panel_info table.info_table td {
|
div.panel_info table.info_table > tbody > tr > td {
|
||||||
border: 0;
|
border: 0;
|
||||||
width: 100%!important;
|
width: 100%!important;
|
||||||
}
|
}
|
||||||
@ -114,11 +115,11 @@ div.panel_info table.info_table td.value_td {
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.key_td_green {
|
.green {
|
||||||
color: green!important;
|
color: green!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.key_td_red {
|
.red {
|
||||||
color: #B81515!important;
|
color: #B81515!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +363,7 @@ tr.even:hover{
|
|||||||
vertical-align:top;
|
vertical-align:top;
|
||||||
}
|
}
|
||||||
|
|
||||||
.info_table th,h3 {
|
.info_table > thead th,h3 {
|
||||||
border-bottom: 2px solid #353735;
|
border-bottom: 2px solid #353735;
|
||||||
color: #353735;
|
color: #353735;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@ -371,7 +372,7 @@ tr.even:hover{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.info_table td{
|
.info_table > tbody > tr > td{
|
||||||
border-bottom: 1px solid #CCCCCC;
|
border-bottom: 1px solid #CCCCCC;
|
||||||
color: #353735;
|
color: #353735;
|
||||||
padding-top: 6px;
|
padding-top: 6px;
|
||||||
@ -387,6 +388,12 @@ tr.even:hover{
|
|||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info_table td.graph_td{
|
||||||
|
padding-top:0px!important;
|
||||||
|
padding-bottom:0px!important;
|
||||||
|
vertical-align:middle!important;
|
||||||
|
}
|
||||||
|
|
||||||
.info_table td.value_td{
|
.info_table td.value_td{
|
||||||
text-align:left;
|
text-align:left;
|
||||||
}
|
}
|
||||||
|
@ -471,6 +471,70 @@ var OpenNebula = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
"monitor" : function(params){
|
||||||
|
var callback = params.success;
|
||||||
|
var callback_error = params.error;
|
||||||
|
var id = params.data.id;
|
||||||
|
var resource = OpenNebula.Host.resource;
|
||||||
|
var data = params.data;
|
||||||
|
|
||||||
|
var method = "monitor";
|
||||||
|
var action = OpenNebula.Helper.action(method);
|
||||||
|
var request = OpenNebula.Helper.request(resource,method, data);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "host/"+id+"/monitor",
|
||||||
|
type: "GET",
|
||||||
|
data: data['monitor'],
|
||||||
|
dataType: "json",
|
||||||
|
success: function(response)
|
||||||
|
{
|
||||||
|
if (callback)
|
||||||
|
{
|
||||||
|
callback(request,response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(response)
|
||||||
|
{
|
||||||
|
if (callback_error)
|
||||||
|
{
|
||||||
|
callback_error(request, OpenNebula.Error(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"monitor_all" : function(params){
|
||||||
|
var callback = params.success;
|
||||||
|
var callback_error = params.error;
|
||||||
|
var resource = OpenNebula.Host.resource;
|
||||||
|
var data = params.data;
|
||||||
|
|
||||||
|
var method = "monitor";
|
||||||
|
var action = OpenNebula.Helper.action(method);
|
||||||
|
var request = OpenNebula.Helper.request(resource,method, data);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "host/monitor",
|
||||||
|
type: "GET",
|
||||||
|
data: data['monitor'],
|
||||||
|
dataType: "json",
|
||||||
|
success: function(response)
|
||||||
|
{
|
||||||
|
if (callback)
|
||||||
|
{
|
||||||
|
callback(request,response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(response)
|
||||||
|
{
|
||||||
|
if (callback_error)
|
||||||
|
{
|
||||||
|
callback_error(request, OpenNebula.Error(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1303,8 +1367,72 @@ var OpenNebula = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
"monitor" : function(params){
|
||||||
|
var callback = params.success;
|
||||||
|
var callback_error = params.error;
|
||||||
|
var id = params.data.id;
|
||||||
|
var resource = OpenNebula.VM.resource;
|
||||||
|
var data = params.data;
|
||||||
|
|
||||||
|
var method = "monitor";
|
||||||
|
var action = OpenNebula.Helper.action(method);
|
||||||
|
var request = OpenNebula.Helper.request(resource,method, data);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "vm/"+id+"/monitor",
|
||||||
|
type: "GET",
|
||||||
|
data: data['monitor'],
|
||||||
|
dataType: "json",
|
||||||
|
success: function(response)
|
||||||
|
{
|
||||||
|
if (callback)
|
||||||
|
{
|
||||||
|
callback(request,response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(response)
|
||||||
|
{
|
||||||
|
if (callback_error)
|
||||||
|
{
|
||||||
|
callback_error(request, OpenNebula.Error(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"monitor_all" : function(params){
|
||||||
|
var callback = params.success;
|
||||||
|
var callback_error = params.error;
|
||||||
|
var resource = OpenNebula.VM.resource;
|
||||||
|
var data = params.data;
|
||||||
|
|
||||||
|
var method = "monitor";
|
||||||
|
var action = OpenNebula.Helper.action(method);
|
||||||
|
var request = OpenNebula.Helper.request(resource,method, data);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "vm/monitor",
|
||||||
|
type: "GET",
|
||||||
|
data: data['monitor'],
|
||||||
|
dataType: "json",
|
||||||
|
success: function(response)
|
||||||
|
{
|
||||||
|
if (callback)
|
||||||
|
{
|
||||||
|
callback(request,response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(response)
|
||||||
|
{
|
||||||
|
if (callback_error)
|
||||||
|
{
|
||||||
|
callback_error(request, OpenNebula.Error(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"Cluster": {
|
"Cluster": {
|
||||||
|
@ -14,44 +14,81 @@
|
|||||||
/* limitations under the License. */
|
/* limitations under the License. */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
var HISTORY_LENGTH=40;
|
||||||
|
var GRAPH_AUTOREFRESH_INTERVAL=10000; //10 secs
|
||||||
|
|
||||||
|
var graph1 = {
|
||||||
|
title : "graph1",
|
||||||
|
monitor_resources : "total,active,error",
|
||||||
|
history_length : HISTORY_LENGTH
|
||||||
|
};
|
||||||
|
|
||||||
|
var graph2 = {
|
||||||
|
title : "graph2",
|
||||||
|
monitor_resources : "cpu_usage,used_cpu,max_cpu",
|
||||||
|
history_length : HISTORY_LENGTH
|
||||||
|
};
|
||||||
|
|
||||||
|
var graph3 = {
|
||||||
|
title : "graph3",
|
||||||
|
monitor_resources : "mem_usage,used_mem,max_mem",
|
||||||
|
history_length : HISTORY_LENGTH
|
||||||
|
};
|
||||||
|
|
||||||
|
var graph4 = {
|
||||||
|
title : "graph4",
|
||||||
|
monitor_resources : "total,active,error",
|
||||||
|
history_length : HISTORY_LENGTH
|
||||||
|
};
|
||||||
|
|
||||||
|
var graph5 = {
|
||||||
|
title : "graph5",
|
||||||
|
monitor_resources : "net_tx,net_rx",
|
||||||
|
history_length : HISTORY_LENGTH
|
||||||
|
};
|
||||||
|
|
||||||
var dashboard_tab_content =
|
var dashboard_tab_content =
|
||||||
'<table id="dashboard_table">\
|
'<table id="dashboard_table">\
|
||||||
|
<tr>\
|
||||||
|
<td style="width:40%">\
|
||||||
|
<table id="information_table">\
|
||||||
<tr>\
|
<tr>\
|
||||||
<td>\
|
|
||||||
<div class="panel">\
|
|
||||||
<h3><a href="#hosts_tab">Hosts</a>\
|
|
||||||
<div class="new-resource">\
|
|
||||||
<a class="action_button" href="#hosts_tab" value="Host.create_dialog">+</a>\
|
|
||||||
</div>\
|
|
||||||
</h3>\
|
|
||||||
<div class="panel_info">\
|
|
||||||
<table class="info_table">\
|
|
||||||
<tr>\
|
|
||||||
<td class="key_td">Total</td>\
|
|
||||||
<td class="value_td"><span id="total_hosts"></span></td>\
|
|
||||||
</tr>\
|
|
||||||
<tr>\
|
|
||||||
<td class="key_td key_td_green">Active</td>\
|
|
||||||
<td class="value_td"><span id="active_hosts"></span></td>\
|
|
||||||
</tr>\
|
|
||||||
</table>\
|
|
||||||
</div>\
|
|
||||||
</div>\
|
|
||||||
</td>\
|
|
||||||
<td>\
|
<td>\
|
||||||
<div class="panel">\
|
<div class="panel">\
|
||||||
<h3><a href="#hosts_tab">Clusters</a>\
|
<h3>Summary of resources</h3>\
|
||||||
<div class="new-resource">\
|
|
||||||
<a class="action_button" href="#hosts_tab" value="Cluster.create_dialog">+</a>\
|
|
||||||
</div>\
|
|
||||||
</h3>\
|
|
||||||
<div class="panel_info">\
|
<div class="panel_info">\
|
||||||
<table class="info_table">\
|
\
|
||||||
<tr>\
|
<table class="info_table">\
|
||||||
<td class="key_td">Total</td>\
|
<tr>\
|
||||||
<td class="value_td"><span id="total_clusters"></span></td>\
|
<td class="key_td">Hosts (total/active)</td>\
|
||||||
</tr>\
|
<td class="value_td"><span id="total_hosts"></span><span id="active_hosts" class="green"></span></td>\
|
||||||
</table>\
|
</tr>\
|
||||||
|
<tr>\
|
||||||
|
<td class="key_td">Clusters</td>\
|
||||||
|
<td class="value_td"><span id="total_clusters"></span></td>\
|
||||||
|
</tr>\
|
||||||
|
<tr>\
|
||||||
|
<td class="key_td">VM Templates (total/public)</td>\
|
||||||
|
<td class="value_td"><span id="total_templates"></span><span id="public_templates"></span></td>\
|
||||||
|
</tr>\
|
||||||
|
<tr>\
|
||||||
|
<td class="key_td">VM Instances (total/<span class="green">running</span>/<span class="red">failed</span>)</td>\
|
||||||
|
<td class="value_td"><span id="total_vms"></span><span id="running_vms" class="green"></span><span id="failed_vms" class="red"></span></td>\
|
||||||
|
</tr>\
|
||||||
|
<tr>\
|
||||||
|
<td class="key_td">Virtual Networks (total/public)</td>\
|
||||||
|
<td class="value_td"><span id="total_vnets"></span><span id="public_vnets"></span></td>\
|
||||||
|
</tr>\
|
||||||
|
<tr>\
|
||||||
|
<td class="key_td">Images (total/public)</td>\
|
||||||
|
<td class="value_td"><span id="total_images"></span><span id="public_images"></span></td>\
|
||||||
|
</tr>\
|
||||||
|
<tr>\
|
||||||
|
<td class="key_td oneadmin">Users</td>\
|
||||||
|
<td class="value_td oneadmin"><span id="total_users"></span></td>\
|
||||||
|
</tr>\
|
||||||
|
</table>\
|
||||||
|
\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
</td>\
|
</td>\
|
||||||
@ -59,95 +96,67 @@ var dashboard_tab_content =
|
|||||||
<tr>\
|
<tr>\
|
||||||
<td>\
|
<td>\
|
||||||
<div class="panel">\
|
<div class="panel">\
|
||||||
<h3><a href="#vms_tab">Virtual Machines</a>\
|
<h3>Quickstart</h3>\
|
||||||
<div class="new-resource">\
|
<form id="quickstart_form"><fieldset>\
|
||||||
<a class="action_button" href="#vms_tab" value="VM.create_dialog">+</a>\
|
<table style="width:100%;"><tr style="vertical-align:middle;"><td style="width:70%">\
|
||||||
</div>\
|
<label style="font-weight:bold;width:40px;height:7em;">New:</label>\
|
||||||
</h3>\
|
<input type="radio" name="quickstart" value="Host.create_dialog">Host</input><br />\
|
||||||
<div class="panel_info">\
|
<input type="radio" name="quickstart" value="Cluster.create_dialog">Cluster</input><br />\
|
||||||
<table class="info_table">\
|
<input type="radio" name="quickstart" value="Template.create_dialog">VM Template</input><br />\
|
||||||
<tr>\
|
<input type="radio" name="quickstart" value="VM.create_dialog">VM Instance</input><br />\
|
||||||
<td class="key_td">Total</td>\
|
<input type="radio" name="quickstart" value="Image.create_dialog">Image</input><br />\
|
||||||
<td class="value_td"><span id="total_vms"></span></td>\
|
<input type="radio" name="quickstart" value="User.create_dialog">User</input><br />\
|
||||||
</tr>\
|
</td><td>\
|
||||||
<tr>\
|
<button id="quickstart">Go</button></fieldset></form>\
|
||||||
<td class="key_td key_td_green">Running</td>\
|
</td></tr></table>\
|
||||||
<td class="value_td"><span id="running_vms"></span></td>\
|
|
||||||
</tr>\
|
|
||||||
<tr>\
|
|
||||||
<td class="key_td key_td_red">Failed</td>\
|
|
||||||
<td class="value_td"><span id="failed_vms"></span></td>\
|
|
||||||
</tr>\
|
|
||||||
</table>\
|
|
||||||
</div>\
|
|
||||||
</div>\
|
|
||||||
</td>\
|
|
||||||
<td>\
|
|
||||||
<div class="panel">\
|
|
||||||
<h3><a href="#vnets_tab">Virtual Networks</a>\
|
|
||||||
<div class="new-resource">\
|
|
||||||
<a class="action_button" href="#vnets_tab" value="Network.create_dialog">+</a>\
|
|
||||||
</div>\
|
|
||||||
</h3>\
|
|
||||||
<div class="panel_info">\
|
|
||||||
<table class="info_table">\
|
|
||||||
<tr>\
|
|
||||||
<td class="key_td">Total</td>\
|
|
||||||
<td class="value_td"><span id="total_vnets"></span></td>\
|
|
||||||
</tr>\
|
|
||||||
<tr>\
|
|
||||||
<td class="key_td">Public</td>\
|
|
||||||
<td class="value_td"><span id="public_vnets"></span></td>\
|
|
||||||
</tr>\
|
|
||||||
</table>\
|
|
||||||
</div>\
|
|
||||||
</div>\
|
|
||||||
</div>\
|
</div>\
|
||||||
</td>\
|
</td>\
|
||||||
</tr>\
|
</tr>\
|
||||||
<tr>\
|
<tr>\
|
||||||
<td>\
|
<td>\
|
||||||
<div class="panel">\
|
<div class="panel">\
|
||||||
<h3>\
|
<h3>Sunstone documentation</h3>\
|
||||||
<a href="#images_tab">Images</a>\
|
<ul style="list-style-type:none;">\
|
||||||
<div class="new-resource">\
|
<li>Sunstone installation and setup</li>\
|
||||||
<a class="action_button" href="#images_tab" value="Image.create_dialog">+</a>\
|
<li>Sunstone plugin guide</li>\
|
||||||
</div>\
|
<li>Sunstone plugin reference</li>\
|
||||||
</h3>\
|
</ul>\
|
||||||
<div class="panel_info">\
|
|
||||||
<table class="info_table">\
|
|
||||||
<tr>\
|
|
||||||
<td class="key_td">Total</td>\
|
|
||||||
<td class="value_td"><span id="total_images"></span></td>\
|
|
||||||
</tr>\
|
|
||||||
<tr>\
|
|
||||||
<td class="key_td">Public</td>\
|
|
||||||
<td class="value_td"><span id="public_images"></span></td>\
|
|
||||||
</tr>\
|
|
||||||
</table>\
|
|
||||||
</div>\
|
|
||||||
</div>\
|
</div>\
|
||||||
</td>\
|
</td>\
|
||||||
<td class="oneadmin">\
|
</tr>\
|
||||||
|
</table>\
|
||||||
|
</td>\
|
||||||
|
<td style="width:60%">\
|
||||||
|
<table id="historical_table" style="width:100%">\
|
||||||
|
<tr>\
|
||||||
|
<td>\
|
||||||
<div class="panel">\
|
<div class="panel">\
|
||||||
<h3><a href="#users_tab">Users</a>\
|
<h3>Historical monitoring information</h3>\
|
||||||
<div class="new-resource">\
|
|
||||||
<a class="action_button" href="#users_tab" value="User.create_dialog">+</a>\
|
|
||||||
</div>\
|
|
||||||
</h3>\
|
|
||||||
<div class="panel_info">\
|
<div class="panel_info">\
|
||||||
<table class="info_table">\
|
<table class="info_table">\
|
||||||
<tr>\
|
<tr><td class="key_td graph_td">Total host count</td>\
|
||||||
<td class="key_td">Total</td>\
|
<td class="graph_td" id="graph1_legend"></td></tr>\
|
||||||
<td class="value_td"><span id="total_users"></span></td>\
|
<tr><td id="graph1" colspan="2">'+spinner+'</td></tr>\
|
||||||
</tr>\
|
<tr><td class="key_td graph_td">Hosts CPU</td>\
|
||||||
</table>\
|
<td class="graph_td" id="graph2_legend"></td></tr>\
|
||||||
|
<tr><td id="graph2" colspan="2">'+spinner+'</td></tr>\
|
||||||
|
<tr><td class="key_td graph_td">Hosts memory</td>\
|
||||||
|
<td class="graph_td" id="graph3_legend"></td></tr>\
|
||||||
|
<tr><td id="graph3" colspan="2">'+spinner+'</td></tr>\
|
||||||
|
<tr><td class="key_td graph_td">Total VM count</td>\
|
||||||
|
<td class="graph_td" id="graph4_legend"></td></tr>\
|
||||||
|
<tr><td id="graph4" colspan="2">'+spinner+'</td></tr>\
|
||||||
|
<tr><td class="key_td graph_td">VM Network stats</td>\
|
||||||
|
<td class="graph_td" id="graph5_legend"></td></tr>\
|
||||||
|
<tr><td id="graph5" colspan="2">'+spinner+'</td></tr>\
|
||||||
|
</table>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>\
|
</div>\
|
||||||
</td>\
|
</td>\
|
||||||
</tr>\
|
</tr>\
|
||||||
</table>';
|
</table>\
|
||||||
|
</td>\
|
||||||
|
</tr></table>';
|
||||||
|
|
||||||
var dashboard_tab = {
|
var dashboard_tab = {
|
||||||
title: 'Dashboard',
|
title: 'Dashboard',
|
||||||
@ -157,6 +166,74 @@ var dashboard_tab = {
|
|||||||
|
|
||||||
Sunstone.addMainTab('dashboard_tab',dashboard_tab);
|
Sunstone.addMainTab('dashboard_tab',dashboard_tab);
|
||||||
|
|
||||||
|
function plot_global_graph(data,info){
|
||||||
|
var id = info.title;
|
||||||
|
var labels_arr = info.monitor_resources.split(',');
|
||||||
|
var serie;
|
||||||
|
var series = [];
|
||||||
|
var width = ($(window).width()-129)*45/100;
|
||||||
|
|
||||||
|
$('#'+id).html('<div id="'+id+'_graph" style="height:70px;width:'+width+'px"><div>');
|
||||||
|
|
||||||
|
for (var i = 0; i< labels_arr.length; i++) {
|
||||||
|
serie = {
|
||||||
|
label: labels_arr[i],
|
||||||
|
data: data[i]
|
||||||
|
};
|
||||||
|
series.push(serie);
|
||||||
|
};
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
legend : { show : true,
|
||||||
|
noColumns: labels_arr.length,
|
||||||
|
container: $('#'+id+'_legend')},
|
||||||
|
xaxis : { mode: "time",
|
||||||
|
timeformat: "%h:%M"
|
||||||
|
},
|
||||||
|
yaxis : { labelWidth: 40 }
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (id){
|
||||||
|
case "graph3":
|
||||||
|
case "graph5":
|
||||||
|
options["yaxis"]["tickFormatter"] = function(val,axis) { return humanize_size(val); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$.plot($('#'+id+'_graph'),series,options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function quickstart_setup(){
|
||||||
|
|
||||||
|
$('#quickstart').button("disable");
|
||||||
|
|
||||||
|
$('#quickstart_form input').click(function(){
|
||||||
|
$('#quickstart').val($(this).val());
|
||||||
|
$('#quickstart').button("enable");
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#quickstart').click(function(){
|
||||||
|
Sunstone.runAction($(this).val());
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function graph_autorefresh(){
|
||||||
|
setInterval(function(){
|
||||||
|
refresh_graphs();
|
||||||
|
},GRAPH_AUTOREFRESH_INTERVAL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh_graphs(){
|
||||||
|
Sunstone.runAction("Host.monitor_all", graph1);
|
||||||
|
Sunstone.runAction("Host.monitor_all", graph2);
|
||||||
|
Sunstone.runAction("Host.monitor_all", graph3);
|
||||||
|
Sunstone.runAction("VM.monitor_all", graph4);
|
||||||
|
Sunstone.runAction("VM.monitor_all", graph5);
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
//Dashboard link listener
|
//Dashboard link listener
|
||||||
$("#dashboard_table h3 a").live("click", function (){
|
$("#dashboard_table h3 a").live("click", function (){
|
||||||
@ -164,13 +241,17 @@ $(document).ready(function(){
|
|||||||
showTab(tab);
|
showTab(tab);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
emptyDashboard();
|
emptyDashboard();
|
||||||
if (uid!=0) {
|
if (uid!=0) {
|
||||||
$("td.oneadmin").hide();
|
$("td.oneadmin").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quickstart_setup();
|
||||||
|
|
||||||
|
refresh_graphs();
|
||||||
|
graph_autorefresh();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//puts the dashboard values into "retrieving"
|
//puts the dashboard values into "retrieving"
|
||||||
@ -180,62 +261,73 @@ function emptyDashboard(){
|
|||||||
|
|
||||||
|
|
||||||
function updateDashboard(what,json_info){
|
function updateDashboard(what,json_info){
|
||||||
db = $('#dashboard_tab');
|
var db = $('#dashboard_tab');
|
||||||
switch (what){
|
switch (what){
|
||||||
case "hosts":
|
case "hosts":
|
||||||
total_hosts=json_info.length;
|
var total_hosts=json_info.length;
|
||||||
active_hosts=0;
|
var active_hosts=0;
|
||||||
$.each(json_info,function(){
|
$.each(json_info,function(){
|
||||||
if (parseInt(this.HOST.STATE) < 3){
|
if (parseInt(this.HOST.STATE) < 3){
|
||||||
active_hosts++;}
|
active_hosts++;}
|
||||||
});
|
});
|
||||||
$('#total_hosts',db).html(total_hosts);
|
$('#total_hosts',db).html(total_hosts+' / ');
|
||||||
$('#active_hosts',db).html(active_hosts);
|
$('#active_hosts',db).html(active_hosts);
|
||||||
break;
|
break;
|
||||||
case "clusters":
|
case "clusters":
|
||||||
total_clusters=json_info.length;
|
var total_clusters=json_info.length;
|
||||||
$('#total_clusters',db).html(total_clusters);
|
$('#total_clusters',db).html(total_clusters);
|
||||||
break;
|
break;
|
||||||
case "vms":
|
case "vms":
|
||||||
total_vms=json_info.length;
|
var total_vms=json_info.length;
|
||||||
running_vms=0;
|
var running_vms=0;
|
||||||
failed_vms=0;
|
failed_vms=0;
|
||||||
$.each(json_info,function(){
|
$.each(json_info,function(){
|
||||||
vm_state = parseInt(this.VM.STATE);
|
vm_state = parseInt(this.VM.STATE);
|
||||||
if (vm_state == 3){
|
if (vm_state == 3){
|
||||||
running_vms++;
|
running_vms++;
|
||||||
}
|
}
|
||||||
else if (vm_state == 7) {
|
else if (vm_state == 7) {
|
||||||
failed_vms++;
|
failed_vms++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#total_vms',db).html(total_vms);
|
$('#total_vms',db).html(total_vms+' / ');
|
||||||
$('#running_vms',db).html(running_vms);
|
$('#running_vms',db).html(running_vms+' / ');
|
||||||
$('#failed_vms',db).html(failed_vms);
|
$('#failed_vms',db).html(failed_vms);
|
||||||
break;
|
break;
|
||||||
case "vnets":
|
case "vnets":
|
||||||
public_vnets=0;
|
var public_vnets=0;
|
||||||
total_vnets=json_info.length;
|
var total_vnets=json_info.length;
|
||||||
$.each(json_info,function(){
|
$.each(json_info,function(){
|
||||||
if (parseInt(this.VNET.PUBLIC)){
|
if (parseInt(this.VNET.PUBLIC)){
|
||||||
public_vnets++;}
|
public_vnets++;}
|
||||||
});
|
});
|
||||||
$('#total_vnets',db).html(total_vnets);
|
$('#total_vnets',db).html(total_vnets+' / ');
|
||||||
$('#public_vnets',db).html(public_vnets);
|
$('#public_vnets',db).html(public_vnets);
|
||||||
break;
|
break;
|
||||||
case "users":
|
case "users":
|
||||||
total_users=json_info.length;
|
var total_users=json_info.length;
|
||||||
$('#total_users',db).html(total_users);
|
$('#total_users',db).html(total_users);
|
||||||
break;
|
break;
|
||||||
case "images":
|
case "images":
|
||||||
total_images=json_info.length;
|
var total_images=json_info.length;
|
||||||
public_images=0;
|
var public_images=0;
|
||||||
$.each(json_info,function(){
|
$.each(json_info,function(){
|
||||||
if (parseInt(this.IMAGE.PUBLIC)){
|
if (parseInt(this.IMAGE.PUBLIC)){
|
||||||
public_images++;}
|
public_images++;}
|
||||||
});
|
});
|
||||||
$('#total_images',db).html(total_images);
|
$('#total_images',db).html(total_images+' / ');
|
||||||
$('#public_images',db).html(public_images);
|
$('#public_images',db).html(public_images);
|
||||||
break;
|
break;
|
||||||
}
|
case "templates":
|
||||||
}
|
var total_templates=json_info.length;
|
||||||
|
var public_templates=0;
|
||||||
|
$.each(json_info,function(){
|
||||||
|
if (parseInt(this.VMTEMPLATE.PUBLIC)){
|
||||||
|
public_templates++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#total_templates',db).html(total_templates+' / ');
|
||||||
|
$('#public_templates',db).html(public_templates);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,24 @@
|
|||||||
|
|
||||||
/*Host tab plugin*/
|
/*Host tab plugin*/
|
||||||
|
|
||||||
|
var HOST_HISTORY_LENGTH = 40;
|
||||||
|
var host_graphs = [
|
||||||
|
{
|
||||||
|
title : "CPU Monitoring information",
|
||||||
|
monitor_resources : "cpu_usage,used_cpu,max_cpu",
|
||||||
|
humanize_figures : false,
|
||||||
|
history_length : HOST_HISTORY_LENGTH
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Memory monitoring information",
|
||||||
|
monitor_resources : "mem_usage,used_mem,max_mem",
|
||||||
|
humanize_figures : true,
|
||||||
|
history_length : HOST_HISTORY_LENGTH
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var hosts_tab_content =
|
var hosts_tab_content =
|
||||||
'<form id="form_hosts" action="javascript:alert(\'js errors?!\')">\
|
'<form id="form_hosts" action="javascript:alert(\'js errors?!\')">\
|
||||||
<div class="action_blocks">\
|
<div class="action_blocks">\
|
||||||
@ -198,7 +216,28 @@ var host_actions = {
|
|||||||
OpenNebula.Cluster.list({success: updateClustersView, error: onError});
|
OpenNebula.Cluster.list({success: updateClustersView, error: onError});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"Host.monitor" : {
|
||||||
|
type: "monitor",
|
||||||
|
call : OpenNebula.Host.monitor,
|
||||||
|
callback: function(req,response) {
|
||||||
|
var info = req.request.data[0].monitor;
|
||||||
|
plot_graph(response,'#host_monitoring_tab',
|
||||||
|
'host_monitor_',info);
|
||||||
|
},
|
||||||
|
error: onError
|
||||||
|
},
|
||||||
|
|
||||||
|
"Host.monitor_all" : {
|
||||||
|
type: "monitor_global",
|
||||||
|
call: OpenNebula.Host.monitor_all,
|
||||||
|
callback: function(req,response) {
|
||||||
|
var info = req.request.data[0].monitor;
|
||||||
|
plot_global_graph(response,info);
|
||||||
|
},
|
||||||
|
error: onError
|
||||||
|
},
|
||||||
|
|
||||||
"Cluster.create" : {
|
"Cluster.create" : {
|
||||||
type: "create",
|
type: "create",
|
||||||
call : OpenNebula.Cluster.create,
|
call : OpenNebula.Cluster.create,
|
||||||
@ -208,7 +247,7 @@ var host_actions = {
|
|||||||
error : onError,
|
error : onError,
|
||||||
notify: true
|
notify: true
|
||||||
},
|
},
|
||||||
|
|
||||||
"Cluster.create_dialog" : {
|
"Cluster.create_dialog" : {
|
||||||
type: "custom",
|
type: "custom",
|
||||||
call: popUpCreateClusterDialog
|
call: popUpCreateClusterDialog
|
||||||
@ -327,6 +366,10 @@ var host_info_panel = {
|
|||||||
"host_template_tab" : {
|
"host_template_tab" : {
|
||||||
title: "Host template",
|
title: "Host template",
|
||||||
content: ""
|
content: ""
|
||||||
|
},
|
||||||
|
"host_monitoring_tab": {
|
||||||
|
title: "Monitoring information",
|
||||||
|
content: ""
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -533,7 +576,7 @@ function updateHostInfo(request,host){
|
|||||||
<td class="value_td">'+host_info.HOST_SHARE.USED_CPU+'</td>\
|
<td class="value_td">'+host_info.HOST_SHARE.USED_CPU+'</td>\
|
||||||
</tr>\
|
</tr>\
|
||||||
<tr>\
|
<tr>\
|
||||||
<td class="key_td">Used CPU(allocated)</td>\
|
<td class="key_td">Used CPU (allocated)</td>\
|
||||||
<td class="value_td">'+host_info.HOST_SHARE.CPU_USAGE+'</td>\
|
<td class="value_td">'+host_info.HOST_SHARE.CPU_USAGE+'</td>\
|
||||||
</tr>\
|
</tr>\
|
||||||
<tr>\
|
<tr>\
|
||||||
@ -552,11 +595,23 @@ function updateHostInfo(request,host){
|
|||||||
prettyPrintJSON(host_info.TEMPLATE)+
|
prettyPrintJSON(host_info.TEMPLATE)+
|
||||||
'</table>'
|
'</table>'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var monitor_tab = {
|
||||||
|
title: "Monitoring information",
|
||||||
|
content : generateMonitoringDivs(host_graphs,"host_monitor_")
|
||||||
|
}
|
||||||
|
|
||||||
//Sunstone.updateInfoPanelTab(info_panel_name,tab_name, new tab object);
|
//Sunstone.updateInfoPanelTab(info_panel_name,tab_name, new tab object);
|
||||||
Sunstone.updateInfoPanelTab("host_info_panel","host_info_tab",info_tab);
|
Sunstone.updateInfoPanelTab("host_info_panel","host_info_tab",info_tab);
|
||||||
Sunstone.updateInfoPanelTab("host_info_panel","host_template_tab",template_tab);
|
Sunstone.updateInfoPanelTab("host_info_panel","host_template_tab",template_tab);
|
||||||
|
Sunstone.updateInfoPanelTab("host_info_panel","host_monitoring_tab",monitor_tab);
|
||||||
|
|
||||||
Sunstone.popUpInfoPanel("host_info_panel");
|
Sunstone.popUpInfoPanel("host_info_panel");
|
||||||
|
//pop up panel while we retrieve the graphs
|
||||||
|
for (var i=0; i<host_graphs.length; i++){
|
||||||
|
Sunstone.runAction("Host.monitor",host_info.ID,host_graphs[i]);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,13 +663,16 @@ function setupCreateImageDialog(){
|
|||||||
//Insert HTML in place
|
//Insert HTML in place
|
||||||
$('#create_image_dialog').html(create_image_tmpl);
|
$('#create_image_dialog').html(create_image_tmpl);
|
||||||
|
|
||||||
|
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
|
||||||
|
|
||||||
//Prepare jquery dialog
|
//Prepare jquery dialog
|
||||||
$('#create_image_dialog').dialog({
|
$('#create_image_dialog').dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
modal:true,
|
modal:true,
|
||||||
width: 520
|
width: 520,
|
||||||
});
|
height: height
|
||||||
|
});
|
||||||
|
|
||||||
$('#img_tabs').tabs();
|
$('#img_tabs').tabs();
|
||||||
$('#create_image_dialog button').button();
|
$('#create_image_dialog button').button();
|
||||||
$('#img_type option').first().attr("selected","selected");
|
$('#img_type option').first().attr("selected","selected");
|
||||||
|
@ -803,6 +803,7 @@ function updateTemplateSelect(){
|
|||||||
|
|
||||||
//update static selectors:
|
//update static selectors:
|
||||||
$('#create_vm_dialog #template_id').html(templates_select);
|
$('#create_vm_dialog #template_id').html(templates_select);
|
||||||
|
$('#speed_virt').html(templates_select);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback to update an element in the dataTable
|
// Callback to update an element in the dataTable
|
||||||
|
@ -16,12 +16,37 @@
|
|||||||
|
|
||||||
/*Virtual Machines tab plugin*/
|
/*Virtual Machines tab plugin*/
|
||||||
var INCLUDE_URI = "vendor/noVNC/include/";
|
var INCLUDE_URI = "vendor/noVNC/include/";
|
||||||
|
var VM_HISTORY_LENGTH = 40;
|
||||||
|
|
||||||
function loadVNC(){
|
function loadVNC(){
|
||||||
var script = '<script src="vendor/noVNC/include/vnc.js"></script>';
|
var script = '<script src="vendor/noVNC/include/vnc.js"></script>';
|
||||||
document.write(script);
|
document.write(script);
|
||||||
}
|
}
|
||||||
loadVNC();
|
loadVNC();
|
||||||
|
|
||||||
|
var vm_graphs = [
|
||||||
|
{ title : "CPU",
|
||||||
|
monitor_resources : "cpu",
|
||||||
|
humanize_figures : false,
|
||||||
|
history_length : VM_HISTORY_LENGTH
|
||||||
|
},
|
||||||
|
{ title : "Memory",
|
||||||
|
monitor_resources : "memory",
|
||||||
|
humanize_figures : true,
|
||||||
|
history_length : VM_HISTORY_LENGTH
|
||||||
|
},
|
||||||
|
{ title : "Network transmission",
|
||||||
|
monitor_resources : "net_tx",
|
||||||
|
humanize_figures : true,
|
||||||
|
history_length : VM_HISTORY_LENGTH
|
||||||
|
},
|
||||||
|
{ title : "Network reception",
|
||||||
|
monitor_resources : "net_rx",
|
||||||
|
humanize_figures : true,
|
||||||
|
history_length : VM_HISTORY_LENGTH
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
var vms_tab_content =
|
var vms_tab_content =
|
||||||
'<form id="virtualMachine_list" action="javascript:alert(\'js error!\');">\
|
'<form id="virtualMachine_list" action="javascript:alert(\'js error!\');">\
|
||||||
<div class="action_blocks">\
|
<div class="action_blocks">\
|
||||||
@ -305,13 +330,7 @@ var vm_actions = {
|
|||||||
colored_log += line + "\n";
|
colored_log += line + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
var log_tab = {
|
$('#vm_log_tab#').html('<pre>'+colored_log+'</pre>')
|
||||||
title: "VM log",
|
|
||||||
content: '<pre>'+colored_log+'</pre>'
|
|
||||||
}
|
|
||||||
Sunstone.updateInfoPanelTab("vm_info_panel","vm_log_tab",log_tab);
|
|
||||||
Sunstone.popUpInfoPanel("vm_info_panel",0);
|
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function(request,error_json){
|
error: function(request,error_json){
|
||||||
$("#vm_log pre").html('');
|
$("#vm_log pre").html('');
|
||||||
@ -333,7 +352,27 @@ var vm_actions = {
|
|||||||
callback: null,
|
callback: null,
|
||||||
error: onError,
|
error: onError,
|
||||||
notify: true
|
notify: true
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"VM.monitor" : {
|
||||||
|
type: "monitor",
|
||||||
|
call : OpenNebula.VM.monitor,
|
||||||
|
callback: function(req,response) {
|
||||||
|
var info = req.request.data[0].monitor;
|
||||||
|
plot_graph(response,'#vm_monitoring_tab',
|
||||||
|
'vm_monitor_',info);
|
||||||
|
},
|
||||||
|
error: onError
|
||||||
|
},
|
||||||
|
"VM.monitor_all" : {
|
||||||
|
type: "monitor_global",
|
||||||
|
call: OpenNebula.VM.monitor_all,
|
||||||
|
callback: function(req,response) {
|
||||||
|
var info = req.request.data[0].monitor;
|
||||||
|
plot_global_graph(response,info);
|
||||||
|
},
|
||||||
|
error: onError
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -624,30 +663,36 @@ function updateVMInfo(request,vm){
|
|||||||
</tr>\
|
</tr>\
|
||||||
</table>'
|
</table>'
|
||||||
}
|
}
|
||||||
|
|
||||||
var template_tab = {
|
var template_tab = {
|
||||||
title: "VM Template",
|
title: "VM Template",
|
||||||
content: '<table id="vm_template_table" class="info_table">\
|
content: '<table id="vm_template_table" class="info_table">\
|
||||||
<thead><tr><th colspan="2">VM template</th></tr></thead>'+
|
<thead><tr><th colspan="2">VM template</th></tr></thead>'+
|
||||||
prettyPrintJSON(vm_info.TEMPLATE)+
|
prettyPrintJSON(vm_info.TEMPLATE)+
|
||||||
'</table>'
|
'</table>'
|
||||||
}
|
}
|
||||||
|
|
||||||
var log_tab = {
|
var log_tab = {
|
||||||
title: "VM log",
|
title: "VM log",
|
||||||
content: '<pre>'+spinner+'</pre>'
|
content: '<div>'+spinner+'</div>'
|
||||||
}
|
}
|
||||||
|
|
||||||
Sunstone.updateInfoPanelTab("vm_info_panel","vm_info_tab",info_tab);
|
var monitoring_tab = {
|
||||||
|
title: "Monitoring information",
|
||||||
|
content: generateMonitoringDivs(vm_graphs,"vm_monitor_")
|
||||||
|
}
|
||||||
|
|
||||||
|
Sunstone.updateInfoPanelTab("vm_info_panel","vm_info_tab",info_tab);
|
||||||
Sunstone.updateInfoPanelTab("vm_info_panel","vm_template_tab",template_tab);
|
Sunstone.updateInfoPanelTab("vm_info_panel","vm_template_tab",template_tab);
|
||||||
Sunstone.updateInfoPanelTab("vm_info_panel","vm_log_tab",log_tab);
|
Sunstone.updateInfoPanelTab("vm_info_panel","vm_log_tab",log_tab);
|
||||||
|
Sunstone.updateInfoPanelTab("vm_info_panel","vm_monitoring_tab",monitoring_tab);
|
||||||
|
|
||||||
//Here it is special, as we will let the callback from the VM.log
|
//Pop up the info panel and asynchronously get vm_log and stats
|
||||||
//action popUp the info panel again when the info is received.
|
|
||||||
Sunstone.popUpInfoPanel("vm_info_panel");
|
Sunstone.popUpInfoPanel("vm_info_panel");
|
||||||
Sunstone.runAction("VM.log",vm_info.ID);
|
Sunstone.runAction("VM.log",vm_info.ID);
|
||||||
|
for (var i=0; i<vm_graphs.length; i++){
|
||||||
|
Sunstone.runAction("VM.monitor",vm_info.ID,vm_graphs[i]);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets up the create-template dialog and all the processing associated to it,
|
// Sets up the create-template dialog and all the processing associated to it,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Some useful functions for Sunstone default plugins */
|
/* Some useful functions for Sunstone default plugins */
|
||||||
var INTERVAL=60000;
|
var INTERVAL=60000; //milisecs
|
||||||
|
|
||||||
function someTime(){
|
function someTime(){
|
||||||
return Math.floor(Math.random()*30000);
|
return Math.floor(Math.random()*30000);
|
||||||
@ -478,10 +478,68 @@ function escapeDoubleQuotes(string){
|
|||||||
return string.replace(/"/g,'\\"');
|
return string.replace(/"/g,'\\"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateMonitoringDivs(graphs, id_prefix){
|
||||||
|
var str = "";
|
||||||
|
//40% of the width of the screen minus
|
||||||
|
//129px (left menu size)
|
||||||
|
var width = ($(window).width()-129)*45/100;
|
||||||
|
var id_suffix="";
|
||||||
|
var label="";
|
||||||
|
|
||||||
|
$.each(graphs,function(){
|
||||||
|
label = this.monitor_resources;
|
||||||
|
id_suffix=label.replace(/,/g,'_');
|
||||||
|
id = id_prefix+id_suffix;
|
||||||
|
str+='<table class="info_table">\
|
||||||
|
<thead><tr><th colspan="1">'+this.title+'</th></tr></thead>\
|
||||||
|
<tr><td id="legend_'+id_suffix+'"></td></tr>\
|
||||||
|
<tr><td style="border:0">\
|
||||||
|
<div id="'+id+'" style="width:'+width+'px; height:150px;">'+spinner+'</div>\
|
||||||
|
</td></tr></table>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function plot_graph(data,context,id_prefix,info){
|
||||||
|
var labels = info.monitor_resources;
|
||||||
|
var humanize = info.humanize_figures ? humanize_size : function(val){return val};
|
||||||
|
var labels_arr = labels.split(',');
|
||||||
|
var id_suffix = labels.replace(/,/g,'_');
|
||||||
|
var series = [];
|
||||||
|
var serie = null;
|
||||||
|
|
||||||
|
for (var i = 0; i< labels_arr.length; i++) {
|
||||||
|
serie = {
|
||||||
|
label: labels_arr[i],
|
||||||
|
data: data[i]
|
||||||
|
};
|
||||||
|
series.push(serie);
|
||||||
|
};
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
legend : { show : true,
|
||||||
|
noColumns: labels_arr.length,
|
||||||
|
container: $('#legend_'+id_suffix)
|
||||||
|
},
|
||||||
|
xaxis : { mode: "time",
|
||||||
|
timeformat: "%h:%M"
|
||||||
|
},
|
||||||
|
yaxis : { labelWidth: 40,
|
||||||
|
tickFormatter: function(val, axis) {
|
||||||
|
return humanize(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
id = id_prefix + id_suffix;
|
||||||
|
$.plot($('#'+id, context),series,options);
|
||||||
|
}
|
||||||
|
|
||||||
//functions that used as true and false conditions for testing mainly
|
//functions that used as true and false conditions for testing mainly
|
||||||
function True(){
|
function True(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function False(){
|
function False(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
var cookie = {};
|
var cookie = {};
|
||||||
var username = '';
|
var username = '';
|
||||||
var uid = '';
|
var uid = '';
|
||||||
var spinner = '<img src="/images/ajax-loader.gif" alt="retrieving" class="loading_img"/>';
|
var spinner = '<img src="/images/ajax-loader.gif" alt="retrieving" class="loading_img" />';
|
||||||
|
|
||||||
|
|
||||||
//Sunstone configuration is formed by predifined "actions", main tabs
|
//Sunstone configuration is formed by predifined "actions", main tabs
|
||||||
@ -187,12 +187,14 @@ var Sunstone = {
|
|||||||
// * "create" calls to opennebula.js
|
// * "create" calls to opennebula.js
|
||||||
// * "single" element calls to opennebula.js
|
// * "single" element calls to opennebula.js
|
||||||
// * "list" (get the pool of elements) calls to opennebula.js
|
// * "list" (get the pool of elements) calls to opennebula.js
|
||||||
|
// * "monitor_global" (returns monitoring information from a pool of elements
|
||||||
|
// * "monitor_single" (returns monitoring information from 1 element to create graphs)
|
||||||
// * "multiple" - actions to be run on a given list of elements
|
// * "multiple" - actions to be run on a given list of elements
|
||||||
// (with maybe an extra parameter).
|
// (with maybe an extra parameter).
|
||||||
// * The default actions. Simple call the the pre-defined "call"
|
// * The default actions. Simple call the the pre-defined "call"
|
||||||
// function with an extraparam if defined.
|
// function with an extraparam if defined.
|
||||||
switch (action_cfg.type){
|
switch (action_cfg.type){
|
||||||
|
|
||||||
case "create":
|
case "create":
|
||||||
case "register":
|
case "register":
|
||||||
call({data:data_arg, success: callback, error:err});
|
call({data:data_arg, success: callback, error:err});
|
||||||
@ -203,6 +205,13 @@ var Sunstone = {
|
|||||||
case "list":
|
case "list":
|
||||||
call({success: callback, error:err});
|
call({success: callback, error:err});
|
||||||
break;
|
break;
|
||||||
|
case "monitor_global":
|
||||||
|
call({timeout: true, success: callback, error:err, data: {monitor: data_arg}});
|
||||||
|
break;
|
||||||
|
case "monitor":
|
||||||
|
case "monitor_single":
|
||||||
|
call({timeout: true, success: callback, error:err, data: {id:data_arg, monitor: extra_param}});
|
||||||
|
break;
|
||||||
case "multiple":
|
case "multiple":
|
||||||
//run on the list of nodes that come on the data
|
//run on the list of nodes that come on the data
|
||||||
$.each(data_arg,function(){
|
$.each(data_arg,function(){
|
||||||
|
1201
src/sunstone/public/vendor/flot/API.txt
vendored
Normal file
1201
src/sunstone/public/vendor/flot/API.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
76
src/sunstone/public/vendor/flot/FAQ.txt
vendored
Normal file
76
src/sunstone/public/vendor/flot/FAQ.txt
vendored
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
Frequently asked questions
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Q: How much data can Flot cope with?
|
||||||
|
|
||||||
|
A: Flot will happily draw everything you send to it so the answer
|
||||||
|
depends on the browser. The excanvas emulation used for IE (built with
|
||||||
|
VML) makes IE by far the slowest browser so be sure to test with that
|
||||||
|
if IE users are in your target group.
|
||||||
|
|
||||||
|
1000 points is not a problem, but as soon as you start having more
|
||||||
|
points than the pixel width, you should probably start thinking about
|
||||||
|
downsampling/aggregation as this is near the resolution limit of the
|
||||||
|
chart anyway. If you downsample server-side, you also save bandwidth.
|
||||||
|
|
||||||
|
|
||||||
|
Q: Flot isn't working when I'm using JSON data as source!
|
||||||
|
|
||||||
|
A: Actually, Flot loves JSON data, you just got the format wrong.
|
||||||
|
Double check that you're not inputting strings instead of numbers,
|
||||||
|
like [["0", "-2.13"], ["5", "4.3"]]. This is most common mistake, and
|
||||||
|
the error might not show up immediately because Javascript can do some
|
||||||
|
conversion automatically.
|
||||||
|
|
||||||
|
|
||||||
|
Q: Can I export the graph?
|
||||||
|
|
||||||
|
A: This is a limitation of the canvas technology. There's a hook in
|
||||||
|
the canvas object for getting an image out, but you won't get the tick
|
||||||
|
labels. And it's not likely to be supported by IE. At this point, your
|
||||||
|
best bet is probably taking a screenshot, e.g. with PrtScn.
|
||||||
|
|
||||||
|
|
||||||
|
Q: The bars are all tiny in time mode?
|
||||||
|
|
||||||
|
A: It's not really possible to determine the bar width automatically.
|
||||||
|
So you have to set the width with the barWidth option which is NOT in
|
||||||
|
pixels, but in the units of the x axis (or the y axis for horizontal
|
||||||
|
bars). For time mode that's milliseconds so the default value of 1
|
||||||
|
makes the bars 1 millisecond wide.
|
||||||
|
|
||||||
|
|
||||||
|
Q: Can I use Flot with libraries like Mootools or Prototype?
|
||||||
|
|
||||||
|
A: Yes, Flot supports it out of the box and it's easy! Just use jQuery
|
||||||
|
instead of $, e.g. call jQuery.plot instead of $.plot and use
|
||||||
|
jQuery(something) instead of $(something). As a convenience, you can
|
||||||
|
put in a DOM element for the graph placeholder where the examples and
|
||||||
|
the API documentation are using jQuery objects.
|
||||||
|
|
||||||
|
Depending on how you include jQuery, you may have to add one line of
|
||||||
|
code to prevent jQuery from overwriting functions from the other
|
||||||
|
libraries, see the documentation in jQuery ("Using jQuery with other
|
||||||
|
libraries") for details.
|
||||||
|
|
||||||
|
|
||||||
|
Q: Flot doesn't work with [insert name of Javascript UI framework]!
|
||||||
|
|
||||||
|
A: The only non-standard thing used by Flot is the canvas tag;
|
||||||
|
otherwise it is simply a series of absolute positioned divs within the
|
||||||
|
placeholder tag you put in. If this is not working, it's probably
|
||||||
|
because the framework you're using is doing something weird with the
|
||||||
|
DOM, or you're using it the wrong way.
|
||||||
|
|
||||||
|
A common problem is that there's display:none on a container until the
|
||||||
|
user does something. Many tab widgets work this way, and there's
|
||||||
|
nothing wrong with it - you just can't call Flot inside a display:none
|
||||||
|
container as explained in the README so you need to hold off the Flot
|
||||||
|
call until the container is actually displayed (or use
|
||||||
|
visibility:hidden instead of display:none or move the container
|
||||||
|
off-screen).
|
||||||
|
|
||||||
|
If you find there's a specific thing we can do to Flot to help, feel
|
||||||
|
free to submit a bug report. Otherwise, you're welcome to ask for help
|
||||||
|
on the forum/mailing list, but please don't submit a bug report to
|
||||||
|
Flot.
|
22
src/sunstone/public/vendor/flot/LICENSE.txt
vendored
Normal file
22
src/sunstone/public/vendor/flot/LICENSE.txt
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 2007-2009 IOLA and Ole Laursen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
9
src/sunstone/public/vendor/flot/Makefile
vendored
Normal file
9
src/sunstone/public/vendor/flot/Makefile
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Makefile for generating minified files
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
# we cheat and process all .js files instead of an exhaustive list
|
||||||
|
all: $(patsubst %.js,%.min.js,$(filter-out %.min.js,$(wildcard *.js)))
|
||||||
|
|
||||||
|
%.min.js: %.js
|
||||||
|
yui-compressor $< -o $@
|
508
src/sunstone/public/vendor/flot/NEWS.txt
vendored
Normal file
508
src/sunstone/public/vendor/flot/NEWS.txt
vendored
Normal file
@ -0,0 +1,508 @@
|
|||||||
|
Flot 0.7
|
||||||
|
--------
|
||||||
|
|
||||||
|
API changes:
|
||||||
|
|
||||||
|
Multiple axes support. Code using dual axes should be changed from
|
||||||
|
using x2axis/y2axis in the options to using an array (although
|
||||||
|
backwards-compatibility hooks are in place). For instance,
|
||||||
|
|
||||||
|
{
|
||||||
|
xaxis: { ... }, x2axis: { ... },
|
||||||
|
yaxis: { ... }, y2axis: { ... }
|
||||||
|
}
|
||||||
|
|
||||||
|
becomes
|
||||||
|
|
||||||
|
{
|
||||||
|
xaxes: [ { ... }, { ... } ],
|
||||||
|
yaxes: [ { ... }, { ... } ]
|
||||||
|
}
|
||||||
|
|
||||||
|
Note that if you're just using one axis, continue to use the
|
||||||
|
xaxis/yaxis directly (it now sets the default settings for the
|
||||||
|
arrays). Plugins touching the axes must be ported to take the extra
|
||||||
|
axes into account, check the source to see some examples.
|
||||||
|
|
||||||
|
A related change is that the visibility of axes is now auto-detected.
|
||||||
|
So if you were relying on an axis to show up even without any data in
|
||||||
|
the chart, you now need to set the axis "show" option explicitly.
|
||||||
|
|
||||||
|
"tickColor" on the grid options is now deprecated in favour of a
|
||||||
|
corresponding option on the axes, so { grid: { tickColor: "#000" }}
|
||||||
|
becomes { xaxis: { tickColor: "#000"}, yaxis: { tickColor: "#000"} },
|
||||||
|
but if you just configure a base color Flot will now autogenerate a
|
||||||
|
tick color by adding transparency. Backwards-compatibility hooks are
|
||||||
|
in place.
|
||||||
|
|
||||||
|
Final note: now that IE 9 is coming out with canvas support, you may
|
||||||
|
want to adapt the excanvas include to skip loading it in IE 9 (the
|
||||||
|
examples have been adapted thanks to Ryley Breiddal). An alternative
|
||||||
|
to excanvas using Flash has also surfaced, if your graphs are slow in
|
||||||
|
IE, you may want to give it a spin:
|
||||||
|
|
||||||
|
http://code.google.com/p/flashcanvas/
|
||||||
|
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Support for specifying a bottom for each point for line charts when
|
||||||
|
filling them, this means that an arbitrary bottom can be used
|
||||||
|
instead of just the x axis (based on patches patiently provided by
|
||||||
|
Roman V. Prikhodchenko).
|
||||||
|
- New fillbetween plugin that can compute a bottom for a series from
|
||||||
|
another series, useful for filling areas between lines (see new
|
||||||
|
example percentiles.html for a use case).
|
||||||
|
- More predictable handling of gaps for the stacking plugin, now all
|
||||||
|
undefined ranges are skipped.
|
||||||
|
- Stacking plugin can stack horizontal bar charts.
|
||||||
|
- Navigate plugin now redraws the plot while panning instead of only
|
||||||
|
after the fact (can be disabled by setting the pan.frameRate option
|
||||||
|
to null), raised by lastthemy (issue 235).
|
||||||
|
- Date formatter now accepts %0m and %0d to get a zero-padded month or
|
||||||
|
day (issue raised by Maximillian Dornseif).
|
||||||
|
- Revamped internals to support an unlimited number of axes, not just
|
||||||
|
dual (sponsored by Flight Data Services,
|
||||||
|
www.flightdataservices.com).
|
||||||
|
- New setting on axes, "tickLength", to control the size of ticks or
|
||||||
|
turn them off without turning off the labels.
|
||||||
|
- Axis labels are now put in container divs with classes, for instance
|
||||||
|
labels in the x axes can be reached via ".xAxis .tickLabel".
|
||||||
|
- Support for setting the color of an axis (sponsored by Flight Data
|
||||||
|
Services, www.flightdataservices.com).
|
||||||
|
- Tick color is now auto-generated as the base color with some
|
||||||
|
transparency (unless you override it).
|
||||||
|
- Support for aligning ticks in the axes with "alignTicksWithAxis" to
|
||||||
|
ensure that they appear next to each other rather than in between,
|
||||||
|
at the expense of possibly awkward tick steps (sponsored by Flight
|
||||||
|
Data Services, www.flightdataservices.com).
|
||||||
|
- Support for customizing the point type through a callback when
|
||||||
|
plotting points and new symbol plugin with some predefined point
|
||||||
|
types (sponsored by Utility Data Corporation).
|
||||||
|
- Resize plugin for automatically redrawing when the placeholder
|
||||||
|
changes size, e.g. on window resizes (sponsored by Novus Partners).
|
||||||
|
A resize() method has been added to plot object facilitate this.
|
||||||
|
- Support Infinity/-Infinity for plotting asymptotes by hacking it
|
||||||
|
into +/-Number.MAX_VALUE (reported by rabaea.mircea).
|
||||||
|
- Support for restricting navigate plugin to not pan/zoom an axis (based
|
||||||
|
on patch by kkaefer).
|
||||||
|
- Support for providing the drag cursor for the navigate plugin as an
|
||||||
|
option (based on patch by Kelly T. Moore).
|
||||||
|
- Options for controlling whether an axis is shown or not (suggestion
|
||||||
|
by Timo Tuominen) and whether to reserve space for it even if it
|
||||||
|
isn't shown.
|
||||||
|
- New attribute $.plot.version with the Flot version as a string.
|
||||||
|
- The version comment is now included in the minified jquery.flot.min.js.
|
||||||
|
- New options.grid.minBorderMargin for adjusting the minimum margin
|
||||||
|
provided around the border (based on patch by corani, issue 188).
|
||||||
|
- Refactor replot behaviour so Flot tries to reuse the existing
|
||||||
|
canvas, adding shutdown() methods to the plot (based on patch by
|
||||||
|
Ryley Breiddal, issue 269). This prevents a memory leak in Chrome
|
||||||
|
and hopefully makes replotting faster for those who are using $.plot
|
||||||
|
instead of .setData()/.draw(). Also update jQuery to 1.5.1 to
|
||||||
|
prevent IE leaks fixed in jQuery.
|
||||||
|
- New real-time line chart example.
|
||||||
|
|
||||||
|
- New hooks: drawSeries, shutdown
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
- Fixed problem with findNearbyItem and bars on top of each other
|
||||||
|
(reported by ragingchikn, issue 242).
|
||||||
|
- Fixed problem with ticks and the border (based on patch from
|
||||||
|
ultimatehustler69, issue 236).
|
||||||
|
- Fixed problem with plugins adding options to the series objects.
|
||||||
|
- Fixed a problem introduced in 0.6 with specifying a gradient with {
|
||||||
|
brightness: x, opacity: y }.
|
||||||
|
- Don't use $.browser.msie, check for getContext on the created canvas
|
||||||
|
element instead and try to use excanvas if it's not found (fixes IE
|
||||||
|
9 compatibility).
|
||||||
|
- highlight(s, index) was looking up the point in the original s.data
|
||||||
|
instead of in the computed datapoints array, which breaks with
|
||||||
|
plugins that modify the datapoints (such as the stacking plugin).
|
||||||
|
Issue 316 reported by curlypaul924.
|
||||||
|
- More robust handling of axis from data passed in from getData()
|
||||||
|
(problem reported by Morgan).
|
||||||
|
- Fixed problem with turning off bar outline (issue 253, fix by Jordi
|
||||||
|
Castells).
|
||||||
|
- Check the selection passed into setSelection in the selection
|
||||||
|
plugin, to guard against errors when synchronizing plots (fix by Lau
|
||||||
|
Bech Lauritzen).
|
||||||
|
- Fix bug in crosshair code with mouseout resetting the crosshair even
|
||||||
|
if it is locked (fix by Lau Bech Lauritzen and Banko Adam).
|
||||||
|
- Fix bug with points plotting using line width from lines rather than
|
||||||
|
points.
|
||||||
|
- Fix bug with passing non-array 0 data (for plugins that don't expect
|
||||||
|
arrays, patch by vpapp1).
|
||||||
|
- Fix errors in JSON in examples so they work with jQuery 1.4.2
|
||||||
|
(fix reported by honestbleeps, issue 357).
|
||||||
|
- Fix bug with tooltip in interacting.html, this makes the tooltip
|
||||||
|
much smoother (fix by bdkahn). Fix related bug inside highlighting
|
||||||
|
handler in Flot.
|
||||||
|
- Use closure trick to make inline colorhelpers plugin respect
|
||||||
|
jQuery.noConflict(true), renaming the global jQuery object (reported
|
||||||
|
by Nick Stielau).
|
||||||
|
- Listen for mouseleave events and fire a plothover event with empty
|
||||||
|
item when it occurs to drop highlights when the mouse leaves the
|
||||||
|
plot (reported by by outspirit).
|
||||||
|
- Fix bug with using aboveData with a background (reported by
|
||||||
|
amitayd).
|
||||||
|
- Fix possible excanvas leak (report and suggested fix by tom9729).
|
||||||
|
- Fix bug with backwards compatibility for shadowSize = 0 (report and
|
||||||
|
suggested fix by aspinak).
|
||||||
|
- Adapt examples to skip loading excanvas (fix by Ryley Breiddal).
|
||||||
|
- Fix bug that prevent a simple f(x) = -x transform from working
|
||||||
|
correctly (fix by Mike, issue 263).
|
||||||
|
- Fix bug in restoring cursor in navigate plugin (reported by Matteo
|
||||||
|
Gattanini, issue 395).
|
||||||
|
- Fix bug in picking items when transform/inverseTransform is in use
|
||||||
|
(reported by Ofri Raviv, and patches and analysis by Jan and Tom
|
||||||
|
Paton, issue 334 and 467).
|
||||||
|
- Fix problem with unaligned ticks and hover/click events caused by
|
||||||
|
padding on the placeholder by hardcoding the placeholder padding to
|
||||||
|
0 (reported by adityadineshsaxena, Matt Sommer, Daniel Atos and some
|
||||||
|
other people, issue 301).
|
||||||
|
- Update colorhelpers plugin to avoid dying when trying to parse an
|
||||||
|
invalid string (reported by cadavor, issue 483).
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.6
|
||||||
|
--------
|
||||||
|
|
||||||
|
API changes:
|
||||||
|
|
||||||
|
1. Selection support has been moved to a plugin. Thus if you're
|
||||||
|
passing selection: { mode: something }, you MUST include the file
|
||||||
|
jquery.flot.selection.js after jquery.flot.js. This reduces the size
|
||||||
|
of base Flot and makes it easier to customize the selection as well as
|
||||||
|
improving code clarity. The change is based on a patch from andershol.
|
||||||
|
|
||||||
|
2. In the global options specified in the $.plot command,
|
||||||
|
"lines", "points", "bars" and "shadowSize" have been moved to a
|
||||||
|
sub-object called "series", i.e.
|
||||||
|
|
||||||
|
$.plot(placeholder, data, { lines: { show: true }})
|
||||||
|
|
||||||
|
should be changed to
|
||||||
|
|
||||||
|
$.plot(placeholder, data, { series: { lines: { show: true }}})
|
||||||
|
|
||||||
|
All future series-specific options will go into this sub-object to
|
||||||
|
simplify plugin writing. Backward-compatibility code is in place, so
|
||||||
|
old code should not break.
|
||||||
|
|
||||||
|
3. "plothover" no longer provides the original data point, but instead
|
||||||
|
a normalized one, since there may be no corresponding original point.
|
||||||
|
|
||||||
|
4. Due to a bug in previous versions of jQuery, you now need at least
|
||||||
|
jQuery 1.2.6. But if you can, try jQuery 1.3.2 as it got some
|
||||||
|
improvements in event handling speed.
|
||||||
|
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Added support for disabling interactivity for specific data series
|
||||||
|
(request from Ronald Schouten and Steve Upton).
|
||||||
|
|
||||||
|
- Flot now calls $() on the placeholder and optional legend container
|
||||||
|
passed in so you can specify DOM elements or CSS expressions to make
|
||||||
|
it easier to use Flot with libraries like Prototype or Mootools or
|
||||||
|
through raw JSON from Ajax responses.
|
||||||
|
|
||||||
|
- A new "plotselecting" event is now emitted while the user is making
|
||||||
|
a selection.
|
||||||
|
|
||||||
|
- The "plothover" event is now emitted immediately instead of at most
|
||||||
|
10 times per second, you'll have to put in a setTimeout yourself if
|
||||||
|
you're doing something really expensive on this event.
|
||||||
|
|
||||||
|
- The built-in date formatter can now be accessed as
|
||||||
|
$.plot.formatDate(...) (suggestion by Matt Manela) and even
|
||||||
|
replaced.
|
||||||
|
|
||||||
|
- Added "borderColor" option to the grid (patch from Amaury Chamayou
|
||||||
|
and patch from Mike R. Williamson).
|
||||||
|
|
||||||
|
- Added support for gradient backgrounds for the grid, take a look at
|
||||||
|
the "setting options" example (based on patch from Amaury Chamayou,
|
||||||
|
issue 90).
|
||||||
|
|
||||||
|
- Gradient bars (suggestion by stefpet).
|
||||||
|
|
||||||
|
- Added a "plotunselected" event which is triggered when the selection
|
||||||
|
is removed, see "selection" example (suggestion by Meda Ugo);
|
||||||
|
|
||||||
|
- The option legend.margin can now specify horizontal and vertical
|
||||||
|
margins independently (suggestion by someone who's annoyed).
|
||||||
|
|
||||||
|
- Data passed into Flot is now copied to a new canonical format to
|
||||||
|
enable further processing before it hits the drawing routines. As a
|
||||||
|
side-effect, this should make Flot more robust in the face of bad
|
||||||
|
data (and fixes issue 112).
|
||||||
|
|
||||||
|
- Step-wise charting: line charts have a new option "steps" that when
|
||||||
|
set to true connects the points with horizontal/vertical steps
|
||||||
|
instead of diagonal lines.
|
||||||
|
|
||||||
|
- The legend labelFormatter now passes the series in addition to just
|
||||||
|
the label (suggestion by Vincent Lemeltier).
|
||||||
|
|
||||||
|
- Horizontal bars (based on patch by Jason LeBrun).
|
||||||
|
|
||||||
|
- Support for partial bars by specifying a third coordinate, i.e. they
|
||||||
|
don't have to start from the axis. This can be used to make stacked
|
||||||
|
bars.
|
||||||
|
|
||||||
|
- New option to disable the (grid.show).
|
||||||
|
|
||||||
|
- Added pointOffset method for converting a point in data space to an
|
||||||
|
offset within the placeholder.
|
||||||
|
|
||||||
|
- Plugin system: register an init method in the $.flot.plugins array
|
||||||
|
to get started, see PLUGINS.txt for details on how to write plugins
|
||||||
|
(it's easy). There are also some extra methods to enable access to
|
||||||
|
internal state.
|
||||||
|
|
||||||
|
- Hooks: you can register functions that are called while Flot is
|
||||||
|
crunching the data and doing the plot. This can be used to modify
|
||||||
|
Flot without changing the source, useful for writing plugins. Some
|
||||||
|
hooks are defined, more are likely to come.
|
||||||
|
|
||||||
|
- Threshold plugin: you can set a threshold and a color, and the data
|
||||||
|
points below that threshold will then get the color. Useful for
|
||||||
|
marking data below 0, for instance.
|
||||||
|
|
||||||
|
- Stack plugin: you can specify a stack key for each series to have
|
||||||
|
them summed. This is useful for drawing additive/cumulative graphs
|
||||||
|
with bars and (currently unfilled) lines.
|
||||||
|
|
||||||
|
- Crosshairs plugin: trace the mouse position on the axes, enable with
|
||||||
|
crosshair: { mode: "x"} (see the new tracking example for a use).
|
||||||
|
|
||||||
|
- Image plugin: plot prerendered images.
|
||||||
|
|
||||||
|
- Navigation plugin for panning and zooming a plot.
|
||||||
|
|
||||||
|
- More configurable grid.
|
||||||
|
|
||||||
|
- Axis transformation support, useful for non-linear plots, e.g. log
|
||||||
|
axes and compressed time axes (like omitting weekends).
|
||||||
|
|
||||||
|
- Support for twelve-hour date formatting (patch by Forrest Aldridge).
|
||||||
|
|
||||||
|
- The color parsing code in Flot has been cleaned up and split out so
|
||||||
|
it's now available as a separate jQuery plugin. It's included inline
|
||||||
|
in the Flot source to make dependency managing easier. This also
|
||||||
|
makes it really easy to use the color helpers in Flot plugins.
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
- Fixed two corner-case bugs when drawing filled curves (report and
|
||||||
|
analysis by Joshua Varner).
|
||||||
|
- Fix auto-adjustment code when setting min to 0 for an axis where the
|
||||||
|
dataset is completely flat on that axis (report by chovy).
|
||||||
|
- Fixed a bug with passing in data from getData to setData when the
|
||||||
|
secondary axes are used (issue 65, reported by nperelman).
|
||||||
|
- Fixed so that it is possible to turn lines off when no other chart
|
||||||
|
type is shown (based on problem reported by Glenn Vanderburg), and
|
||||||
|
fixed so that setting lineWidth to 0 also hides the shadow (based on
|
||||||
|
problem reported by Sergio Nunes).
|
||||||
|
- Updated mousemove position expression to the latest from jQuery (bug
|
||||||
|
reported by meyuchas).
|
||||||
|
- Use CSS borders instead of background in legend (fix printing issue 25
|
||||||
|
and 45).
|
||||||
|
- Explicitly convert axis min/max to numbers.
|
||||||
|
- Fixed a bug with drawing marking lines with different colors
|
||||||
|
(reported by Khurram).
|
||||||
|
- Fixed a bug with returning y2 values in the selection event (fix
|
||||||
|
by exists, issue 75).
|
||||||
|
- Only set position relative on placeholder if it hasn't already a
|
||||||
|
position different from static (reported by kyberneticist, issue 95).
|
||||||
|
- Don't round markings to prevent sub-pixel problems (reported by Dan
|
||||||
|
Lipsitt).
|
||||||
|
- Make the grid border act similarly to a regular CSS border, i.e.
|
||||||
|
prevent it from overlapping the plot itself. This also fixes a
|
||||||
|
problem with anti-aliasing when the width is 1 pixel (reported by
|
||||||
|
Anthony Ettinger).
|
||||||
|
- Imported version 3 of excanvas and fixed two issues with the newer
|
||||||
|
version. Hopefully, this will make Flot work with IE8 (nudge by
|
||||||
|
Fabien Menager, further analysis by Booink, issue 133).
|
||||||
|
- Changed the shadow code for lines to hopefully look a bit better
|
||||||
|
with vertical lines.
|
||||||
|
- Round tick positions to avoid possible problems with fractions
|
||||||
|
(suggestion by Fred, issue 130).
|
||||||
|
- Made the heuristic for determining how many ticks to aim for a bit
|
||||||
|
smarter.
|
||||||
|
- Fix for uneven axis margins (report and patch by Paul Kienzle) and
|
||||||
|
snapping to ticks (concurrent report and patch by lifthrasiir).
|
||||||
|
- Fixed bug with slicing in findNearbyItems (patch by zollman).
|
||||||
|
- Make heuristic for x axis label widths more dynamic (patch by
|
||||||
|
rickinhethuis).
|
||||||
|
- Make sure points on top take precedence when finding nearby points
|
||||||
|
when hovering (reported by didroe, issue 224).
|
||||||
|
|
||||||
|
Flot 0.5
|
||||||
|
--------
|
||||||
|
|
||||||
|
Backwards API change summary: Timestamps are now in UTC. Also
|
||||||
|
"selected" event -> becomes "plotselected" with new data, the
|
||||||
|
parameters for setSelection are now different (but backwards
|
||||||
|
compatibility hooks are in place), coloredAreas becomes markings with
|
||||||
|
a new interface (but backwards compatibility hooks are in place).
|
||||||
|
|
||||||
|
|
||||||
|
Interactivity: added a new "plothover" event and this and the
|
||||||
|
"plotclick" event now returns the closest data item (based on patch by
|
||||||
|
/david, patch by Mark Byers for bar support). See the revamped
|
||||||
|
"interacting with the data" example for some hints on what you can do.
|
||||||
|
|
||||||
|
Highlighting: you can now highlight points and datapoints are
|
||||||
|
autohighlighted when you hover over them (if hovering is turned on).
|
||||||
|
|
||||||
|
Support for dual axis has been added (based on patch by someone who's
|
||||||
|
annoyed and /david). For each data series you can specify which axes
|
||||||
|
it belongs to, and there are two more axes, x2axis and y2axis, to
|
||||||
|
customize. This affects the "selected" event which has been renamed to
|
||||||
|
"plotselected" and spews out { xaxis: { from: -10, to: 20 } ... },
|
||||||
|
setSelection in which the parameters are on a new form (backwards
|
||||||
|
compatible hooks are in place so old code shouldn't break) and
|
||||||
|
markings (formerly coloredAreas).
|
||||||
|
|
||||||
|
Timestamps in time mode are now displayed according to
|
||||||
|
UTC instead of the time zone of the visitor. This affects the way the
|
||||||
|
timestamps should be input; you'll probably have to offset the
|
||||||
|
timestamps according to your local time zone. It also affects any
|
||||||
|
custom date handling code (which basically now should use the
|
||||||
|
equivalent UTC date mehods, e.g. .setUTCMonth() instead of
|
||||||
|
.setMonth().
|
||||||
|
|
||||||
|
Added support for specifying the size of tick labels (axis.labelWidth,
|
||||||
|
axis.labelHeight). Useful for specifying a max label size to keep
|
||||||
|
multiple plots aligned.
|
||||||
|
|
||||||
|
Markings, previously coloredAreas, are now specified as ranges on the
|
||||||
|
axes, like { xaxis: { from: 0, to: 10 }}. Furthermore with markings
|
||||||
|
you can now draw horizontal/vertical lines by setting from and to to
|
||||||
|
the same coordinate (idea from line support patch by by Ryan Funduk).
|
||||||
|
|
||||||
|
The "fill" option can now be a number that specifies the opacity of
|
||||||
|
the fill.
|
||||||
|
|
||||||
|
You can now specify a coordinate as null (like [2, null]) and Flot
|
||||||
|
will take the other coordinate into account when scaling the axes
|
||||||
|
(based on patch by joebno).
|
||||||
|
|
||||||
|
New option for bars "align". Set it to "center" to center the bars on
|
||||||
|
the value they represent.
|
||||||
|
|
||||||
|
setSelection now takes a second parameter which you can use to prevent
|
||||||
|
the method from firing the "plotselected" handler.
|
||||||
|
|
||||||
|
Using the "container" option in legend now overwrites the container
|
||||||
|
element instead of just appending to it (fixes infinite legend bug,
|
||||||
|
reported by several people, fix by Brad Dewey).
|
||||||
|
|
||||||
|
Fixed a bug in calculating spacing around the plot (reported by
|
||||||
|
timothytoe). Fixed a bug in finding max values for all-negative data
|
||||||
|
sets. Prevent the possibility of eternal looping in tick calculations.
|
||||||
|
Fixed a bug when borderWidth is set to 0 (reported by
|
||||||
|
Rob/sanchothefat). Fixed a bug with drawing bars extending below 0
|
||||||
|
(reported by James Hewitt, patch by Ryan Funduk). Fixed a
|
||||||
|
bug with line widths of bars (reported by MikeM). Fixed a bug with
|
||||||
|
'nw' and 'sw' legend positions. Improved the handling of axis
|
||||||
|
auto-scaling with bars. Fixed a bug with multi-line x-axis tick
|
||||||
|
labels (reported by Luca Ciano). IE-fix help by Savage Zhang.
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.4
|
||||||
|
--------
|
||||||
|
|
||||||
|
API changes: deprecated axis.noTicks in favor of just specifying the
|
||||||
|
number as axis.ticks. So "xaxis: { noTicks: 10 }" becomes
|
||||||
|
"xaxis: { ticks: 10 }"
|
||||||
|
|
||||||
|
Time series support. Specify axis.mode: "time", put in Javascript
|
||||||
|
timestamps as data, and Flot will automatically spit out sensible
|
||||||
|
ticks. Take a look at the two new examples. The format can be
|
||||||
|
customized with axis.timeformat and axis.monthNames, or if that fails
|
||||||
|
with axis.tickFormatter.
|
||||||
|
|
||||||
|
Support for colored background areas via grid.coloredAreas. Specify an
|
||||||
|
array of { x1, y1, x2, y2 } objects or a function that returns these
|
||||||
|
given { xmin, xmax, ymin, ymax }.
|
||||||
|
|
||||||
|
More members on the plot object (report by Chris Davies and others).
|
||||||
|
"getData" for inspecting the assigned settings on data series (e.g.
|
||||||
|
color) and "setData", "setupGrid" and "draw" for updating the contents
|
||||||
|
without a total replot.
|
||||||
|
|
||||||
|
The default number of ticks to aim for is now dependent on the size of
|
||||||
|
the plot in pixels. Support for customizing tick interval sizes
|
||||||
|
directly with axis.minTickSize and axis.tickSize.
|
||||||
|
|
||||||
|
Cleaned up the automatic axis scaling algorithm and fixed how it
|
||||||
|
interacts with ticks. Also fixed a couple of tick-related corner case
|
||||||
|
bugs (one reported by mainstreetmark, another reported by timothytoe).
|
||||||
|
|
||||||
|
The option axis.tickFormatter now takes a function with two
|
||||||
|
parameters, the second parameter is an optional object with
|
||||||
|
information about the axis. It has min, max, tickDecimals, tickSize.
|
||||||
|
|
||||||
|
Added support for segmented lines (based on patch from Michael
|
||||||
|
MacDonald) and for ignoring null and bad values (suggestion from Nick
|
||||||
|
Konidaris and joshwaihi).
|
||||||
|
|
||||||
|
Added support for changing the border width (joebno and safoo).
|
||||||
|
Label colors can be changed via CSS by selecting the tickLabel class.
|
||||||
|
|
||||||
|
Fixed a bug in handling single-item bar series (reported by Emil
|
||||||
|
Filipov). Fixed erratic behaviour when interacting with the plot
|
||||||
|
with IE 7 (reported by Lau Bech Lauritzen). Prevent IE/Safari text
|
||||||
|
selection when selecting stuff on the canvas.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.3
|
||||||
|
--------
|
||||||
|
|
||||||
|
This is mostly a quick-fix release because jquery.js wasn't included
|
||||||
|
in the previous zip/tarball.
|
||||||
|
|
||||||
|
Support clicking on the plot. Turn it on with grid: { clickable: true },
|
||||||
|
then you get a "plotclick" event on the graph placeholder with the
|
||||||
|
position in units of the plot.
|
||||||
|
|
||||||
|
Fixed a bug in dealing with data where min = max, thanks to Michael
|
||||||
|
Messinides.
|
||||||
|
|
||||||
|
Include jquery.js in the zip/tarball.
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.2
|
||||||
|
--------
|
||||||
|
|
||||||
|
Added support for putting a background behind the default legend. The
|
||||||
|
default is the partly transparent background color. Added
|
||||||
|
backgroundColor and backgroundOpacity to the legend options to control
|
||||||
|
this.
|
||||||
|
|
||||||
|
The ticks options can now be a callback function that takes one
|
||||||
|
parameter, an object with the attributes min and max. The function
|
||||||
|
should return a ticks array.
|
||||||
|
|
||||||
|
Added labelFormatter option in legend, useful for turning the legend
|
||||||
|
labels into links.
|
||||||
|
|
||||||
|
Fixed a couple of bugs.
|
||||||
|
|
||||||
|
The API should now be fully documented.
|
||||||
|
|
||||||
|
Patch from Guy Fraser to make parts of the code smaller.
|
||||||
|
|
||||||
|
API changes: Moved labelMargin option to grid from x/yaxis.
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.1
|
||||||
|
--------
|
||||||
|
|
||||||
|
First public release.
|
137
src/sunstone/public/vendor/flot/PLUGINS.txt
vendored
Normal file
137
src/sunstone/public/vendor/flot/PLUGINS.txt
vendored
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
Writing plugins
|
||||||
|
---------------
|
||||||
|
|
||||||
|
All you need to do to make a new plugin is creating an init function
|
||||||
|
and a set of options (if needed), stuffing it into an object and
|
||||||
|
putting it in the $.plot.plugins array. For example:
|
||||||
|
|
||||||
|
function myCoolPluginInit(plot) {
|
||||||
|
plot.coolstring = "Hello!";
|
||||||
|
};
|
||||||
|
|
||||||
|
$.plot.plugins.push({ init: myCoolPluginInit, options: { ... } });
|
||||||
|
|
||||||
|
// if $.plot is called, it will return a plot object with the
|
||||||
|
// attribute "coolstring"
|
||||||
|
|
||||||
|
Now, given that the plugin might run in many different places, it's
|
||||||
|
a good idea to avoid leaking names. The usual trick here is wrap the
|
||||||
|
above lines in an anonymous function which is called immediately, like
|
||||||
|
this: (function () { inner code ... })(). To make it even more robust
|
||||||
|
in case $ is not bound to jQuery but some other Javascript library, we
|
||||||
|
can write it as
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
// plugin definition
|
||||||
|
// ...
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
There's a complete example below, but you should also check out the
|
||||||
|
plugins bundled with Flot.
|
||||||
|
|
||||||
|
|
||||||
|
Complete example
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Here is a simple debug plugin which alerts each of the series in the
|
||||||
|
plot. It has a single option that control whether it is enabled and
|
||||||
|
how much info to output:
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
function init(plot) {
|
||||||
|
var debugLevel = 1;
|
||||||
|
|
||||||
|
function checkDebugEnabled(plot, options) {
|
||||||
|
if (options.debug) {
|
||||||
|
debugLevel = options.debug;
|
||||||
|
|
||||||
|
plot.hooks.processDatapoints.push(alertSeries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function alertSeries(plot, series, datapoints) {
|
||||||
|
var msg = "series " + series.label;
|
||||||
|
if (debugLevel > 1)
|
||||||
|
msg += " with " + series.data.length + " points";
|
||||||
|
alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.processOptions.push(checkDebugEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = { debug: 0 };
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: "simpledebug",
|
||||||
|
version: "0.1"
|
||||||
|
});
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
We also define "name" and "version". It's not used by Flot, but might
|
||||||
|
be helpful for other plugins in resolving dependencies.
|
||||||
|
|
||||||
|
Put the above in a file named "jquery.flot.debug.js", include it in an
|
||||||
|
HTML page and then it can be used with:
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [...], { debug: 2 });
|
||||||
|
|
||||||
|
This simple plugin illustrates a couple of points:
|
||||||
|
|
||||||
|
- It uses the anonymous function trick to avoid name pollution.
|
||||||
|
- It can be enabled/disabled through an option.
|
||||||
|
- Variables in the init function can be used to store plot-specific
|
||||||
|
state between the hooks.
|
||||||
|
|
||||||
|
The two last points are important because there may be multiple plots
|
||||||
|
on the same page, and you'd want to make sure they are not mixed up.
|
||||||
|
|
||||||
|
|
||||||
|
Shutting down a plugin
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Each plot object has a shutdown hook which is run when plot.shutdown()
|
||||||
|
is called. This usually mostly happens in case another plot is made on
|
||||||
|
top of an existing one.
|
||||||
|
|
||||||
|
The purpose of the hook is to give you a chance to unbind any event
|
||||||
|
handlers you've registered and remove any extra DOM things you've
|
||||||
|
inserted.
|
||||||
|
|
||||||
|
The problem with event handlers is that you can have registered a
|
||||||
|
handler which is run in some point in the future, e.g. with
|
||||||
|
setTimeout(). Meanwhile, the plot may have been shutdown and removed,
|
||||||
|
but because your event handler is still referencing it, it can't be
|
||||||
|
garbage collected yet, and worse, if your handler eventually runs, it
|
||||||
|
may overwrite stuff on a completely different plot.
|
||||||
|
|
||||||
|
|
||||||
|
Some hints on the options
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Plugins should always support appropriate options to enable/disable
|
||||||
|
them because the plugin user may have several plots on the same page
|
||||||
|
where only one should use the plugin. In most cases it's probably a
|
||||||
|
good idea if the plugin is turned off rather than on per default, just
|
||||||
|
like most of the powerful features in Flot.
|
||||||
|
|
||||||
|
If the plugin needs options that are specific to each series, like the
|
||||||
|
points or lines options in core Flot, you can put them in "series" in
|
||||||
|
the options object, e.g.
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
series: {
|
||||||
|
downsample: {
|
||||||
|
algorithm: null,
|
||||||
|
maxpoints: 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Then they will be copied by Flot into each series, providing default
|
||||||
|
values in case none are specified.
|
||||||
|
|
||||||
|
Think hard and long about naming the options. These names are going to
|
||||||
|
be public API, and code is going to depend on them if the plugin is
|
||||||
|
successful.
|
90
src/sunstone/public/vendor/flot/README.txt
vendored
Normal file
90
src/sunstone/public/vendor/flot/README.txt
vendored
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
About
|
||||||
|
-----
|
||||||
|
|
||||||
|
Flot is a Javascript plotting library for jQuery. Read more at the
|
||||||
|
website:
|
||||||
|
|
||||||
|
http://code.google.com/p/flot/
|
||||||
|
|
||||||
|
Take a look at the examples linked from above, they should give a good
|
||||||
|
impression of what Flot can do and the source code of the examples is
|
||||||
|
probably the fastest way to learn how to use Flot.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
Just include the Javascript file after you've included jQuery.
|
||||||
|
|
||||||
|
Generally, all browsers that support the HTML5 canvas tag are
|
||||||
|
supported.
|
||||||
|
|
||||||
|
For support for Internet Explorer < 9, you can use Excanvas, a canvas
|
||||||
|
emulator; this is used in the examples bundled with Flot. You just
|
||||||
|
include the excanvas script like this:
|
||||||
|
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]-->
|
||||||
|
|
||||||
|
If it's not working on your development IE 6.0, check that it has
|
||||||
|
support for VML which Excanvas is relying on. It appears that some
|
||||||
|
stripped down versions used for test environments on virtual machines
|
||||||
|
lack the VML support.
|
||||||
|
|
||||||
|
You can also try using Flashcanvas (see
|
||||||
|
http://code.google.com/p/flashcanvas/), which uses Flash to do the
|
||||||
|
emulation. Although Flash can be a bit slower to load than VML, if
|
||||||
|
you've got a lot of points, the Flash version can be much faster
|
||||||
|
overall. Flot contains some wrapper code for activating Excanvas which
|
||||||
|
Flashcanvas is compatible with.
|
||||||
|
|
||||||
|
You need at least jQuery 1.2.6, but try at least 1.3.2 for interactive
|
||||||
|
charts because of performance improvements in event handling.
|
||||||
|
|
||||||
|
|
||||||
|
Basic usage
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Create a placeholder div to put the graph in:
|
||||||
|
|
||||||
|
<div id="placeholder"></div>
|
||||||
|
|
||||||
|
You need to set the width and height of this div, otherwise the plot
|
||||||
|
library doesn't know how to scale the graph. You can do it inline like
|
||||||
|
this:
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||||
|
|
||||||
|
You can also do it with an external stylesheet. Make sure that the
|
||||||
|
placeholder isn't within something with a display:none CSS property -
|
||||||
|
in that case, Flot has trouble measuring label dimensions which
|
||||||
|
results in garbled looks and might have trouble measuring the
|
||||||
|
placeholder dimensions which is fatal (it'll throw an exception).
|
||||||
|
|
||||||
|
Then when the div is ready in the DOM, which is usually on document
|
||||||
|
ready, run the plot function:
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), data, options);
|
||||||
|
|
||||||
|
Here, data is an array of data series and options is an object with
|
||||||
|
settings if you want to customize the plot. Take a look at the
|
||||||
|
examples for some ideas of what to put in or look at the reference
|
||||||
|
in the file "API.txt". Here's a quick example that'll draw a line from
|
||||||
|
(0, 0) to (1, 1):
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } });
|
||||||
|
|
||||||
|
The plot function immediately draws the chart and then returns a plot
|
||||||
|
object with a couple of methods.
|
||||||
|
|
||||||
|
|
||||||
|
What's with the name?
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
First: it's pronounced with a short o, like "plot". Not like "flawed".
|
||||||
|
|
||||||
|
So "Flot" rhymes with "plot".
|
||||||
|
|
||||||
|
And if you look up "flot" in a Danish-to-English dictionary, some up
|
||||||
|
the words that come up are "good-looking", "attractive", "stylish",
|
||||||
|
"smart", "impressive", "extravagant". One of the main goals with Flot
|
||||||
|
is pretty looks.
|
143
src/sunstone/public/vendor/flot/examples/ajax.html
vendored
Normal file
143
src/sunstone/public/vendor/flot/examples/ajax.html
vendored
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>Example of loading data dynamically with AJAX. Percentage change in GDP (source: <a href="http://epp.eurostat.ec.europa.eu/tgm/table.do?tab=table&init=1&plugin=1&language=en&pcode=tsieb020">Eurostat</a>). Click the buttons below.</p>
|
||||||
|
|
||||||
|
<p>The data is fetched over HTTP, in this case directly from text
|
||||||
|
files. Usually the URL would point to some web server handler
|
||||||
|
(e.g. a PHP page or Java/.NET/Python/Ruby on Rails handler) that
|
||||||
|
extracts it from a database and serializes it to JSON.</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input class="fetchSeries" type="button" value="First dataset"> -
|
||||||
|
<a href="data-eu-gdp-growth.json">data</a> -
|
||||||
|
<span></span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input class="fetchSeries" type="button" value="Second dataset"> -
|
||||||
|
<a href="data-japan-gdp-growth.json">data</a> -
|
||||||
|
<span></span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input class="fetchSeries" type="button" value="Third dataset"> -
|
||||||
|
<a href="data-usa-gdp-growth.json">data</a> -
|
||||||
|
<span></span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>If you combine AJAX with setTimeout, you can poll the server
|
||||||
|
for new data.</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input class="dataUpdate" type="button" value="Poll for data">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var options = {
|
||||||
|
lines: { show: true },
|
||||||
|
points: { show: true },
|
||||||
|
xaxis: { tickDecimals: 0, tickSize: 1 }
|
||||||
|
};
|
||||||
|
var data = [];
|
||||||
|
var placeholder = $("#placeholder");
|
||||||
|
|
||||||
|
$.plot(placeholder, data, options);
|
||||||
|
|
||||||
|
|
||||||
|
// fetch one series, adding to what we got
|
||||||
|
var alreadyFetched = {};
|
||||||
|
|
||||||
|
$("input.fetchSeries").click(function () {
|
||||||
|
var button = $(this);
|
||||||
|
|
||||||
|
// find the URL in the link right next to us
|
||||||
|
var dataurl = button.siblings('a').attr('href');
|
||||||
|
|
||||||
|
// then fetch the data with jQuery
|
||||||
|
function onDataReceived(series) {
|
||||||
|
// extract the first coordinate pair so you can see that
|
||||||
|
// data is now an ordinary Javascript object
|
||||||
|
var firstcoordinate = '(' + series.data[0][0] + ', ' + series.data[0][1] + ')';
|
||||||
|
|
||||||
|
button.siblings('span').text('Fetched ' + series.label + ', first point: ' + firstcoordinate);
|
||||||
|
|
||||||
|
// let's add it to our current data
|
||||||
|
if (!alreadyFetched[series.label]) {
|
||||||
|
alreadyFetched[series.label] = true;
|
||||||
|
data.push(series);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and plot all we got
|
||||||
|
$.plot(placeholder, data, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: dataurl,
|
||||||
|
method: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
success: onDataReceived
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// initiate a recurring data update
|
||||||
|
$("input.dataUpdate").click(function () {
|
||||||
|
// reset data
|
||||||
|
data = [];
|
||||||
|
alreadyFetched = {};
|
||||||
|
|
||||||
|
$.plot(placeholder, data, options);
|
||||||
|
|
||||||
|
var iteration = 0;
|
||||||
|
|
||||||
|
function fetchData() {
|
||||||
|
++iteration;
|
||||||
|
|
||||||
|
function onDataReceived(series) {
|
||||||
|
// we get all the data in one go, if we only got partial
|
||||||
|
// data, we could merge it with what we already got
|
||||||
|
data = [ series ];
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), data, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
// usually, we'll just call the same URL, a script
|
||||||
|
// connected to a database, but in this case we only
|
||||||
|
// have static example files so we need to modify the
|
||||||
|
// URL
|
||||||
|
url: "data-eu-gdp-growth-" + iteration + ".json",
|
||||||
|
method: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
success: onDataReceived
|
||||||
|
});
|
||||||
|
|
||||||
|
if (iteration < 5)
|
||||||
|
setTimeout(fetchData, 1000);
|
||||||
|
else {
|
||||||
|
data = [];
|
||||||
|
alreadyFetched = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(fetchData, 1000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
75
src/sunstone/public/vendor/flot/examples/annotating.html
vendored
Normal file
75
src/sunstone/public/vendor/flot/examples/annotating.html
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>Flot has support for simple background decorations such as
|
||||||
|
lines and rectangles. They can be useful for marking up certain
|
||||||
|
areas. You can easily add any HTML you need with standard DOM
|
||||||
|
manipulation, e.g. for labels. For drawing custom shapes there is
|
||||||
|
also direct access to the canvas.</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
// generate a dataset
|
||||||
|
var d1 = [];
|
||||||
|
for (var i = 0; i < 20; ++i)
|
||||||
|
d1.push([i, Math.sin(i)]);
|
||||||
|
|
||||||
|
var data = [{ data: d1, label: "Pressure", color: "#333" }];
|
||||||
|
|
||||||
|
// setup background areas
|
||||||
|
var markings = [
|
||||||
|
{ color: '#f6f6f6', yaxis: { from: 1 } },
|
||||||
|
{ color: '#f6f6f6', yaxis: { to: -1 } },
|
||||||
|
{ color: '#000', lineWidth: 1, xaxis: { from: 2, to: 2 } },
|
||||||
|
{ color: '#000', lineWidth: 1, xaxis: { from: 8, to: 8 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
var placeholder = $("#placeholder");
|
||||||
|
|
||||||
|
// plot it
|
||||||
|
var plot = $.plot(placeholder, data, {
|
||||||
|
bars: { show: true, barWidth: 0.5, fill: 0.9 },
|
||||||
|
xaxis: { ticks: [], autoscaleMargin: 0.02 },
|
||||||
|
yaxis: { min: -2, max: 2 },
|
||||||
|
grid: { markings: markings }
|
||||||
|
});
|
||||||
|
|
||||||
|
// add labels
|
||||||
|
var o;
|
||||||
|
|
||||||
|
o = plot.pointOffset({ x: 2, y: -1.2});
|
||||||
|
// we just append it to the placeholder which Flot already uses
|
||||||
|
// for positioning
|
||||||
|
placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Warming up</div>');
|
||||||
|
|
||||||
|
o = plot.pointOffset({ x: 8, y: -1.2});
|
||||||
|
placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Actual measurements</div>');
|
||||||
|
|
||||||
|
// draw a little arrow on top of the last label to demonstrate
|
||||||
|
// canvas drawing
|
||||||
|
var ctx = plot.getCanvas().getContext("2d");
|
||||||
|
ctx.beginPath();
|
||||||
|
o.left += 4;
|
||||||
|
ctx.moveTo(o.left, o.top);
|
||||||
|
ctx.lineTo(o.left, o.top - 10);
|
||||||
|
ctx.lineTo(o.left + 10, o.top - 5);
|
||||||
|
ctx.lineTo(o.left, o.top);
|
||||||
|
ctx.fillStyle = "#000";
|
||||||
|
ctx.fill();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
src/sunstone/public/vendor/flot/examples/arrow-down.gif
vendored
Normal file
BIN
src/sunstone/public/vendor/flot/examples/arrow-down.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 916 B |
BIN
src/sunstone/public/vendor/flot/examples/arrow-left.gif
vendored
Normal file
BIN
src/sunstone/public/vendor/flot/examples/arrow-left.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 891 B |
BIN
src/sunstone/public/vendor/flot/examples/arrow-right.gif
vendored
Normal file
BIN
src/sunstone/public/vendor/flot/examples/arrow-right.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 897 B |
BIN
src/sunstone/public/vendor/flot/examples/arrow-up.gif
vendored
Normal file
BIN
src/sunstone/public/vendor/flot/examples/arrow-up.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 916 B |
38
src/sunstone/public/vendor/flot/examples/basic.html
vendored
Normal file
38
src/sunstone/public/vendor/flot/examples/basic.html
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>Simple example. You don't need to specify much to get an
|
||||||
|
attractive look. Put in a placeholder, make sure you set its
|
||||||
|
dimensions (otherwise the plot library will barf) and call the
|
||||||
|
plot function with the data. The axes are automatically
|
||||||
|
scaled.</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var d1 = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.5)
|
||||||
|
d1.push([i, Math.sin(i)]);
|
||||||
|
|
||||||
|
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
|
||||||
|
|
||||||
|
// a null signifies separate line segments
|
||||||
|
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [ d1, d2, d3 ]);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-1.json
vendored
Normal file
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-1.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"label": "Europe (EU27)",
|
||||||
|
"data": [[1999, 3.0], [2000, 3.9]]
|
||||||
|
}
|
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-2.json
vendored
Normal file
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-2.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"label": "Europe (EU27)",
|
||||||
|
"data": [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2]]
|
||||||
|
}
|
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-3.json
vendored
Normal file
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-3.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"label": "Europe (EU27)",
|
||||||
|
"data": [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5]]
|
||||||
|
}
|
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-4.json
vendored
Normal file
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-4.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"label": "Europe (EU27)",
|
||||||
|
"data": [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1]]
|
||||||
|
}
|
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-5.json
vendored
Normal file
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth-5.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"label": "Europe (EU27)",
|
||||||
|
"data": [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1], [2007, 2.9], [2008, 0.9]]
|
||||||
|
}
|
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth.json
vendored
Normal file
4
src/sunstone/public/vendor/flot/examples/data-eu-gdp-growth.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"label": "Europe (EU27)",
|
||||||
|
"data": [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1], [2007, 2.9], [2008, 0.9]]
|
||||||
|
}
|
4
src/sunstone/public/vendor/flot/examples/data-japan-gdp-growth.json
vendored
Normal file
4
src/sunstone/public/vendor/flot/examples/data-japan-gdp-growth.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"label": "Japan",
|
||||||
|
"data": [[1999, -0.1], [2000, 2.9], [2001, 0.2], [2002, 0.3], [2003, 1.4], [2004, 2.7], [2005, 1.9], [2006, 2.0], [2007, 2.3], [2008, -0.7]]
|
||||||
|
}
|
4
src/sunstone/public/vendor/flot/examples/data-usa-gdp-growth.json
vendored
Normal file
4
src/sunstone/public/vendor/flot/examples/data-usa-gdp-growth.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"label": "USA",
|
||||||
|
"data": [[1999, 4.4], [2000, 3.7], [2001, 0.8], [2002, 1.6], [2003, 2.5], [2004, 3.6], [2005, 2.9], [2006, 2.8], [2007, 2.0], [2008, 1.1]]
|
||||||
|
}
|
75
src/sunstone/public/vendor/flot/examples/graph-types.html
vendored
Normal file
75
src/sunstone/public/vendor/flot/examples/graph-types.html
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||||
|
|
||||||
|
<p>Flot supports lines, points, filled areas, bars and any
|
||||||
|
combinations of these, in the same plot and even on the same data
|
||||||
|
series.</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var d1 = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.5)
|
||||||
|
d1.push([i, Math.sin(i)]);
|
||||||
|
|
||||||
|
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
|
||||||
|
|
||||||
|
var d3 = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.5)
|
||||||
|
d3.push([i, Math.cos(i)]);
|
||||||
|
|
||||||
|
var d4 = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.1)
|
||||||
|
d4.push([i, Math.sqrt(i * 10)]);
|
||||||
|
|
||||||
|
var d5 = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.5)
|
||||||
|
d5.push([i, Math.sqrt(i)]);
|
||||||
|
|
||||||
|
var d6 = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.5 + Math.random())
|
||||||
|
d6.push([i, Math.sqrt(2*i + Math.sin(i) + 5)]);
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [
|
||||||
|
{
|
||||||
|
data: d1,
|
||||||
|
lines: { show: true, fill: true }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: d2,
|
||||||
|
bars: { show: true }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: d3,
|
||||||
|
points: { show: true }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: d4,
|
||||||
|
lines: { show: true }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: d5,
|
||||||
|
lines: { show: true },
|
||||||
|
points: { show: true }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: d6,
|
||||||
|
lines: { show: true, steps: true }
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
src/sunstone/public/vendor/flot/examples/hs-2004-27-a-large_web.jpg
vendored
Normal file
BIN
src/sunstone/public/vendor/flot/examples/hs-2004-27-a-large_web.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
45
src/sunstone/public/vendor/flot/examples/image.html
vendored
Normal file
45
src/sunstone/public/vendor/flot/examples/image.html
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.image.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:400px;height:400px;"></div>
|
||||||
|
|
||||||
|
<p>The Cat's Eye Nebula (<a href="http://hubblesite.org/gallery/album/nebula/pr2004027a/">picture from Hubble</a>).</p>
|
||||||
|
|
||||||
|
<p>With the image plugin, you can plot images. This is for example
|
||||||
|
useful for getting ticks on complex prerendered visualizations.
|
||||||
|
Instead of inputting data points, you put in the images and where
|
||||||
|
their two opposite corners are supposed to be in plot space.</p>
|
||||||
|
|
||||||
|
<p>Images represent a little further complication because you need
|
||||||
|
to make sure they are loaded before you can use them (Flot skips
|
||||||
|
incomplete images). The plugin comes with a couple of helpers
|
||||||
|
for doing that.</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var data = [ [ ["hs-2004-27-a-large_web.jpg", -10, -10, 10, 10] ] ];
|
||||||
|
var options = {
|
||||||
|
series: { images: { show: true } },
|
||||||
|
xaxis: { min: -8, max: 4 },
|
||||||
|
yaxis: { min: -8, max: 4 }
|
||||||
|
};
|
||||||
|
|
||||||
|
$.plot.image.loadDataImages(data, options, function () {
|
||||||
|
$.plot($("#placeholder"), data, options);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
44
src/sunstone/public/vendor/flot/examples/index.html
vendored
Normal file
44
src/sunstone/public/vendor/flot/examples/index.html
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<p>Here are some examples for <a href="http://code.google.com/p/flot/">Flot</a>, the Javascript charting library for jQuery:</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a href="basic.html">Basic example</a></li>
|
||||||
|
<li><a href="graph-types.html">Different graph types</a></li>
|
||||||
|
<li><a href="setting-options.html">Setting various options</a> and <a href="annotating.html">annotating a chart</a></li>
|
||||||
|
<li><a href="ajax.html">Updating graphs with AJAX</a> and <a href="realtime.html">real-time updates</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>Being interactive:</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a href="turning-series.html">Turning series on/off</a></li>
|
||||||
|
<li><a href="selection.html">Rectangular selection support and zooming</a> and <a href="zooming.html">zooming with overview</a> (both with selection plugin)</li>
|
||||||
|
<li><a href="interacting.html">Interacting with the data points</a></li>
|
||||||
|
<li><a href="navigate.html">Panning and zooming</a> (with navigation plugin)</li>
|
||||||
|
<li><a href="resize.html">Automatically redraw when window is resized</a> (with resize plugin)</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>Various features:</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a href="symbols.html">Using other symbols than circles for points</a> (with symbol plugin)</li>
|
||||||
|
<li><a href="time.html">Plotting time series</a> and <a href="visitors.html">visitors per day with zooming and weekends</a> (with selection plugin)</li>
|
||||||
|
<li><a href="multiple-axes.html">Multiple axes</a> and <a href="interacting-axes.html">interacting with the axes</a></li>
|
||||||
|
<li><a href="thresholding.html">Thresholding the data</a> (with threshold plugin)</li>
|
||||||
|
<li><a href="stacking.html">Stacked charts</a> (with stacking plugin)</li>
|
||||||
|
<li><a href="percentiles.html">Using filled areas to plot percentiles</a> (with fillbetween plugin)</li>
|
||||||
|
<li><a href="tracking.html">Tracking curves with crosshair</a> (with crosshair plugin)</li>
|
||||||
|
<li><a href="image.html">Plotting prerendered images</a> (with image plugin)</li>
|
||||||
|
<li><a href="pie.html">Pie charts</a> (with pie plugin)</li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
97
src/sunstone/public/vendor/flot/examples/interacting-axes.html
vendored
Normal file
97
src/sunstone/public/vendor/flot/examples/interacting-axes.html
vendored
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>With multiple axes, you sometimes need to interact with them. A
|
||||||
|
simple way to do this is to draw the plot, deduce the axis
|
||||||
|
placements and insert a couple of divs on top to catch events.
|
||||||
|
Try clicking an axis.</p>
|
||||||
|
|
||||||
|
<p id="click"></p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
function generate(start, end, fn) {
|
||||||
|
var res = [];
|
||||||
|
for (var i = 0; i <= 100; ++i) {
|
||||||
|
var x = start + i / 100 * (end - start);
|
||||||
|
res.push([x, fn(x)]);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = [
|
||||||
|
{ data: generate(0, 10, function (x) { return Math.sqrt(x)}), xaxis: 1, yaxis:1 },
|
||||||
|
{ data: generate(0, 10, function (x) { return Math.sin(x)}), xaxis: 1, yaxis:2 },
|
||||||
|
{ data: generate(0, 10, function (x) { return Math.cos(x)}), xaxis: 1, yaxis:3 },
|
||||||
|
{ data: generate(2, 10, function (x) { return Math.tan(x)}), xaxis: 2, yaxis: 4 }
|
||||||
|
];
|
||||||
|
|
||||||
|
var plot = $.plot($("#placeholder"),
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
xaxes: [
|
||||||
|
{ position: 'bottom' },
|
||||||
|
{ position: 'top'}
|
||||||
|
],
|
||||||
|
yaxes: [
|
||||||
|
{ position: 'left' },
|
||||||
|
{ position: 'left' },
|
||||||
|
{ position: 'right' },
|
||||||
|
{ position: 'left' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// now for each axis, create a div
|
||||||
|
|
||||||
|
function getBoundingBoxForAxis(plot, axis) {
|
||||||
|
var left = axis.box.left, top = axis.box.top,
|
||||||
|
right = left + axis.box.width, bottom = top + axis.box.height;
|
||||||
|
|
||||||
|
// some ticks may stick out, enlarge the box to encompass all ticks
|
||||||
|
var cls = axis.direction + axis.n + 'Axis';
|
||||||
|
plot.getPlaceholder().find('.' + cls + ' .tickLabel').each(function () {
|
||||||
|
var pos = $(this).position();
|
||||||
|
left = Math.min(pos.left, left);
|
||||||
|
top = Math.min(pos.top, top);
|
||||||
|
right = Math.max(Math.round(pos.left) + $(this).outerWidth(), right);
|
||||||
|
bottom = Math.max(Math.round(pos.top) + $(this).outerHeight(), bottom);
|
||||||
|
});
|
||||||
|
|
||||||
|
return { left: left, top: top, width: right - left, height: bottom - top };
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each(plot.getAxes(), function (i, axis) {
|
||||||
|
if (!axis.show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var box = getBoundingBoxForAxis(plot, axis);
|
||||||
|
|
||||||
|
$('<div class="axisTarget" style="position:absolute;left:' + box.left + 'px;top:' + box.top + 'px;width:' + box.width + 'px;height:' + box.height + 'px"></div>')
|
||||||
|
.data('axis.direction', axis.direction)
|
||||||
|
.data('axis.n', axis.n)
|
||||||
|
.css({ backgroundColor: "#f00", opacity: 0, cursor: "pointer" })
|
||||||
|
.appendTo(plot.getPlaceholder())
|
||||||
|
.hover(
|
||||||
|
function () { $(this).css({ opacity: 0.10 }) },
|
||||||
|
function () { $(this).css({ opacity: 0 }) }
|
||||||
|
)
|
||||||
|
.click(function () {
|
||||||
|
$("#click").text("You clicked the " + axis.direction + axis.n + "axis!")
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
93
src/sunstone/public/vendor/flot/examples/interacting.html
vendored
Normal file
93
src/sunstone/public/vendor/flot/examples/interacting.html
vendored
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||||
|
|
||||||
|
<p>One of the goals of Flot is to support user interactions. Try
|
||||||
|
pointing and clicking on the points.</p>
|
||||||
|
|
||||||
|
<p id="hoverdata">Mouse hovers at
|
||||||
|
(<span id="x">0</span>, <span id="y">0</span>). <span id="clickdata"></span></p>
|
||||||
|
|
||||||
|
<p>A tooltip is easy to build with a bit of jQuery code and the
|
||||||
|
data returned from the plot.</p>
|
||||||
|
|
||||||
|
<p><input id="enableTooltip" type="checkbox">Enable tooltip</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var sin = [], cos = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.5) {
|
||||||
|
sin.push([i, Math.sin(i)]);
|
||||||
|
cos.push([i, Math.cos(i)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var plot = $.plot($("#placeholder"),
|
||||||
|
[ { data: sin, label: "sin(x)"}, { data: cos, label: "cos(x)" } ], {
|
||||||
|
series: {
|
||||||
|
lines: { show: true },
|
||||||
|
points: { show: true }
|
||||||
|
},
|
||||||
|
grid: { hoverable: true, clickable: true },
|
||||||
|
yaxis: { min: -1.2, max: 1.2 }
|
||||||
|
});
|
||||||
|
|
||||||
|
function showTooltip(x, y, contents) {
|
||||||
|
$('<div id="tooltip">' + contents + '</div>').css( {
|
||||||
|
position: 'absolute',
|
||||||
|
display: 'none',
|
||||||
|
top: y + 5,
|
||||||
|
left: x + 5,
|
||||||
|
border: '1px solid #fdd',
|
||||||
|
padding: '2px',
|
||||||
|
'background-color': '#fee',
|
||||||
|
opacity: 0.80
|
||||||
|
}).appendTo("body").fadeIn(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
var previousPoint = null;
|
||||||
|
$("#placeholder").bind("plothover", function (event, pos, item) {
|
||||||
|
$("#x").text(pos.x.toFixed(2));
|
||||||
|
$("#y").text(pos.y.toFixed(2));
|
||||||
|
|
||||||
|
if ($("#enableTooltip:checked").length > 0) {
|
||||||
|
if (item) {
|
||||||
|
if (previousPoint != item.dataIndex) {
|
||||||
|
previousPoint = item.dataIndex;
|
||||||
|
|
||||||
|
$("#tooltip").remove();
|
||||||
|
var x = item.datapoint[0].toFixed(2),
|
||||||
|
y = item.datapoint[1].toFixed(2);
|
||||||
|
|
||||||
|
showTooltip(item.pageX, item.pageY,
|
||||||
|
item.series.label + " of " + x + " = " + y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#tooltip").remove();
|
||||||
|
previousPoint = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#placeholder").bind("plotclick", function (event, pos, item) {
|
||||||
|
if (item) {
|
||||||
|
$("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + ".");
|
||||||
|
plot.highlight(item.series, item.datapoint);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
6
src/sunstone/public/vendor/flot/examples/layout.css
vendored
Normal file
6
src/sunstone/public/vendor/flot/examples/layout.css
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 50px;
|
||||||
|
max-width: 800px;
|
||||||
|
}
|
60
src/sunstone/public/vendor/flot/examples/multiple-axes.html
vendored
Normal file
60
src/sunstone/public/vendor/flot/examples/multiple-axes.html
vendored
Normal file
File diff suppressed because one or more lines are too long
118
src/sunstone/public/vendor/flot/examples/navigate.html
vendored
Normal file
118
src/sunstone/public/vendor/flot/examples/navigate.html
vendored
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.navigate.js"></script>
|
||||||
|
<style type="text/css">
|
||||||
|
#placeholder .button {
|
||||||
|
position: absolute;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#placeholder div.button {
|
||||||
|
font-size: smaller;
|
||||||
|
color: #999;
|
||||||
|
background-color: #eee;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
.message {
|
||||||
|
padding-left: 50px;
|
||||||
|
font-size: smaller;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p class="message"></p>
|
||||||
|
|
||||||
|
<p>With the navigate plugin it is easy to add panning and zooming.
|
||||||
|
Drag to pan, double click to zoom (or use the mouse scrollwheel).</p>
|
||||||
|
|
||||||
|
<p>The plugin fires events (useful for synchronizing several
|
||||||
|
plots) and adds a couple of public methods so you can easily build
|
||||||
|
a little user interface around it, like the little buttons at the
|
||||||
|
top right in the plot.</p>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
// generate data set from a parametric function with a fractal
|
||||||
|
// look
|
||||||
|
function sumf(f, t, m) {
|
||||||
|
var res = 0;
|
||||||
|
for (var i = 1; i < m; ++i)
|
||||||
|
res += f(i * i * t) / (i * i);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
var d1 = [];
|
||||||
|
for (var t = 0; t <= 2 * Math.PI; t += 0.01)
|
||||||
|
d1.push([sumf(Math.cos, t, 10), sumf(Math.sin, t, 10)]);
|
||||||
|
var data = [ d1 ];
|
||||||
|
|
||||||
|
|
||||||
|
var placeholder = $("#placeholder");
|
||||||
|
var options = {
|
||||||
|
series: { lines: { show: true }, shadowSize: 0 },
|
||||||
|
xaxis: { zoomRange: [0.1, 10], panRange: [-10, 10] },
|
||||||
|
yaxis: { zoomRange: [0.1, 10], panRange: [-10, 10] },
|
||||||
|
zoom: {
|
||||||
|
interactive: true
|
||||||
|
},
|
||||||
|
pan: {
|
||||||
|
interactive: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var plot = $.plot(placeholder, data, options);
|
||||||
|
|
||||||
|
// show pan/zoom messages to illustrate events
|
||||||
|
placeholder.bind('plotpan', function (event, plot) {
|
||||||
|
var axes = plot.getAxes();
|
||||||
|
$(".message").html("Panning to x: " + axes.xaxis.min.toFixed(2)
|
||||||
|
+ " – " + axes.xaxis.max.toFixed(2)
|
||||||
|
+ " and y: " + axes.yaxis.min.toFixed(2)
|
||||||
|
+ " – " + axes.yaxis.max.toFixed(2));
|
||||||
|
});
|
||||||
|
|
||||||
|
placeholder.bind('plotzoom', function (event, plot) {
|
||||||
|
var axes = plot.getAxes();
|
||||||
|
$(".message").html("Zooming to x: " + axes.xaxis.min.toFixed(2)
|
||||||
|
+ " – " + axes.xaxis.max.toFixed(2)
|
||||||
|
+ " and y: " + axes.yaxis.min.toFixed(2)
|
||||||
|
+ " – " + axes.yaxis.max.toFixed(2));
|
||||||
|
});
|
||||||
|
|
||||||
|
// add zoom out button
|
||||||
|
$('<div class="button" style="right:20px;top:20px">zoom out</div>').appendTo(placeholder).click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
plot.zoomOut();
|
||||||
|
});
|
||||||
|
|
||||||
|
// and add panning buttons
|
||||||
|
|
||||||
|
// little helper for taking the repetitive work out of placing
|
||||||
|
// panning arrows
|
||||||
|
function addArrow(dir, right, top, offset) {
|
||||||
|
$('<img class="button" src="arrow-' + dir + '.gif" style="right:' + right + 'px;top:' + top + 'px">').appendTo(placeholder).click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
plot.pan(offset);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addArrow('left', 55, 60, { left: -100 });
|
||||||
|
addArrow('right', 25, 60, { left: 100 });
|
||||||
|
addArrow('up', 40, 45, { top: -100 });
|
||||||
|
addArrow('down', 40, 75, { top: 100 });
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
57
src/sunstone/public/vendor/flot/examples/percentiles.html
vendored
Normal file
57
src/sunstone/public/vendor/flot/examples/percentiles.html
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.fillbetween.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:400px;"></div>
|
||||||
|
|
||||||
|
<p>Height in centimeters of individuals from the US (2003-2006) as function of
|
||||||
|
age in years (source: <a href="http://www.cdc.gov/nchs/data/nhsr/nhsr010.pdf">CDC</a>).
|
||||||
|
The 15%-85%, 25%-75% and 50% percentiles are indicated.</p>
|
||||||
|
|
||||||
|
<p>For each point of a filled curve, you can specify an arbitrary
|
||||||
|
bottom. As this example illustrates, this can be useful for
|
||||||
|
plotting percentiles. If you have the data sets available without
|
||||||
|
appropriate fill bottoms, you can use the fillbetween plugin to
|
||||||
|
compute the data point bottoms automatically.</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var males = {'15%': [[2, 88.0], [3, 93.3], [4, 102.0], [5, 108.5], [6, 115.7], [7, 115.6], [8, 124.6], [9, 130.3], [10, 134.3], [11, 141.4], [12, 146.5], [13, 151.7], [14, 159.9], [15, 165.4], [16, 167.8], [17, 168.7], [18, 169.5], [19, 168.0]], '90%': [[2, 96.8], [3, 105.2], [4, 113.9], [5, 120.8], [6, 127.0], [7, 133.1], [8, 139.1], [9, 143.9], [10, 151.3], [11, 161.1], [12, 164.8], [13, 173.5], [14, 179.0], [15, 182.0], [16, 186.9], [17, 185.2], [18, 186.3], [19, 186.6]], '25%': [[2, 89.2], [3, 94.9], [4, 104.4], [5, 111.4], [6, 117.5], [7, 120.2], [8, 127.1], [9, 132.9], [10, 136.8], [11, 144.4], [12, 149.5], [13, 154.1], [14, 163.1], [15, 169.2], [16, 170.4], [17, 171.2], [18, 172.4], [19, 170.8]], '10%': [[2, 86.9], [3, 92.6], [4, 99.9], [5, 107.0], [6, 114.0], [7, 113.5], [8, 123.6], [9, 129.2], [10, 133.0], [11, 140.6], [12, 145.2], [13, 149.7], [14, 158.4], [15, 163.5], [16, 166.9], [17, 167.5], [18, 167.1], [19, 165.3]], 'mean': [[2, 91.9], [3, 98.5], [4, 107.1], [5, 114.4], [6, 120.6], [7, 124.7], [8, 131.1], [9, 136.8], [10, 142.3], [11, 150.0], [12, 154.7], [13, 161.9], [14, 168.7], [15, 173.6], [16, 175.9], [17, 176.6], [18, 176.8], [19, 176.7]], '75%': [[2, 94.5], [3, 102.1], [4, 110.8], [5, 117.9], [6, 124.0], [7, 129.3], [8, 134.6], [9, 141.4], [10, 147.0], [11, 156.1], [12, 160.3], [13, 168.3], [14, 174.7], [15, 178.0], [16, 180.2], [17, 181.7], [18, 181.3], [19, 182.5]], '85%': [[2, 96.2], [3, 103.8], [4, 111.8], [5, 119.6], [6, 125.6], [7, 131.5], [8, 138.0], [9, 143.3], [10, 149.3], [11, 159.8], [12, 162.5], [13, 171.3], [14, 177.5], [15, 180.2], [16, 183.8], [17, 183.4], [18, 183.5], [19, 185.5]], '50%': [[2, 91.9], [3, 98.2], [4, 106.8], [5, 114.6], [6, 120.8], [7, 125.2], [8, 130.3], [9, 137.1], [10, 141.5], [11, 149.4], [12, 153.9], [13, 162.2], [14, 169.0], [15, 174.8], [16, 176.0], [17, 176.8], [18, 176.4], [19, 177.4]]};
|
||||||
|
var females = {'15%': [[2, 84.8], [3, 93.7], [4, 100.6], [5, 105.8], [6, 113.3], [7, 119.3], [8, 124.3], [9, 131.4], [10, 136.9], [11, 143.8], [12, 149.4], [13, 151.2], [14, 152.3], [15, 155.9], [16, 154.7], [17, 157.0], [18, 156.1], [19, 155.4]], '90%': [[2, 95.6], [3, 104.1], [4, 111.9], [5, 119.6], [6, 127.6], [7, 133.1], [8, 138.7], [9, 147.1], [10, 152.8], [11, 161.3], [12, 166.6], [13, 167.9], [14, 169.3], [15, 170.1], [16, 172.4], [17, 169.2], [18, 171.1], [19, 172.4]], '25%': [[2, 87.2], [3, 95.9], [4, 101.9], [5, 107.4], [6, 114.8], [7, 121.4], [8, 126.8], [9, 133.4], [10, 138.6], [11, 146.2], [12, 152.0], [13, 153.8], [14, 155.7], [15, 158.4], [16, 157.0], [17, 158.5], [18, 158.4], [19, 158.1]], '10%': [[2, 84.0], [3, 91.9], [4, 99.2], [5, 105.2], [6, 112.7], [7, 118.0], [8, 123.3], [9, 130.2], [10, 135.0], [11, 141.1], [12, 148.3], [13, 150.0], [14, 150.7], [15, 154.3], [16, 153.6], [17, 155.6], [18, 154.7], [19, 153.1]], 'mean': [[2, 90.2], [3, 98.3], [4, 105.2], [5, 112.2], [6, 119.0], [7, 125.8], [8, 131.3], [9, 138.6], [10, 144.2], [11, 151.3], [12, 156.7], [13, 158.6], [14, 160.5], [15, 162.1], [16, 162.9], [17, 162.2], [18, 163.0], [19, 163.1]], '75%': [[2, 93.2], [3, 101.5], [4, 107.9], [5, 116.6], [6, 122.8], [7, 129.3], [8, 135.2], [9, 143.7], [10, 148.7], [11, 156.9], [12, 160.8], [13, 163.0], [14, 165.0], [15, 165.8], [16, 168.7], [17, 166.2], [18, 167.6], [19, 168.0]], '85%': [[2, 94.5], [3, 102.8], [4, 110.4], [5, 119.0], [6, 125.7], [7, 131.5], [8, 137.9], [9, 146.0], [10, 151.3], [11, 159.9], [12, 164.0], [13, 166.5], [14, 167.5], [15, 168.5], [16, 171.5], [17, 168.0], [18, 169.8], [19, 170.3]], '50%': [[2, 90.2], [3, 98.1], [4, 105.2], [5, 111.7], [6, 118.2], [7, 125.6], [8, 130.5], [9, 138.3], [10, 143.7], [11, 151.4], [12, 156.7], [13, 157.7], [14, 161.0], [15, 162.0], [16, 162.8], [17, 162.2], [18, 162.8], [19, 163.3]]};
|
||||||
|
|
||||||
|
var dataset = [
|
||||||
|
{ label: 'Female mean', data: females['mean'], lines: { show: true }, color: "rgb(255,50,50)" },
|
||||||
|
{ id: 'f15%', data: females['15%'], lines: { show: true, lineWidth: 0, fill: false }, color: "rgb(255,50,50)" },
|
||||||
|
{ id: 'f25%', data: females['25%'], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(255,50,50)", fillBetween: 'f15%' },
|
||||||
|
{ id: 'f50%', data: females['50%'], lines: { show: true, lineWidth: 0.5, fill: 0.4, shadowSize: 0 }, color: "rgb(255,50,50)", fillBetween: 'f25%' },
|
||||||
|
{ id: 'f75%', data: females['75%'], lines: { show: true, lineWidth: 0, fill: 0.4 }, color: "rgb(255,50,50)", fillBetween: 'f50%' },
|
||||||
|
{ id: 'f85%', data: females['85%'], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(255,50,50)", fillBetween: 'f75%' },
|
||||||
|
|
||||||
|
{ label: 'Male mean', data: males['mean'], lines: { show: true }, color: "rgb(50,50,255)" },
|
||||||
|
{ id: 'm15%', data: males['15%'], lines: { show: true, lineWidth: 0, fill: false }, color: "rgb(50,50,255)" },
|
||||||
|
{ id: 'm25%', data: males['25%'], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(50,50,255)", fillBetween: 'm15%' },
|
||||||
|
{ id: 'm50%', data: males['50%'], lines: { show: true, lineWidth: 0.5, fill: 0.4, shadowSize: 0 }, color: "rgb(50,50,255)", fillBetween: 'm25%' },
|
||||||
|
{ id: 'm75%', data: males['75%'], lines: { show: true, lineWidth: 0, fill: 0.4 }, color: "rgb(50,50,255)", fillBetween: 'm50%' },
|
||||||
|
{ id: 'm85%', data: males['85%'], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(50,50,255)", fillBetween: 'm75%' }
|
||||||
|
]
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), dataset, {
|
||||||
|
xaxis: { tickDecimals: 0 },
|
||||||
|
yaxis: { tickFormatter: function (v) { return v + " cm"; } },
|
||||||
|
legend: { position: 'se' }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
756
src/sunstone/public/vendor/flot/examples/pie.html
vendored
Normal file
756
src/sunstone/public/vendor/flot/examples/pie.html
vendored
Normal file
@ -0,0 +1,756 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Pie Examples</title>
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.pie.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
// data
|
||||||
|
/*var data = [
|
||||||
|
{ label: "Series1", data: 10},
|
||||||
|
{ label: "Series2", data: 30},
|
||||||
|
{ label: "Series3", data: 90},
|
||||||
|
{ label: "Series4", data: 70},
|
||||||
|
{ label: "Series5", data: 80},
|
||||||
|
{ label: "Series6", data: 110}
|
||||||
|
];*/
|
||||||
|
/*var data = [
|
||||||
|
{ label: "Series1", data: [[1,10]]},
|
||||||
|
{ label: "Series2", data: [[1,30]]},
|
||||||
|
{ label: "Series3", data: [[1,90]]},
|
||||||
|
{ label: "Series4", data: [[1,70]]},
|
||||||
|
{ label: "Series5", data: [[1,80]]},
|
||||||
|
{ label: "Series6", data: [[1,0]]}
|
||||||
|
];*/
|
||||||
|
var data = [];
|
||||||
|
var series = Math.floor(Math.random()*10)+1;
|
||||||
|
for( var i = 0; i<series; i++)
|
||||||
|
{
|
||||||
|
data[i] = { label: "Series"+(i+1), data: Math.floor(Math.random()*100)+1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEFAULT
|
||||||
|
$.plot($("#default"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 1
|
||||||
|
$.plot($("#graph1"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 2
|
||||||
|
$.plot($("#graph2"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true,
|
||||||
|
radius: 1,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
radius: 1,
|
||||||
|
formatter: function(label, series){
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
|
},
|
||||||
|
background: { opacity: 0.8 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 3
|
||||||
|
$.plot($("#graph3"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true,
|
||||||
|
radius: 1,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
radius: 3/4,
|
||||||
|
formatter: function(label, series){
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
|
},
|
||||||
|
background: { opacity: 0.5 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 4
|
||||||
|
$.plot($("#graph4"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true,
|
||||||
|
radius: 1,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
radius: 3/4,
|
||||||
|
formatter: function(label, series){
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
|
},
|
||||||
|
background: {
|
||||||
|
opacity: 0.5,
|
||||||
|
color: '#000'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 5
|
||||||
|
$.plot($("#graph5"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true,
|
||||||
|
radius: 3/4,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
radius: 3/4,
|
||||||
|
formatter: function(label, series){
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
|
},
|
||||||
|
background: {
|
||||||
|
opacity: 0.5,
|
||||||
|
color: '#000'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 6
|
||||||
|
$.plot($("#graph6"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true,
|
||||||
|
radius: 1,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
radius: 2/3,
|
||||||
|
formatter: function(label, series){
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
|
},
|
||||||
|
threshold: 0.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 7
|
||||||
|
$.plot($("#graph7"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true,
|
||||||
|
combine: {
|
||||||
|
color: '#999',
|
||||||
|
threshold: 0.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 8
|
||||||
|
$.plot($("#graph8"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true,
|
||||||
|
radius:300,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
formatter: function(label, series){
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
|
},
|
||||||
|
threshold: 0.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GRAPH 9
|
||||||
|
$.plot($("#graph9"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true,
|
||||||
|
radius: 1,
|
||||||
|
tilt: 0.5,
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
radius: 1,
|
||||||
|
formatter: function(label, series){
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
|
},
|
||||||
|
background: { opacity: 0.8 }
|
||||||
|
},
|
||||||
|
combine: {
|
||||||
|
color: '#999',
|
||||||
|
threshold: 0.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// DONUT
|
||||||
|
$.plot($("#donut"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
innerRadius: 0.5,
|
||||||
|
show: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// INTERACTIVE
|
||||||
|
$.plot($("#interactive"), data,
|
||||||
|
{
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
hoverable: true,
|
||||||
|
clickable: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#interactive").bind("plothover", pieHover);
|
||||||
|
$("#interactive").bind("plotclick", pieClick);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function pieHover(event, pos, obj)
|
||||||
|
{
|
||||||
|
if (!obj)
|
||||||
|
return;
|
||||||
|
percent = parseFloat(obj.series.percent).toFixed(2);
|
||||||
|
$("#hover").html('<span style="font-weight: bold; color: '+obj.series.color+'">'+obj.series.label+' ('+percent+'%)</span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
function pieClick(event, pos, obj)
|
||||||
|
{
|
||||||
|
if (!obj)
|
||||||
|
return;
|
||||||
|
percent = parseFloat(obj.series.percent).toFixed(2);
|
||||||
|
alert(''+obj.series.label+': '+percent+'%');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style type="text/css">
|
||||||
|
* {
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
padding: 0 1em 1em 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.graph
|
||||||
|
{
|
||||||
|
width: 400px;
|
||||||
|
height: 300px;
|
||||||
|
float: left;
|
||||||
|
border: 1px dashed gainsboro;
|
||||||
|
}
|
||||||
|
|
||||||
|
label
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
margin-left: 400px;
|
||||||
|
padding-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2
|
||||||
|
{
|
||||||
|
padding-top: 1em;
|
||||||
|
margin-bottom: 0;
|
||||||
|
clear: both;
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
code
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
background-color: #eee;
|
||||||
|
border: 1px dashed #999;
|
||||||
|
padding: 0.5em;
|
||||||
|
margin: 0.5em;
|
||||||
|
color: #666;
|
||||||
|
font-size: 10pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
code b
|
||||||
|
{
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul
|
||||||
|
{
|
||||||
|
font-size: 10pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li
|
||||||
|
{
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.options li
|
||||||
|
{
|
||||||
|
list-style: none;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li i
|
||||||
|
{
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Pie Examples</h1>
|
||||||
|
|
||||||
|
<h2>Default with Legend</h2>
|
||||||
|
<div id="default" class="graph"></div>
|
||||||
|
<label for="default">
|
||||||
|
Default pie graph with no options set.
|
||||||
|
<code>
|
||||||
|
$.plot($("#default"), data,<br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true<br/>
|
||||||
|
}<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Default without Legend</h2>
|
||||||
|
<div id="graph1" class="graph"></div>
|
||||||
|
<label for="graph1">
|
||||||
|
Default pie graph when legend is disabled. Since the labels would normally be outside the container, the graph is resized to fit.
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph1"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true<br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
<b>legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}</b><br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Graph2</h2>
|
||||||
|
<div id="graph2" class="graph"></div>
|
||||||
|
<label for="graph2">
|
||||||
|
Added a semi-transparent background to the labels and a custom labelFormatter function.
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph2"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true,<br/>
|
||||||
|
radius: 1,<br/>
|
||||||
|
<b>label: {<br/>
|
||||||
|
show: true,<br/>
|
||||||
|
radius: 1,<br/>
|
||||||
|
formatter: function(label, series){<br/>
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||||
|
},<br/>
|
||||||
|
background: { opacity: 0.8 }<br/>
|
||||||
|
}</b><br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Graph3</h2>
|
||||||
|
<div id="graph3" class="graph"></div>
|
||||||
|
<label for="graph3">
|
||||||
|
Slightly more transparent label backgrounds and adjusted the radius values to place them within the pie.
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph3"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true,<br/>
|
||||||
|
radius: 1,<br/>
|
||||||
|
label: {<br/>
|
||||||
|
show: true,<br/>
|
||||||
|
<b>radius: 3/4,</b><br/>
|
||||||
|
formatter: function(label, series){<br/>
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||||
|
},<br/>
|
||||||
|
<b>background: { opacity: 0.5 }</b><br/>
|
||||||
|
}<br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Graph4</h2>
|
||||||
|
<div id="graph4" class="graph"></div>
|
||||||
|
<label for="graph4">
|
||||||
|
Semi-transparent, black-colored label background.
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph4"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true,<br/>
|
||||||
|
radius: 1,<br/>
|
||||||
|
label: {<br/>
|
||||||
|
show: true,<br/>
|
||||||
|
radius: 3/4,<br/>
|
||||||
|
formatter: function(label, series){<br/>
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||||
|
},<br/>
|
||||||
|
background: { <br/>
|
||||||
|
opacity: 0.5,<br/>
|
||||||
|
<b>color: '#000'</b><br/>
|
||||||
|
}<br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Graph5</h2>
|
||||||
|
<div id="graph5" class="graph"></div>
|
||||||
|
<label for="graph5">
|
||||||
|
Semi-transparent, black-colored label background placed at pie edge.
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph5"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true,<br/>
|
||||||
|
<b>radius: 3/4,</b><br/>
|
||||||
|
label: {<br/>
|
||||||
|
show: true,<br/>
|
||||||
|
radius: 3/4,<br/>
|
||||||
|
formatter: function(label, series){<br/>
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||||
|
},<br/>
|
||||||
|
background: { <br/>
|
||||||
|
opacity: 0.5,<br/>
|
||||||
|
color: '#000'<br/>
|
||||||
|
}<br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Graph6</h2>
|
||||||
|
<div id="graph6" class="graph"></div>
|
||||||
|
<label for="graph6">
|
||||||
|
Labels can be hidden if the slice is less than a given percentage of the pie (10% in this case).
|
||||||
|
<br><span style="color: red">Note: you may need to refresh the page to see this effect.</span>
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph6"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true,<br/>
|
||||||
|
<b>radius: 1,</b><br/>
|
||||||
|
label: {<br/>
|
||||||
|
show: true,<br/>
|
||||||
|
<b>radius: 2/3,</b><br/>
|
||||||
|
formatter: function(label, series){<br/>
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||||
|
},<br/>
|
||||||
|
<b>threshold: 0.1</b><br/>
|
||||||
|
}<br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Graph7</h2>
|
||||||
|
<div id="graph7" class="graph"></div>
|
||||||
|
<label for="graph7">
|
||||||
|
All slices less than a given percentage of the pie can be combined into a single, larger slice (10% in this case).
|
||||||
|
<br><span style="color: red">Note: you may need to refresh the page to see this effect.</span>
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph7"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true,<br/>
|
||||||
|
<b>combine: {<br/>
|
||||||
|
color: '#999',<br/>
|
||||||
|
threshold: 0.1<br/>
|
||||||
|
}</b><br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Graph8</h2>
|
||||||
|
<div id="graph8" class="graph"></div>
|
||||||
|
<label for="graph8">
|
||||||
|
The radius can also be set to a specific size (even larger than the container itself).
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph8"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true,<br/>
|
||||||
|
<b>radius:300,</b><br/>
|
||||||
|
label: {<br/>
|
||||||
|
show: true,<br/>
|
||||||
|
formatter: function(label, series){<br/>
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||||
|
},<br/>
|
||||||
|
threshold: 0.1<br/>
|
||||||
|
}<br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Graph9</h2>
|
||||||
|
<div id="graph9" class="graph" style="height: 250px;"></div>
|
||||||
|
<label for="graph9">
|
||||||
|
The pie can be tilted at an angle.
|
||||||
|
<code>
|
||||||
|
$.plot($("#graph9"), data, <br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true,<br/>
|
||||||
|
radius: 1,<br/>
|
||||||
|
<b>tilt: 0.5,</b><br/>
|
||||||
|
label: {<br/>
|
||||||
|
show: true,<br/>
|
||||||
|
radius: 1,<br/>
|
||||||
|
formatter: function(label, series){<br/>
|
||||||
|
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||||
|
},<br/>
|
||||||
|
background: { opacity: 0.8 }<br/>
|
||||||
|
},<br/>
|
||||||
|
combine: {<br/>
|
||||||
|
color: '#999',<br/>
|
||||||
|
threshold: 0.1<br/>
|
||||||
|
}<br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
legend: {<br/>
|
||||||
|
show: false<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Donut</h2>
|
||||||
|
<div id="donut" class="graph"></div>
|
||||||
|
<label for="donut">
|
||||||
|
A donut hole can be added.
|
||||||
|
<code>
|
||||||
|
$.plot($("#donut"), data,<br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
<b>innerRadius: 0.5,</b><br/>
|
||||||
|
show: true<br/>
|
||||||
|
}<br/>
|
||||||
|
}<br/>
|
||||||
|
});<br/>
|
||||||
|
</code>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Interactive</h2>
|
||||||
|
<div id="interactive" class="graph"></div>
|
||||||
|
<label for="interactive">
|
||||||
|
The pie can be made interactive with hover and click events.
|
||||||
|
<code>
|
||||||
|
$.plot($("#interactive"), data,<br/>
|
||||||
|
{<br/>
|
||||||
|
series: {<br/>
|
||||||
|
pie: { <br/>
|
||||||
|
show: true<br/>
|
||||||
|
}<br/>
|
||||||
|
},<br/>
|
||||||
|
<b>grid: {<br/>
|
||||||
|
hoverable: true,<br/>
|
||||||
|
clickable: true<br/>
|
||||||
|
}</b><br/>
|
||||||
|
});<br/>
|
||||||
|
<b>$("#interactive").bind("plothover", pieHover);<br/>
|
||||||
|
$("#interactive").bind("plotclick", pieClick);</b><br/>
|
||||||
|
</code>
|
||||||
|
<div id="hover"></div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<h2>Pie Options</h2>
|
||||||
|
<ul class="options">
|
||||||
|
<li style="border-bottom: 1px dotted #ccc;"><b>option:</b> <i>default value</i> - Description of option</li>
|
||||||
|
<li><b>show:</b> <i>false</i> - Enable the plugin and draw as a pie.</li>
|
||||||
|
<li><b>radius:</b> <i>'auto'</i> - Sets the radius of the pie. If value is between 0 and 1 (inclusive) then it will use that as a percentage of the available space (size of the container), otherwise it will use the value as a direct pixel length. If set to 'auto', it will be set to 1 if the legend is enabled and 3/4 if not.</li>
|
||||||
|
<li><b>innerRadius:</b> <i>0</i> - Sets the radius of the donut hole. If value is between 0 and 1 (inclusive) then it will use that as a percentage of the radius, otherwise it will use the value as a direct pixel length.</li>
|
||||||
|
<li><b>startAngle:</b> <i>3/2</i> - Factor of PI used for the starting angle (in radians) It can range between 0 and 2 (where 0 and 2 have the same result).</li>
|
||||||
|
<li><b>tilt:</b> <i>1</i> - Percentage of tilt ranging from 0 and 1, where 1 has no change (fully vertical) and 0 is completely flat (fully horizontal -- in which case nothing actually gets drawn).</li>
|
||||||
|
<li><b>offset:</b> <ul>
|
||||||
|
<li><b>top:</b> <i>0</i> - Pixel distance to move the pie up and down (relative to the center).</li>
|
||||||
|
<li><b>left:</b> <i>'auto'</i> - Pixel distance to move the pie left and right (relative to the center).</li>
|
||||||
|
</ul>
|
||||||
|
<li><b>stroke:</b> <ul>
|
||||||
|
<li><b>color:</b> <i>'#FFF'</i> - Color of the border of each slice. Hexadecimal color definitions are prefered (other formats may or may not work).</li>
|
||||||
|
<li><b>width:</b> <i>1</i> - Pixel width of the border of each slice.</li>
|
||||||
|
</ul>
|
||||||
|
<li><b>label:</b> <ul>
|
||||||
|
<li><b>show:</b> <i>'auto'</i> - Enable/Disable the labels. This can be set to true, false, or 'auto'. When set to 'auto', it will be set to false if the legend is enabled and true if not.</li>
|
||||||
|
<li><b>radius:</b> <i>1</i> - Sets the radius at which to place the labels. If value is between 0 and 1 (inclusive) then it will use that as a percentage of the available space (size of the container), otherwise it will use the value as a direct pixel length.</li>
|
||||||
|
<li><b>threshold:</b> <i>0</i> - Hides the labels of any pie slice that is smaller than the specified percentage (ranging from 0 to 1) i.e. a value of '0.03' will hide all slices 3% or less of the total.</li>
|
||||||
|
<li><b>formatter:</b> <i>[function]</i> - This function specifies how the positioned labels should be formatted, and is applied after the legend's labelFormatter function. The labels can also still be styled using the class "pieLabel" (i.e. ".pieLabel" or "#graph1 .pieLabel").</li>
|
||||||
|
<li><b>radius:</b> <i>1</i> - Sets the radius at which to place the labels. If value is between 0 and 1 (inclusive) then it will use that as a percentage of the available space (size of the container), otherwise it will use the value as a direct pixel length.</li>
|
||||||
|
<li><b>background:</b> <ul>
|
||||||
|
<li><b>color:</b> <i>null</i> - Backgound color of the positioned labels. If null, the plugin will automatically use the color of the slice.</li>
|
||||||
|
<li><b>opacity:</b> <i>0</i> - Opacity of the background for the positioned labels. Acceptable values range from 0 to 1, where 0 is completely transparent and 1 is completely opaque.</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
<li><b>combine:</b> <ul>
|
||||||
|
<li><b>threshold:</b> <i>0</i> - Combines all slices that are smaller than the specified percentage (ranging from 0 to 1) i.e. a value of '0.03' will combine all slices 3% or less into one slice).</li>
|
||||||
|
<li><b>color:</b> <i>null</i> - Backgound color of the positioned labels. If null, the plugin will automatically use the color of the first slice to be combined.</li>
|
||||||
|
<li><b>label:</b> <i>'Other'</i> - Label text for the combined slice.</li>
|
||||||
|
</ul>
|
||||||
|
<li><b>highlight:</b> <ul>
|
||||||
|
<li><b>opacity:</b> <i>0.5</i> - Opacity of the highlight overlay on top of the current pie slice. Currently this just uses a white overlay, but support for changing the color of the overlay will also be added at a later date.
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Changes/Features</h2>
|
||||||
|
<ul>
|
||||||
|
<li style="list-style: none;"><i>v1.0 - November 20th, 2009 - Brian Medendorp</i></li>
|
||||||
|
<li>The pie plug-in is now part of the Flot repository! This should make it a lot easier to deal with.</li>
|
||||||
|
<li>Added a new option (innerRadius) to add a "donut hole" to the center of the pie, based on comtributions from Anthony Aragues. I was a little reluctant to add this feature because it doesn't work very well with the shadow created for the tilted pie, but figured it was worthwhile for non-tilted pies. Also, excanvas apparently doesn't support compositing, so it will fall back to using the stroke color to fill in the center (but I recommend setting the stroke color to the background color anyway).</li>
|
||||||
|
<li>Changed the lineJoin for the border of the pie slices to use the 'round' option. This should make the center of the pie look better, particularly when there are numerous thin slices.</li>
|
||||||
|
<li>Included a bug fix submitted by btburnett3 to display a slightly smaller slice in the event that the slice is 100% and being rendered with Internet Explorer. I haven't experienced this bug myself, but it doesn't seem to hurt anything so I've included it.</li>
|
||||||
|
<li>The tilt value is now used when calculating the maximum radius of the pie in relation to the height of the container. This should prevent the pie from being smaller than it needed to in some cases, as well as reducing the amount of extra white space generated above and below the pie.</li>
|
||||||
|
<li><b>Hover and Click functionality are now availabe!</b><ul>
|
||||||
|
<li>Thanks to btburnett3 for the original hover functionality and Anthony Aragues for the modification that makes it compatable with excanvas, this was a huge help!</li>
|
||||||
|
<li>Added a new option (highlight opacity) to modify the highlight created when mousing over a slice. Currently this just uses a white overlay, but an option to change the hightlight color will be added when the appropriate functionality becomes available.
|
||||||
|
<li>I had a major setback that required me to practically rebuild the hover/click events from scratch one piece at a time (I discovered that it only worked with a single pie on a page at a time), but the end result ended up being virtually identical to the original, so I'm not quite sure what exactly made it work.</li>
|
||||||
|
<li><span style="color: red;">Warning:</span> There are some minor issues with using this functionality in conjuction with some of the other more advanced features (tilt and donut). When using a donut hole, the inner portion still triggers the events even though that portion of the pie is no longer visible. When tilted, the interactive portions still use the original, untilted version of the pie when determining mouse position (this is because the isPointInPath function apparently doesn't work with transformations), however hover and click both work this way, so the appropriate slice is still highlighted when clicking, and it isn't as noticable of a problem.</li>
|
||||||
|
</ul></li>
|
||||||
|
<li>Included a bug fix submitted by Xavi Ivars to fix array issues when other javascript libraries are included in addition to jQuery</li>
|
||||||
|
<br/>
|
||||||
|
<li style="list-style: none;"><i>v0.4 - July 1st, 2009 - Brian Medendorp</i></li>
|
||||||
|
<li>Each series will now be shown in the legend, even if it's value is zero. The series will not get a positioned label because it will overlap with the other labels present and often makes them unreadable.</li>
|
||||||
|
<li>Data can now be passed in using the standard Flot method using an array of datapoints, the pie plugin will simply use the first y-value that it finds for each series in this case. The plugin uses this datastructure internally, but you can still use the old method of passing in a single numerical value for each series (the plugin will convert it as necessary). This should make it easier to transition from other types of graphs (such as a stacked bar graph) to a pie.</li>
|
||||||
|
<li>The pie can now be tilted at an angle with a new "tilt" option. Acceptable values range from 0-1, where 1 has no change (fully vertical) and 0 is completely flat (fully horizontal -- in which case nothing actually gets drawn). If the plugin determines that it will fit within the canvas, a drop shadow will be drawn under the tilted pie (this also requires a tilt value of 0.8 or less).</li>
|
||||||
|
<br/>
|
||||||
|
<li style="list-style: none;"><i>v0.3.2 - June 25th, 2009 - Brian Medendorp</i></li>
|
||||||
|
<li>Fixed a bug that was causing the pie to be shifted too far left or right when the legend is showing in some cases.</li>
|
||||||
|
<br/>
|
||||||
|
<li style="list-style: none;"><i>v0.3.1 - June 24th, 2009 - Brian Medendorp</i></li>
|
||||||
|
<li>Fixed a bug that was causing nothing to be drawn and generating a javascript error if any of the data values were set to zero.</li>
|
||||||
|
<br/>
|
||||||
|
<li style="list-style: none;"><i>v0.3 - June 23rd, 2009 - Brian Medendorp</i></li>
|
||||||
|
<li>The legend now works without any modifications! Because of changes made to flot and the plugin system (thanks Ole Laursen!) I was able to simplify a number of things and am now able to use the legend without the direct access hack that was required in the previous version.</li>
|
||||||
|
<br/>
|
||||||
|
<li style="list-style: none;"><i>v0.2 - June 22nd, 2009 - Brian Medendorp</i></li>
|
||||||
|
<li>The legend now works but only if you make the necessary changes to jquery.flot.js. Because of this, I changed the default values for pie.radius and pie.label.show to new 'auto' settings that change the default behavior of the size and labels depending on whether the legend functionality is available or not.</li>
|
||||||
|
<br/>
|
||||||
|
<li style="list-style: none;"><i>v0.1 - June 18th, 2009 - Brian Medendorp</i></li>
|
||||||
|
<li>Rewrote the entire pie code into a flot plugin (since that is now an option), so it should be much easier to use and the code is cleaned up a bit. However, the (standard flot) legend is no longer available because the only way to prevent the grid lines from being displayed also prevents the legend from being displayed. Hopefully this can be fixed at a later date.</li>
|
||||||
|
<li>Restructured and combined some of the options. It should be much easier to deal with now.</li>
|
||||||
|
<li>Added the ability to change the starting point of the pie (still defaults to the top).</li>
|
||||||
|
<li>Modified the default options to show the labels to compensate for the lack of a legend.</li>
|
||||||
|
<li>Modified this page to use a random dataset. <span style="color: red">Note: you may need to refresh the page to see the effects of some of the examples.</span></li>
|
||||||
|
<br/>
|
||||||
|
<li style="list-style: none;"><i>May 21st, 2009 - Brian Medendorp</i></li>
|
||||||
|
<li>Merged original pie modifications by Sergey Nosenko into the latest SVN version <i>(as of May 15th, 2009)</i> so that it will work with ie8.</li>
|
||||||
|
<li>Pie graph will now be centered in the canvas unless moved because of the legend or manually via the options. Additionally it prevents the pie from being moved beyond the edge of the canvas.</li>
|
||||||
|
<li>Modified the code related to the labelFormatter option to apply flot's legend labelFormatter first. This is so that the labels will be consistent, but still provide extra formatting for the positioned labels (such as adding the percentage value).</li>
|
||||||
|
<li>Positioned labels now have their backgrounds applied as a seperate element (much like the legend background) so that the opacity value can be set independently from the label itself (foreground). Additionally, the background color defaults to that of the matching slice.</li>
|
||||||
|
<li>As long as the labelOffset and radiusLimit are not set to hard values, the pie will be shrunk if the labels will extend outside the edge of the canvas</li>
|
||||||
|
<li>Added new options "radiusLimitFactor" and "radiusLimit" which limits how large the (visual) radius of the pie is in relation to the full radius (as calculated from the canvas dimensions) or a hard-pixel value (respectively). This allows for pushing the labels "outside" the pie.</li>
|
||||||
|
<li>Added a new option "labelHidePercent" that does not show the positioned labels of slices smaller than the specified percentage. This is to help prevent a bunch of overlapping labels from small slices.</li>
|
||||||
|
<li>Added a new option "sliceCombinePercent" that combines all slices smaller than the specified percentage into one larger slice. This is to help make the pie more attractive when there are a number of tiny slices. The options "sliceCombineColor" and "sliceCombineLabel" have also been added to change the color and name of the new slice if desired.</li>
|
||||||
|
<li>Tested in Firefox (3.0.10, 3.5b4), Internet Explorer (6.0.2900, 7.0.5730, 8.0.6001), Chrome (1.0.154), Opera (9.64), and Safari (3.1.1, 4 beta 5528.16).
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
83
src/sunstone/public/vendor/flot/examples/realtime.html
vendored
Normal file
83
src/sunstone/public/vendor/flot/examples/realtime.html
vendored
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>You can update a chart periodically to get a real-time effect
|
||||||
|
by using a timer to insert the new data in the plot and redraw it.</p>
|
||||||
|
|
||||||
|
<p>Time between updates: <input id="updateInterval" type="text" value="" style="text-align: right; width:5em"> milliseconds</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
// we use an inline data source in the example, usually data would
|
||||||
|
// be fetched from a server
|
||||||
|
var data = [], totalPoints = 300;
|
||||||
|
function getRandomData() {
|
||||||
|
if (data.length > 0)
|
||||||
|
data = data.slice(1);
|
||||||
|
|
||||||
|
// do a random walk
|
||||||
|
while (data.length < totalPoints) {
|
||||||
|
var prev = data.length > 0 ? data[data.length - 1] : 50;
|
||||||
|
var y = prev + Math.random() * 10 - 5;
|
||||||
|
if (y < 0)
|
||||||
|
y = 0;
|
||||||
|
if (y > 100)
|
||||||
|
y = 100;
|
||||||
|
data.push(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// zip the generated y values with the x values
|
||||||
|
var res = [];
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
res.push([i, data[i]])
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup control widget
|
||||||
|
var updateInterval = 30;
|
||||||
|
$("#updateInterval").val(updateInterval).change(function () {
|
||||||
|
var v = $(this).val();
|
||||||
|
if (v && !isNaN(+v)) {
|
||||||
|
updateInterval = +v;
|
||||||
|
if (updateInterval < 1)
|
||||||
|
updateInterval = 1;
|
||||||
|
if (updateInterval > 2000)
|
||||||
|
updateInterval = 2000;
|
||||||
|
$(this).val("" + updateInterval);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// setup plot
|
||||||
|
var options = {
|
||||||
|
series: { shadowSize: 0 }, // drawing is faster without shadows
|
||||||
|
yaxis: { min: 0, max: 100 },
|
||||||
|
xaxis: { show: false }
|
||||||
|
};
|
||||||
|
var plot = $.plot($("#placeholder"), [ getRandomData() ], options);
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
plot.setData([ getRandomData() ]);
|
||||||
|
// since the axes don't change, we don't need to call plot.setupGrid()
|
||||||
|
plot.draw();
|
||||||
|
|
||||||
|
setTimeout(update, updateInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
61
src/sunstone/public/vendor/flot/examples/resize.html
vendored
Normal file
61
src/sunstone/public/vendor/flot/examples/resize.html
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.resize.js"></script>
|
||||||
|
<style type="text/css">
|
||||||
|
html, body {
|
||||||
|
height: 100%; /* make the percentage height on placeholder work */
|
||||||
|
}
|
||||||
|
.message {
|
||||||
|
padding-left: 50px;
|
||||||
|
font-size: smaller;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:80%;height:40%;"></div>
|
||||||
|
|
||||||
|
<p class="message"></p>
|
||||||
|
|
||||||
|
<p>Sometimes it makes more sense to just let the plot take up the
|
||||||
|
available space. In that case, we need to redraw the plot each
|
||||||
|
time the placeholder changes its size. If you include the resize
|
||||||
|
plugin, this is handled automatically.</p>
|
||||||
|
|
||||||
|
<p>Try resizing the window.</p>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var d1 = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.5)
|
||||||
|
d1.push([i, Math.sin(i)]);
|
||||||
|
|
||||||
|
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
|
||||||
|
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
|
||||||
|
|
||||||
|
var placeholder = $("#placeholder");
|
||||||
|
|
||||||
|
var plot = $.plot(placeholder, [d1, d2, d3]);
|
||||||
|
|
||||||
|
// the plugin includes a jQuery plugin for adding resize events to
|
||||||
|
// any element, let's just add a callback so we can display the
|
||||||
|
// placeholder size
|
||||||
|
placeholder.resize(function () {
|
||||||
|
$(".message").text("Placeholder is now "
|
||||||
|
+ $(this).width() + "x" + $(this).height()
|
||||||
|
+ " pixels");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
114
src/sunstone/public/vendor/flot/examples/selection.html
vendored
Normal file
114
src/sunstone/public/vendor/flot/examples/selection.html
vendored
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.selection.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||||
|
|
||||||
|
<p>1000 kg. CO<sub>2</sub> emissions per year per capita for various countries (source: <a href="http://en.wikipedia.org/wiki/List_of_countries_by_carbon_dioxide_emissions_per_capita">Wikipedia</a>).</p>
|
||||||
|
|
||||||
|
<p>Flot supports selections through the selection plugin.
|
||||||
|
You can enable rectangular selection
|
||||||
|
or one-dimensional selection if the user should only be able to
|
||||||
|
select on one axis. Try left-click and drag on the plot above
|
||||||
|
where selection on the x axis is enabled.</p>
|
||||||
|
|
||||||
|
<p>You selected: <span id="selection"></span></p>
|
||||||
|
|
||||||
|
<p>The plot command returns a plot object you can use to control
|
||||||
|
the selection. Click the buttons below.</p>
|
||||||
|
|
||||||
|
<p><input id="clearSelection" type="button" value="Clear selection" />
|
||||||
|
<input id="setSelection" type="button" value="Select year 1994" /></p>
|
||||||
|
|
||||||
|
<p>Selections are really useful for zooming. Just replot the
|
||||||
|
chart with min and max values for the axes set to the values
|
||||||
|
in the "plotselected" event triggered. Enable the checkbox
|
||||||
|
below and select a region again.</p>
|
||||||
|
|
||||||
|
<p><label><input id="zoom" type="checkbox" />Zoom to selection.</label></p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var data = [
|
||||||
|
{
|
||||||
|
label: "United States",
|
||||||
|
data: [[1990, 18.9], [1991, 18.7], [1992, 18.4], [1993, 19.3], [1994, 19.5], [1995, 19.3], [1996, 19.4], [1997, 20.2], [1998, 19.8], [1999, 19.9], [2000, 20.4], [2001, 20.1], [2002, 20.0], [2003, 19.8], [2004, 20.4]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Russia",
|
||||||
|
data: [[1992, 13.4], [1993, 12.2], [1994, 10.6], [1995, 10.2], [1996, 10.1], [1997, 9.7], [1998, 9.5], [1999, 9.7], [2000, 9.9], [2001, 9.9], [2002, 9.9], [2003, 10.3], [2004, 10.5]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "United Kingdom",
|
||||||
|
data: [[1990, 10.0], [1991, 11.3], [1992, 9.9], [1993, 9.6], [1994, 9.5], [1995, 9.5], [1996, 9.9], [1997, 9.3], [1998, 9.2], [1999, 9.2], [2000, 9.5], [2001, 9.6], [2002, 9.3], [2003, 9.4], [2004, 9.79]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Germany",
|
||||||
|
data: [[1990, 12.4], [1991, 11.2], [1992, 10.8], [1993, 10.5], [1994, 10.4], [1995, 10.2], [1996, 10.5], [1997, 10.2], [1998, 10.1], [1999, 9.6], [2000, 9.7], [2001, 10.0], [2002, 9.7], [2003, 9.8], [2004, 9.79]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Denmark",
|
||||||
|
data: [[1990, 9.7], [1991, 12.1], [1992, 10.3], [1993, 11.3], [1994, 11.7], [1995, 10.6], [1996, 12.8], [1997, 10.8], [1998, 10.3], [1999, 9.4], [2000, 8.7], [2001, 9.0], [2002, 8.9], [2003, 10.1], [2004, 9.80]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Sweden",
|
||||||
|
data: [[1990, 5.8], [1991, 6.0], [1992, 5.9], [1993, 5.5], [1994, 5.7], [1995, 5.3], [1996, 6.1], [1997, 5.4], [1998, 5.4], [1999, 5.1], [2000, 5.2], [2001, 5.4], [2002, 6.2], [2003, 5.9], [2004, 5.89]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Norway",
|
||||||
|
data: [[1990, 8.3], [1991, 8.3], [1992, 7.8], [1993, 8.3], [1994, 8.4], [1995, 5.9], [1996, 6.4], [1997, 6.7], [1998, 6.9], [1999, 7.6], [2000, 7.4], [2001, 8.1], [2002, 12.5], [2003, 9.9], [2004, 19.0]]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
series: {
|
||||||
|
lines: { show: true },
|
||||||
|
points: { show: true }
|
||||||
|
},
|
||||||
|
legend: { noColumns: 2 },
|
||||||
|
xaxis: { tickDecimals: 0 },
|
||||||
|
yaxis: { min: 0 },
|
||||||
|
selection: { mode: "x" }
|
||||||
|
};
|
||||||
|
|
||||||
|
var placeholder = $("#placeholder");
|
||||||
|
|
||||||
|
placeholder.bind("plotselected", function (event, ranges) {
|
||||||
|
$("#selection").text(ranges.xaxis.from.toFixed(1) + " to " + ranges.xaxis.to.toFixed(1));
|
||||||
|
|
||||||
|
var zoom = $("#zoom").attr("checked");
|
||||||
|
if (zoom)
|
||||||
|
plot = $.plot(placeholder, data,
|
||||||
|
$.extend(true, {}, options, {
|
||||||
|
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
placeholder.bind("plotunselected", function (event) {
|
||||||
|
$("#selection").text("");
|
||||||
|
});
|
||||||
|
|
||||||
|
var plot = $.plot(placeholder, data, options);
|
||||||
|
|
||||||
|
$("#clearSelection").click(function () {
|
||||||
|
plot.clearSelection();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#setSelection").click(function () {
|
||||||
|
plot.setSelection({ xaxis: { from: 1994, to: 1995 } });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
61
src/sunstone/public/vendor/flot/examples/setting-options.html
vendored
Normal file
61
src/sunstone/public/vendor/flot/examples/setting-options.html
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||||
|
|
||||||
|
<p>There are plenty of options you can set to control the precise
|
||||||
|
looks of your plot. You can control the ticks on the axes, the
|
||||||
|
legend, the graph type, etc. The idea is that Flot goes to great
|
||||||
|
lengths to provide sensible defaults so that you don't have to
|
||||||
|
customize much for a good result.</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var d1 = [];
|
||||||
|
for (var i = 0; i < Math.PI * 2; i += 0.25)
|
||||||
|
d1.push([i, Math.sin(i)]);
|
||||||
|
|
||||||
|
var d2 = [];
|
||||||
|
for (var i = 0; i < Math.PI * 2; i += 0.25)
|
||||||
|
d2.push([i, Math.cos(i)]);
|
||||||
|
|
||||||
|
var d3 = [];
|
||||||
|
for (var i = 0; i < Math.PI * 2; i += 0.1)
|
||||||
|
d3.push([i, Math.tan(i)]);
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [
|
||||||
|
{ label: "sin(x)", data: d1},
|
||||||
|
{ label: "cos(x)", data: d2},
|
||||||
|
{ label: "tan(x)", data: d3}
|
||||||
|
], {
|
||||||
|
series: {
|
||||||
|
lines: { show: true },
|
||||||
|
points: { show: true }
|
||||||
|
},
|
||||||
|
xaxis: {
|
||||||
|
ticks: [0, [Math.PI/2, "\u03c0/2"], [Math.PI, "\u03c0"], [Math.PI * 3/2, "3\u03c0/2"], [Math.PI * 2, "2\u03c0"]]
|
||||||
|
},
|
||||||
|
yaxis: {
|
||||||
|
ticks: 10,
|
||||||
|
min: -2,
|
||||||
|
max: 2
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
backgroundColor: { colors: ["#fff", "#eee"] }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
77
src/sunstone/public/vendor/flot/examples/stacking.html
vendored
Normal file
77
src/sunstone/public/vendor/flot/examples/stacking.html
vendored
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.stack.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>With the stack plugin, you can have Flot stack the
|
||||||
|
series. This is useful if you wish to display both a total and the
|
||||||
|
constituents it is made of. The only requirement is that you provide
|
||||||
|
the input sorted on x.</p>
|
||||||
|
|
||||||
|
<p class="stackControls">
|
||||||
|
<input type="button" value="With stacking">
|
||||||
|
<input type="button" value="Without stacking">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="graphControls">
|
||||||
|
<input type="button" value="Bars">
|
||||||
|
<input type="button" value="Lines">
|
||||||
|
<input type="button" value="Lines with steps">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<script id="source">
|
||||||
|
$(function () {
|
||||||
|
var d1 = [];
|
||||||
|
for (var i = 0; i <= 10; i += 1)
|
||||||
|
d1.push([i, parseInt(Math.random() * 30)]);
|
||||||
|
|
||||||
|
var d2 = [];
|
||||||
|
for (var i = 0; i <= 10; i += 1)
|
||||||
|
d2.push([i, parseInt(Math.random() * 30)]);
|
||||||
|
|
||||||
|
var d3 = [];
|
||||||
|
for (var i = 0; i <= 10; i += 1)
|
||||||
|
d3.push([i, parseInt(Math.random() * 30)]);
|
||||||
|
|
||||||
|
var stack = 0, bars = true, lines = false, steps = false;
|
||||||
|
|
||||||
|
function plotWithOptions() {
|
||||||
|
$.plot($("#placeholder"), [ d1, d2, d3 ], {
|
||||||
|
series: {
|
||||||
|
stack: stack,
|
||||||
|
lines: { show: lines, fill: true, steps: steps },
|
||||||
|
bars: { show: bars, barWidth: 0.6 }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
plotWithOptions();
|
||||||
|
|
||||||
|
$(".stackControls input").click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
stack = $(this).val() == "With stacking" ? true : null;
|
||||||
|
plotWithOptions();
|
||||||
|
});
|
||||||
|
$(".graphControls input").click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
bars = $(this).val().indexOf("Bars") != -1;
|
||||||
|
lines = $(this).val().indexOf("Lines") != -1;
|
||||||
|
steps = $(this).val().indexOf("steps") != -1;
|
||||||
|
plotWithOptions();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
49
src/sunstone/public/vendor/flot/examples/symbols.html
vendored
Normal file
49
src/sunstone/public/vendor/flot/examples/symbols.html
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.symbol.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||||
|
|
||||||
|
<p>Various point types. Circles are built-in. For other
|
||||||
|
point types, you can define a little callback function to draw the
|
||||||
|
symbol; some common ones are available in the symbol plugin.</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
function generate(offset, amplitude) {
|
||||||
|
var res = [];
|
||||||
|
var start = 0, end = 10;
|
||||||
|
for (var i = 0; i <= 50; ++i) {
|
||||||
|
var x = start + i / 50 * (end - start);
|
||||||
|
res.push([x, amplitude * Math.sin(x + offset)]);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = [
|
||||||
|
{ data: generate(2, 1.8), points: { symbol: "circle" } },
|
||||||
|
{ data: generate(3, 1.5), points: { symbol: "square" } },
|
||||||
|
{ data: generate(4, 0.9), points: { symbol: "diamond" } },
|
||||||
|
{ data: generate(6, 1.4), points: { symbol: "triangle" } },
|
||||||
|
{ data: generate(7, 1.1), points: { symbol: "cross" } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), data, {
|
||||||
|
series: { points: { show: true, radius: 3 } },
|
||||||
|
grid: { hoverable: true }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
54
src/sunstone/public/vendor/flot/examples/thresholding.html
vendored
Normal file
54
src/sunstone/public/vendor/flot/examples/thresholding.html
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.threshold.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>With the threshold plugin, you can apply a specific color to
|
||||||
|
the part of a data series below a threshold. This is can be useful
|
||||||
|
for highlighting negative values, e.g. when displaying net results
|
||||||
|
or what's in stock.</p>
|
||||||
|
|
||||||
|
<p class="controls">
|
||||||
|
<input type="button" value="Threshold at 5">
|
||||||
|
<input type="button" value="Threshold at 0">
|
||||||
|
<input type="button" value="Threshold at -2.5">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var d1 = [];
|
||||||
|
for (var i = 0; i <= 60; i += 1)
|
||||||
|
d1.push([i, parseInt(Math.random() * 30 - 10)]);
|
||||||
|
|
||||||
|
function plotWithOptions(t) {
|
||||||
|
$.plot($("#placeholder"), [ {
|
||||||
|
data: d1,
|
||||||
|
color: "rgb(30, 180, 20)",
|
||||||
|
threshold: { below: t, color: "rgb(200, 20, 30)" },
|
||||||
|
lines: { steps: true }
|
||||||
|
} ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
plotWithOptions(0);
|
||||||
|
|
||||||
|
$(".controls input").click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var t = parseFloat($(this).val().replace('Threshold at ', ''));
|
||||||
|
plotWithOptions(t);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
71
src/sunstone/public/vendor/flot/examples/time.html
vendored
Normal file
71
src/sunstone/public/vendor/flot/examples/time.html
vendored
Normal file
File diff suppressed because one or more lines are too long
95
src/sunstone/public/vendor/flot/examples/tracking.html
vendored
Normal file
95
src/sunstone/public/vendor/flot/examples/tracking.html
vendored
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.crosshair.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||||
|
|
||||||
|
<p>You can add crosshairs that'll track the mouse position, either
|
||||||
|
on both axes or as here on only one.</p>
|
||||||
|
|
||||||
|
<p>If you combine it with listening on hover events, you can use
|
||||||
|
it to track the intersection on the curves by interpolating
|
||||||
|
the data points (look at the legend).</p>
|
||||||
|
|
||||||
|
<p id="hoverdata"></p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var plot;
|
||||||
|
$(function () {
|
||||||
|
var sin = [], cos = [];
|
||||||
|
for (var i = 0; i < 14; i += 0.1) {
|
||||||
|
sin.push([i, Math.sin(i)]);
|
||||||
|
cos.push([i, Math.cos(i)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot = $.plot($("#placeholder"),
|
||||||
|
[ { data: sin, label: "sin(x) = -0.00"},
|
||||||
|
{ data: cos, label: "cos(x) = -0.00" } ], {
|
||||||
|
series: {
|
||||||
|
lines: { show: true }
|
||||||
|
},
|
||||||
|
crosshair: { mode: "x" },
|
||||||
|
grid: { hoverable: true, autoHighlight: false },
|
||||||
|
yaxis: { min: -1.2, max: 1.2 }
|
||||||
|
});
|
||||||
|
var legends = $("#placeholder .legendLabel");
|
||||||
|
legends.each(function () {
|
||||||
|
// fix the widths so they don't jump around
|
||||||
|
$(this).css('width', $(this).width());
|
||||||
|
});
|
||||||
|
|
||||||
|
var updateLegendTimeout = null;
|
||||||
|
var latestPosition = null;
|
||||||
|
|
||||||
|
function updateLegend() {
|
||||||
|
updateLegendTimeout = null;
|
||||||
|
|
||||||
|
var pos = latestPosition;
|
||||||
|
|
||||||
|
var axes = plot.getAxes();
|
||||||
|
if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max ||
|
||||||
|
pos.y < axes.yaxis.min || pos.y > axes.yaxis.max)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var i, j, dataset = plot.getData();
|
||||||
|
for (i = 0; i < dataset.length; ++i) {
|
||||||
|
var series = dataset[i];
|
||||||
|
|
||||||
|
// find the nearest points, x-wise
|
||||||
|
for (j = 0; j < series.data.length; ++j)
|
||||||
|
if (series.data[j][0] > pos.x)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// now interpolate
|
||||||
|
var y, p1 = series.data[j - 1], p2 = series.data[j];
|
||||||
|
if (p1 == null)
|
||||||
|
y = p2[1];
|
||||||
|
else if (p2 == null)
|
||||||
|
y = p1[1];
|
||||||
|
else
|
||||||
|
y = p1[1] + (p2[1] - p1[1]) * (pos.x - p1[0]) / (p2[0] - p1[0]);
|
||||||
|
|
||||||
|
legends.eq(i).text(series.label.replace(/=.*/, "= " + y.toFixed(2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#placeholder").bind("plothover", function (event, pos, item) {
|
||||||
|
latestPosition = pos;
|
||||||
|
if (!updateLegendTimeout)
|
||||||
|
updateLegendTimeout = setTimeout(updateLegend, 50);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
98
src/sunstone/public/vendor/flot/examples/turning-series.html
vendored
Normal file
98
src/sunstone/public/vendor/flot/examples/turning-series.html
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>Here is an example with real data: military budgets for
|
||||||
|
various countries in constant (2005) million US dollars (source: <a href="http://www.sipri.org/">SIPRI</a>).</p>
|
||||||
|
|
||||||
|
<p>Since all data is available client-side, it's pretty easy to
|
||||||
|
make the plot interactive. Try turning countries on/off with the
|
||||||
|
checkboxes below.</p>
|
||||||
|
|
||||||
|
<p id="choices">Show:</p>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var datasets = {
|
||||||
|
"usa": {
|
||||||
|
label: "USA",
|
||||||
|
data: [[1988, 483994], [1989, 479060], [1990, 457648], [1991, 401949], [1992, 424705], [1993, 402375], [1994, 377867], [1995, 357382], [1996, 337946], [1997, 336185], [1998, 328611], [1999, 329421], [2000, 342172], [2001, 344932], [2002, 387303], [2003, 440813], [2004, 480451], [2005, 504638], [2006, 528692]]
|
||||||
|
},
|
||||||
|
"russia": {
|
||||||
|
label: "Russia",
|
||||||
|
data: [[1988, 218000], [1989, 203000], [1990, 171000], [1992, 42500], [1993, 37600], [1994, 36600], [1995, 21700], [1996, 19200], [1997, 21300], [1998, 13600], [1999, 14000], [2000, 19100], [2001, 21300], [2002, 23600], [2003, 25100], [2004, 26100], [2005, 31100], [2006, 34700]]
|
||||||
|
},
|
||||||
|
"uk": {
|
||||||
|
label: "UK",
|
||||||
|
data: [[1988, 62982], [1989, 62027], [1990, 60696], [1991, 62348], [1992, 58560], [1993, 56393], [1994, 54579], [1995, 50818], [1996, 50554], [1997, 48276], [1998, 47691], [1999, 47529], [2000, 47778], [2001, 48760], [2002, 50949], [2003, 57452], [2004, 60234], [2005, 60076], [2006, 59213]]
|
||||||
|
},
|
||||||
|
"germany": {
|
||||||
|
label: "Germany",
|
||||||
|
data: [[1988, 55627], [1989, 55475], [1990, 58464], [1991, 55134], [1992, 52436], [1993, 47139], [1994, 43962], [1995, 43238], [1996, 42395], [1997, 40854], [1998, 40993], [1999, 41822], [2000, 41147], [2001, 40474], [2002, 40604], [2003, 40044], [2004, 38816], [2005, 38060], [2006, 36984]]
|
||||||
|
},
|
||||||
|
"denmark": {
|
||||||
|
label: "Denmark",
|
||||||
|
data: [[1988, 3813], [1989, 3719], [1990, 3722], [1991, 3789], [1992, 3720], [1993, 3730], [1994, 3636], [1995, 3598], [1996, 3610], [1997, 3655], [1998, 3695], [1999, 3673], [2000, 3553], [2001, 3774], [2002, 3728], [2003, 3618], [2004, 3638], [2005, 3467], [2006, 3770]]
|
||||||
|
},
|
||||||
|
"sweden": {
|
||||||
|
label: "Sweden",
|
||||||
|
data: [[1988, 6402], [1989, 6474], [1990, 6605], [1991, 6209], [1992, 6035], [1993, 6020], [1994, 6000], [1995, 6018], [1996, 3958], [1997, 5780], [1998, 5954], [1999, 6178], [2000, 6411], [2001, 5993], [2002, 5833], [2003, 5791], [2004, 5450], [2005, 5521], [2006, 5271]]
|
||||||
|
},
|
||||||
|
"norway": {
|
||||||
|
label: "Norway",
|
||||||
|
data: [[1988, 4382], [1989, 4498], [1990, 4535], [1991, 4398], [1992, 4766], [1993, 4441], [1994, 4670], [1995, 4217], [1996, 4275], [1997, 4203], [1998, 4482], [1999, 4506], [2000, 4358], [2001, 4385], [2002, 5269], [2003, 5066], [2004, 5194], [2005, 4887], [2006, 4891]]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// hard-code color indices to prevent them from shifting as
|
||||||
|
// countries are turned on/off
|
||||||
|
var i = 0;
|
||||||
|
$.each(datasets, function(key, val) {
|
||||||
|
val.color = i;
|
||||||
|
++i;
|
||||||
|
});
|
||||||
|
|
||||||
|
// insert checkboxes
|
||||||
|
var choiceContainer = $("#choices");
|
||||||
|
$.each(datasets, function(key, val) {
|
||||||
|
choiceContainer.append('<br/><input type="checkbox" name="' + key +
|
||||||
|
'" checked="checked" id="id' + key + '">' +
|
||||||
|
'<label for="id' + key + '">'
|
||||||
|
+ val.label + '</label>');
|
||||||
|
});
|
||||||
|
choiceContainer.find("input").click(plotAccordingToChoices);
|
||||||
|
|
||||||
|
|
||||||
|
function plotAccordingToChoices() {
|
||||||
|
var data = [];
|
||||||
|
|
||||||
|
choiceContainer.find("input:checked").each(function () {
|
||||||
|
var key = $(this).attr("name");
|
||||||
|
if (key && datasets[key])
|
||||||
|
data.push(datasets[key]);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data.length > 0)
|
||||||
|
$.plot($("#placeholder"), data, {
|
||||||
|
yaxis: { min: 0 },
|
||||||
|
xaxis: { tickDecimals: 0 }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
plotAccordingToChoices();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
90
src/sunstone/public/vendor/flot/examples/visitors.html
vendored
Normal file
90
src/sunstone/public/vendor/flot/examples/visitors.html
vendored
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.selection.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||||
|
|
||||||
|
<p>Visitors per day to the Flot homepage. Weekends are colored. Try zooming.
|
||||||
|
The plot below shows an overview.</p>
|
||||||
|
|
||||||
|
<div id="overview" style="margin-left:50px;margin-top:20px;width:400px;height:50px"></div>
|
||||||
|
|
||||||
|
<script id="source">
|
||||||
|
$(function () {
|
||||||
|
var d = [[1196463600000, 0], [1196550000000, 0], [1196636400000, 0], [1196722800000, 77], [1196809200000, 3636], [1196895600000, 3575], [1196982000000, 2736], [1197068400000, 1086], [1197154800000, 676], [1197241200000, 1205], [1197327600000, 906], [1197414000000, 710], [1197500400000, 639], [1197586800000, 540], [1197673200000, 435], [1197759600000, 301], [1197846000000, 575], [1197932400000, 481], [1198018800000, 591], [1198105200000, 608], [1198191600000, 459], [1198278000000, 234], [1198364400000, 1352], [1198450800000, 686], [1198537200000, 279], [1198623600000, 449], [1198710000000, 468], [1198796400000, 392], [1198882800000, 282], [1198969200000, 208], [1199055600000, 229], [1199142000000, 177], [1199228400000, 374], [1199314800000, 436], [1199401200000, 404], [1199487600000, 253], [1199574000000, 218], [1199660400000, 476], [1199746800000, 462], [1199833200000, 448], [1199919600000, 442], [1200006000000, 403], [1200092400000, 204], [1200178800000, 194], [1200265200000, 327], [1200351600000, 374], [1200438000000, 507], [1200524400000, 546], [1200610800000, 482], [1200697200000, 283], [1200783600000, 221], [1200870000000, 483], [1200956400000, 523], [1201042800000, 528], [1201129200000, 483], [1201215600000, 452], [1201302000000, 270], [1201388400000, 222], [1201474800000, 439], [1201561200000, 559], [1201647600000, 521], [1201734000000, 477], [1201820400000, 442], [1201906800000, 252], [1201993200000, 236], [1202079600000, 525], [1202166000000, 477], [1202252400000, 386], [1202338800000, 409], [1202425200000, 408], [1202511600000, 237], [1202598000000, 193], [1202684400000, 357], [1202770800000, 414], [1202857200000, 393], [1202943600000, 353], [1203030000000, 364], [1203116400000, 215], [1203202800000, 214], [1203289200000, 356], [1203375600000, 399], [1203462000000, 334], [1203548400000, 348], [1203634800000, 243], [1203721200000, 126], [1203807600000, 157], [1203894000000, 288]];
|
||||||
|
|
||||||
|
// first correct the timestamps - they are recorded as the daily
|
||||||
|
// midnights in UTC+0100, but Flot always displays dates in UTC
|
||||||
|
// so we have to add one hour to hit the midnights in the plot
|
||||||
|
for (var i = 0; i < d.length; ++i)
|
||||||
|
d[i][0] += 60 * 60 * 1000;
|
||||||
|
|
||||||
|
// helper for returning the weekends in a period
|
||||||
|
function weekendAreas(axes) {
|
||||||
|
var markings = [];
|
||||||
|
var d = new Date(axes.xaxis.min);
|
||||||
|
// go to the first Saturday
|
||||||
|
d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7))
|
||||||
|
d.setUTCSeconds(0);
|
||||||
|
d.setUTCMinutes(0);
|
||||||
|
d.setUTCHours(0);
|
||||||
|
var i = d.getTime();
|
||||||
|
do {
|
||||||
|
// when we don't set yaxis, the rectangle automatically
|
||||||
|
// extends to infinity upwards and downwards
|
||||||
|
markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } });
|
||||||
|
i += 7 * 24 * 60 * 60 * 1000;
|
||||||
|
} while (i < axes.xaxis.max);
|
||||||
|
|
||||||
|
return markings;
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
xaxis: { mode: "time", tickLength: 5 },
|
||||||
|
selection: { mode: "x" },
|
||||||
|
grid: { markings: weekendAreas }
|
||||||
|
};
|
||||||
|
|
||||||
|
var plot = $.plot($("#placeholder"), [d], options);
|
||||||
|
|
||||||
|
var overview = $.plot($("#overview"), [d], {
|
||||||
|
series: {
|
||||||
|
lines: { show: true, lineWidth: 1 },
|
||||||
|
shadowSize: 0
|
||||||
|
},
|
||||||
|
xaxis: { ticks: [], mode: "time" },
|
||||||
|
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
|
||||||
|
selection: { mode: "x" }
|
||||||
|
});
|
||||||
|
|
||||||
|
// now connect the two
|
||||||
|
|
||||||
|
$("#placeholder").bind("plotselected", function (event, ranges) {
|
||||||
|
// do the zooming
|
||||||
|
plot = $.plot($("#placeholder"), [d],
|
||||||
|
$.extend(true, {}, options, {
|
||||||
|
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
|
||||||
|
}));
|
||||||
|
|
||||||
|
// don't fire event on the overview to prevent eternal loop
|
||||||
|
overview.setSelection(ranges, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#overview").bind("plotselected", function (event, ranges) {
|
||||||
|
plot.setSelection(ranges);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
98
src/sunstone/public/vendor/flot/examples/zooming.html
vendored
Normal file
98
src/sunstone/public/vendor/flot/examples/zooming.html
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Flot Examples</title>
|
||||||
|
<link href="layout.css" rel="stylesheet" type="text/css">
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="../jquery.flot.selection.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Flot Examples</h1>
|
||||||
|
|
||||||
|
<div style="float:left">
|
||||||
|
<div id="placeholder" style="width:500px;height:300px"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="miniature" style="float:left;margin-left:20px">
|
||||||
|
<div id="overview" style="width:166px;height:100px"></div>
|
||||||
|
|
||||||
|
<p id="overviewLegend" style="margin-left:10px"></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p style="clear:left">The selection support makes it easy to
|
||||||
|
construct flexible zooming schemes. With a few lines of code, the
|
||||||
|
small overview plot to the right has been connected to the large
|
||||||
|
plot. Try selecting a rectangle on either of them.</p>
|
||||||
|
|
||||||
|
<script id="source">
|
||||||
|
$(function () {
|
||||||
|
// setup plot
|
||||||
|
function getData(x1, x2) {
|
||||||
|
var d = [];
|
||||||
|
for (var i = 0; i <= 100; ++i) {
|
||||||
|
var x = x1 + i * (x2 - x1) / 100;
|
||||||
|
d.push([x, Math.sin(x * Math.sin(x))]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
{ label: "sin(x sin(x))", data: d }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
legend: { show: false },
|
||||||
|
series: {
|
||||||
|
lines: { show: true },
|
||||||
|
points: { show: true }
|
||||||
|
},
|
||||||
|
yaxis: { ticks: 10 },
|
||||||
|
selection: { mode: "xy" }
|
||||||
|
};
|
||||||
|
|
||||||
|
var startData = getData(0, 3 * Math.PI);
|
||||||
|
|
||||||
|
var plot = $.plot($("#placeholder"), startData, options);
|
||||||
|
|
||||||
|
// setup overview
|
||||||
|
var overview = $.plot($("#overview"), startData, {
|
||||||
|
legend: { show: true, container: $("#overviewLegend") },
|
||||||
|
series: {
|
||||||
|
lines: { show: true, lineWidth: 1 },
|
||||||
|
shadowSize: 0
|
||||||
|
},
|
||||||
|
xaxis: { ticks: 4 },
|
||||||
|
yaxis: { ticks: 3, min: -2, max: 2 },
|
||||||
|
grid: { color: "#999" },
|
||||||
|
selection: { mode: "xy" }
|
||||||
|
});
|
||||||
|
|
||||||
|
// now connect the two
|
||||||
|
|
||||||
|
$("#placeholder").bind("plotselected", function (event, ranges) {
|
||||||
|
// clamp the zooming to prevent eternal zoom
|
||||||
|
if (ranges.xaxis.to - ranges.xaxis.from < 0.00001)
|
||||||
|
ranges.xaxis.to = ranges.xaxis.from + 0.00001;
|
||||||
|
if (ranges.yaxis.to - ranges.yaxis.from < 0.00001)
|
||||||
|
ranges.yaxis.to = ranges.yaxis.from + 0.00001;
|
||||||
|
|
||||||
|
// do the zooming
|
||||||
|
plot = $.plot($("#placeholder"), getData(ranges.xaxis.from, ranges.xaxis.to),
|
||||||
|
$.extend(true, {}, options, {
|
||||||
|
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
|
||||||
|
yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
|
||||||
|
}));
|
||||||
|
|
||||||
|
// don't fire event on the overview to prevent eternal loop
|
||||||
|
overview.setSelection(ranges, true);
|
||||||
|
});
|
||||||
|
$("#overview").bind("plotselected", function (event, ranges) {
|
||||||
|
plot.setSelection(ranges);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
1427
src/sunstone/public/vendor/flot/excanvas.js
vendored
Normal file
1427
src/sunstone/public/vendor/flot/excanvas.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
src/sunstone/public/vendor/flot/excanvas.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/excanvas.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
179
src/sunstone/public/vendor/flot/jquery.colorhelpers.js
vendored
Normal file
179
src/sunstone/public/vendor/flot/jquery.colorhelpers.js
vendored
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
/* Plugin for jQuery for working with colors.
|
||||||
|
*
|
||||||
|
* Version 1.1.
|
||||||
|
*
|
||||||
|
* Inspiration from jQuery color animation plugin by John Resig.
|
||||||
|
*
|
||||||
|
* Released under the MIT license by Ole Laursen, October 2009.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString()
|
||||||
|
* var c = $.color.extract($("#mydiv"), 'background-color');
|
||||||
|
* console.log(c.r, c.g, c.b, c.a);
|
||||||
|
* $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)"
|
||||||
|
*
|
||||||
|
* Note that .scale() and .add() return the same modified object
|
||||||
|
* instead of making a new one.
|
||||||
|
*
|
||||||
|
* V. 1.1: Fix error handling so e.g. parsing an empty string does
|
||||||
|
* produce a color rather than just crashing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
$.color = {};
|
||||||
|
|
||||||
|
// construct color object with some convenient chainable helpers
|
||||||
|
$.color.make = function (r, g, b, a) {
|
||||||
|
var o = {};
|
||||||
|
o.r = r || 0;
|
||||||
|
o.g = g || 0;
|
||||||
|
o.b = b || 0;
|
||||||
|
o.a = a != null ? a : 1;
|
||||||
|
|
||||||
|
o.add = function (c, d) {
|
||||||
|
for (var i = 0; i < c.length; ++i)
|
||||||
|
o[c.charAt(i)] += d;
|
||||||
|
return o.normalize();
|
||||||
|
};
|
||||||
|
|
||||||
|
o.scale = function (c, f) {
|
||||||
|
for (var i = 0; i < c.length; ++i)
|
||||||
|
o[c.charAt(i)] *= f;
|
||||||
|
return o.normalize();
|
||||||
|
};
|
||||||
|
|
||||||
|
o.toString = function () {
|
||||||
|
if (o.a >= 1.0) {
|
||||||
|
return "rgb("+[o.r, o.g, o.b].join(",")+")";
|
||||||
|
} else {
|
||||||
|
return "rgba("+[o.r, o.g, o.b, o.a].join(",")+")";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
o.normalize = function () {
|
||||||
|
function clamp(min, value, max) {
|
||||||
|
return value < min ? min: (value > max ? max: value);
|
||||||
|
}
|
||||||
|
|
||||||
|
o.r = clamp(0, parseInt(o.r), 255);
|
||||||
|
o.g = clamp(0, parseInt(o.g), 255);
|
||||||
|
o.b = clamp(0, parseInt(o.b), 255);
|
||||||
|
o.a = clamp(0, o.a, 1);
|
||||||
|
return o;
|
||||||
|
};
|
||||||
|
|
||||||
|
o.clone = function () {
|
||||||
|
return $.color.make(o.r, o.b, o.g, o.a);
|
||||||
|
};
|
||||||
|
|
||||||
|
return o.normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract CSS color property from element, going up in the DOM
|
||||||
|
// if it's "transparent"
|
||||||
|
$.color.extract = function (elem, css) {
|
||||||
|
var c;
|
||||||
|
do {
|
||||||
|
c = elem.css(css).toLowerCase();
|
||||||
|
// keep going until we find an element that has color, or
|
||||||
|
// we hit the body
|
||||||
|
if (c != '' && c != 'transparent')
|
||||||
|
break;
|
||||||
|
elem = elem.parent();
|
||||||
|
} while (!$.nodeName(elem.get(0), "body"));
|
||||||
|
|
||||||
|
// catch Safari's way of signalling transparent
|
||||||
|
if (c == "rgba(0, 0, 0, 0)")
|
||||||
|
c = "transparent";
|
||||||
|
|
||||||
|
return $.color.parse(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse CSS color string (like "rgb(10, 32, 43)" or "#fff"),
|
||||||
|
// returns color object, if parsing failed, you get black (0, 0,
|
||||||
|
// 0) out
|
||||||
|
$.color.parse = function (str) {
|
||||||
|
var res, m = $.color.make;
|
||||||
|
|
||||||
|
// Look for rgb(num,num,num)
|
||||||
|
if (res = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))
|
||||||
|
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10));
|
||||||
|
|
||||||
|
// Look for rgba(num,num,num,num)
|
||||||
|
if (res = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))
|
||||||
|
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10), parseFloat(res[4]));
|
||||||
|
|
||||||
|
// Look for rgb(num%,num%,num%)
|
||||||
|
if (res = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))
|
||||||
|
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55);
|
||||||
|
|
||||||
|
// Look for rgba(num%,num%,num%,num)
|
||||||
|
if (res = /rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))
|
||||||
|
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55, parseFloat(res[4]));
|
||||||
|
|
||||||
|
// Look for #a0b1c2
|
||||||
|
if (res = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))
|
||||||
|
return m(parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16));
|
||||||
|
|
||||||
|
// Look for #fff
|
||||||
|
if (res = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))
|
||||||
|
return m(parseInt(res[1]+res[1], 16), parseInt(res[2]+res[2], 16), parseInt(res[3]+res[3], 16));
|
||||||
|
|
||||||
|
// Otherwise, we're most likely dealing with a named color
|
||||||
|
var name = $.trim(str).toLowerCase();
|
||||||
|
if (name == "transparent")
|
||||||
|
return m(255, 255, 255, 0);
|
||||||
|
else {
|
||||||
|
// default to black
|
||||||
|
res = lookupColors[name] || [0, 0, 0];
|
||||||
|
return m(res[0], res[1], res[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var lookupColors = {
|
||||||
|
aqua:[0,255,255],
|
||||||
|
azure:[240,255,255],
|
||||||
|
beige:[245,245,220],
|
||||||
|
black:[0,0,0],
|
||||||
|
blue:[0,0,255],
|
||||||
|
brown:[165,42,42],
|
||||||
|
cyan:[0,255,255],
|
||||||
|
darkblue:[0,0,139],
|
||||||
|
darkcyan:[0,139,139],
|
||||||
|
darkgrey:[169,169,169],
|
||||||
|
darkgreen:[0,100,0],
|
||||||
|
darkkhaki:[189,183,107],
|
||||||
|
darkmagenta:[139,0,139],
|
||||||
|
darkolivegreen:[85,107,47],
|
||||||
|
darkorange:[255,140,0],
|
||||||
|
darkorchid:[153,50,204],
|
||||||
|
darkred:[139,0,0],
|
||||||
|
darksalmon:[233,150,122],
|
||||||
|
darkviolet:[148,0,211],
|
||||||
|
fuchsia:[255,0,255],
|
||||||
|
gold:[255,215,0],
|
||||||
|
green:[0,128,0],
|
||||||
|
indigo:[75,0,130],
|
||||||
|
khaki:[240,230,140],
|
||||||
|
lightblue:[173,216,230],
|
||||||
|
lightcyan:[224,255,255],
|
||||||
|
lightgreen:[144,238,144],
|
||||||
|
lightgrey:[211,211,211],
|
||||||
|
lightpink:[255,182,193],
|
||||||
|
lightyellow:[255,255,224],
|
||||||
|
lime:[0,255,0],
|
||||||
|
magenta:[255,0,255],
|
||||||
|
maroon:[128,0,0],
|
||||||
|
navy:[0,0,128],
|
||||||
|
olive:[128,128,0],
|
||||||
|
orange:[255,165,0],
|
||||||
|
pink:[255,192,203],
|
||||||
|
purple:[128,0,128],
|
||||||
|
violet:[128,0,128],
|
||||||
|
red:[255,0,0],
|
||||||
|
silver:[192,192,192],
|
||||||
|
white:[255,255,255],
|
||||||
|
yellow:[255,255,0]
|
||||||
|
};
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.colorhelpers.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.colorhelpers.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(b){b.color={};b.color.make=function(f,e,c,d){var h={};h.r=f||0;h.g=e||0;h.b=c||0;h.a=d!=null?d:1;h.add=function(k,j){for(var g=0;g<k.length;++g){h[k.charAt(g)]+=j}return h.normalize()};h.scale=function(k,j){for(var g=0;g<k.length;++g){h[k.charAt(g)]*=j}return h.normalize()};h.toString=function(){if(h.a>=1){return"rgb("+[h.r,h.g,h.b].join(",")+")"}else{return"rgba("+[h.r,h.g,h.b,h.a].join(",")+")"}};h.normalize=function(){function g(j,k,i){return k<j?j:(k>i?i:k)}h.r=g(0,parseInt(h.r),255);h.g=g(0,parseInt(h.g),255);h.b=g(0,parseInt(h.b),255);h.a=g(0,h.a,1);return h};h.clone=function(){return b.color.make(h.r,h.b,h.g,h.a)};return h.normalize()};b.color.extract=function(e,d){var f;do{f=e.css(d).toLowerCase();if(f!=""&&f!="transparent"){break}e=e.parent()}while(!b.nodeName(e.get(0),"body"));if(f=="rgba(0, 0, 0, 0)"){f="transparent"}return b.color.parse(f)};b.color.parse=function(f){var e,c=b.color.make;if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return c(parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10))}if(e=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(f)){return c(parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),parseFloat(e[4]))}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return c(parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55)}if(e=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(f)){return c(parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55,parseFloat(e[4]))}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return c(parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16))}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return c(parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16))}var d=b.trim(f).toLowerCase();if(d=="transparent"){return c(255,255,255,0)}else{e=a[d]||[0,0,0];return c(e[0],e[1],e[2])}};var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
|
167
src/sunstone/public/vendor/flot/jquery.flot.crosshair.js
vendored
Normal file
167
src/sunstone/public/vendor/flot/jquery.flot.crosshair.js
vendored
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for showing crosshairs, thin lines, when the mouse hovers
|
||||||
|
over the plot.
|
||||||
|
|
||||||
|
crosshair: {
|
||||||
|
mode: null or "x" or "y" or "xy"
|
||||||
|
color: color
|
||||||
|
lineWidth: number
|
||||||
|
}
|
||||||
|
|
||||||
|
Set the mode to one of "x", "y" or "xy". The "x" mode enables a
|
||||||
|
vertical crosshair that lets you trace the values on the x axis, "y"
|
||||||
|
enables a horizontal crosshair and "xy" enables them both. "color" is
|
||||||
|
the color of the crosshair (default is "rgba(170, 0, 0, 0.80)"),
|
||||||
|
"lineWidth" is the width of the drawn lines (default is 1).
|
||||||
|
|
||||||
|
The plugin also adds four public methods:
|
||||||
|
|
||||||
|
- setCrosshair(pos)
|
||||||
|
|
||||||
|
Set the position of the crosshair. Note that this is cleared if
|
||||||
|
the user moves the mouse. "pos" is in coordinates of the plot and
|
||||||
|
should be on the form { x: xpos, y: ypos } (you can use x2/x3/...
|
||||||
|
if you're using multiple axes), which is coincidentally the same
|
||||||
|
format as what you get from a "plothover" event. If "pos" is null,
|
||||||
|
the crosshair is cleared.
|
||||||
|
|
||||||
|
- clearCrosshair()
|
||||||
|
|
||||||
|
Clear the crosshair.
|
||||||
|
|
||||||
|
- lockCrosshair(pos)
|
||||||
|
|
||||||
|
Cause the crosshair to lock to the current location, no longer
|
||||||
|
updating if the user moves the mouse. Optionally supply a position
|
||||||
|
(passed on to setCrosshair()) to move it to.
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
var myFlot = $.plot( $("#graph"), ..., { crosshair: { mode: "x" } } };
|
||||||
|
$("#graph").bind("plothover", function (evt, position, item) {
|
||||||
|
if (item) {
|
||||||
|
// Lock the crosshair to the data point being hovered
|
||||||
|
myFlot.lockCrosshair({ x: item.datapoint[0], y: item.datapoint[1] });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Return normal crosshair operation
|
||||||
|
myFlot.unlockCrosshair();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
- unlockCrosshair()
|
||||||
|
|
||||||
|
Free the crosshair to move again after locking it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
crosshair: {
|
||||||
|
mode: null, // one of null, "x", "y" or "xy",
|
||||||
|
color: "rgba(170, 0, 0, 0.80)",
|
||||||
|
lineWidth: 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
// position of crosshair in pixels
|
||||||
|
var crosshair = { x: -1, y: -1, locked: false };
|
||||||
|
|
||||||
|
plot.setCrosshair = function setCrosshair(pos) {
|
||||||
|
if (!pos)
|
||||||
|
crosshair.x = -1;
|
||||||
|
else {
|
||||||
|
var o = plot.p2c(pos);
|
||||||
|
crosshair.x = Math.max(0, Math.min(o.left, plot.width()));
|
||||||
|
crosshair.y = Math.max(0, Math.min(o.top, plot.height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
};
|
||||||
|
|
||||||
|
plot.clearCrosshair = plot.setCrosshair; // passes null for pos
|
||||||
|
|
||||||
|
plot.lockCrosshair = function lockCrosshair(pos) {
|
||||||
|
if (pos)
|
||||||
|
plot.setCrosshair(pos);
|
||||||
|
crosshair.locked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.unlockCrosshair = function unlockCrosshair() {
|
||||||
|
crosshair.locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseOut(e) {
|
||||||
|
if (crosshair.locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (crosshair.x != -1) {
|
||||||
|
crosshair.x = -1;
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseMove(e) {
|
||||||
|
if (crosshair.locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (plot.getSelection && plot.getSelection()) {
|
||||||
|
crosshair.x = -1; // hide the crosshair while selecting
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var offset = plot.offset();
|
||||||
|
crosshair.x = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));
|
||||||
|
crosshair.y = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.bindEvents.push(function (plot, eventHolder) {
|
||||||
|
if (!plot.getOptions().crosshair.mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
eventHolder.mouseout(onMouseOut);
|
||||||
|
eventHolder.mousemove(onMouseMove);
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
||||||
|
var c = plot.getOptions().crosshair;
|
||||||
|
if (!c.mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var plotOffset = plot.getPlotOffset();
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(plotOffset.left, plotOffset.top);
|
||||||
|
|
||||||
|
if (crosshair.x != -1) {
|
||||||
|
ctx.strokeStyle = c.color;
|
||||||
|
ctx.lineWidth = c.lineWidth;
|
||||||
|
ctx.lineJoin = "round";
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
if (c.mode.indexOf("x") != -1) {
|
||||||
|
ctx.moveTo(crosshair.x, 0);
|
||||||
|
ctx.lineTo(crosshair.x, plot.height());
|
||||||
|
}
|
||||||
|
if (c.mode.indexOf("y") != -1) {
|
||||||
|
ctx.moveTo(0, crosshair.y);
|
||||||
|
ctx.lineTo(plot.width(), crosshair.y);
|
||||||
|
}
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
||||||
|
eventHolder.unbind("mouseout", onMouseOut);
|
||||||
|
eventHolder.unbind("mousemove", onMouseMove);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'crosshair',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.crosshair.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.crosshair.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(b){var a={crosshair:{mode:null,color:"rgba(170, 0, 0, 0.80)",lineWidth:1}};function c(h){var j={x:-1,y:-1,locked:false};h.setCrosshair=function e(l){if(!l){j.x=-1}else{var k=h.p2c(l);j.x=Math.max(0,Math.min(k.left,h.width()));j.y=Math.max(0,Math.min(k.top,h.height()))}h.triggerRedrawOverlay()};h.clearCrosshair=h.setCrosshair;h.lockCrosshair=function f(k){if(k){h.setCrosshair(k)}j.locked=true};h.unlockCrosshair=function g(){j.locked=false};function d(k){if(j.locked){return}if(j.x!=-1){j.x=-1;h.triggerRedrawOverlay()}}function i(k){if(j.locked){return}if(h.getSelection&&h.getSelection()){j.x=-1;return}var l=h.offset();j.x=Math.max(0,Math.min(k.pageX-l.left,h.width()));j.y=Math.max(0,Math.min(k.pageY-l.top,h.height()));h.triggerRedrawOverlay()}h.hooks.bindEvents.push(function(l,k){if(!l.getOptions().crosshair.mode){return}k.mouseout(d);k.mousemove(i)});h.hooks.drawOverlay.push(function(m,k){var n=m.getOptions().crosshair;if(!n.mode){return}var l=m.getPlotOffset();k.save();k.translate(l.left,l.top);if(j.x!=-1){k.strokeStyle=n.color;k.lineWidth=n.lineWidth;k.lineJoin="round";k.beginPath();if(n.mode.indexOf("x")!=-1){k.moveTo(j.x,0);k.lineTo(j.x,m.height())}if(n.mode.indexOf("y")!=-1){k.moveTo(0,j.y);k.lineTo(m.width(),j.y)}k.stroke()}k.restore()});h.hooks.shutdown.push(function(l,k){k.unbind("mouseout",d);k.unbind("mousemove",i)})}b.plot.plugins.push({init:c,options:a,name:"crosshair",version:"1.0"})})(jQuery);
|
183
src/sunstone/public/vendor/flot/jquery.flot.fillbetween.js
vendored
Normal file
183
src/sunstone/public/vendor/flot/jquery.flot.fillbetween.js
vendored
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for computing bottoms for filled line and bar charts.
|
||||||
|
|
||||||
|
The case: you've got two series that you want to fill the area
|
||||||
|
between. In Flot terms, you need to use one as the fill bottom of the
|
||||||
|
other. You can specify the bottom of each data point as the third
|
||||||
|
coordinate manually, or you can use this plugin to compute it for you.
|
||||||
|
|
||||||
|
In order to name the other series, you need to give it an id, like this
|
||||||
|
|
||||||
|
var dataset = [
|
||||||
|
{ data: [ ... ], id: "foo" } , // use default bottom
|
||||||
|
{ data: [ ... ], fillBetween: "foo" }, // use first dataset as bottom
|
||||||
|
];
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), dataset, { line: { show: true, fill: true }});
|
||||||
|
|
||||||
|
As a convenience, if the id given is a number that doesn't appear as
|
||||||
|
an id in the series, it is interpreted as the index in the array
|
||||||
|
instead (so fillBetween: 0 can also mean the first series).
|
||||||
|
|
||||||
|
Internally, the plugin modifies the datapoints in each series. For
|
||||||
|
line series, extra data points might be inserted through
|
||||||
|
interpolation. Note that at points where the bottom line is not
|
||||||
|
defined (due to a null point or start/end of line), the current line
|
||||||
|
will show a gap too. The algorithm comes from the jquery.flot.stack.js
|
||||||
|
plugin, possibly some code could be shared.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
series: { fillBetween: null } // or number
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function findBottomSeries(s, allseries) {
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < allseries.length; ++i) {
|
||||||
|
if (allseries[i].id == s.fillBetween)
|
||||||
|
return allseries[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof s.fillBetween == "number") {
|
||||||
|
i = s.fillBetween;
|
||||||
|
|
||||||
|
if (i < 0 || i >= allseries.length)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return allseries[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeFillBottoms(plot, s, datapoints) {
|
||||||
|
if (s.fillBetween == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var other = findBottomSeries(s, plot.getData());
|
||||||
|
if (!other)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ps = datapoints.pointsize,
|
||||||
|
points = datapoints.points,
|
||||||
|
otherps = other.datapoints.pointsize,
|
||||||
|
otherpoints = other.datapoints.points,
|
||||||
|
newpoints = [],
|
||||||
|
px, py, intery, qx, qy, bottom,
|
||||||
|
withlines = s.lines.show,
|
||||||
|
withbottom = ps > 2 && datapoints.format[2].y,
|
||||||
|
withsteps = withlines && s.lines.steps,
|
||||||
|
fromgap = true,
|
||||||
|
i = 0, j = 0, l;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (i >= points.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
l = newpoints.length;
|
||||||
|
|
||||||
|
if (points[i] == null) {
|
||||||
|
// copy gaps
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
else if (j >= otherpoints.length) {
|
||||||
|
// for lines, we can't use the rest of the points
|
||||||
|
if (!withlines) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
}
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
else if (otherpoints[j] == null) {
|
||||||
|
// oops, got a gap
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(null);
|
||||||
|
fromgap = true;
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// cases where we actually got two points
|
||||||
|
px = points[i];
|
||||||
|
py = points[i + 1];
|
||||||
|
qx = otherpoints[j];
|
||||||
|
qy = otherpoints[j + 1];
|
||||||
|
bottom = 0;
|
||||||
|
|
||||||
|
if (px == qx) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
//newpoints[l + 1] += qy;
|
||||||
|
bottom = qy;
|
||||||
|
|
||||||
|
i += ps;
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else if (px > qx) {
|
||||||
|
// we got past point below, might need to
|
||||||
|
// insert interpolated extra point
|
||||||
|
if (withlines && i > 0 && points[i - ps] != null) {
|
||||||
|
intery = py + (points[i - ps + 1] - py) * (qx - px) / (points[i - ps] - px);
|
||||||
|
newpoints.push(qx);
|
||||||
|
newpoints.push(intery)
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
bottom = qy;
|
||||||
|
}
|
||||||
|
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else { // px < qx
|
||||||
|
if (fromgap && withlines) {
|
||||||
|
// if we come from a gap, we just skip this point
|
||||||
|
i += ps;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
// we might be able to interpolate a point below,
|
||||||
|
// this can give us a better y
|
||||||
|
if (withlines && j > 0 && otherpoints[j - otherps] != null)
|
||||||
|
bottom = qy + (otherpoints[j - otherps + 1] - qy) * (px - qx) / (otherpoints[j - otherps] - qx);
|
||||||
|
|
||||||
|
//newpoints[l + 1] += bottom;
|
||||||
|
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromgap = false;
|
||||||
|
|
||||||
|
if (l != newpoints.length && withbottom)
|
||||||
|
newpoints[l + 2] = bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
// maintain the line steps invariant
|
||||||
|
if (withsteps && l != newpoints.length && l > 0
|
||||||
|
&& newpoints[l] != null
|
||||||
|
&& newpoints[l] != newpoints[l - ps]
|
||||||
|
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints[l + ps + m] = newpoints[l + m];
|
||||||
|
newpoints[l + 1] = newpoints[l - ps + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
datapoints.points = newpoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.processDatapoints.push(computeFillBottoms);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'fillbetween',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.fillbetween.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.fillbetween.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(b){var a={series:{fillBetween:null}};function c(f){function d(j,h){var g;for(g=0;g<h.length;++g){if(h[g].id==j.fillBetween){return h[g]}}if(typeof j.fillBetween=="number"){g=j.fillBetween;if(g<0||g>=h.length){return null}return h[g]}return null}function e(B,u,g){if(u.fillBetween==null){return}var p=d(u,B.getData());if(!p){return}var y=g.pointsize,E=g.points,h=p.datapoints.pointsize,x=p.datapoints.points,r=[],w,v,k,G,F,q,t=u.lines.show,o=y>2&&g.format[2].y,n=t&&u.lines.steps,D=true,C=0,A=0,z;while(true){if(C>=E.length){break}z=r.length;if(E[C]==null){for(m=0;m<y;++m){r.push(E[C+m])}C+=y}else{if(A>=x.length){if(!t){for(m=0;m<y;++m){r.push(E[C+m])}}C+=y}else{if(x[A]==null){for(m=0;m<y;++m){r.push(null)}D=true;A+=h}else{w=E[C];v=E[C+1];G=x[A];F=x[A+1];q=0;if(w==G){for(m=0;m<y;++m){r.push(E[C+m])}q=F;C+=y;A+=h}else{if(w>G){if(t&&C>0&&E[C-y]!=null){k=v+(E[C-y+1]-v)*(G-w)/(E[C-y]-w);r.push(G);r.push(k);for(m=2;m<y;++m){r.push(E[C+m])}q=F}A+=h}else{if(D&&t){C+=y;continue}for(m=0;m<y;++m){r.push(E[C+m])}if(t&&A>0&&x[A-h]!=null){q=F+(x[A-h+1]-F)*(w-G)/(x[A-h]-G)}C+=y}}D=false;if(z!=r.length&&o){r[z+2]=q}}}}if(n&&z!=r.length&&z>0&&r[z]!=null&&r[z]!=r[z-y]&&r[z+1]!=r[z-y+1]){for(m=0;m<y;++m){r[z+y+m]=r[z+m]}r[z+1]=r[z-y+1]}}g.points=r}f.hooks.processDatapoints.push(e)}b.plot.plugins.push({init:c,options:a,name:"fillbetween",version:"1.0"})})(jQuery);
|
238
src/sunstone/public/vendor/flot/jquery.flot.image.js
vendored
Normal file
238
src/sunstone/public/vendor/flot/jquery.flot.image.js
vendored
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for plotting images, e.g. useful for putting ticks on a
|
||||||
|
prerendered complex visualization.
|
||||||
|
|
||||||
|
The data syntax is [[image, x1, y1, x2, y2], ...] where (x1, y1) and
|
||||||
|
(x2, y2) are where you intend the two opposite corners of the image to
|
||||||
|
end up in the plot. Image must be a fully loaded Javascript image (you
|
||||||
|
can make one with new Image()). If the image is not complete, it's
|
||||||
|
skipped when plotting.
|
||||||
|
|
||||||
|
There are two helpers included for retrieving images. The easiest work
|
||||||
|
the way that you put in URLs instead of images in the data (like
|
||||||
|
["myimage.png", 0, 0, 10, 10]), then call $.plot.image.loadData(data,
|
||||||
|
options, callback) where data and options are the same as you pass in
|
||||||
|
to $.plot. This loads the images, replaces the URLs in the data with
|
||||||
|
the corresponding images and calls "callback" when all images are
|
||||||
|
loaded (or failed loading). In the callback, you can then call $.plot
|
||||||
|
with the data set. See the included example.
|
||||||
|
|
||||||
|
A more low-level helper, $.plot.image.load(urls, callback) is also
|
||||||
|
included. Given a list of URLs, it calls callback with an object
|
||||||
|
mapping from URL to Image object when all images are loaded or have
|
||||||
|
failed loading.
|
||||||
|
|
||||||
|
Options for the plugin are
|
||||||
|
|
||||||
|
series: {
|
||||||
|
images: {
|
||||||
|
show: boolean
|
||||||
|
anchor: "corner" or "center"
|
||||||
|
alpha: [0,1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
which can be specified for a specific series
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [{ data: [ ... ], images: { ... } ])
|
||||||
|
|
||||||
|
Note that because the data format is different from usual data points,
|
||||||
|
you can't use images with anything else in a specific data series.
|
||||||
|
|
||||||
|
Setting "anchor" to "center" causes the pixels in the image to be
|
||||||
|
anchored at the corner pixel centers inside of at the pixel corners,
|
||||||
|
effectively letting half a pixel stick out to each side in the plot.
|
||||||
|
|
||||||
|
|
||||||
|
A possible future direction could be support for tiling for large
|
||||||
|
images (like Google Maps).
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
series: {
|
||||||
|
images: {
|
||||||
|
show: false,
|
||||||
|
alpha: 1,
|
||||||
|
anchor: "corner" // or "center"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.plot.image = {};
|
||||||
|
|
||||||
|
$.plot.image.loadDataImages = function (series, options, callback) {
|
||||||
|
var urls = [], points = [];
|
||||||
|
|
||||||
|
var defaultShow = options.series.images.show;
|
||||||
|
|
||||||
|
$.each(series, function (i, s) {
|
||||||
|
if (!(defaultShow || s.images.show))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (s.data)
|
||||||
|
s = s.data;
|
||||||
|
|
||||||
|
$.each(s, function (i, p) {
|
||||||
|
if (typeof p[0] == "string") {
|
||||||
|
urls.push(p[0]);
|
||||||
|
points.push(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$.plot.image.load(urls, function (loadedImages) {
|
||||||
|
$.each(points, function (i, p) {
|
||||||
|
var url = p[0];
|
||||||
|
if (loadedImages[url])
|
||||||
|
p[0] = loadedImages[url];
|
||||||
|
});
|
||||||
|
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.image.load = function (urls, callback) {
|
||||||
|
var missing = urls.length, loaded = {};
|
||||||
|
if (missing == 0)
|
||||||
|
callback({});
|
||||||
|
|
||||||
|
$.each(urls, function (i, url) {
|
||||||
|
var handler = function () {
|
||||||
|
--missing;
|
||||||
|
|
||||||
|
loaded[url] = this;
|
||||||
|
|
||||||
|
if (missing == 0)
|
||||||
|
callback(loaded);
|
||||||
|
};
|
||||||
|
|
||||||
|
$('<img />').load(handler).error(handler).attr('src', url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawSeries(plot, ctx, series) {
|
||||||
|
var plotOffset = plot.getPlotOffset();
|
||||||
|
|
||||||
|
if (!series.images || !series.images.show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var points = series.datapoints.points,
|
||||||
|
ps = series.datapoints.pointsize;
|
||||||
|
|
||||||
|
for (var i = 0; i < points.length; i += ps) {
|
||||||
|
var img = points[i],
|
||||||
|
x1 = points[i + 1], y1 = points[i + 2],
|
||||||
|
x2 = points[i + 3], y2 = points[i + 4],
|
||||||
|
xaxis = series.xaxis, yaxis = series.yaxis,
|
||||||
|
tmp;
|
||||||
|
|
||||||
|
// actually we should check img.complete, but it
|
||||||
|
// appears to be a somewhat unreliable indicator in
|
||||||
|
// IE6 (false even after load event)
|
||||||
|
if (!img || img.width <= 0 || img.height <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (x1 > x2) {
|
||||||
|
tmp = x2;
|
||||||
|
x2 = x1;
|
||||||
|
x1 = tmp;
|
||||||
|
}
|
||||||
|
if (y1 > y2) {
|
||||||
|
tmp = y2;
|
||||||
|
y2 = y1;
|
||||||
|
y1 = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the anchor is at the center of the pixel, expand the
|
||||||
|
// image by 1/2 pixel in each direction
|
||||||
|
if (series.images.anchor == "center") {
|
||||||
|
tmp = 0.5 * (x2-x1) / (img.width - 1);
|
||||||
|
x1 -= tmp;
|
||||||
|
x2 += tmp;
|
||||||
|
tmp = 0.5 * (y2-y1) / (img.height - 1);
|
||||||
|
y1 -= tmp;
|
||||||
|
y2 += tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clip
|
||||||
|
if (x1 == x2 || y1 == y2 ||
|
||||||
|
x1 >= xaxis.max || x2 <= xaxis.min ||
|
||||||
|
y1 >= yaxis.max || y2 <= yaxis.min)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var sx1 = 0, sy1 = 0, sx2 = img.width, sy2 = img.height;
|
||||||
|
if (x1 < xaxis.min) {
|
||||||
|
sx1 += (sx2 - sx1) * (xaxis.min - x1) / (x2 - x1);
|
||||||
|
x1 = xaxis.min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x2 > xaxis.max) {
|
||||||
|
sx2 += (sx2 - sx1) * (xaxis.max - x2) / (x2 - x1);
|
||||||
|
x2 = xaxis.max;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y1 < yaxis.min) {
|
||||||
|
sy2 += (sy1 - sy2) * (yaxis.min - y1) / (y2 - y1);
|
||||||
|
y1 = yaxis.min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y2 > yaxis.max) {
|
||||||
|
sy1 += (sy1 - sy2) * (yaxis.max - y2) / (y2 - y1);
|
||||||
|
y2 = yaxis.max;
|
||||||
|
}
|
||||||
|
|
||||||
|
x1 = xaxis.p2c(x1);
|
||||||
|
x2 = xaxis.p2c(x2);
|
||||||
|
y1 = yaxis.p2c(y1);
|
||||||
|
y2 = yaxis.p2c(y2);
|
||||||
|
|
||||||
|
// the transformation may have swapped us
|
||||||
|
if (x1 > x2) {
|
||||||
|
tmp = x2;
|
||||||
|
x2 = x1;
|
||||||
|
x1 = tmp;
|
||||||
|
}
|
||||||
|
if (y1 > y2) {
|
||||||
|
tmp = y2;
|
||||||
|
y2 = y1;
|
||||||
|
y1 = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = ctx.globalAlpha;
|
||||||
|
ctx.globalAlpha *= series.images.alpha;
|
||||||
|
ctx.drawImage(img,
|
||||||
|
sx1, sy1, sx2 - sx1, sy2 - sy1,
|
||||||
|
x1 + plotOffset.left, y1 + plotOffset.top,
|
||||||
|
x2 - x1, y2 - y1);
|
||||||
|
ctx.globalAlpha = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function processRawData(plot, series, data, datapoints) {
|
||||||
|
if (!series.images.show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// format is Image, x1, y1, x2, y2 (opposite corners)
|
||||||
|
datapoints.format = [
|
||||||
|
{ required: true },
|
||||||
|
{ x: true, number: true, required: true },
|
||||||
|
{ y: true, number: true, required: true },
|
||||||
|
{ x: true, number: true, required: true },
|
||||||
|
{ y: true, number: true, required: true }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
plot.hooks.processRawData.push(processRawData);
|
||||||
|
plot.hooks.drawSeries.push(drawSeries);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'image',
|
||||||
|
version: '1.1'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.image.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.image.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(c){var a={series:{images:{show:false,alpha:1,anchor:"corner"}}};c.plot.image={};c.plot.image.loadDataImages=function(g,f,k){var j=[],h=[];var i=f.series.images.show;c.each(g,function(l,m){if(!(i||m.images.show)){return}if(m.data){m=m.data}c.each(m,function(n,o){if(typeof o[0]=="string"){j.push(o[0]);h.push(o)}})});c.plot.image.load(j,function(l){c.each(h,function(n,o){var m=o[0];if(l[m]){o[0]=l[m]}});k()})};c.plot.image.load=function(h,i){var g=h.length,f={};if(g==0){i({})}c.each(h,function(k,j){var l=function(){--g;f[j]=this;if(g==0){i(f)}};c("<img />").load(l).error(l).attr("src",j)})};function d(q,o,l){var m=q.getPlotOffset();if(!l.images||!l.images.show){return}var r=l.datapoints.points,n=l.datapoints.pointsize;for(var t=0;t<r.length;t+=n){var y=r[t],w=r[t+1],g=r[t+2],v=r[t+3],f=r[t+4],h=l.xaxis,u=l.yaxis,x;if(!y||y.width<=0||y.height<=0){continue}if(w>v){x=v;v=w;w=x}if(g>f){x=f;f=g;g=x}if(l.images.anchor=="center"){x=0.5*(v-w)/(y.width-1);w-=x;v+=x;x=0.5*(f-g)/(y.height-1);g-=x;f+=x}if(w==v||g==f||w>=h.max||v<=h.min||g>=u.max||f<=u.min){continue}var k=0,s=0,j=y.width,p=y.height;if(w<h.min){k+=(j-k)*(h.min-w)/(v-w);w=h.min}if(v>h.max){j+=(j-k)*(h.max-v)/(v-w);v=h.max}if(g<u.min){p+=(s-p)*(u.min-g)/(f-g);g=u.min}if(f>u.max){s+=(s-p)*(u.max-f)/(f-g);f=u.max}w=h.p2c(w);v=h.p2c(v);g=u.p2c(g);f=u.p2c(f);if(w>v){x=v;v=w;w=x}if(g>f){x=f;f=g;g=x}x=o.globalAlpha;o.globalAlpha*=l.images.alpha;o.drawImage(y,k,s,j-k,p-s,w+m.left,g+m.top,v-w,f-g);o.globalAlpha=x}}function b(i,f,g,h){if(!f.images.show){return}h.format=[{required:true},{x:true,number:true,required:true},{y:true,number:true,required:true},{x:true,number:true,required:true},{y:true,number:true,required:true}]}function e(f){f.hooks.processRawData.push(b);f.hooks.drawSeries.push(d)}c.plot.plugins.push({init:e,options:a,name:"image",version:"1.1"})})(jQuery);
|
2599
src/sunstone/public/vendor/flot/jquery.flot.js
vendored
Normal file
2599
src/sunstone/public/vendor/flot/jquery.flot.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
src/sunstone/public/vendor/flot/jquery.flot.min.js
vendored
Normal file
6
src/sunstone/public/vendor/flot/jquery.flot.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
336
src/sunstone/public/vendor/flot/jquery.flot.navigate.js
vendored
Normal file
336
src/sunstone/public/vendor/flot/jquery.flot.navigate.js
vendored
Normal file
@ -0,0 +1,336 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for adding panning and zooming capabilities to a plot.
|
||||||
|
|
||||||
|
The default behaviour is double click and scrollwheel up/down to zoom
|
||||||
|
in, drag to pan. The plugin defines plot.zoom({ center }),
|
||||||
|
plot.zoomOut() and plot.pan(offset) so you easily can add custom
|
||||||
|
controls. It also fires a "plotpan" and "plotzoom" event when
|
||||||
|
something happens, useful for synchronizing plots.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
zoom: {
|
||||||
|
interactive: false
|
||||||
|
trigger: "dblclick" // or "click" for single click
|
||||||
|
amount: 1.5 // 2 = 200% (zoom in), 0.5 = 50% (zoom out)
|
||||||
|
}
|
||||||
|
|
||||||
|
pan: {
|
||||||
|
interactive: false
|
||||||
|
cursor: "move" // CSS mouse cursor value used when dragging, e.g. "pointer"
|
||||||
|
frameRate: 20
|
||||||
|
}
|
||||||
|
|
||||||
|
xaxis, yaxis, x2axis, y2axis: {
|
||||||
|
zoomRange: null // or [number, number] (min range, max range) or false
|
||||||
|
panRange: null // or [number, number] (min, max) or false
|
||||||
|
}
|
||||||
|
|
||||||
|
"interactive" enables the built-in drag/click behaviour. If you enable
|
||||||
|
interactive for pan, then you'll have a basic plot that supports
|
||||||
|
moving around; the same for zoom.
|
||||||
|
|
||||||
|
"amount" specifies the default amount to zoom in (so 1.5 = 150%)
|
||||||
|
relative to the current viewport.
|
||||||
|
|
||||||
|
"cursor" is a standard CSS mouse cursor string used for visual
|
||||||
|
feedback to the user when dragging.
|
||||||
|
|
||||||
|
"frameRate" specifies the maximum number of times per second the plot
|
||||||
|
will update itself while the user is panning around on it (set to null
|
||||||
|
to disable intermediate pans, the plot will then not update until the
|
||||||
|
mouse button is released).
|
||||||
|
|
||||||
|
"zoomRange" is the interval in which zooming can happen, e.g. with
|
||||||
|
zoomRange: [1, 100] the zoom will never scale the axis so that the
|
||||||
|
difference between min and max is smaller than 1 or larger than 100.
|
||||||
|
You can set either end to null to ignore, e.g. [1, null]. If you set
|
||||||
|
zoomRange to false, zooming on that axis will be disabled.
|
||||||
|
|
||||||
|
"panRange" confines the panning to stay within a range, e.g. with
|
||||||
|
panRange: [-10, 20] panning stops at -10 in one end and at 20 in the
|
||||||
|
other. Either can be null, e.g. [-10, null]. If you set
|
||||||
|
panRange to false, panning on that axis will be disabled.
|
||||||
|
|
||||||
|
Example API usage:
|
||||||
|
|
||||||
|
plot = $.plot(...);
|
||||||
|
|
||||||
|
// zoom default amount in on the pixel (10, 20)
|
||||||
|
plot.zoom({ center: { left: 10, top: 20 } });
|
||||||
|
|
||||||
|
// zoom out again
|
||||||
|
plot.zoomOut({ center: { left: 10, top: 20 } });
|
||||||
|
|
||||||
|
// zoom 200% in on the pixel (10, 20)
|
||||||
|
plot.zoom({ amount: 2, center: { left: 10, top: 20 } });
|
||||||
|
|
||||||
|
// pan 100 pixels to the left and 20 down
|
||||||
|
plot.pan({ left: -100, top: 20 })
|
||||||
|
|
||||||
|
Here, "center" specifies where the center of the zooming should
|
||||||
|
happen. Note that this is defined in pixel space, not the space of the
|
||||||
|
data points (you can use the p2c helpers on the axes in Flot to help
|
||||||
|
you convert between these).
|
||||||
|
|
||||||
|
"amount" is the amount to zoom the viewport relative to the current
|
||||||
|
range, so 1 is 100% (i.e. no change), 1.5 is 150% (zoom in), 0.7 is
|
||||||
|
70% (zoom out). You can set the default in the options.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// First two dependencies, jquery.event.drag.js and
|
||||||
|
// jquery.mousewheel.js, we put them inline here to save people the
|
||||||
|
// effort of downloading them.
|
||||||
|
|
||||||
|
/*
|
||||||
|
jquery.event.drag.js ~ v1.5 ~ Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
|
||||||
|
Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-LICENSE.txt
|
||||||
|
*/
|
||||||
|
(function(E){E.fn.drag=function(L,K,J){if(K){this.bind("dragstart",L)}if(J){this.bind("dragend",J)}return !L?this.trigger("drag"):this.bind("drag",K?K:L)};var A=E.event,B=A.special,F=B.drag={not:":input",distance:0,which:1,dragging:false,setup:function(J){J=E.extend({distance:F.distance,which:F.which,not:F.not},J||{});J.distance=I(J.distance);A.add(this,"mousedown",H,J);if(this.attachEvent){this.attachEvent("ondragstart",D)}},teardown:function(){A.remove(this,"mousedown",H);if(this===F.dragging){F.dragging=F.proxy=false}G(this,true);if(this.detachEvent){this.detachEvent("ondragstart",D)}}};B.dragstart=B.dragend={setup:function(){},teardown:function(){}};function H(L){var K=this,J,M=L.data||{};if(M.elem){K=L.dragTarget=M.elem;L.dragProxy=F.proxy||K;L.cursorOffsetX=M.pageX-M.left;L.cursorOffsetY=M.pageY-M.top;L.offsetX=L.pageX-L.cursorOffsetX;L.offsetY=L.pageY-L.cursorOffsetY}else{if(F.dragging||(M.which>0&&L.which!=M.which)||E(L.target).is(M.not)){return }}switch(L.type){case"mousedown":E.extend(M,E(K).offset(),{elem:K,target:L.target,pageX:L.pageX,pageY:L.pageY});A.add(document,"mousemove mouseup",H,M);G(K,false);F.dragging=null;return false;case !F.dragging&&"mousemove":if(I(L.pageX-M.pageX)+I(L.pageY-M.pageY)<M.distance){break}L.target=M.target;J=C(L,"dragstart",K);if(J!==false){F.dragging=K;F.proxy=L.dragProxy=E(J||K)[0]}case"mousemove":if(F.dragging){J=C(L,"drag",K);if(B.drop){B.drop.allowed=(J!==false);B.drop.handler(L)}if(J!==false){break}L.type="mouseup"}case"mouseup":A.remove(document,"mousemove mouseup",H);if(F.dragging){if(B.drop){B.drop.handler(L)}C(L,"dragend",K)}G(K,true);F.dragging=F.proxy=M.elem=false;break}return true}function C(M,K,L){M.type=K;var J=E.event.handle.call(L,M);return J===false?false:J||M.result}function I(J){return Math.pow(J,2)}function D(){return(F.dragging===false)}function G(K,J){if(!K){return }K.unselectable=J?"off":"on";K.onselectstart=function(){return J};if(K.style){K.style.MozUserSelect=J?"":"none"}}})(jQuery);
|
||||||
|
|
||||||
|
|
||||||
|
/* jquery.mousewheel.min.js
|
||||||
|
* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
|
||||||
|
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||||
|
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||||
|
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||||
|
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||||
|
*
|
||||||
|
* Version: 3.0.2
|
||||||
|
*
|
||||||
|
* Requires: 1.2.2+
|
||||||
|
*/
|
||||||
|
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
xaxis: {
|
||||||
|
zoomRange: null, // or [number, number] (min range, max range)
|
||||||
|
panRange: null // or [number, number] (min, max)
|
||||||
|
},
|
||||||
|
zoom: {
|
||||||
|
interactive: false,
|
||||||
|
trigger: "dblclick", // or "click" for single click
|
||||||
|
amount: 1.5 // how much to zoom relative to current position, 2 = 200% (zoom in), 0.5 = 50% (zoom out)
|
||||||
|
},
|
||||||
|
pan: {
|
||||||
|
interactive: false,
|
||||||
|
cursor: "move",
|
||||||
|
frameRate: 20
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function onZoomClick(e, zoomOut) {
|
||||||
|
var c = plot.offset();
|
||||||
|
c.left = e.pageX - c.left;
|
||||||
|
c.top = e.pageY - c.top;
|
||||||
|
if (zoomOut)
|
||||||
|
plot.zoomOut({ center: c });
|
||||||
|
else
|
||||||
|
plot.zoom({ center: c });
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseWheel(e, delta) {
|
||||||
|
onZoomClick(e, delta < 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var prevCursor = 'default', prevPageX = 0, prevPageY = 0,
|
||||||
|
panTimeout = null;
|
||||||
|
|
||||||
|
function onDragStart(e) {
|
||||||
|
if (e.which != 1) // only accept left-click
|
||||||
|
return false;
|
||||||
|
var c = plot.getPlaceholder().css('cursor');
|
||||||
|
if (c)
|
||||||
|
prevCursor = c;
|
||||||
|
plot.getPlaceholder().css('cursor', plot.getOptions().pan.cursor);
|
||||||
|
prevPageX = e.pageX;
|
||||||
|
prevPageY = e.pageY;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDrag(e) {
|
||||||
|
var frameRate = plot.getOptions().pan.frameRate;
|
||||||
|
if (panTimeout || !frameRate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
panTimeout = setTimeout(function () {
|
||||||
|
plot.pan({ left: prevPageX - e.pageX,
|
||||||
|
top: prevPageY - e.pageY });
|
||||||
|
prevPageX = e.pageX;
|
||||||
|
prevPageY = e.pageY;
|
||||||
|
|
||||||
|
panTimeout = null;
|
||||||
|
}, 1 / frameRate * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDragEnd(e) {
|
||||||
|
if (panTimeout) {
|
||||||
|
clearTimeout(panTimeout);
|
||||||
|
panTimeout = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.getPlaceholder().css('cursor', prevCursor);
|
||||||
|
plot.pan({ left: prevPageX - e.pageX,
|
||||||
|
top: prevPageY - e.pageY });
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindEvents(plot, eventHolder) {
|
||||||
|
var o = plot.getOptions();
|
||||||
|
if (o.zoom.interactive) {
|
||||||
|
eventHolder[o.zoom.trigger](onZoomClick);
|
||||||
|
eventHolder.mousewheel(onMouseWheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.pan.interactive) {
|
||||||
|
eventHolder.bind("dragstart", { distance: 10 }, onDragStart);
|
||||||
|
eventHolder.bind("drag", onDrag);
|
||||||
|
eventHolder.bind("dragend", onDragEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.zoomOut = function (args) {
|
||||||
|
if (!args)
|
||||||
|
args = {};
|
||||||
|
|
||||||
|
if (!args.amount)
|
||||||
|
args.amount = plot.getOptions().zoom.amount
|
||||||
|
|
||||||
|
args.amount = 1 / args.amount;
|
||||||
|
plot.zoom(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.zoom = function (args) {
|
||||||
|
if (!args)
|
||||||
|
args = {};
|
||||||
|
|
||||||
|
var c = args.center,
|
||||||
|
amount = args.amount || plot.getOptions().zoom.amount,
|
||||||
|
w = plot.width(), h = plot.height();
|
||||||
|
|
||||||
|
if (!c)
|
||||||
|
c = { left: w / 2, top: h / 2 };
|
||||||
|
|
||||||
|
var xf = c.left / w,
|
||||||
|
yf = c.top / h,
|
||||||
|
minmax = {
|
||||||
|
x: {
|
||||||
|
min: c.left - xf * w / amount,
|
||||||
|
max: c.left + (1 - xf) * w / amount
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
min: c.top - yf * h / amount,
|
||||||
|
max: c.top + (1 - yf) * h / amount
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.each(plot.getAxes(), function(_, axis) {
|
||||||
|
var opts = axis.options,
|
||||||
|
min = minmax[axis.direction].min,
|
||||||
|
max = minmax[axis.direction].max,
|
||||||
|
zr = opts.zoomRange;
|
||||||
|
|
||||||
|
if (zr === false) // no zooming on this axis
|
||||||
|
return;
|
||||||
|
|
||||||
|
min = axis.c2p(min);
|
||||||
|
max = axis.c2p(max);
|
||||||
|
if (min > max) {
|
||||||
|
// make sure min < max
|
||||||
|
var tmp = min;
|
||||||
|
min = max;
|
||||||
|
max = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
var range = max - min;
|
||||||
|
if (zr &&
|
||||||
|
((zr[0] != null && range < zr[0]) ||
|
||||||
|
(zr[1] != null && range > zr[1])))
|
||||||
|
return;
|
||||||
|
|
||||||
|
opts.min = min;
|
||||||
|
opts.max = max;
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.setupGrid();
|
||||||
|
plot.draw();
|
||||||
|
|
||||||
|
if (!args.preventEvent)
|
||||||
|
plot.getPlaceholder().trigger("plotzoom", [ plot ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.pan = function (args) {
|
||||||
|
var delta = {
|
||||||
|
x: +args.left,
|
||||||
|
y: +args.top
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isNaN(delta.x))
|
||||||
|
delta.x = 0;
|
||||||
|
if (isNaN(delta.y))
|
||||||
|
delta.y = 0;
|
||||||
|
|
||||||
|
$.each(plot.getAxes(), function (_, axis) {
|
||||||
|
var opts = axis.options,
|
||||||
|
min, max, d = delta[axis.direction];
|
||||||
|
|
||||||
|
min = axis.c2p(axis.p2c(axis.min) + d),
|
||||||
|
max = axis.c2p(axis.p2c(axis.max) + d);
|
||||||
|
|
||||||
|
var pr = opts.panRange;
|
||||||
|
if (pr === false) // no panning on this axis
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (pr) {
|
||||||
|
// check whether we hit the wall
|
||||||
|
if (pr[0] != null && pr[0] > min) {
|
||||||
|
d = pr[0] - min;
|
||||||
|
min += d;
|
||||||
|
max += d;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pr[1] != null && pr[1] < max) {
|
||||||
|
d = pr[1] - max;
|
||||||
|
min += d;
|
||||||
|
max += d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
opts.min = min;
|
||||||
|
opts.max = max;
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.setupGrid();
|
||||||
|
plot.draw();
|
||||||
|
|
||||||
|
if (!args.preventEvent)
|
||||||
|
plot.getPlaceholder().trigger("plotpan", [ plot ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function shutdown(plot, eventHolder) {
|
||||||
|
eventHolder.unbind(plot.getOptions().zoom.trigger, onZoomClick);
|
||||||
|
eventHolder.unbind("mousewheel", onMouseWheel);
|
||||||
|
eventHolder.unbind("dragstart", onDragStart);
|
||||||
|
eventHolder.unbind("drag", onDrag);
|
||||||
|
eventHolder.unbind("dragend", onDragEnd);
|
||||||
|
if (panTimeout)
|
||||||
|
clearTimeout(panTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.bindEvents.push(bindEvents);
|
||||||
|
plot.hooks.shutdown.push(shutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'navigate',
|
||||||
|
version: '1.3'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.navigate.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.navigate.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
750
src/sunstone/public/vendor/flot/jquery.flot.pie.js
vendored
Normal file
750
src/sunstone/public/vendor/flot/jquery.flot.pie.js
vendored
Normal file
@ -0,0 +1,750 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for rendering pie charts. The plugin assumes the data is
|
||||||
|
coming is as a single data value for each series, and each of those
|
||||||
|
values is a positive value or zero (negative numbers don't make
|
||||||
|
any sense and will cause strange effects). The data values do
|
||||||
|
NOT need to be passed in as percentage values because it
|
||||||
|
internally calculates the total and percentages.
|
||||||
|
|
||||||
|
* Created by Brian Medendorp, June 2009
|
||||||
|
* Updated November 2009 with contributions from: btburnett3, Anthony Aragues and Xavi Ivars
|
||||||
|
|
||||||
|
* Changes:
|
||||||
|
2009-10-22: lineJoin set to round
|
||||||
|
2009-10-23: IE full circle fix, donut
|
||||||
|
2009-11-11: Added basic hover from btburnett3 - does not work in IE, and center is off in Chrome and Opera
|
||||||
|
2009-11-17: Added IE hover capability submitted by Anthony Aragues
|
||||||
|
2009-11-18: Added bug fix submitted by Xavi Ivars (issues with arrays when other JS libraries are included as well)
|
||||||
|
|
||||||
|
|
||||||
|
Available options are:
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true/false
|
||||||
|
radius: 0-1 for percentage of fullsize, or a specified pixel length, or 'auto'
|
||||||
|
innerRadius: 0-1 for percentage of fullsize or a specified pixel length, for creating a donut effect
|
||||||
|
startAngle: 0-2 factor of PI used for starting angle (in radians) i.e 3/2 starts at the top, 0 and 2 have the same result
|
||||||
|
tilt: 0-1 for percentage to tilt the pie, where 1 is no tilt, and 0 is completely flat (nothing will show)
|
||||||
|
offset: {
|
||||||
|
top: integer value to move the pie up or down
|
||||||
|
left: integer value to move the pie left or right, or 'auto'
|
||||||
|
},
|
||||||
|
stroke: {
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#FFF')
|
||||||
|
width: integer pixel width of the stroke
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
show: true/false, or 'auto'
|
||||||
|
formatter: a user-defined function that modifies the text/style of the label text
|
||||||
|
radius: 0-1 for percentage of fullsize, or a specified pixel length
|
||||||
|
background: {
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#000')
|
||||||
|
opacity: 0-1
|
||||||
|
},
|
||||||
|
threshold: 0-1 for the percentage value at which to hide labels (if they're too small)
|
||||||
|
},
|
||||||
|
combine: {
|
||||||
|
threshold: 0-1 for the percentage value at which to combine slices (if they're too small)
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#CCC'), if null, the plugin will automatically use the color of the first slice to be combined
|
||||||
|
label: any text value of what the combined slice should be labeled
|
||||||
|
}
|
||||||
|
highlight: {
|
||||||
|
opacity: 0-1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
More detail and specific examples can be found in the included HTML file.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($)
|
||||||
|
{
|
||||||
|
function init(plot) // this is the "body" of the plugin
|
||||||
|
{
|
||||||
|
var canvas = null;
|
||||||
|
var target = null;
|
||||||
|
var maxRadius = null;
|
||||||
|
var centerLeft = null;
|
||||||
|
var centerTop = null;
|
||||||
|
var total = 0;
|
||||||
|
var redraw = true;
|
||||||
|
var redrawAttempts = 10;
|
||||||
|
var shrink = 0.95;
|
||||||
|
var legendWidth = 0;
|
||||||
|
var processed = false;
|
||||||
|
var raw = false;
|
||||||
|
|
||||||
|
// interactive variables
|
||||||
|
var highlights = [];
|
||||||
|
|
||||||
|
// add hook to determine if pie plugin in enabled, and then perform necessary operations
|
||||||
|
plot.hooks.processOptions.push(checkPieEnabled);
|
||||||
|
plot.hooks.bindEvents.push(bindEvents);
|
||||||
|
|
||||||
|
// check to see if the pie plugin is enabled
|
||||||
|
function checkPieEnabled(plot, options)
|
||||||
|
{
|
||||||
|
if (options.series.pie.show)
|
||||||
|
{
|
||||||
|
//disable grid
|
||||||
|
options.grid.show = false;
|
||||||
|
|
||||||
|
// set labels.show
|
||||||
|
if (options.series.pie.label.show=='auto')
|
||||||
|
if (options.legend.show)
|
||||||
|
options.series.pie.label.show = false;
|
||||||
|
else
|
||||||
|
options.series.pie.label.show = true;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius=='auto')
|
||||||
|
if (options.series.pie.label.show)
|
||||||
|
options.series.pie.radius = 3/4;
|
||||||
|
else
|
||||||
|
options.series.pie.radius = 1;
|
||||||
|
|
||||||
|
// ensure sane tilt
|
||||||
|
if (options.series.pie.tilt>1)
|
||||||
|
options.series.pie.tilt=1;
|
||||||
|
if (options.series.pie.tilt<0)
|
||||||
|
options.series.pie.tilt=0;
|
||||||
|
|
||||||
|
// add processData hook to do transformations on the data
|
||||||
|
plot.hooks.processDatapoints.push(processDatapoints);
|
||||||
|
plot.hooks.drawOverlay.push(drawOverlay);
|
||||||
|
|
||||||
|
// add draw hook
|
||||||
|
plot.hooks.draw.push(draw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bind hoverable events
|
||||||
|
function bindEvents(plot, eventHolder)
|
||||||
|
{
|
||||||
|
var options = plot.getOptions();
|
||||||
|
|
||||||
|
if (options.series.pie.show && options.grid.hoverable)
|
||||||
|
eventHolder.unbind('mousemove').mousemove(onMouseMove);
|
||||||
|
|
||||||
|
if (options.series.pie.show && options.grid.clickable)
|
||||||
|
eventHolder.unbind('click').click(onClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// debugging function that prints out an object
|
||||||
|
function alertObject(obj)
|
||||||
|
{
|
||||||
|
var msg = '';
|
||||||
|
function traverse(obj, depth)
|
||||||
|
{
|
||||||
|
if (!depth)
|
||||||
|
depth = 0;
|
||||||
|
for (var i = 0; i < obj.length; ++i)
|
||||||
|
{
|
||||||
|
for (var j=0; j<depth; j++)
|
||||||
|
msg += '\t';
|
||||||
|
|
||||||
|
if( typeof obj[i] == "object")
|
||||||
|
{ // its an object
|
||||||
|
msg += ''+i+':\n';
|
||||||
|
traverse(obj[i], depth+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // its a value
|
||||||
|
msg += ''+i+': '+obj[i]+'\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
traverse(obj);
|
||||||
|
alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcTotal(data)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
var item = parseFloat(data[i].data[0][1]);
|
||||||
|
if (item)
|
||||||
|
total += item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function processDatapoints(plot, series, data, datapoints)
|
||||||
|
{
|
||||||
|
if (!processed)
|
||||||
|
{
|
||||||
|
processed = true;
|
||||||
|
|
||||||
|
canvas = plot.getCanvas();
|
||||||
|
target = $(canvas).parent();
|
||||||
|
options = plot.getOptions();
|
||||||
|
|
||||||
|
plot.setData(combine(plot.getData()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupPie()
|
||||||
|
{
|
||||||
|
legendWidth = target.children().filter('.legend').children().width();
|
||||||
|
|
||||||
|
// calculate maximum radius and center point
|
||||||
|
maxRadius = Math.min(canvas.width,(canvas.height/options.series.pie.tilt))/2;
|
||||||
|
centerTop = (canvas.height/2)+options.series.pie.offset.top;
|
||||||
|
centerLeft = (canvas.width/2);
|
||||||
|
|
||||||
|
if (options.series.pie.offset.left=='auto')
|
||||||
|
if (options.legend.position.match('w'))
|
||||||
|
centerLeft += legendWidth/2;
|
||||||
|
else
|
||||||
|
centerLeft -= legendWidth/2;
|
||||||
|
else
|
||||||
|
centerLeft += options.series.pie.offset.left;
|
||||||
|
|
||||||
|
if (centerLeft<maxRadius)
|
||||||
|
centerLeft = maxRadius;
|
||||||
|
else if (centerLeft>canvas.width-maxRadius)
|
||||||
|
centerLeft = canvas.width-maxRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixData(data)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
if (typeof(data[i].data)=='number')
|
||||||
|
data[i].data = [[1,data[i].data]];
|
||||||
|
else if (typeof(data[i].data)=='undefined' || typeof(data[i].data[0])=='undefined')
|
||||||
|
{
|
||||||
|
if (typeof(data[i].data)!='undefined' && typeof(data[i].data.label)!='undefined')
|
||||||
|
data[i].label = data[i].data.label; // fix weirdness coming from flot
|
||||||
|
data[i].data = [[1,0]];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function combine(data)
|
||||||
|
{
|
||||||
|
data = fixData(data);
|
||||||
|
calcTotal(data);
|
||||||
|
var combined = 0;
|
||||||
|
var numCombined = 0;
|
||||||
|
var color = options.series.pie.combine.color;
|
||||||
|
|
||||||
|
var newdata = [];
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
// make sure its a number
|
||||||
|
data[i].data[0][1] = parseFloat(data[i].data[0][1]);
|
||||||
|
if (!data[i].data[0][1])
|
||||||
|
data[i].data[0][1] = 0;
|
||||||
|
|
||||||
|
if (data[i].data[0][1]/total<=options.series.pie.combine.threshold)
|
||||||
|
{
|
||||||
|
combined += data[i].data[0][1];
|
||||||
|
numCombined++;
|
||||||
|
if (!color)
|
||||||
|
color = data[i].color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newdata.push({
|
||||||
|
data: [[1,data[i].data[0][1]]],
|
||||||
|
color: data[i].color,
|
||||||
|
label: data[i].label,
|
||||||
|
angle: (data[i].data[0][1]*(Math.PI*2))/total,
|
||||||
|
percent: (data[i].data[0][1]/total*100)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (numCombined>0)
|
||||||
|
newdata.push({
|
||||||
|
data: [[1,combined]],
|
||||||
|
color: color,
|
||||||
|
label: options.series.pie.combine.label,
|
||||||
|
angle: (combined*(Math.PI*2))/total,
|
||||||
|
percent: (combined/total*100)
|
||||||
|
});
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw(plot, newCtx)
|
||||||
|
{
|
||||||
|
if (!target) return; // if no series were passed
|
||||||
|
ctx = newCtx;
|
||||||
|
|
||||||
|
setupPie();
|
||||||
|
var slices = plot.getData();
|
||||||
|
|
||||||
|
var attempts = 0;
|
||||||
|
while (redraw && attempts<redrawAttempts)
|
||||||
|
{
|
||||||
|
redraw = false;
|
||||||
|
if (attempts>0)
|
||||||
|
maxRadius *= shrink;
|
||||||
|
attempts += 1;
|
||||||
|
clear();
|
||||||
|
if (options.series.pie.tilt<=0.8)
|
||||||
|
drawShadow();
|
||||||
|
drawPie();
|
||||||
|
}
|
||||||
|
if (attempts >= redrawAttempts) {
|
||||||
|
clear();
|
||||||
|
target.prepend('<div class="error">Could not draw pie with labels contained inside canvas</div>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( plot.setSeries && plot.insertLegend )
|
||||||
|
{
|
||||||
|
plot.setSeries(slices);
|
||||||
|
plot.insertLegend();
|
||||||
|
}
|
||||||
|
|
||||||
|
// we're actually done at this point, just defining internal functions at this point
|
||||||
|
|
||||||
|
function clear()
|
||||||
|
{
|
||||||
|
ctx.clearRect(0,0,canvas.width,canvas.height);
|
||||||
|
target.children().filter('.pieLabel, .pieLabelBackground').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawShadow()
|
||||||
|
{
|
||||||
|
var shadowLeft = 5;
|
||||||
|
var shadowTop = 15;
|
||||||
|
var edge = 10;
|
||||||
|
var alpha = 0.02;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius>1)
|
||||||
|
var radius = options.series.pie.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
if (radius>=(canvas.width/2)-shadowLeft || radius*options.series.pie.tilt>=(canvas.height/2)-shadowTop || radius<=edge)
|
||||||
|
return; // shadow would be outside canvas, so don't draw it
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(shadowLeft,shadowTop);
|
||||||
|
ctx.globalAlpha = alpha;
|
||||||
|
ctx.fillStyle = '#000';
|
||||||
|
|
||||||
|
// center and rotate to starting position
|
||||||
|
ctx.translate(centerLeft,centerTop);
|
||||||
|
ctx.scale(1, options.series.pie.tilt);
|
||||||
|
|
||||||
|
//radius -= edge;
|
||||||
|
for (var i=1; i<=edge; i++)
|
||||||
|
{
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(0,0,radius,0,Math.PI*2,false);
|
||||||
|
ctx.fill();
|
||||||
|
radius -= i;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawPie()
|
||||||
|
{
|
||||||
|
startAngle = Math.PI*options.series.pie.startAngle;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius>1)
|
||||||
|
var radius = options.series.pie.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
// center and rotate to starting position
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(centerLeft,centerTop);
|
||||||
|
ctx.scale(1, options.series.pie.tilt);
|
||||||
|
//ctx.rotate(startAngle); // start at top; -- This doesn't work properly in Opera
|
||||||
|
|
||||||
|
// draw slices
|
||||||
|
ctx.save();
|
||||||
|
var currentAngle = startAngle;
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
slices[i].startAngle = currentAngle;
|
||||||
|
drawSlice(slices[i].angle, slices[i].color, true);
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// draw slice outlines
|
||||||
|
ctx.save();
|
||||||
|
ctx.lineWidth = options.series.pie.stroke.width;
|
||||||
|
currentAngle = startAngle;
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
drawSlice(slices[i].angle, options.series.pie.stroke.color, false);
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// draw donut hole
|
||||||
|
drawDonutHole(ctx);
|
||||||
|
|
||||||
|
// draw labels
|
||||||
|
if (options.series.pie.label.show)
|
||||||
|
drawLabels();
|
||||||
|
|
||||||
|
// restore to original state
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
function drawSlice(angle, color, fill)
|
||||||
|
{
|
||||||
|
if (angle<=0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fill)
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctx.strokeStyle = color;
|
||||||
|
ctx.lineJoin = 'round';
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
if (Math.abs(angle - Math.PI*2) > 0.000000001)
|
||||||
|
ctx.moveTo(0,0); // Center of the pie
|
||||||
|
else if ($.browser.msie)
|
||||||
|
angle -= 0.0001;
|
||||||
|
//ctx.arc(0,0,radius,0,angle,false); // This doesn't work properly in Opera
|
||||||
|
ctx.arc(0,0,radius,currentAngle,currentAngle+angle,false);
|
||||||
|
ctx.closePath();
|
||||||
|
//ctx.rotate(angle); // This doesn't work properly in Opera
|
||||||
|
currentAngle += angle;
|
||||||
|
|
||||||
|
if (fill)
|
||||||
|
ctx.fill();
|
||||||
|
else
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLabels()
|
||||||
|
{
|
||||||
|
var currentAngle = startAngle;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.label.radius>1)
|
||||||
|
var radius = options.series.pie.label.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.label.radius;
|
||||||
|
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
if (slices[i].percent >= options.series.pie.label.threshold*100)
|
||||||
|
drawLabel(slices[i], currentAngle, i);
|
||||||
|
currentAngle += slices[i].angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLabel(slice, startAngle, index)
|
||||||
|
{
|
||||||
|
if (slice.data[0][1]==0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// format label text
|
||||||
|
var lf = options.legend.labelFormatter, text, plf = options.series.pie.label.formatter;
|
||||||
|
if (lf)
|
||||||
|
text = lf(slice.label, slice);
|
||||||
|
else
|
||||||
|
text = slice.label;
|
||||||
|
if (plf)
|
||||||
|
text = plf(text, slice);
|
||||||
|
|
||||||
|
var halfAngle = ((startAngle+slice.angle) + startAngle)/2;
|
||||||
|
var x = centerLeft + Math.round(Math.cos(halfAngle) * radius);
|
||||||
|
var y = centerTop + Math.round(Math.sin(halfAngle) * radius) * options.series.pie.tilt;
|
||||||
|
|
||||||
|
var html = '<span class="pieLabel" id="pieLabel'+index+'" style="position:absolute;top:' + y + 'px;left:' + x + 'px;">' + text + "</span>";
|
||||||
|
target.append(html);
|
||||||
|
var label = target.children('#pieLabel'+index);
|
||||||
|
var labelTop = (y - label.height()/2);
|
||||||
|
var labelLeft = (x - label.width()/2);
|
||||||
|
label.css('top', labelTop);
|
||||||
|
label.css('left', labelLeft);
|
||||||
|
|
||||||
|
// check to make sure that the label is not outside the canvas
|
||||||
|
if (0-labelTop>0 || 0-labelLeft>0 || canvas.height-(labelTop+label.height())<0 || canvas.width-(labelLeft+label.width())<0)
|
||||||
|
redraw = true;
|
||||||
|
|
||||||
|
if (options.series.pie.label.background.opacity != 0) {
|
||||||
|
// put in the transparent background separately to avoid blended labels and label boxes
|
||||||
|
var c = options.series.pie.label.background.color;
|
||||||
|
if (c == null) {
|
||||||
|
c = slice.color;
|
||||||
|
}
|
||||||
|
var pos = 'top:'+labelTop+'px;left:'+labelLeft+'px;';
|
||||||
|
$('<div class="pieLabelBackground" style="position:absolute;width:' + label.width() + 'px;height:' + label.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').insertBefore(label).css('opacity', options.series.pie.label.background.opacity);
|
||||||
|
}
|
||||||
|
} // end individual label function
|
||||||
|
} // end drawLabels function
|
||||||
|
} // end drawPie function
|
||||||
|
} // end draw function
|
||||||
|
|
||||||
|
// Placed here because it needs to be accessed from multiple locations
|
||||||
|
function drawDonutHole(layer)
|
||||||
|
{
|
||||||
|
// draw donut hole
|
||||||
|
if(options.series.pie.innerRadius > 0)
|
||||||
|
{
|
||||||
|
// subtract the center
|
||||||
|
layer.save();
|
||||||
|
innerRadius = options.series.pie.innerRadius > 1 ? options.series.pie.innerRadius : maxRadius * options.series.pie.innerRadius;
|
||||||
|
layer.globalCompositeOperation = 'destination-out'; // this does not work with excanvas, but it will fall back to using the stroke color
|
||||||
|
layer.beginPath();
|
||||||
|
layer.fillStyle = options.series.pie.stroke.color;
|
||||||
|
layer.arc(0,0,innerRadius,0,Math.PI*2,false);
|
||||||
|
layer.fill();
|
||||||
|
layer.closePath();
|
||||||
|
layer.restore();
|
||||||
|
|
||||||
|
// add inner stroke
|
||||||
|
layer.save();
|
||||||
|
layer.beginPath();
|
||||||
|
layer.strokeStyle = options.series.pie.stroke.color;
|
||||||
|
layer.arc(0,0,innerRadius,0,Math.PI*2,false);
|
||||||
|
layer.stroke();
|
||||||
|
layer.closePath();
|
||||||
|
layer.restore();
|
||||||
|
// TODO: add extra shadow inside hole (with a mask) if the pie is tilted.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- Additional Interactive related functions --
|
||||||
|
|
||||||
|
function isPointInPoly(poly, pt)
|
||||||
|
{
|
||||||
|
for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
|
||||||
|
((poly[i][1] <= pt[1] && pt[1] < poly[j][1]) || (poly[j][1] <= pt[1] && pt[1]< poly[i][1]))
|
||||||
|
&& (pt[0] < (poly[j][0] - poly[i][0]) * (pt[1] - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0])
|
||||||
|
&& (c = !c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findNearbySlice(mouseX, mouseY)
|
||||||
|
{
|
||||||
|
var slices = plot.getData(),
|
||||||
|
options = plot.getOptions(),
|
||||||
|
radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
var s = slices[i];
|
||||||
|
|
||||||
|
if(s.pie.show)
|
||||||
|
{
|
||||||
|
ctx.save();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0,0); // Center of the pie
|
||||||
|
//ctx.scale(1, options.series.pie.tilt); // this actually seems to break everything when here.
|
||||||
|
ctx.arc(0,0,radius,s.startAngle,s.startAngle+s.angle,false);
|
||||||
|
ctx.closePath();
|
||||||
|
x = mouseX-centerLeft;
|
||||||
|
y = mouseY-centerTop;
|
||||||
|
if(ctx.isPointInPath)
|
||||||
|
{
|
||||||
|
if (ctx.isPointInPath(mouseX-centerLeft, mouseY-centerTop))
|
||||||
|
{
|
||||||
|
//alert('found slice!');
|
||||||
|
ctx.restore();
|
||||||
|
return {datapoint: [s.percent, s.data], dataIndex: 0, series: s, seriesIndex: i};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// excanvas for IE doesn;t support isPointInPath, this is a workaround.
|
||||||
|
p1X = (radius * Math.cos(s.startAngle));
|
||||||
|
p1Y = (radius * Math.sin(s.startAngle));
|
||||||
|
p2X = (radius * Math.cos(s.startAngle+(s.angle/4)));
|
||||||
|
p2Y = (radius * Math.sin(s.startAngle+(s.angle/4)));
|
||||||
|
p3X = (radius * Math.cos(s.startAngle+(s.angle/2)));
|
||||||
|
p3Y = (radius * Math.sin(s.startAngle+(s.angle/2)));
|
||||||
|
p4X = (radius * Math.cos(s.startAngle+(s.angle/1.5)));
|
||||||
|
p4Y = (radius * Math.sin(s.startAngle+(s.angle/1.5)));
|
||||||
|
p5X = (radius * Math.cos(s.startAngle+s.angle));
|
||||||
|
p5Y = (radius * Math.sin(s.startAngle+s.angle));
|
||||||
|
arrPoly = [[0,0],[p1X,p1Y],[p2X,p2Y],[p3X,p3Y],[p4X,p4Y],[p5X,p5Y]];
|
||||||
|
arrPoint = [x,y];
|
||||||
|
// TODO: perhaps do some mathmatical trickery here with the Y-coordinate to compensate for pie tilt?
|
||||||
|
if(isPointInPoly(arrPoly, arrPoint))
|
||||||
|
{
|
||||||
|
ctx.restore();
|
||||||
|
return {datapoint: [s.percent, s.data], dataIndex: 0, series: s, seriesIndex: i};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseMove(e)
|
||||||
|
{
|
||||||
|
triggerClickHoverEvent('plothover', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClick(e)
|
||||||
|
{
|
||||||
|
triggerClickHoverEvent('plotclick', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// trigger click or hover event (they send the same parameters so we share their code)
|
||||||
|
function triggerClickHoverEvent(eventname, e)
|
||||||
|
{
|
||||||
|
var offset = plot.offset(),
|
||||||
|
canvasX = parseInt(e.pageX - offset.left),
|
||||||
|
canvasY = parseInt(e.pageY - offset.top),
|
||||||
|
item = findNearbySlice(canvasX, canvasY);
|
||||||
|
|
||||||
|
if (options.grid.autoHighlight)
|
||||||
|
{
|
||||||
|
// clear auto-highlights
|
||||||
|
for (var i = 0; i < highlights.length; ++i)
|
||||||
|
{
|
||||||
|
var h = highlights[i];
|
||||||
|
if (h.auto == eventname && !(item && h.series == item.series))
|
||||||
|
unhighlight(h.series);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// highlight the slice
|
||||||
|
if (item)
|
||||||
|
highlight(item.series, eventname);
|
||||||
|
|
||||||
|
// trigger any hover bind events
|
||||||
|
var pos = { pageX: e.pageX, pageY: e.pageY };
|
||||||
|
target.trigger(eventname, [ pos, item ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlight(s, auto)
|
||||||
|
{
|
||||||
|
if (typeof s == "number")
|
||||||
|
s = series[s];
|
||||||
|
|
||||||
|
var i = indexOfHighlight(s);
|
||||||
|
if (i == -1)
|
||||||
|
{
|
||||||
|
highlights.push({ series: s, auto: auto });
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
else if (!auto)
|
||||||
|
highlights[i].auto = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unhighlight(s)
|
||||||
|
{
|
||||||
|
if (s == null)
|
||||||
|
{
|
||||||
|
highlights = [];
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof s == "number")
|
||||||
|
s = series[s];
|
||||||
|
|
||||||
|
var i = indexOfHighlight(s);
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
highlights.splice(i, 1);
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexOfHighlight(s)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < highlights.length; ++i)
|
||||||
|
{
|
||||||
|
var h = highlights[i];
|
||||||
|
if (h.series == s)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawOverlay(plot, octx)
|
||||||
|
{
|
||||||
|
//alert(options.series.pie.radius);
|
||||||
|
var options = plot.getOptions();
|
||||||
|
//alert(options.series.pie.radius);
|
||||||
|
|
||||||
|
var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
octx.save();
|
||||||
|
octx.translate(centerLeft, centerTop);
|
||||||
|
octx.scale(1, options.series.pie.tilt);
|
||||||
|
|
||||||
|
for (i = 0; i < highlights.length; ++i)
|
||||||
|
drawHighlight(highlights[i].series);
|
||||||
|
|
||||||
|
drawDonutHole(octx);
|
||||||
|
|
||||||
|
octx.restore();
|
||||||
|
|
||||||
|
function drawHighlight(series)
|
||||||
|
{
|
||||||
|
if (series.angle < 0) return;
|
||||||
|
|
||||||
|
//octx.fillStyle = parseColor(options.series.pie.highlight.color).scale(null, null, null, options.series.pie.highlight.opacity).toString();
|
||||||
|
octx.fillStyle = "rgba(255, 255, 255, "+options.series.pie.highlight.opacity+")"; // this is temporary until we have access to parseColor
|
||||||
|
|
||||||
|
octx.beginPath();
|
||||||
|
if (Math.abs(series.angle - Math.PI*2) > 0.000000001)
|
||||||
|
octx.moveTo(0,0); // Center of the pie
|
||||||
|
octx.arc(0,0,radius,series.startAngle,series.startAngle+series.angle,false);
|
||||||
|
octx.closePath();
|
||||||
|
octx.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end init (plugin body)
|
||||||
|
|
||||||
|
// define pie specific options and their default values
|
||||||
|
var options = {
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: false,
|
||||||
|
radius: 'auto', // actual radius of the visible pie (based on full calculated radius if <=1, or hard pixel value)
|
||||||
|
innerRadius:0, /* for donut */
|
||||||
|
startAngle: 3/2,
|
||||||
|
tilt: 1,
|
||||||
|
offset: {
|
||||||
|
top: 0,
|
||||||
|
left: 'auto'
|
||||||
|
},
|
||||||
|
stroke: {
|
||||||
|
color: '#FFF',
|
||||||
|
width: 1
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
show: 'auto',
|
||||||
|
formatter: function(label, slice){
|
||||||
|
return '<div style="font-size:x-small;text-align:center;padding:2px;color:'+slice.color+';">'+label+'<br/>'+Math.round(slice.percent)+'%</div>';
|
||||||
|
}, // formatter function
|
||||||
|
radius: 1, // radius at which to place the labels (based on full calculated radius if <=1, or hard pixel value)
|
||||||
|
background: {
|
||||||
|
color: null,
|
||||||
|
opacity: 0
|
||||||
|
},
|
||||||
|
threshold: 0 // percentage at which to hide the label (i.e. the slice is too narrow)
|
||||||
|
},
|
||||||
|
combine: {
|
||||||
|
threshold: -1, // percentage at which to combine little slices into one larger slice
|
||||||
|
color: null, // color to give the new slice (auto-generated if null)
|
||||||
|
label: 'Other' // label to give the new slice
|
||||||
|
},
|
||||||
|
highlight: {
|
||||||
|
//color: '#FFF', // will add this functionality once parseColor is available
|
||||||
|
opacity: 0.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: "pie",
|
||||||
|
version: "1.0"
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.pie.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.pie.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
60
src/sunstone/public/vendor/flot/jquery.flot.resize.js
vendored
Normal file
60
src/sunstone/public/vendor/flot/jquery.flot.resize.js
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for automatically redrawing plots when the placeholder
|
||||||
|
size changes, e.g. on window resizes.
|
||||||
|
|
||||||
|
It works by listening for changes on the placeholder div (through the
|
||||||
|
jQuery resize event plugin) - if the size changes, it will redraw the
|
||||||
|
plot.
|
||||||
|
|
||||||
|
There are no options. If you need to disable the plugin for some
|
||||||
|
plots, you can just fix the size of their placeholders.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Inline dependency:
|
||||||
|
* jQuery resize event - v1.1 - 3/14/2010
|
||||||
|
* http://benalman.com/projects/jquery-resize-plugin/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||||
|
* Dual licensed under the MIT and GPL licenses.
|
||||||
|
* http://benalman.com/about/license/
|
||||||
|
*/
|
||||||
|
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
|
||||||
|
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = { }; // no options
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function onResize() {
|
||||||
|
var placeholder = plot.getPlaceholder();
|
||||||
|
|
||||||
|
// somebody might have hidden us and we can't plot
|
||||||
|
// when we don't have the dimensions
|
||||||
|
if (placeholder.width() == 0 || placeholder.height() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
plot.resize();
|
||||||
|
plot.setupGrid();
|
||||||
|
plot.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindEvents(plot, eventHolder) {
|
||||||
|
plot.getPlaceholder().resize(onResize);
|
||||||
|
}
|
||||||
|
|
||||||
|
function shutdown(plot, eventHolder) {
|
||||||
|
plot.getPlaceholder().unbind("resize", onResize);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.bindEvents.push(bindEvents);
|
||||||
|
plot.hooks.shutdown.push(shutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'resize',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.resize.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.resize.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(n,p,u){var w=n([]),s=n.resize=n.extend(n.resize,{}),o,l="setTimeout",m="resize",t=m+"-special-event",v="delay",r="throttleWindow";s[v]=250;s[r]=true;n.event.special[m]={setup:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.add(a);n.data(this,t,{w:a.width(),h:a.height()});if(w.length===1){q()}},teardown:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.not(a);a.removeData(t);if(!w.length){clearTimeout(o)}},add:function(b){if(!s[r]&&this[l]){return false}var c;function a(d,h,g){var f=n(this),e=n.data(this,t);e.w=h!==u?h:f.width();e.h=g!==u?g:f.height();c.apply(this,arguments)}if(n.isFunction(b)){c=b;return a}else{c=b.handler;b.handler=a}}};function q(){o=p[l](function(){w.each(function(){var d=n(this),a=d.width(),b=d.height(),c=n.data(this,t);if(a!==c.w||b!==c.h){d.trigger(m,[c.w=a,c.h=b])}});q()},s[v])}})(jQuery,this);(function(b){var a={};function c(f){function e(){var h=f.getPlaceholder();if(h.width()==0||h.height()==0){return}f.resize();f.setupGrid();f.draw()}function g(i,h){i.getPlaceholder().resize(e)}function d(i,h){i.getPlaceholder().unbind("resize",e)}f.hooks.bindEvents.push(g);f.hooks.shutdown.push(d)}b.plot.plugins.push({init:c,options:a,name:"resize",version:"1.0"})})(jQuery);
|
344
src/sunstone/public/vendor/flot/jquery.flot.selection.js
vendored
Normal file
344
src/sunstone/public/vendor/flot/jquery.flot.selection.js
vendored
Normal file
@ -0,0 +1,344 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for selecting regions.
|
||||||
|
|
||||||
|
The plugin defines the following options:
|
||||||
|
|
||||||
|
selection: {
|
||||||
|
mode: null or "x" or "y" or "xy",
|
||||||
|
color: color
|
||||||
|
}
|
||||||
|
|
||||||
|
Selection support is enabled by setting the mode to one of "x", "y" or
|
||||||
|
"xy". In "x" mode, the user will only be able to specify the x range,
|
||||||
|
similarly for "y" mode. For "xy", the selection becomes a rectangle
|
||||||
|
where both ranges can be specified. "color" is color of the selection
|
||||||
|
(if you need to change the color later on, you can get to it with
|
||||||
|
plot.getOptions().selection.color).
|
||||||
|
|
||||||
|
When selection support is enabled, a "plotselected" event will be
|
||||||
|
emitted on the DOM element you passed into the plot function. The
|
||||||
|
event handler gets a parameter with the ranges selected on the axes,
|
||||||
|
like this:
|
||||||
|
|
||||||
|
placeholder.bind("plotselected", function(event, ranges) {
|
||||||
|
alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
|
||||||
|
// similar for yaxis - with multiple axes, the extra ones are in
|
||||||
|
// x2axis, x3axis, ...
|
||||||
|
});
|
||||||
|
|
||||||
|
The "plotselected" event is only fired when the user has finished
|
||||||
|
making the selection. A "plotselecting" event is fired during the
|
||||||
|
process with the same parameters as the "plotselected" event, in case
|
||||||
|
you want to know what's happening while it's happening,
|
||||||
|
|
||||||
|
A "plotunselected" event with no arguments is emitted when the user
|
||||||
|
clicks the mouse to remove the selection.
|
||||||
|
|
||||||
|
The plugin allso adds the following methods to the plot object:
|
||||||
|
|
||||||
|
- setSelection(ranges, preventEvent)
|
||||||
|
|
||||||
|
Set the selection rectangle. The passed in ranges is on the same
|
||||||
|
form as returned in the "plotselected" event. If the selection mode
|
||||||
|
is "x", you should put in either an xaxis range, if the mode is "y"
|
||||||
|
you need to put in an yaxis range and both xaxis and yaxis if the
|
||||||
|
selection mode is "xy", like this:
|
||||||
|
|
||||||
|
setSelection({ xaxis: { from: 0, to: 10 }, yaxis: { from: 40, to: 60 } });
|
||||||
|
|
||||||
|
setSelection will trigger the "plotselected" event when called. If
|
||||||
|
you don't want that to happen, e.g. if you're inside a
|
||||||
|
"plotselected" handler, pass true as the second parameter. If you
|
||||||
|
are using multiple axes, you can specify the ranges on any of those,
|
||||||
|
e.g. as x2axis/x3axis/... instead of xaxis, the plugin picks the
|
||||||
|
first one it sees.
|
||||||
|
|
||||||
|
- clearSelection(preventEvent)
|
||||||
|
|
||||||
|
Clear the selection rectangle. Pass in true to avoid getting a
|
||||||
|
"plotunselected" event.
|
||||||
|
|
||||||
|
- getSelection()
|
||||||
|
|
||||||
|
Returns the current selection in the same format as the
|
||||||
|
"plotselected" event. If there's currently no selection, the
|
||||||
|
function returns null.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
function init(plot) {
|
||||||
|
var selection = {
|
||||||
|
first: { x: -1, y: -1}, second: { x: -1, y: -1},
|
||||||
|
show: false,
|
||||||
|
active: false
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: The drag handling implemented here should be
|
||||||
|
// abstracted out, there's some similar code from a library in
|
||||||
|
// the navigation plugin, this should be massaged a bit to fit
|
||||||
|
// the Flot cases here better and reused. Doing this would
|
||||||
|
// make this plugin much slimmer.
|
||||||
|
var savedhandlers = {};
|
||||||
|
|
||||||
|
var mouseUpHandler = null;
|
||||||
|
|
||||||
|
function onMouseMove(e) {
|
||||||
|
if (selection.active) {
|
||||||
|
updateSelection(e);
|
||||||
|
|
||||||
|
plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseDown(e) {
|
||||||
|
if (e.which != 1) // only accept left-click
|
||||||
|
return;
|
||||||
|
|
||||||
|
// cancel out any text selections
|
||||||
|
document.body.focus();
|
||||||
|
|
||||||
|
// prevent text selection and drag in old-school browsers
|
||||||
|
if (document.onselectstart !== undefined && savedhandlers.onselectstart == null) {
|
||||||
|
savedhandlers.onselectstart = document.onselectstart;
|
||||||
|
document.onselectstart = function () { return false; };
|
||||||
|
}
|
||||||
|
if (document.ondrag !== undefined && savedhandlers.ondrag == null) {
|
||||||
|
savedhandlers.ondrag = document.ondrag;
|
||||||
|
document.ondrag = function () { return false; };
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectionPos(selection.first, e);
|
||||||
|
|
||||||
|
selection.active = true;
|
||||||
|
|
||||||
|
// this is a bit silly, but we have to use a closure to be
|
||||||
|
// able to whack the same handler again
|
||||||
|
mouseUpHandler = function (e) { onMouseUp(e); };
|
||||||
|
|
||||||
|
$(document).one("mouseup", mouseUpHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseUp(e) {
|
||||||
|
mouseUpHandler = null;
|
||||||
|
|
||||||
|
// revert drag stuff for old-school browsers
|
||||||
|
if (document.onselectstart !== undefined)
|
||||||
|
document.onselectstart = savedhandlers.onselectstart;
|
||||||
|
if (document.ondrag !== undefined)
|
||||||
|
document.ondrag = savedhandlers.ondrag;
|
||||||
|
|
||||||
|
// no more dragging
|
||||||
|
selection.active = false;
|
||||||
|
updateSelection(e);
|
||||||
|
|
||||||
|
if (selectionIsSane())
|
||||||
|
triggerSelectedEvent();
|
||||||
|
else {
|
||||||
|
// this counts as a clear
|
||||||
|
plot.getPlaceholder().trigger("plotunselected", [ ]);
|
||||||
|
plot.getPlaceholder().trigger("plotselecting", [ null ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelection() {
|
||||||
|
if (!selectionIsSane())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var r = {}, c1 = selection.first, c2 = selection.second;
|
||||||
|
$.each(plot.getAxes(), function (name, axis) {
|
||||||
|
if (axis.used) {
|
||||||
|
var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
|
||||||
|
r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
function triggerSelectedEvent() {
|
||||||
|
var r = getSelection();
|
||||||
|
|
||||||
|
plot.getPlaceholder().trigger("plotselected", [ r ]);
|
||||||
|
|
||||||
|
// backwards-compat stuff, to be removed in future
|
||||||
|
if (r.xaxis && r.yaxis)
|
||||||
|
plot.getPlaceholder().trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clamp(min, value, max) {
|
||||||
|
return value < min ? min: (value > max ? max: value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSelectionPos(pos, e) {
|
||||||
|
var o = plot.getOptions();
|
||||||
|
var offset = plot.getPlaceholder().offset();
|
||||||
|
var plotOffset = plot.getPlotOffset();
|
||||||
|
pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
|
||||||
|
pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
|
||||||
|
|
||||||
|
if (o.selection.mode == "y")
|
||||||
|
pos.x = pos == selection.first ? 0 : plot.width();
|
||||||
|
|
||||||
|
if (o.selection.mode == "x")
|
||||||
|
pos.y = pos == selection.first ? 0 : plot.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSelection(pos) {
|
||||||
|
if (pos.pageX == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setSelectionPos(selection.second, pos);
|
||||||
|
if (selectionIsSane()) {
|
||||||
|
selection.show = true;
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
clearSelection(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearSelection(preventEvent) {
|
||||||
|
if (selection.show) {
|
||||||
|
selection.show = false;
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
if (!preventEvent)
|
||||||
|
plot.getPlaceholder().trigger("plotunselected", [ ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// function taken from markings support in Flot
|
||||||
|
function extractRange(ranges, coord) {
|
||||||
|
var axis, from, to, key, axes = plot.getAxes();
|
||||||
|
|
||||||
|
for (var k in axes) {
|
||||||
|
axis = axes[k];
|
||||||
|
if (axis.direction == coord) {
|
||||||
|
key = coord + axis.n + "axis";
|
||||||
|
if (!ranges[key] && axis.n == 1)
|
||||||
|
key = coord + "axis"; // support x1axis as xaxis
|
||||||
|
if (ranges[key]) {
|
||||||
|
from = ranges[key].from;
|
||||||
|
to = ranges[key].to;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// backwards-compat stuff - to be removed in future
|
||||||
|
if (!ranges[key]) {
|
||||||
|
axis = coord == "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
|
||||||
|
from = ranges[coord + "1"];
|
||||||
|
to = ranges[coord + "2"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto-reverse as an added bonus
|
||||||
|
if (from != null && to != null && from > to) {
|
||||||
|
var tmp = from;
|
||||||
|
from = to;
|
||||||
|
to = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { from: from, to: to, axis: axis };
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSelection(ranges, preventEvent) {
|
||||||
|
var axis, range, o = plot.getOptions();
|
||||||
|
|
||||||
|
if (o.selection.mode == "y") {
|
||||||
|
selection.first.x = 0;
|
||||||
|
selection.second.x = plot.width();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
range = extractRange(ranges, "x");
|
||||||
|
|
||||||
|
selection.first.x = range.axis.p2c(range.from);
|
||||||
|
selection.second.x = range.axis.p2c(range.to);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.selection.mode == "x") {
|
||||||
|
selection.first.y = 0;
|
||||||
|
selection.second.y = plot.height();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
range = extractRange(ranges, "y");
|
||||||
|
|
||||||
|
selection.first.y = range.axis.p2c(range.from);
|
||||||
|
selection.second.y = range.axis.p2c(range.to);
|
||||||
|
}
|
||||||
|
|
||||||
|
selection.show = true;
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
if (!preventEvent && selectionIsSane())
|
||||||
|
triggerSelectedEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectionIsSane() {
|
||||||
|
var minSize = 5;
|
||||||
|
return Math.abs(selection.second.x - selection.first.x) >= minSize &&
|
||||||
|
Math.abs(selection.second.y - selection.first.y) >= minSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.clearSelection = clearSelection;
|
||||||
|
plot.setSelection = setSelection;
|
||||||
|
plot.getSelection = getSelection;
|
||||||
|
|
||||||
|
plot.hooks.bindEvents.push(function(plot, eventHolder) {
|
||||||
|
var o = plot.getOptions();
|
||||||
|
if (o.selection.mode != null) {
|
||||||
|
eventHolder.mousemove(onMouseMove);
|
||||||
|
eventHolder.mousedown(onMouseDown);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
||||||
|
// draw selection
|
||||||
|
if (selection.show && selectionIsSane()) {
|
||||||
|
var plotOffset = plot.getPlotOffset();
|
||||||
|
var o = plot.getOptions();
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(plotOffset.left, plotOffset.top);
|
||||||
|
|
||||||
|
var c = $.color.parse(o.selection.color);
|
||||||
|
|
||||||
|
ctx.strokeStyle = c.scale('a', 0.8).toString();
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
ctx.lineJoin = "round";
|
||||||
|
ctx.fillStyle = c.scale('a', 0.4).toString();
|
||||||
|
|
||||||
|
var x = Math.min(selection.first.x, selection.second.x),
|
||||||
|
y = Math.min(selection.first.y, selection.second.y),
|
||||||
|
w = Math.abs(selection.second.x - selection.first.x),
|
||||||
|
h = Math.abs(selection.second.y - selection.first.y);
|
||||||
|
|
||||||
|
ctx.fillRect(x, y, w, h);
|
||||||
|
ctx.strokeRect(x, y, w, h);
|
||||||
|
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
||||||
|
eventHolder.unbind("mousemove", onMouseMove);
|
||||||
|
eventHolder.unbind("mousedown", onMouseDown);
|
||||||
|
|
||||||
|
if (mouseUpHandler)
|
||||||
|
$(document).unbind("mouseup", mouseUpHandler);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: {
|
||||||
|
selection: {
|
||||||
|
mode: null, // one of null, "x", "y" or "xy"
|
||||||
|
color: "#e8cfac"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
name: 'selection',
|
||||||
|
version: '1.1'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.selection.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.selection.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(a){function b(k){var p={first:{x:-1,y:-1},second:{x:-1,y:-1},show:false,active:false};var m={};var r=null;function e(s){if(p.active){l(s);k.getPlaceholder().trigger("plotselecting",[g()])}}function n(s){if(s.which!=1){return}document.body.focus();if(document.onselectstart!==undefined&&m.onselectstart==null){m.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!==undefined&&m.ondrag==null){m.ondrag=document.ondrag;document.ondrag=function(){return false}}d(p.first,s);p.active=true;r=function(t){j(t)};a(document).one("mouseup",r)}function j(s){r=null;if(document.onselectstart!==undefined){document.onselectstart=m.onselectstart}if(document.ondrag!==undefined){document.ondrag=m.ondrag}p.active=false;l(s);if(f()){i()}else{k.getPlaceholder().trigger("plotunselected",[]);k.getPlaceholder().trigger("plotselecting",[null])}return false}function g(){if(!f()){return null}var u={},t=p.first,s=p.second;a.each(k.getAxes(),function(v,w){if(w.used){var y=w.c2p(t[w.direction]),x=w.c2p(s[w.direction]);u[v]={from:Math.min(y,x),to:Math.max(y,x)}}});return u}function i(){var s=g();k.getPlaceholder().trigger("plotselected",[s]);if(s.xaxis&&s.yaxis){k.getPlaceholder().trigger("selected",[{x1:s.xaxis.from,y1:s.yaxis.from,x2:s.xaxis.to,y2:s.yaxis.to}])}}function h(t,u,s){return u<t?t:(u>s?s:u)}function d(w,t){var v=k.getOptions();var u=k.getPlaceholder().offset();var s=k.getPlotOffset();w.x=h(0,t.pageX-u.left-s.left,k.width());w.y=h(0,t.pageY-u.top-s.top,k.height());if(v.selection.mode=="y"){w.x=w==p.first?0:k.width()}if(v.selection.mode=="x"){w.y=w==p.first?0:k.height()}}function l(s){if(s.pageX==null){return}d(p.second,s);if(f()){p.show=true;k.triggerRedrawOverlay()}else{q(true)}}function q(s){if(p.show){p.show=false;k.triggerRedrawOverlay();if(!s){k.getPlaceholder().trigger("plotunselected",[])}}}function c(s,w){var t,y,z,A,x=k.getAxes();for(var u in x){t=x[u];if(t.direction==w){A=w+t.n+"axis";if(!s[A]&&t.n==1){A=w+"axis"}if(s[A]){y=s[A].from;z=s[A].to;break}}}if(!s[A]){t=w=="x"?k.getXAxes()[0]:k.getYAxes()[0];y=s[w+"1"];z=s[w+"2"]}if(y!=null&&z!=null&&y>z){var v=y;y=z;z=v}return{from:y,to:z,axis:t}}function o(t,s){var v,u,w=k.getOptions();if(w.selection.mode=="y"){p.first.x=0;p.second.x=k.width()}else{u=c(t,"x");p.first.x=u.axis.p2c(u.from);p.second.x=u.axis.p2c(u.to)}if(w.selection.mode=="x"){p.first.y=0;p.second.y=k.height()}else{u=c(t,"y");p.first.y=u.axis.p2c(u.from);p.second.y=u.axis.p2c(u.to)}p.show=true;k.triggerRedrawOverlay();if(!s&&f()){i()}}function f(){var s=5;return Math.abs(p.second.x-p.first.x)>=s&&Math.abs(p.second.y-p.first.y)>=s}k.clearSelection=q;k.setSelection=o;k.getSelection=g;k.hooks.bindEvents.push(function(t,s){var u=t.getOptions();if(u.selection.mode!=null){s.mousemove(e);s.mousedown(n)}});k.hooks.drawOverlay.push(function(v,D){if(p.show&&f()){var t=v.getPlotOffset();var s=v.getOptions();D.save();D.translate(t.left,t.top);var z=a.color.parse(s.selection.color);D.strokeStyle=z.scale("a",0.8).toString();D.lineWidth=1;D.lineJoin="round";D.fillStyle=z.scale("a",0.4).toString();var B=Math.min(p.first.x,p.second.x),A=Math.min(p.first.y,p.second.y),C=Math.abs(p.second.x-p.first.x),u=Math.abs(p.second.y-p.first.y);D.fillRect(B,A,C,u);D.strokeRect(B,A,C,u);D.restore()}});k.hooks.shutdown.push(function(t,s){s.unbind("mousemove",e);s.unbind("mousedown",n);if(r){a(document).unbind("mouseup",r)}})}a.plot.plugins.push({init:b,options:{selection:{mode:null,color:"#e8cfac"}},name:"selection",version:"1.1"})})(jQuery);
|
184
src/sunstone/public/vendor/flot/jquery.flot.stack.js
vendored
Normal file
184
src/sunstone/public/vendor/flot/jquery.flot.stack.js
vendored
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for stacking data sets, i.e. putting them on top of each
|
||||||
|
other, for accumulative graphs.
|
||||||
|
|
||||||
|
The plugin assumes the data is sorted on x (or y if stacking
|
||||||
|
horizontally). For line charts, it is assumed that if a line has an
|
||||||
|
undefined gap (from a null point), then the line above it should have
|
||||||
|
the same gap - insert zeros instead of "null" if you want another
|
||||||
|
behaviour. This also holds for the start and end of the chart. Note
|
||||||
|
that stacking a mix of positive and negative values in most instances
|
||||||
|
doesn't make sense (so it looks weird).
|
||||||
|
|
||||||
|
Two or more series are stacked when their "stack" attribute is set to
|
||||||
|
the same key (which can be any number or string or just "true"). To
|
||||||
|
specify the default stack, you can set
|
||||||
|
|
||||||
|
series: {
|
||||||
|
stack: null or true or key (number/string)
|
||||||
|
}
|
||||||
|
|
||||||
|
or specify it for a specific series
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [{ data: [ ... ], stack: true }])
|
||||||
|
|
||||||
|
The stacking order is determined by the order of the data series in
|
||||||
|
the array (later series end up on top of the previous).
|
||||||
|
|
||||||
|
Internally, the plugin modifies the datapoints in each series, adding
|
||||||
|
an offset to the y value. For line series, extra data points are
|
||||||
|
inserted through interpolation. If there's a second y value, it's also
|
||||||
|
adjusted (e.g for bar charts or filled areas).
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
series: { stack: null } // or number/string
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function findMatchingSeries(s, allseries) {
|
||||||
|
var res = null
|
||||||
|
for (var i = 0; i < allseries.length; ++i) {
|
||||||
|
if (s == allseries[i])
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (allseries[i].stack == s.stack)
|
||||||
|
res = allseries[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stackData(plot, s, datapoints) {
|
||||||
|
if (s.stack == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var other = findMatchingSeries(s, plot.getData());
|
||||||
|
if (!other)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ps = datapoints.pointsize,
|
||||||
|
points = datapoints.points,
|
||||||
|
otherps = other.datapoints.pointsize,
|
||||||
|
otherpoints = other.datapoints.points,
|
||||||
|
newpoints = [],
|
||||||
|
px, py, intery, qx, qy, bottom,
|
||||||
|
withlines = s.lines.show,
|
||||||
|
horizontal = s.bars.horizontal,
|
||||||
|
withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
|
||||||
|
withsteps = withlines && s.lines.steps,
|
||||||
|
fromgap = true,
|
||||||
|
keyOffset = horizontal ? 1 : 0,
|
||||||
|
accumulateOffset = horizontal ? 0 : 1,
|
||||||
|
i = 0, j = 0, l;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (i >= points.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
l = newpoints.length;
|
||||||
|
|
||||||
|
if (points[i] == null) {
|
||||||
|
// copy gaps
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
else if (j >= otherpoints.length) {
|
||||||
|
// for lines, we can't use the rest of the points
|
||||||
|
if (!withlines) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
}
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
else if (otherpoints[j] == null) {
|
||||||
|
// oops, got a gap
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(null);
|
||||||
|
fromgap = true;
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// cases where we actually got two points
|
||||||
|
px = points[i + keyOffset];
|
||||||
|
py = points[i + accumulateOffset];
|
||||||
|
qx = otherpoints[j + keyOffset];
|
||||||
|
qy = otherpoints[j + accumulateOffset];
|
||||||
|
bottom = 0;
|
||||||
|
|
||||||
|
if (px == qx) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
newpoints[l + accumulateOffset] += qy;
|
||||||
|
bottom = qy;
|
||||||
|
|
||||||
|
i += ps;
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else if (px > qx) {
|
||||||
|
// we got past point below, might need to
|
||||||
|
// insert interpolated extra point
|
||||||
|
if (withlines && i > 0 && points[i - ps] != null) {
|
||||||
|
intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
|
||||||
|
newpoints.push(qx);
|
||||||
|
newpoints.push(intery + qy);
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
bottom = qy;
|
||||||
|
}
|
||||||
|
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else { // px < qx
|
||||||
|
if (fromgap && withlines) {
|
||||||
|
// if we come from a gap, we just skip this point
|
||||||
|
i += ps;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
// we might be able to interpolate a point below,
|
||||||
|
// this can give us a better y
|
||||||
|
if (withlines && j > 0 && otherpoints[j - otherps] != null)
|
||||||
|
bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
|
||||||
|
|
||||||
|
newpoints[l + accumulateOffset] += bottom;
|
||||||
|
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromgap = false;
|
||||||
|
|
||||||
|
if (l != newpoints.length && withbottom)
|
||||||
|
newpoints[l + 2] += bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
// maintain the line steps invariant
|
||||||
|
if (withsteps && l != newpoints.length && l > 0
|
||||||
|
&& newpoints[l] != null
|
||||||
|
&& newpoints[l] != newpoints[l - ps]
|
||||||
|
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints[l + ps + m] = newpoints[l + m];
|
||||||
|
newpoints[l + 1] = newpoints[l - ps + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
datapoints.points = newpoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.processDatapoints.push(stackData);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'stack',
|
||||||
|
version: '1.2'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.stack.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.stack.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(b){var a={series:{stack:null}};function c(f){function d(k,j){var h=null;for(var g=0;g<j.length;++g){if(k==j[g]){break}if(j[g].stack==k.stack){h=j[g]}}return h}function e(C,v,g){if(v.stack==null){return}var p=d(v,C.getData());if(!p){return}var z=g.pointsize,F=g.points,h=p.datapoints.pointsize,y=p.datapoints.points,t=[],x,w,k,J,I,r,u=v.lines.show,G=v.bars.horizontal,o=z>2&&(G?g.format[2].x:g.format[2].y),n=u&&v.lines.steps,E=true,q=G?1:0,H=G?0:1,D=0,B=0,A;while(true){if(D>=F.length){break}A=t.length;if(F[D]==null){for(m=0;m<z;++m){t.push(F[D+m])}D+=z}else{if(B>=y.length){if(!u){for(m=0;m<z;++m){t.push(F[D+m])}}D+=z}else{if(y[B]==null){for(m=0;m<z;++m){t.push(null)}E=true;B+=h}else{x=F[D+q];w=F[D+H];J=y[B+q];I=y[B+H];r=0;if(x==J){for(m=0;m<z;++m){t.push(F[D+m])}t[A+H]+=I;r=I;D+=z;B+=h}else{if(x>J){if(u&&D>0&&F[D-z]!=null){k=w+(F[D-z+H]-w)*(J-x)/(F[D-z+q]-x);t.push(J);t.push(k+I);for(m=2;m<z;++m){t.push(F[D+m])}r=I}B+=h}else{if(E&&u){D+=z;continue}for(m=0;m<z;++m){t.push(F[D+m])}if(u&&B>0&&y[B-h]!=null){r=I+(y[B-h+H]-I)*(x-J)/(y[B-h+q]-J)}t[A+H]+=r;D+=z}}E=false;if(A!=t.length&&o){t[A+2]+=r}}}}if(n&&A!=t.length&&A>0&&t[A]!=null&&t[A]!=t[A-z]&&t[A+1]!=t[A-z+1]){for(m=0;m<z;++m){t[A+z+m]=t[A+m]}t[A+1]=t[A-z+1]}}g.points=t}f.hooks.processDatapoints.push(e)}b.plot.plugins.push({init:c,options:a,name:"stack",version:"1.2"})})(jQuery);
|
70
src/sunstone/public/vendor/flot/jquery.flot.symbol.js
vendored
Normal file
70
src/sunstone/public/vendor/flot/jquery.flot.symbol.js
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin that adds some extra symbols for plotting points.
|
||||||
|
|
||||||
|
The symbols are accessed as strings through the standard symbol
|
||||||
|
choice:
|
||||||
|
|
||||||
|
series: {
|
||||||
|
points: {
|
||||||
|
symbol: "square" // or "diamond", "triangle", "cross"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
function processRawData(plot, series, datapoints) {
|
||||||
|
// we normalize the area of each symbol so it is approximately the
|
||||||
|
// same as a circle of the given radius
|
||||||
|
|
||||||
|
var handlers = {
|
||||||
|
square: function (ctx, x, y, radius, shadow) {
|
||||||
|
// pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
|
||||||
|
var size = radius * Math.sqrt(Math.PI) / 2;
|
||||||
|
ctx.rect(x - size, y - size, size + size, size + size);
|
||||||
|
},
|
||||||
|
diamond: function (ctx, x, y, radius, shadow) {
|
||||||
|
// pi * r^2 = 2s^2 => s = r * sqrt(pi/2)
|
||||||
|
var size = radius * Math.sqrt(Math.PI / 2);
|
||||||
|
ctx.moveTo(x - size, y);
|
||||||
|
ctx.lineTo(x, y - size);
|
||||||
|
ctx.lineTo(x + size, y);
|
||||||
|
ctx.lineTo(x, y + size);
|
||||||
|
ctx.lineTo(x - size, y);
|
||||||
|
},
|
||||||
|
triangle: function (ctx, x, y, radius, shadow) {
|
||||||
|
// pi * r^2 = 1/2 * s^2 * sin (pi / 3) => s = r * sqrt(2 * pi / sin(pi / 3))
|
||||||
|
var size = radius * Math.sqrt(2 * Math.PI / Math.sin(Math.PI / 3));
|
||||||
|
var height = size * Math.sin(Math.PI / 3);
|
||||||
|
ctx.moveTo(x - size/2, y + height/2);
|
||||||
|
ctx.lineTo(x + size/2, y + height/2);
|
||||||
|
if (!shadow) {
|
||||||
|
ctx.lineTo(x, y - height/2);
|
||||||
|
ctx.lineTo(x - size/2, y + height/2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cross: function (ctx, x, y, radius, shadow) {
|
||||||
|
// pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
|
||||||
|
var size = radius * Math.sqrt(Math.PI) / 2;
|
||||||
|
ctx.moveTo(x - size, y - size);
|
||||||
|
ctx.lineTo(x + size, y + size);
|
||||||
|
ctx.moveTo(x - size, y + size);
|
||||||
|
ctx.lineTo(x + size, y - size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var s = series.points.symbol;
|
||||||
|
if (handlers[s])
|
||||||
|
series.points.symbol = handlers[s];
|
||||||
|
}
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
plot.hooks.processDatapoints.push(processRawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
name: 'symbols',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.symbol.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.symbol.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(b){function a(h,e,g){var d={square:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI)/2;k.rect(j-l,n-l,l+l,l+l)},diamond:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI/2);k.moveTo(j-l,n);k.lineTo(j,n-l);k.lineTo(j+l,n);k.lineTo(j,n+l);k.lineTo(j-l,n)},triangle:function(l,k,o,j,n){var m=j*Math.sqrt(2*Math.PI/Math.sin(Math.PI/3));var i=m*Math.sin(Math.PI/3);l.moveTo(k-m/2,o+i/2);l.lineTo(k+m/2,o+i/2);if(!n){l.lineTo(k,o-i/2);l.lineTo(k-m/2,o+i/2)}},cross:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI)/2;k.moveTo(j-l,n-l);k.lineTo(j+l,n+l);k.moveTo(j-l,n+l);k.lineTo(j+l,n-l)}};var f=e.points.symbol;if(d[f]){e.points.symbol=d[f]}}function c(d){d.hooks.processDatapoints.push(a)}b.plot.plugins.push({init:c,name:"symbols",version:"1.0"})})(jQuery);
|
103
src/sunstone/public/vendor/flot/jquery.flot.threshold.js
vendored
Normal file
103
src/sunstone/public/vendor/flot/jquery.flot.threshold.js
vendored
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
Flot plugin for thresholding data. Controlled through the option
|
||||||
|
"threshold" in either the global series options
|
||||||
|
|
||||||
|
series: {
|
||||||
|
threshold: {
|
||||||
|
below: number
|
||||||
|
color: colorspec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
or in a specific series
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [{ data: [ ... ], threshold: { ... }}])
|
||||||
|
|
||||||
|
The data points below "below" are drawn with the specified color. This
|
||||||
|
makes it easy to mark points below 0, e.g. for budget data.
|
||||||
|
|
||||||
|
Internally, the plugin works by splitting the data into two series,
|
||||||
|
above and below the threshold. The extra series below the threshold
|
||||||
|
will have its label cleared and the special "originSeries" attribute
|
||||||
|
set to the original series. You may need to check for this in hover
|
||||||
|
events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
series: { threshold: null } // or { below: number, color: color spec}
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function thresholdData(plot, s, datapoints) {
|
||||||
|
if (!s.threshold)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ps = datapoints.pointsize, i, x, y, p, prevp,
|
||||||
|
thresholded = $.extend({}, s); // note: shallow copy
|
||||||
|
|
||||||
|
thresholded.datapoints = { points: [], pointsize: ps };
|
||||||
|
thresholded.label = null;
|
||||||
|
thresholded.color = s.threshold.color;
|
||||||
|
thresholded.threshold = null;
|
||||||
|
thresholded.originSeries = s;
|
||||||
|
thresholded.data = [];
|
||||||
|
|
||||||
|
var below = s.threshold.below,
|
||||||
|
origpoints = datapoints.points,
|
||||||
|
addCrossingPoints = s.lines.show;
|
||||||
|
|
||||||
|
threspoints = [];
|
||||||
|
newpoints = [];
|
||||||
|
|
||||||
|
for (i = 0; i < origpoints.length; i += ps) {
|
||||||
|
x = origpoints[i]
|
||||||
|
y = origpoints[i + 1];
|
||||||
|
|
||||||
|
prevp = p;
|
||||||
|
if (y < below)
|
||||||
|
p = threspoints;
|
||||||
|
else
|
||||||
|
p = newpoints;
|
||||||
|
|
||||||
|
if (addCrossingPoints && prevp != p && x != null
|
||||||
|
&& i > 0 && origpoints[i - ps] != null) {
|
||||||
|
var interx = (x - origpoints[i - ps]) / (y - origpoints[i - ps + 1]) * (below - y) + x;
|
||||||
|
prevp.push(interx);
|
||||||
|
prevp.push(below);
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
prevp.push(origpoints[i + m]);
|
||||||
|
|
||||||
|
p.push(null); // start new segment
|
||||||
|
p.push(null);
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
p.push(origpoints[i + m]);
|
||||||
|
p.push(interx);
|
||||||
|
p.push(below);
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
p.push(origpoints[i + m]);
|
||||||
|
}
|
||||||
|
|
||||||
|
p.push(x);
|
||||||
|
p.push(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
datapoints.points = newpoints;
|
||||||
|
thresholded.datapoints.points = threspoints;
|
||||||
|
|
||||||
|
if (thresholded.datapoints.points.length > 0)
|
||||||
|
plot.getData().push(thresholded);
|
||||||
|
|
||||||
|
// FIXME: there are probably some edge cases left in bars
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.processDatapoints.push(thresholdData);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'threshold',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
1
src/sunstone/public/vendor/flot/jquery.flot.threshold.min.js
vendored
Normal file
1
src/sunstone/public/vendor/flot/jquery.flot.threshold.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(function(B){var A={series:{threshold:null}};function C(D){function E(L,S,M){if(!S.threshold){return }var F=M.pointsize,I,O,N,G,K,H=B.extend({},S);H.datapoints={points:[],pointsize:F};H.label=null;H.color=S.threshold.color;H.threshold=null;H.originSeries=S;H.data=[];var P=S.threshold.below,Q=M.points,R=S.lines.show;threspoints=[];newpoints=[];for(I=0;I<Q.length;I+=F){O=Q[I];N=Q[I+1];K=G;if(N<P){G=threspoints}else{G=newpoints}if(R&&K!=G&&O!=null&&I>0&&Q[I-F]!=null){var J=(O-Q[I-F])/(N-Q[I-F+1])*(P-N)+O;K.push(J);K.push(P);for(m=2;m<F;++m){K.push(Q[I+m])}G.push(null);G.push(null);for(m=2;m<F;++m){G.push(Q[I+m])}G.push(J);G.push(P);for(m=2;m<F;++m){G.push(Q[I+m])}}G.push(O);G.push(N)}M.points=newpoints;H.datapoints.points=threspoints;if(H.datapoints.points.length>0){L.getData().push(H)}}D.hooks.processDatapoints.push(E)}B.plot.plugins.push({init:C,options:A,name:"threshold",version:"1.0"})})(jQuery);
|
8316
src/sunstone/public/vendor/flot/jquery.js
vendored
Normal file
8316
src/sunstone/public/vendor/flot/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
23
src/sunstone/public/vendor/flot/jquery.min.js
vendored
Normal file
23
src/sunstone/public/vendor/flot/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
56
src/sunstone/share/OneMonitor/HostMonitor.rb
Normal file
56
src/sunstone/share/OneMonitor/HostMonitor.rb
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# -------------------------------------------------------------------------- #
|
||||||
|
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||||
|
# #
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||||
|
# not use this file except in compliance with the License. You may obtain #
|
||||||
|
# a copy of the License at #
|
||||||
|
# #
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||||
|
# #
|
||||||
|
# Unless required by applicable law or agreed to in writing, software #
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||||
|
# See the License for the specific language governing permissions and #
|
||||||
|
# limitations under the License. #
|
||||||
|
#--------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
require 'OneMonitor'
|
||||||
|
|
||||||
|
class HostMonitor < OneMonitor
|
||||||
|
#:time, :id labels
|
||||||
|
HOST_MONITORING_ELEMS = {
|
||||||
|
:time => "LAST_MON_TIME",
|
||||||
|
:id => "ID",
|
||||||
|
:name => "NAME",
|
||||||
|
:state => "STATE",
|
||||||
|
:cluster => "CLUSTER",
|
||||||
|
:disk_usage => "HOST_SHARE/DISK_USAGE",
|
||||||
|
:cpu_usage => "HOST_SHARE/CPU_USAGE",
|
||||||
|
:mem_usage => "HOST_SHARE/MEM_USAGE",
|
||||||
|
:max_mem => "HOST_SHARE/MAX_MEM",
|
||||||
|
:max_disk => "HOST_SHARE/MAX_DISK",
|
||||||
|
:max_cpu => "HOST_SHARE/MAX_CPU",
|
||||||
|
:free_mem => "HOST_SHARE/FREE_MEM",
|
||||||
|
:free_disk => "HOST_SHARE/FREE_DISK",
|
||||||
|
:free_cpu => "HOST_SHARE/FREE_CPU",
|
||||||
|
:used_disk => "HOST_SHARE/USED_DISK",
|
||||||
|
:used_mem => "HOST_SHARE/USED_MEM",
|
||||||
|
:used_cpu => "HOST_SHARE/USED_CPU"
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize (log_file_folder,monitoring_elems=HOST_MONITORING_ELEMS)
|
||||||
|
super log_file_folder,monitoring_elems
|
||||||
|
end
|
||||||
|
|
||||||
|
def factory(client)
|
||||||
|
HostPool.new(client)
|
||||||
|
end
|
||||||
|
|
||||||
|
def active (host_hash)
|
||||||
|
host_hash[:state].to_i < 3
|
||||||
|
end
|
||||||
|
|
||||||
|
def error (host_hash)
|
||||||
|
host_hash[:state].to_i == 3
|
||||||
|
end
|
||||||
|
end
|
114
src/sunstone/share/OneMonitor/OneMonitor.rb
Normal file
114
src/sunstone/share/OneMonitor/OneMonitor.rb
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
# -------------------------------------------------------------------------- #
|
||||||
|
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||||
|
# #
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||||
|
# not use this file except in compliance with the License. You may obtain #
|
||||||
|
# a copy of the License at #
|
||||||
|
# #
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||||
|
# #
|
||||||
|
# Unless required by applicable law or agreed to in writing, software #
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||||
|
# See the License for the specific language governing permissions and #
|
||||||
|
# limitations under the License. #
|
||||||
|
#--------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
ONE_LOCATION = ENV["ONE_LOCATION"]
|
||||||
|
|
||||||
|
if !ONE_LOCATION
|
||||||
|
RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
|
||||||
|
else
|
||||||
|
RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby"
|
||||||
|
end
|
||||||
|
|
||||||
|
$: << RUBY_LIB_LOCATION
|
||||||
|
|
||||||
|
require 'OpenNebula'
|
||||||
|
require 'OneMonitorUtils'
|
||||||
|
include OpenNebula
|
||||||
|
|
||||||
|
class OneMonitor
|
||||||
|
|
||||||
|
OUTPUT_METHOD="CSV"
|
||||||
|
case OUTPUT_METHOD
|
||||||
|
when "CSV" then include OneMonitorCSV
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(log_file_folder,monitoring_elems)
|
||||||
|
# Authenticate in OpenNebula
|
||||||
|
@client = Client.new
|
||||||
|
@log_file_folder = log_file_folder
|
||||||
|
@monitoring_elems = monitoring_elems
|
||||||
|
@results = []
|
||||||
|
reinit_global_results
|
||||||
|
end
|
||||||
|
|
||||||
|
def results
|
||||||
|
@results
|
||||||
|
end
|
||||||
|
|
||||||
|
def snapshot
|
||||||
|
#init global results
|
||||||
|
|
||||||
|
rc = monitor #calling the extending class method
|
||||||
|
rc = save if rc
|
||||||
|
if rc
|
||||||
|
@results = []
|
||||||
|
reinit_global_results
|
||||||
|
puts "New monitoring snapshots saved."
|
||||||
|
else
|
||||||
|
puts "Error saving new snapshot."
|
||||||
|
end
|
||||||
|
return rc
|
||||||
|
end
|
||||||
|
|
||||||
|
def monitor
|
||||||
|
pool = factory(@client)
|
||||||
|
rc = pool.info
|
||||||
|
|
||||||
|
if OpenNebula.is_error?(rc)
|
||||||
|
puts "Error monitoring: #{rc.message}"
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
pool.each do | elem |
|
||||||
|
time = elem[@monitoring_elems[:time]].to_i
|
||||||
|
|
||||||
|
hash = {}
|
||||||
|
@monitoring_elems.each do | key,value |
|
||||||
|
hash[key] = elem[value]
|
||||||
|
end
|
||||||
|
|
||||||
|
#do not log time = 0, it causes
|
||||||
|
#graphs being drawn from 1970
|
||||||
|
|
||||||
|
if time > 0
|
||||||
|
@results << hash
|
||||||
|
add_to_global(hash)
|
||||||
|
end
|
||||||
|
|
||||||
|
@n_active += 1 if active(hash)
|
||||||
|
@n_error += 1 if error(hash)
|
||||||
|
@n_total += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def reinit_global_results
|
||||||
|
@global_results = {}
|
||||||
|
@monitoring_elems.each do | key,value |
|
||||||
|
@global_results[key] = 0
|
||||||
|
end
|
||||||
|
@n_active = @n_error = @n_total = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_to_global(hash)
|
||||||
|
hash.each do | key,value |
|
||||||
|
@global_results[key] += value.to_i
|
||||||
|
end
|
||||||
|
time = hash[:time].to_i
|
||||||
|
@global_results[:time] = time
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
35
src/sunstone/share/OneMonitor/OneMonitorClient.rb
Normal file
35
src/sunstone/share/OneMonitor/OneMonitorClient.rb
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
require 'OneMonitorClientUtils'
|
||||||
|
|
||||||
|
class OneMonitorClient
|
||||||
|
|
||||||
|
INPUT_METHOD="CSV"
|
||||||
|
case INPUT_METHOD
|
||||||
|
when "CSV" then include OneMonitorCSVClient
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(ids, log_file_folder)
|
||||||
|
#create filenames to read
|
||||||
|
ids = [ids] unless ids.class == Array
|
||||||
|
@file_names = {}
|
||||||
|
ids.each do | id |
|
||||||
|
@file_names[id] = OneMonitorClient.full_path(log_file_folder,id)
|
||||||
|
end
|
||||||
|
return @file_names
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_multiple_data(columns,length)
|
||||||
|
result = []
|
||||||
|
@file_names.each do | id,file_name |
|
||||||
|
result << get_data_for_id(id,columns,length)
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_data_for_id(id, columns, length)
|
||||||
|
readOneMonitorFile(@file_names[id],columns,length)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.full_path(folder,id)
|
||||||
|
"#{folder}/#{id}"
|
||||||
|
end
|
||||||
|
end
|
40
src/sunstone/share/OneMonitor/OneMonitorClientUtils.rb
Normal file
40
src/sunstone/share/OneMonitor/OneMonitorClientUtils.rb
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
module OneMonitorCSVClient
|
||||||
|
def readOneMonitorFile(file_name,columns,length)
|
||||||
|
first_line = `head -1 #{file_name}`.chomp
|
||||||
|
|
||||||
|
if $?.exitstatus != 0
|
||||||
|
return [] #silently fail, cannot find this file
|
||||||
|
end
|
||||||
|
|
||||||
|
n_lines = `wc -l #{file_name} | cut -d' ' -f 1`.to_i
|
||||||
|
if n_lines <= length.to_i
|
||||||
|
length = n_lines-1
|
||||||
|
end
|
||||||
|
|
||||||
|
fields = first_line.split(',')
|
||||||
|
poll_time_pos = fields.index("time")
|
||||||
|
|
||||||
|
if !poll_time_pos
|
||||||
|
return [] #silently fail, no timestamp
|
||||||
|
end
|
||||||
|
|
||||||
|
tail = `tail -#{length} #{file_name}`
|
||||||
|
series = [] #will hold several graphs
|
||||||
|
|
||||||
|
columns.each do | column_name |
|
||||||
|
|
||||||
|
graph = []
|
||||||
|
column_pos = fields.index(column_name)
|
||||||
|
next unless column_pos
|
||||||
|
|
||||||
|
tail.each_line do | line |
|
||||||
|
line_arr = line.delete('"').split(',')
|
||||||
|
graph << [ line_arr[poll_time_pos].to_i*1000, line_arr[column_pos].to_i ]
|
||||||
|
end
|
||||||
|
|
||||||
|
series << graph
|
||||||
|
end
|
||||||
|
|
||||||
|
return series
|
||||||
|
end
|
||||||
|
end
|
93
src/sunstone/share/OneMonitor/OneMonitorUtils.rb
Normal file
93
src/sunstone/share/OneMonitor/OneMonitorUtils.rb
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# -------------------------------------------------------------------------- #
|
||||||
|
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||||
|
# #
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||||
|
# not use this file except in compliance with the License. You may obtain #
|
||||||
|
# a copy of the License at #
|
||||||
|
# #
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||||
|
# #
|
||||||
|
# Unless required by applicable law or agreed to in writing, software #
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||||
|
# See the License for the specific language governing permissions and #
|
||||||
|
# limitations under the License. #
|
||||||
|
#--------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
module OneMonitorCSV
|
||||||
|
|
||||||
|
def save
|
||||||
|
rc = save_csv
|
||||||
|
save_global_csv if rc
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_csv(separator=",")
|
||||||
|
|
||||||
|
@results.each do | mon_hash |
|
||||||
|
id = mon_hash[:id]
|
||||||
|
log_name = "#{@log_file_folder}/#{id}"
|
||||||
|
|
||||||
|
begin
|
||||||
|
log_file = File.new(log_name,'a')
|
||||||
|
|
||||||
|
if !File.size?(log_name)
|
||||||
|
header = csv_header
|
||||||
|
log_file.puts(header)
|
||||||
|
end
|
||||||
|
|
||||||
|
line = hash_to_csv(mon_hash)
|
||||||
|
log_file.puts(line)
|
||||||
|
log_file.close
|
||||||
|
rescue Exception => e
|
||||||
|
puts e.message
|
||||||
|
puts "Error writing log"
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_global_csv
|
||||||
|
begin
|
||||||
|
|
||||||
|
global_log_file = "#{@log_file_folder}/global"
|
||||||
|
global_file = File.new(global_log_file,'a')
|
||||||
|
|
||||||
|
if !File.size?(global_log_file)
|
||||||
|
then
|
||||||
|
header = csv_header+",active,error,total"
|
||||||
|
global_file.puts(header)
|
||||||
|
end
|
||||||
|
|
||||||
|
csv = hash_to_csv(@global_results)+%&,"#{@n_active}","#{@n_error}","#{@n_total}"&
|
||||||
|
global_file.puts(csv)
|
||||||
|
global_file.close
|
||||||
|
return 0
|
||||||
|
rescue Exception => e
|
||||||
|
puts e.message
|
||||||
|
puts "Error writing global results"
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def hash_to_csv hash,separator=","
|
||||||
|
csv_line = ""
|
||||||
|
#we need to respect the order of monitoring elems
|
||||||
|
#keys, which might not be the same in hash
|
||||||
|
@monitoring_elems.each do | key, value |
|
||||||
|
csv_line += %&"#{hash[key]}"#{separator}&
|
||||||
|
end
|
||||||
|
csv_line.chop! unless csv_line.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def csv_header separator=","
|
||||||
|
str = ""
|
||||||
|
@monitoring_elems.each do | key,value |
|
||||||
|
str += "#{key},"
|
||||||
|
end
|
||||||
|
#remove final separator
|
||||||
|
str.chop! unless str.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
48
src/sunstone/share/OneMonitor/VMMonitor.rb
Normal file
48
src/sunstone/share/OneMonitor/VMMonitor.rb
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# -------------------------------------------------------------------------- #
|
||||||
|
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||||
|
# #
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||||
|
# not use this file except in compliance with the License. You may obtain #
|
||||||
|
# a copy of the License at #
|
||||||
|
# #
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||||
|
# #
|
||||||
|
# Unless required by applicable law or agreed to in writing, software #
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||||
|
# See the License for the specific language governing permissions and #
|
||||||
|
# limitations under the License. #
|
||||||
|
#--------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
require 'OneMonitor'
|
||||||
|
|
||||||
|
class VMMonitor < OneMonitor
|
||||||
|
|
||||||
|
VM_MONITORING_ELEMS = {
|
||||||
|
:time => "LAST_POLL",
|
||||||
|
:id => "ID",
|
||||||
|
:name => "NAME",
|
||||||
|
:lcm_state => "LCM_STATE",
|
||||||
|
:state => "STATE",
|
||||||
|
:memory => "MEMORY",
|
||||||
|
:cpu => "CPU",
|
||||||
|
:net_tx => "NET_TX",
|
||||||
|
:net_rx => "NET_RX"
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize (log_file_folder,monitoring_elems=VM_MONITORING_ELEMS)
|
||||||
|
super log_file_folder,monitoring_elems
|
||||||
|
end
|
||||||
|
|
||||||
|
def factory(client)
|
||||||
|
VirtualMachinePool.new(client)
|
||||||
|
end
|
||||||
|
|
||||||
|
def active (vm_hash)
|
||||||
|
vm_hash[:state].to_i == 3
|
||||||
|
end
|
||||||
|
|
||||||
|
def error (vm_hash)
|
||||||
|
vm_hash[:state].to_i == 7
|
||||||
|
end
|
||||||
|
end
|
41
src/sunstone/share/OneMonitor/runOneMonitor.rb
Executable file
41
src/sunstone/share/OneMonitor/runOneMonitor.rb
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------- #
|
||||||
|
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||||
|
# #
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||||
|
# not use this file except in compliance with the License. You may obtain #
|
||||||
|
# a copy of the License at #
|
||||||
|
# #
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||||
|
# #
|
||||||
|
# Unless required by applicable law or agreed to in writing, software #
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||||
|
# See the License for the specific language governing permissions and #
|
||||||
|
# limitations under the License. #
|
||||||
|
#--------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
$: << File.dirname(__FILE__)
|
||||||
|
|
||||||
|
require 'HostMonitor.rb'
|
||||||
|
require 'VMMonitor.rb'
|
||||||
|
|
||||||
|
DEFAULT_INTERVAL= 600 #secs
|
||||||
|
DEFAULT_HOST_LOG_FOLDER = "#{ENV['ONE_LOCATION']}/logs/host/"
|
||||||
|
DEFAULT_VM_LOG_FOLDER = "#{ENV['ONE_LOCATION']}/logs/vm/"
|
||||||
|
|
||||||
|
|
||||||
|
#ARG0=interval, ARG1=hostfolder, ARG2=vmfolder
|
||||||
|
MONITOR_INTERVAL= ARGV[0]? ARGV[0].to_i : DEFAULT_INTERVAL #secs
|
||||||
|
HOST_LOG_FOLDER= ARGV[1]? ARGV[1]: DEFAULT_HOST_LOG_FOLDER
|
||||||
|
VM_LOG_FOLDER=ARGV[2] ? ARGV[2] : DEFAULT_VM_LOG_FOLDER
|
||||||
|
|
||||||
|
hostm = HostMonitor.new(HOST_LOG_FOLDER)
|
||||||
|
vmm = VMMonitor.new(VM_LOG_FOLDER)
|
||||||
|
|
||||||
|
while true do
|
||||||
|
hostm.snapshot
|
||||||
|
vmm.snapshot
|
||||||
|
sleep MONITOR_INTERVAL
|
||||||
|
end
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# -------------------------------------------------------------------------- #
|
# -------------------------------------------------------------------------- #
|
||||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||||
@ -30,8 +31,12 @@ else
|
|||||||
CONFIGURATION_FILE = ONE_LOCATION+"/etc/sunstone-server.conf"
|
CONFIGURATION_FILE = ONE_LOCATION+"/etc/sunstone-server.conf"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
HOST_LOG_FOLDER = LOG_LOCATION+"/OneMonitor/host"
|
||||||
|
VM_LOG_FOLDER = LOG_LOCATION+"/OneMonitor/vm"
|
||||||
|
|
||||||
$: << RUBY_LIB_LOCATION
|
$: << RUBY_LIB_LOCATION
|
||||||
$: << File.dirname(__FILE__)+'/models'
|
$: << File.dirname(__FILE__)+'/models'
|
||||||
|
$: << File.dirname(__FILE__)+'/share/OneMonitor'
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Required libraries
|
# Required libraries
|
||||||
@ -90,6 +95,7 @@ helpers do
|
|||||||
session.clear
|
session.clear
|
||||||
return [204, ""]
|
return [204, ""]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@ -155,6 +161,19 @@ get '/vm/:id/log' do
|
|||||||
@SunstoneServer.get_vm_log(params[:id])
|
@SunstoneServer.get_vm_log(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Logs
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
get '/:resource/monitor' do
|
||||||
|
@SunstoneServer.get_log(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/:resource/:id/monitor' do
|
||||||
|
@SunstoneServer.get_log(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# GET Pool information
|
# GET Pool information
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@ -239,4 +258,3 @@ end
|
|||||||
post '/:resource/:id/action' do
|
post '/:resource/:id/action' do
|
||||||
@SunstoneServer.perform_action(params[:resource], params[:id], request.body.read)
|
@SunstoneServer.perform_action(params[:resource], params[:id], request.body.read)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
304
src/sunstone/sunstone-server.rb.startmonitor
Executable file
304
src/sunstone/sunstone-server.rb.startmonitor
Executable file
@ -0,0 +1,304 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------- #
|
||||||
|
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||||
|
# #
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||||
|
# not use this file except in compliance with the License. You may obtain #
|
||||||
|
# a copy of the License at #
|
||||||
|
# #
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||||
|
# #
|
||||||
|
# Unless required by applicable law or agreed to in writing, software #
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||||
|
# See the License for the specific language governing permissions and #
|
||||||
|
# limitations under the License. #
|
||||||
|
#--------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
ONE_LOCATION = ENV["ONE_LOCATION"]
|
||||||
|
|
||||||
|
if !ONE_LOCATION
|
||||||
|
LOG_LOCATION = "/var/log/one"
|
||||||
|
VAR_LOCATION = "/var/lib/one"
|
||||||
|
RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
|
||||||
|
CONFIGURATION_FILE = "/etc/one/sunstone-server.conf"
|
||||||
|
else
|
||||||
|
VAR_LOCATION = ONE_LOCATION+"/var"
|
||||||
|
LOG_LOCATION = ONE_LOCATION+"/var"
|
||||||
|
RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby"
|
||||||
|
CONFIGURATION_FILE = ONE_LOCATION+"/etc/sunstone-server.conf"
|
||||||
|
end
|
||||||
|
|
||||||
|
HOST_LOG_FOLDER = LOG_LOCATION+"/OneMonitor/host"
|
||||||
|
VM_LOG_FOLDER = LOG_LOCATION+"/OneMonitor/vm"
|
||||||
|
|
||||||
|
#TODO put share
|
||||||
|
MONITOR_CMD = File.dirname(__FILE__)+'/share/OneMonitor/runOneMonitor.rb'
|
||||||
|
MONITORING_INTERVAL = 10 #seconds
|
||||||
|
|
||||||
|
$: << RUBY_LIB_LOCATION
|
||||||
|
$: << File.dirname(__FILE__)+'/models'
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Required libraries
|
||||||
|
##############################################################################
|
||||||
|
require 'rubygems'
|
||||||
|
require 'sinatra'
|
||||||
|
|
||||||
|
require 'cloud/Configuration'
|
||||||
|
require 'SunstoneServer'
|
||||||
|
|
||||||
|
set :config, Configuration.new(CONFIGURATION_FILE)
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Sinatra Configuration
|
||||||
|
##############################################################################
|
||||||
|
use Rack::Session::Pool
|
||||||
|
set :host, settings.config[:host]
|
||||||
|
set :port, settings.config[:port]
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Helpers
|
||||||
|
##############################################################################
|
||||||
|
helpers do
|
||||||
|
def authorized?
|
||||||
|
session[:ip] && session[:ip]==request.ip ? true : false
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_session
|
||||||
|
auth = Rack::Auth::Basic::Request.new(request.env)
|
||||||
|
if auth.provided? && auth.basic? && auth.credentials
|
||||||
|
user = auth.credentials[0]
|
||||||
|
sha1_pass = Digest::SHA1.hexdigest(auth.credentials[1])
|
||||||
|
|
||||||
|
rc = SunstoneServer.authorize(user, sha1_pass)
|
||||||
|
if rc[1]
|
||||||
|
session[:user] = user
|
||||||
|
session[:user_id] = rc[1]
|
||||||
|
session[:password] = sha1_pass
|
||||||
|
session[:ip] = request.ip
|
||||||
|
session[:remember] = params[:remember]
|
||||||
|
|
||||||
|
if params[:remember]
|
||||||
|
env['rack.session.options'][:expire_after] = 30*60*60*24
|
||||||
|
end
|
||||||
|
|
||||||
|
return [204, ""]
|
||||||
|
else
|
||||||
|
return [rc.first, ""]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return [401, ""]
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy_session
|
||||||
|
session.clear
|
||||||
|
return [204, ""]
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_monitor
|
||||||
|
if !session['monitor']
|
||||||
|
config = settings.config
|
||||||
|
|
||||||
|
begin
|
||||||
|
Dir.mkdir(HOST_LOG_FOLDER) if !File.directory?(HOST_LOG_FOLDER)
|
||||||
|
Dir.mkdir(VM_LOG_FOLDER) if !File.directory?(VM_LOG_FOLDER)
|
||||||
|
rescue
|
||||||
|
return [500,Error.new("Cannot create log folders")]
|
||||||
|
end
|
||||||
|
|
||||||
|
monitoring_interval = config[:monitoring_interval]
|
||||||
|
monitoring_interval = MONITORING_INTERVAL if !monitoring_interval
|
||||||
|
|
||||||
|
pipe = IO.popen("#{MONITOR_CMD} #{monitoring_interval} #{HOST_LOG_FOLDER} #{VM_LOG_FOLDER}")
|
||||||
|
session['monitor'] = pipe
|
||||||
|
puts "OneMonitor successfully started"
|
||||||
|
return [200,""]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def stop_monitor
|
||||||
|
pipe = session['monitor']
|
||||||
|
if pipe
|
||||||
|
Process.kill('KILL',pipe.pid)
|
||||||
|
pipe.close
|
||||||
|
end
|
||||||
|
return [200,""]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
unless request.path=='/login' || request.path=='/'
|
||||||
|
halt 401 unless authorized?
|
||||||
|
|
||||||
|
@SunstoneServer = SunstoneServer.new(session[:user], session[:password])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
unless request.path=='/login' || request.path=='/'
|
||||||
|
unless session[:remember]
|
||||||
|
if params[:timeout] == true
|
||||||
|
env['rack.session.options'][:defer] = true
|
||||||
|
else
|
||||||
|
env['rack.session.options'][:expire_after] = 60*10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# HTML Requests
|
||||||
|
##############################################################################
|
||||||
|
get '/' do
|
||||||
|
redirect '/login' unless authorized?
|
||||||
|
|
||||||
|
time = Time.now + 60
|
||||||
|
response.set_cookie("one-user",
|
||||||
|
:value=>"#{session[:user]}",
|
||||||
|
:expires=>time)
|
||||||
|
response.set_cookie("one-user_id",
|
||||||
|
:value=>"#{session[:user_id]}",
|
||||||
|
:expires=>time)
|
||||||
|
|
||||||
|
File.read(File.dirname(__FILE__)+'/templates/index.html')
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/login' do
|
||||||
|
File.read(File.dirname(__FILE__)+'/templates/login.html')
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Login
|
||||||
|
##############################################################################
|
||||||
|
post '/login' do
|
||||||
|
build_session
|
||||||
|
end
|
||||||
|
|
||||||
|
post '/logout' do
|
||||||
|
destroy_session
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Config and Logs
|
||||||
|
##############################################################################
|
||||||
|
get '/config' do
|
||||||
|
@SunstoneServer.get_configuration(session[:user_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/vm/:id/log' do
|
||||||
|
@SunstoneServer.get_vm_log(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Logs
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
post '/startmonitor' do
|
||||||
|
start_monitor
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/:resource/monitor' do
|
||||||
|
@SunstoneServer.get_log(params[:resource],
|
||||||
|
-1,
|
||||||
|
settings.config,
|
||||||
|
params['monitor_resources'],
|
||||||
|
params['history_length'])
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/:resource/:id/monitor' do
|
||||||
|
@SunstoneServer.get_log(params[:resource],
|
||||||
|
params[:id],
|
||||||
|
settings.config,
|
||||||
|
params['monitor_resources'],
|
||||||
|
params['history_length'])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# GET Pool information
|
||||||
|
##############################################################################
|
||||||
|
get '/:pool' do
|
||||||
|
@SunstoneServer.get_pool(params[:pool])
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# GET Resource information
|
||||||
|
##############################################################################
|
||||||
|
get '/:resource/:id' do
|
||||||
|
@SunstoneServer.get_resource(params[:resource], params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Delete Resource
|
||||||
|
##############################################################################
|
||||||
|
delete '/:resource/:id' do
|
||||||
|
@SunstoneServer.delete_resource(params[:resource], params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Create a new Resource
|
||||||
|
##############################################################################
|
||||||
|
post '/:pool' do
|
||||||
|
@SunstoneServer.create_resource(params[:pool], request.body.read)
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Stop the VNC Session of a target VM
|
||||||
|
##############################################################################
|
||||||
|
post '/vm/:id/stopvnc' do
|
||||||
|
vm_id = params[:id]
|
||||||
|
vnc_hash = session['vnc']
|
||||||
|
|
||||||
|
if !vnc_hash || !vnc_hash[vm_id]
|
||||||
|
msg = "It seems there is no VNC proxy running for this machine"
|
||||||
|
return [403, OpenNebula::Error.new(msg).to_json]
|
||||||
|
end
|
||||||
|
|
||||||
|
rc = @SunstoneServer.stopvnc(vm_id, vnc_hash[vm_id][:pipe])
|
||||||
|
if rc[0] == 200
|
||||||
|
session['vnc'].delete(vm_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
rc
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start a VNC Session for a target VM
|
||||||
|
##############################################################################
|
||||||
|
post '/vm/:id/startvnc' do
|
||||||
|
vm_id = params[:id]
|
||||||
|
|
||||||
|
vnc_hash = session['vnc']
|
||||||
|
|
||||||
|
if !vnc_hash
|
||||||
|
session['vnc']= {}
|
||||||
|
elsif vnc_hash[vm_id]
|
||||||
|
#return existing information
|
||||||
|
info = vnc_hash[vm_id].clone
|
||||||
|
info.delete(:pipe)
|
||||||
|
|
||||||
|
return [200, info.to_json]
|
||||||
|
end
|
||||||
|
|
||||||
|
rc = @SunstoneServer.startvnc(vm_id, settings.config)
|
||||||
|
if rc[0] == 200
|
||||||
|
info = rc[1]
|
||||||
|
session['vnc'][vm_id] = info.clone
|
||||||
|
info.delete(:pipe)
|
||||||
|
|
||||||
|
[200, info.to_json]
|
||||||
|
else
|
||||||
|
rc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Perform an action on a Resource
|
||||||
|
##############################################################################
|
||||||
|
post '/:resource/:id/action' do
|
||||||
|
@SunstoneServer.perform_action(params[:resource], params[:id], request.body.read)
|
||||||
|
end
|
@ -16,7 +16,7 @@
|
|||||||
<script type="text/javascript" src="/vendor/jQueryUI/jquery-ui-1.8.7.custom.min.js"></script>
|
<script type="text/javascript" src="/vendor/jQueryUI/jquery-ui-1.8.7.custom.min.js"></script>
|
||||||
<script type="text/javascript" src="/vendor/jQueryLayout/jquery.layout.min-1.2.0.js"></script>
|
<script type="text/javascript" src="/vendor/jQueryLayout/jquery.layout.min-1.2.0.js"></script>
|
||||||
<script type="text/javascript" src="/vendor/dataTables/jquery.dataTables.min.js"></script>
|
<script type="text/javascript" src="/vendor/dataTables/jquery.dataTables.min.js"></script>
|
||||||
|
<script language="javascript" type="text/javascript" src="/vendor/flot/jquery.flot.js"></script>
|
||||||
|
|
||||||
<!-- End Vendor Libraries -->
|
<!-- End Vendor Libraries -->
|
||||||
|
|
||||||
@ -69,6 +69,9 @@
|
|||||||
|
|
||||||
<div id="dialogs">
|
<div id="dialogs">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div id="plots">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="info_panels"></div>
|
<div id="info_panels"></div>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user