[llvm-commits] [zorg] r99808 - /zorg/trunk/lnt/lnt/viewer/js/View2D.js
Daniel Dunbar
daniel at zuster.org
Mon Mar 29 01:25:08 PDT 2010
Author: ddunbar
Date: Mon Mar 29 03:25:08 2010
New Revision: 99808
URL: http://llvm.org/viewvc/llvm-project?rev=99808&view=rev
Log:
Graph2D: Add two new graph styles, points and simple error bars (lines).
Modified:
zorg/trunk/lnt/lnt/viewer/js/View2D.js
Modified: zorg/trunk/lnt/lnt/viewer/js/View2D.js
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/js/View2D.js?rev=99808&r1=99807&r2=99808&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/js/View2D.js (original)
+++ zorg/trunk/lnt/lnt/viewer/js/View2D.js Mon Mar 29 03:25:08 2010
@@ -532,6 +532,67 @@
},
});
+var Graph2D_PointPlotStyle = new Class ({
+ Extends: Graph2D_PlotStyle,
+
+ initialize: function(width, color) {
+ if (!width)
+ width = 1;
+ if (!color)
+ color = [0,0,0];
+
+ this.parent();
+ this.width = width;
+ this.color = color;
+ },
+
+ plot: function(graph, ctx, data) {
+ if (data.length === 0)
+ return;
+
+ ctx.beginPath();
+ var radius = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5;
+ for (var i = 0, e = data.length; i != e; ++i) {
+ var co = graph.graphInfo.toNDC(data[i]);
+ ctx.moveTo(co[0], co[1]);
+ ctx.arc(co[0], co[1], radius, 0, Math.PI * 2, /*anticlockwise=*/false);
+ }
+ ctx.fillStyle = col3_to_rgb(this.color);
+ ctx.fill();
+ },
+});
+
+var Graph2D_ErrorBarPlotStyle = new Class ({
+ Extends: Graph2D_PlotStyle,
+
+ initialize: function(width, color) {
+ if (!width)
+ width = 1;
+ if (!color)
+ color = [0,0,0];
+
+ this.parent();
+ this.width = width;
+ this.color = color;
+ },
+
+ plot: function(graph, ctx, data) {
+ if (data.length === 0)
+ return;
+
+ ctx.beginPath();
+ for (var i = 0, e = data.length; i != e; ++i) {
+ var co_min = graph.graphInfo.toNDC([data[i][0], data[i][1]]);
+ var co_max = graph.graphInfo.toNDC([data[i][0], data[i][2]]);
+ ctx.moveTo(co_min[0], co_min[1]);
+ ctx.lineTo(co_max[0], co_max[1]);
+ }
+ ctx.lineWidth = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5;
+ ctx.strokeStyle = col3_to_rgb(this.color);
+ ctx.stroke();
+ },
+});
+
var Graph2D_Axis = new Class ({
// Static Methods
formats: {
More information about the llvm-commits
mailing list