[llvm-commits] [LNT] r164193 - in /lnt/trunk/lnt/server/ui/static/flot: jquery.flot.highlight.js jquery.flot.highlight.min.js
Michael Gottesman
mgottesman at apple.com
Tue Sep 18 19:08:48 PDT 2012
Author: mgottesman
Date: Tue Sep 18 21:08:48 2012
New Revision: 164193
URL: http://llvm.org/viewvc/llvm-project?rev=164193&view=rev
Log:
[LNT] Added a custom trivial float plugin to allow for highlighting of
regression regions to make it easy to find on a v4_graph. This is just
the javascript and not the view code.
Added:
lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.js
lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.min.js
Added: lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.js
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.js?rev=164193&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.js (added)
+++ lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.js Tue Sep 18 21:08:48 2012
@@ -0,0 +1,86 @@
+/*
+Flot plugin for highlighting regionst hat extend infinitely vertically
+in a zoom independent manner.
+
+The relevent arguments for this function are:
+
+ 1. range: Start and end revision number, i.e.,
+
+ range: {start: REVISION1, end: REVISION2}
+
+ 2. color: The color to fill/stroke. Each number must be a string from 0-255, i.e.,
+
+ color: ["0", "0", "255"]
+
+ We use different alpha values for the regular/overview graph so to change that see below.
+
+ 3. alpha: What alpha should we use for the fill on the main graph. This should be a string again, i.e.,
+
+ alpha: "0.2"
+
+ 4. strokealpha: What alpha should we use for the stroke on the overview graph. This should be a string
+ again, i.e.,
+
+ strokealpha: "1.0"
+
+ 5. stroke: Should we stroke the region on the overview graph? Should be a boolean, i.e.,
+
+ stroke: true
+*/
+
+(function ($) {
+
+ function init(plot) {
+ plot.hooks.draw.push(function(plot, ctx) {
+ var plot_offset = plot.getPlotOffset();
+ var plot_height = plot.height();
+
+ var range = plot.getOptions().highlight.range;
+ var stroke = plot.getOptions().highlight.stroke;
+ var color = plot.getOptions().highlight.color;
+ var alpha = plot.getOptions().highlight.alpha;
+ var strokealpha = plot.getOptions().highlight.strokealpha;
+
+ var start = {x: range.start, y: 0};
+ var end = {x: range.end, y: 0};
+
+ var start_offset = plot.pointOffset(start);
+ var end_offset = plot.pointOffset(end);
+
+ var amin = plot.pointOffset({x: plot.getAxes().xaxis.min, y: plot.getAxes().yaxis.min});
+ var amax = plot.pointOffset({x: plot.getAxes().xaxis.max, y: plot.getAxes().yaxis.max});
+ var left_correction = Math.min(0, start_offset.left - amin.left);
+ var right_correction = Math.min(0, amax.left - end_offset.left);
+
+ var left = Math.max(start_offset.left, plot_offset.left);
+ var top = plot_offset.top;
+ var width = Math.max(end_offset.left - start_offset.left + left_correction + right_correction, 0);
+ var height = amin.top - plot_offset.top;
+
+ ctx.save();
+ ctx.fillStyle = "rgba(" + color[0] + ", " + color[1] + ", " + color[2] + ", " + alpha + ")";
+ ctx.fillRect(left, top, width, height);
+ if (stroke) {
+ ctx.lineWidth = 1;
+ ctx.strokeStyle = "rgba(" + color[0] + ", " + color[1] + ", " + color[2] + ", " + strokealpha + ")";
+ ctx.strokeRect(left, top, width, height);
+ }
+ ctx.restore();
+ });
+ }
+
+ $.plot.plugins.push({
+ init: init,
+ options: {
+ highlight: {
+ range: {start: 0, end: 0},
+ color: ["0", "0", "255"],
+ alpha: "0.2",
+ strokealpha: "1.0",
+ stroke: false
+ }
+ },
+ name: 'highlight',
+ version: '1.0'
+ });
+})(jQuery);
Added: lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.min.js
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.min.js?rev=164193&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.min.js (added)
+++ lnt/trunk/lnt/server/ui/static/flot/jquery.flot.highlight.min.js Tue Sep 18 21:08:48 2012
@@ -0,0 +1,2 @@
+(function(f){f.plot.plugins.push({init:function(f){f.hooks.draw.push(function(a,c){var d=a.getPlotOffset();a.height();var b=a.getOptions().highlight.range,f=a.getOptions().highlight.stroke,e=a.getOptions().highlight.color,k=a.getOptions().highlight.alpha,l=a.getOptions().highlight.strokealpha,g={x:b.end,y:0},b=a.pointOffset({x:b.start,y:0}),i=a.pointOffset(g),g=a.pointOffset({x:a.getAxes().xaxis.min,y:a.getAxes().yaxis.min}),h=a.pointOffset({x:a.getAxes().xaxis.max,y:a.getAxes().yaxis.max}),m=Math.min(0,
+b.left-g.left),n=Math.min(0,h.left-i.left),h=Math.max(b.left,d.left),j=d.top,b=Math.max(i.left-b.left+m+n,0),d=g.top-d.top;c.save();c.fillStyle="rgba("+e[0]+", "+e[1]+", "+e[2]+", "+k+")";c.fillRect(h,j,b,d);f&&(c.lineWidth=1,c.strokeStyle="rgba("+e[0]+", "+e[1]+", "+e[2]+", "+l+")",c.strokeRect(h,j,b,d));c.restore()})},options:{highlight:{range:{start:0,end:0},color:["0","0","255"],alpha:"0.2",strokealpha:"1.0",stroke:!1}},name:"highlight",version:"1.0"})})(jQuery);
More information about the llvm-commits
mailing list