Browse Source

cleaned up docs for network, added fontfill for nodes

v3_develop
Alex de Mulder 10 years ago
parent
commit
c1bff7c986
6 changed files with 25425 additions and 25616 deletions
  1. +24983
    -24976
      dist/vis.js
  2. +420
    -625
      docs/network.html
  3. +3
    -3
      examples/network/02_random_nodes.html
  4. +1
    -6
      lib/network/Edge.js
  5. +5
    -4
      lib/network/Network.js
  6. +13
    -2
      lib/network/Node.js

+ 24983
- 24976
dist/vis.js
File diff suppressed because it is too large
View File


+ 420
- 625
docs/network.html
File diff suppressed because it is too large
View File


+ 3
- 3
examples/network/02_random_nodes.html View File

@ -8,6 +8,8 @@
font: 10pt sans; font: 10pt sans;
} }
#mynetwork { #mynetwork {
width: 600px;
height: 600px;
border: 1px solid lightgray; border: 1px solid lightgray;
} }
</style> </style>
@ -74,9 +76,7 @@
nodes: nodes, nodes: nodes,
edges: edges edges: edges
}; };
var options = {
};
var options = {};
network = new vis.Network(container, data, options); network = new vis.Network(container, data, options);
// add event listeners // add event listeners

+ 1
- 6
lib/network/Edge.js View File

@ -71,7 +71,7 @@ Edge.prototype.setProperties = function(properties) {
} }
var fields = ['style','fontSize','fontFace','fontColor','fontFill','width', var fields = ['style','fontSize','fontFace','fontColor','fontFill','width',
'widthSelectionMultiplier','hoverWidth','arrowScaleFactor','dash'
'widthSelectionMultiplier','hoverWidth','arrowScaleFactor','dash','inheritColor'
]; ];
util.selectiveDeepExtend(fields, this.options, properties); util.selectiveDeepExtend(fields, this.options, properties);
@ -85,11 +85,6 @@ Edge.prototype.setProperties = function(properties) {
if (properties.value !== undefined) {this.value = properties.value;} if (properties.value !== undefined) {this.value = properties.value;}
if (properties.length !== undefined) {this.physics.springLength = properties.length;} if (properties.length !== undefined) {this.physics.springLength = properties.length;}
// scale the arrow
if (properties.arrowScaleFactor !== undefined) {this.options.arrowScaleFactor = properties.arrowScaleFactor;}
if (properties.inheritColor !== undefined) {this.options.inheritColor = properties.inheritColor;}
if (properties.color !== undefined) { if (properties.color !== undefined) {
this.options.inheritColor = false; this.options.inheritColor = false;
if (util.isString(properties.color)) { if (util.isString(properties.color)) {

+ 5
- 4
lib/network/Network.js View File

@ -62,10 +62,10 @@ function Network (container, data, options) {
image: undefined, image: undefined,
widthMin: 16, // px widthMin: 16, // px
widthMax: 64, // px widthMax: 64, // px
fixed: false,
fontColor: 'black', fontColor: 'black',
fontSize: 14, // px fontSize: 14, // px
fontFace: 'verdana', fontFace: 'verdana',
fontFill: undefined,
level: -1, level: -1,
color: { color: {
border: '#2B7CE9', border: '#2B7CE9',
@ -83,11 +83,12 @@ function Network (container, data, options) {
backgroundColor: '#97C2FC', backgroundColor: '#97C2FC',
highlightColor: '#D2E5FF', highlightColor: '#D2E5FF',
group: undefined, group: undefined,
borderWidth: 1
borderWidth: 1,
borderWidthSelected: undefined
}, },
edges: { edges: {
widthMin: 1,
widthMax: 15,
widthMin: 1, //
widthMax: 15,//
width: 1, width: 1,
widthSelectionMultiplier: 2, widthSelectionMultiplier: 2,
hoverWidth: 1.5, hoverWidth: 1.5,

+ 13
- 2
lib/network/Node.js View File

@ -136,7 +136,7 @@ Node.prototype.setProperties = function(properties, constants) {
} }
var fields = ['borderWidth','borderWidthSelected','shape','image','radius','fontColor', var fields = ['borderWidth','borderWidthSelected','shape','image','radius','fontColor',
'fontSize','fontFace','group','mass'
'fontSize','fontFace','fontFill','group','mass'
]; ];
util.selectiveDeepExtend(fields, this.options, properties); util.selectiveDeepExtend(fields, this.options, properties);
@ -844,7 +844,6 @@ Node.prototype._drawText = function (ctx) {
Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNode) { Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNode) {
if (text && Number(this.options.fontSize) * this.networkScale > this.fontDrawThreshold) { if (text && Number(this.options.fontSize) * this.networkScale > this.fontDrawThreshold) {
ctx.font = (this.selected ? "bold " : "") + this.options.fontSize + "px " + this.options.fontFace; ctx.font = (this.selected ? "bold " : "") + this.options.fontSize + "px " + this.options.fontFace;
ctx.fillStyle = this.options.fontColor || "black";
ctx.textAlign = align || "center"; ctx.textAlign = align || "center";
ctx.textBaseline = baseline || "middle"; ctx.textBaseline = baseline || "middle";
@ -856,6 +855,18 @@ Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNo
yLine = y + (1 - lineCount) / (2 * fontSize); yLine = y + (1 - lineCount) / (2 * fontSize);
} }
// font fill from edges now for nodes!
if (this.options.fontFill !== undefined && this.options.fontFill !== null && this.options.fontFill !== "none") {
var width = ctx.measureText(text).width;
var height = this.options.fontSize;
var left = x - width / 2;
var top = y - height / 2;
ctx.fillStyle = this.options.fontFill;
ctx.fillRect(left, top, width, height);
}
// draw text
ctx.fillStyle = this.options.fontColor || "black";
for (var i = 0; i < lineCount; i++) { for (var i = 0; i < lineCount; i++) {
ctx.fillText(lines[i], x, yLine); ctx.fillText(lines[i], x, yLine);
yLine += fontSize; yLine += fontSize;

Loading…
Cancel
Save