Can Flot plot a vector field? -


i have js explores properties of planar model , mechanism causes phase transition in lattice of spins. 1 indicator of phase transition way spins oriented in lattice, , plot vector field. can flot that?

yes, can 1 small change flot library. in drawseriespoints(series) function (line 1986 in version 0.7) change line

symbol(ctx, x, y, radius, shadow); 

to this

symbol(ctx, x, y, radius, shadow, series, math.floor(i / ps)); 

this done can access datapoint when drawing it.

format data points in form [x coordinate, y coordinate, vector angle, vector length] , use custom symbol function this:

function vector(ctx, x, y, radius, shadow, series, index) {    var vectorangle = series.data[index][2]; // in radians   var vectorlength = series.data[index][3]; // in pixels    var bottom = [math.round(x + vectorlength * math.sin(vectorangle)), math.round(y - vectorlength * math.cos(vectorangle))];   var top = [math.round(x - vectorlength * math.sin(vectorangle)), math.round(y + vectorlength * math.cos(vectorangle))];   var left = [top[0] - (top[0] - bottom[0]) / 4 + (top[1] - bottom[1]) / 4, top[1] - (top[1] - bottom[1]) / 4 - (top[0] - bottom[0]) / 4];   var right = [top[0] - (top[0] - bottom[0]) / 4 - (top[1] - bottom[1]) / 4, top[1] - (top[1] - bottom[1]) / 4 + (top[0] - bottom[0]) / 4];    ctx.beginpath();   ctx.moveto(top[0], top[1]);   ctx.lineto(left[0], left[1]);   ctx.lineto(right[0], right[1]);   ctx.lineto(top[0], top[1]);   ctx.closepath();   ctx.fillstyle = series.color;   ctx.fill();    ctx.beginpath();   ctx.moveto(top[0], top[1])   ctx.lineto(bottom[0], bottom[1]);   ctx.stroke();    ctx.beginpath();   ctx.moveto(x, y); } 

complete example fiddle.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -