Fixing font definitions so systems without Verdana (eg Linux) don't look so bad.
Also moving the constructor of springyUI to use named parameters so we can specify the dampening repulsion and stiffness in the constructor.
This commit is contained in:
parent
6eabd21ffd
commit
2bc3f927bd
19
springyui.js
19
springyui.js
|
@ -25,10 +25,19 @@ Copyright (c) 2010 Dennis Hotson
|
|||
|
||||
(function() {
|
||||
|
||||
jQuery.fn.springy = function(graph) {
|
||||
jQuery.fn.springy = function(params) {
|
||||
var graph = params.graph;
|
||||
if(!graph){
|
||||
return;
|
||||
}
|
||||
|
||||
var stiffness = params.stiffness || 400.0;
|
||||
var repulsion = params.repulsion || 400.0;
|
||||
var damping = params.damping || 0.5;
|
||||
|
||||
var canvas = this[0];
|
||||
var ctx = canvas.getContext("2d");
|
||||
var layout = new Layout.ForceDirected(graph, 400.0, 400.0, 0.5);
|
||||
var layout = new Layout.ForceDirected(graph, stiffness, repulsion, damping);
|
||||
|
||||
// calculate bounding box of graph layout.. with ease-in
|
||||
var currentBB = layout.getBoundingBox();
|
||||
|
@ -102,7 +111,7 @@ jQuery.fn.springy = function(graph) {
|
|||
Node.prototype.getWidth = function() {
|
||||
ctx.save();
|
||||
var text = typeof(this.data.label) !== 'undefined' ? this.data.label : this.id;
|
||||
ctx.font = "16px Verdana";
|
||||
ctx.font = "16px Verdana, sans-serif";
|
||||
var width = ctx.measureText(text).width + 10;
|
||||
ctx.restore();
|
||||
return width;
|
||||
|
@ -237,9 +246,9 @@ jQuery.fn.springy = function(graph) {
|
|||
|
||||
ctx.textAlign = "left";
|
||||
ctx.textBaseline = "top";
|
||||
ctx.font = "16px Verdana";
|
||||
ctx.font = "16px Verdana, sans-serif";
|
||||
ctx.fillStyle = "#000000";
|
||||
ctx.font = "16px Verdana";
|
||||
ctx.font = "16px Verdana, sans-serif";
|
||||
var text = typeof(node.data.label) !== 'undefined' ? node.data.label : node.id;
|
||||
ctx.fillText(text, s.x - boxWidth/2 + 5, s.y - 8);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user