0)
- maxRadius *= shrink;
- attempts += 1;
- clear();
- if (options.series.pie.tilt<=0.8)
- drawShadow();
- drawPie();
- }
- if (attempts >= redrawAttempts) {
- clear();
- target.prepend('Could not draw pie with labels contained inside canvas
');
- }
-
- 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 = '' + text + "";
- 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;';
- $('
').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 ''+label+'
'+Math.round(slice.percent)+'%
';
- }, // 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);
diff --git a/airtime_mvc/public/js/flot/jquery.flot.selection.js b/airtime_mvc/public/js/flot/jquery.flot.selection.js
deleted file mode 100644
index 7f7b32694..000000000
--- a/airtime_mvc/public/js/flot/jquery.flot.selection.js
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
-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);
diff --git a/airtime_mvc/public/js/flot/jquery.flot.stack.js b/airtime_mvc/public/js/flot/jquery.flot.stack.js
deleted file mode 100644
index a31d5dc9b..000000000
--- a/airtime_mvc/public/js/flot/jquery.flot.stack.js
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
-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);
diff --git a/airtime_mvc/public/js/flot/jquery.flot.symbol.js b/airtime_mvc/public/js/flot/jquery.flot.symbol.js
deleted file mode 100644
index a32fe3185..000000000
--- a/airtime_mvc/public/js/flot/jquery.flot.symbol.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-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);
diff --git a/airtime_mvc/public/js/flot/jquery.flot.threshold.js b/airtime_mvc/public/js/flot/jquery.flot.threshold.js
deleted file mode 100644
index 0b2e7ac82..000000000
--- a/airtime_mvc/public/js/flot/jquery.flot.threshold.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-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);