Update springyui.js

font property for nodes and edges
graph.newEdge(AHM_10, AHM_50 ,{font:'10px Verdana, sans-serif', label: 'ablehnen', color: '#97f23d'});
This commit is contained in:
mikeleber 2013-05-30 11:43:54 +02:00
parent 5439db1423
commit 4adb4308dd

View File

@ -27,7 +27,8 @@ Copyright (c) 2010 Dennis Hotson
jQuery.fn.springy = function(params) { jQuery.fn.springy = function(params) {
var graph = this.graph = params.graph || new Springy.Graph(); var graph = this.graph = params.graph || new Springy.Graph();
var nodeFont = "12px Verdana, sans-serif";
var edgeFont = "8px Verdana, sans-serif";
var stiffness = params.stiffness || 400.0; var stiffness = params.stiffness || 400.0;
var repulsion = params.repulsion || 400.0; var repulsion = params.repulsion || 400.0;
var damping = params.damping || 0.5; var damping = params.damping || 0.5;
@ -126,7 +127,7 @@ jQuery.fn.springy = function(params) {
return this._width[text]; return this._width[text];
ctx.save(); ctx.save();
ctx.font = "16px Verdana, sans-serif"; ctx.font = (this.data.font !== undefined) ? this.data.font : nodeFont;
var width = ctx.measureText(text).width + 10; var width = ctx.measureText(text).width + 10;
ctx.restore(); ctx.restore();
@ -232,7 +233,7 @@ jQuery.fn.springy = function(params) {
ctx.save(); ctx.save();
ctx.textAlign = "center"; ctx.textAlign = "center";
ctx.textBaseline = "top"; ctx.textBaseline = "top";
ctx.font = "10px Helvetica, sans-serif"; ctx.font = (edge.data.font !== undefined) ? edge.data.font : edgeFont;
ctx.fillStyle = "#5BA6EC"; ctx.fillStyle = "#5BA6EC";
ctx.fillText(text, (x1+x2)/2, (y1+y2)/2); ctx.fillText(text, (x1+x2)/2, (y1+y2)/2);
ctx.restore(); ctx.restore();
@ -262,7 +263,7 @@ jQuery.fn.springy = function(params) {
ctx.textAlign = "left"; ctx.textAlign = "left";
ctx.textBaseline = "top"; ctx.textBaseline = "top";
ctx.font = "16px Verdana, sans-serif"; ctx.font = (node.data.font !== undefined) ? node.data.font : nodeFont;
ctx.fillStyle = "#000000"; ctx.fillStyle = "#000000";
ctx.font = "16px Verdana, sans-serif"; ctx.font = "16px Verdana, sans-serif";
var text = (node.data.label !== undefined) ? node.data.label : node.id; var text = (node.data.label !== undefined) ? node.data.label : node.id;