Browse Source

Merge branch 'develop' into graph2d

Conflicts:
	dist/vis.js
	dist/vis.min.css
	dist/vis.min.js
css_transitions
Alex de Mulder 10 years ago
parent
commit
0b6f2c9fb1
5 changed files with 89 additions and 72 deletions
  1. +6
    -2
      HISTORY.md
  2. +72
    -66
      docs/graph.html
  3. +8
    -2
      src/graph/Edge.js
  4. +2
    -1
      src/graph/Graph.js
  5. +1
    -1
      src/graph/Node.js

+ 6
- 2
HISTORY.md View File

@ -17,11 +17,15 @@ http://visjs.org
### Graph ### Graph
- Throws an error when constructing without new keyword.
- Now throws an error when constructing without new keyword.
- Added pull request from Vukk, user can now define the edge width multiplier when selected.
- Fixed graph.storePositions()
- Extended Selection API with selectNodes and selectEdges, deprecating setSelection.
- Fixed multiline labels.
### Graph3d ### Graph3d
- Throws an error when constructing without new keyword.
- Now throws an error when constructing without new keyword.
## 2014-06-19, version 2.0.0 ## 2014-06-19, version 2.0.0

+ 72
- 66
docs/graph.html View File

@ -527,45 +527,45 @@ When using a DataSet, the graph is automatically updating to changes in the Data
<th>Required</th> <th>Required</th>
<th>Description</th> <th>Description</th>
</tr> </tr>
<tr>
<td>arrowScaleFactor</td>
<td>Number</td>
<td>no</td>
<td>If you are using arrows, this will scale the arrow. Values < 1 give smaller arrows, > 1 larger arrows. Default: 1.</td>
</tr>
<tr>
<td>color</td>
<td>String | Object</td>
<td>no</td>
<td>Color for the edge.</td>
</tr>
<tr>
<td>arrowScaleFactor</td>
<td>Number</td>
<td>no</td>
<td>If you are using arrows, this will scale the arrow. Values < 1 give smaller arrows, > 1 larger arrows. Default: 1.</td>
</tr>
<tr>
<td>color</td>
<td>String | Object</td>
<td>no</td>
<td>Color for the edge.</td>
</tr>
<tr>
<td>color.color</td>
<td>String</td>
<td>no</td>
<td>Color of the edge when not selected.</td>
</tr>
<tr>
<td>color.color</td>
<td>String</td>
<td>no</td>
<td>Color of the edge when not selected.</td>
</tr>
<tr>
<td>color.highlight</td>
<td>String</td>
<td>no</td>
<td>Color of the edge when selected.</td>
</tr>
<tr>
<td>color.highlight</td>
<td>String</td>
<td>no</td>
<td>Color of the edge when selected.</td>
</tr>
<tr>
<td>color.hover</td>
<td>String</td>
<td>no</td>
<td>Color of the edge when the edge is hovered over and the hover option is enabled.</td>
</tr>
<tr>
<td>hoverWidth</td>
<td>Number</td>
<td>1.5</td>
<td>This determines the thickness of the edge if it is hovered over. This will only manifest when the hover option is enabled.</td>
</tr>
<tr>
<td>color.hover</td>
<td>String</td>
<td>no</td>
<td>Color of the edge when the edge is hovered over and the hover option is enabled.</td>
</tr>
<tr>
<td>hoverWidth</td>
<td>Number</td>
<td>1.5</td>
<td>This determines the thickness of the edge if it is hovered over. This will only manifest when the hover option is enabled.</td>
</tr>
<tr> <tr>
<td>dash</td> <td>dash</td>
@ -1149,32 +1149,32 @@ var options = {
<th>Default</th> <th>Default</th>
<th>Description</th> <th>Description</th>
</tr> </tr>
<tr>
<td>arrowScaleFactor</td>
<td>Number</td>
<td>1</td>
<td>If you are using arrows, this will scale the arrow. Values < 1 give smaller arrows, > 1 larger arrows. Default: 1.</td>
</tr>
<tr>
<td>color</td>
<td>String | Object</td>
<td>Object</td>
<td>Colors of the edge. This object contains both colors for the selected and unselected state.</td>
</tr>
<tr>
<td>arrowScaleFactor</td>
<td>Number</td>
<td>1</td>
<td>If you are using arrows, this will scale the arrow. Values < 1 give smaller arrows, > 1 larger arrows. Default: 1.</td>
</tr>
<tr>
<td>color</td>
<td>String | Object</td>
<td>Object</td>
<td>Colors of the edge. This object contains both colors for the selected and unselected state.</td>
</tr>
<tr>
<td>color.color</td>
<td>String</td>
<td>"#848484"</td>
<td>Color of the edge when not selected.</td>
</tr>
<tr>
<td>color.color</td>
<td>String</td>
<td>"#848484"</td>
<td>Color of the edge when not selected.</td>
</tr>
<tr>
<td>color.highlight</td>
<td>String</td>
<td>"#848484"</td>
<td>Color of the edge when selected.</td>
</tr>
<tr>
<td>color.highlight</td>
<td>String</td>
<td>"#848484"</td>
<td>Color of the edge when selected.</td>
</tr>
<tr> <tr>
<td>dash</td> <td>dash</td>
@ -1214,12 +1214,12 @@ var options = {
<td>Default length of a gap in pixels on a dashed line. <td>Default length of a gap in pixels on a dashed line.
Only applicable when the line style is <code>dash-line</code>.</td> Only applicable when the line style is <code>dash-line</code>.</td>
</tr> </tr>
<tr>
<td>length</td>
<td>number</td>
<td>physics.[method].springLength</td>
<td>The resting length of the edge when modeled as a spring. By default the springLength determined by the physics is used. By using this setting you can make certain edges have different resting lengths.</td>
</tr>
<tr>
<td>length</td>
<td>number</td>
<td>physics.[method].springLength</td>
<td>The resting length of the edge when modeled as a spring. By default the springLength determined by the physics is used. By using this setting you can make certain edges have different resting lengths.</td>
</tr>
<tr> <tr>
<td>style</td> <td>style</td>
@ -1235,6 +1235,12 @@ var options = {
<td>1</td> <td>1</td>
<td>The default width of a edge.</td> <td>The default width of a edge.</td>
</tr> </tr>
<tr>
<td>widthSelectionMultiplier</td>
<td>Number</td>
<td>2</td>
<td>Determines the thickness scaling of an selected edge. This is applied when an edge, or a node connected to it, is selected.</td>
</tr>
</table> </table>
<h3 id="Groups_configuration">Groups configuration</h3> <h3 id="Groups_configuration">Groups configuration</h3>

+ 8
- 2
src/graph/Edge.js View File

@ -30,6 +30,8 @@ function Edge (properties, graph, constants) {
this.style = constants.edges.style; this.style = constants.edges.style;
this.title = undefined; this.title = undefined;
this.width = constants.edges.width; this.width = constants.edges.width;
this.widthSelectionMultiplier = constants.edges.widthSelectionMultiplier;
this.widthSelected = this.width * this.widthSelectionMultiplier;
this.hoverWidth = constants.edges.hoverWidth; this.hoverWidth = constants.edges.hoverWidth;
this.value = undefined; this.value = undefined;
this.length = constants.physics.springLength; this.length = constants.physics.springLength;
@ -99,6 +101,8 @@ Edge.prototype.setProperties = function(properties, constants) {
if (properties.title !== undefined) {this.title = properties.title;} if (properties.title !== undefined) {this.title = properties.title;}
if (properties.width !== undefined) {this.width = properties.width;} if (properties.width !== undefined) {this.width = properties.width;}
if (properties.widthSelectionMultiplier !== undefined)
{this.widthSelectionMultiplier = properties.widthSelectionMultiplier;}
if (properties.hoverWidth !== undefined) {this.hoverWidth = properties.hoverWidth;} if (properties.hoverWidth !== undefined) {this.hoverWidth = properties.hoverWidth;}
if (properties.value !== undefined) {this.value = properties.value;} if (properties.value !== undefined) {this.value = properties.value;}
if (properties.length !== undefined) {this.length = properties.length; if (properties.length !== undefined) {this.length = properties.length;
@ -133,6 +137,8 @@ Edge.prototype.setProperties = function(properties, constants) {
this.widthFixed = this.widthFixed || (properties.width !== undefined); this.widthFixed = this.widthFixed || (properties.width !== undefined);
this.lengthFixed = this.lengthFixed || (properties.length !== undefined); this.lengthFixed = this.lengthFixed || (properties.length !== undefined);
this.widthSelected = this.width * this.widthSelectionMultiplier;
// set draw method based on style // set draw method based on style
switch (this.style) { switch (this.style) {
case 'line': this.draw = this._drawLine; break; case 'line': this.draw = this._drawLine; break;
@ -310,7 +316,7 @@ Edge.prototype._drawLine = function(ctx) {
*/ */
Edge.prototype._getLineWidth = function() { Edge.prototype._getLineWidth = function() {
if (this.selected == true) { if (this.selected == true) {
return Math.min(this.width * 2, this.widthMax)*this.graphScaleInv;
return Math.min(this.widthSelected, this.widthMax)*this.graphScaleInv;
} }
else { else {
if (this.hover == true) { if (this.hover == true) {
@ -954,4 +960,4 @@ Edge.prototype.getControlNodePositions = function(ctx) {
} }
return {from:{x:xFrom,y:yFrom},to:{x:xTo,y:yTo}}; return {from:{x:xFrom,y:yFrom},to:{x:xTo,y:yTo}};
}
}

+ 2
- 1
src/graph/Graph.js View File

@ -72,6 +72,7 @@ function Graph (container, data, options) {
widthMin: 1, widthMin: 1,
widthMax: 15, widthMax: 15,
width: 1, width: 1,
widthSelectionMultiplier: 2,
hoverWidth: 1.5, hoverWidth: 1.5,
style: 'line', style: 'line',
color: { color: {
@ -2245,7 +2246,7 @@ Graph.prototype.storePosition = function() {
var node = this.nodes[nodeId]; var node = this.nodes[nodeId];
var allowedToMoveX = !this.nodes.xFixed; var allowedToMoveX = !this.nodes.xFixed;
var allowedToMoveY = !this.nodes.yFixed; var allowedToMoveY = !this.nodes.yFixed;
if (this.nodesData.data[nodeId].x != Math.round(node.x) || this.nodesData.data[nodeId].y != Math.round(node.y)) {
if (this.nodesData._data[nodeId].x != Math.round(node.x) || this.nodesData._data[nodeId].y != Math.round(node.y)) {
dataArray.push({id:nodeId,x:Math.round(node.x),y:Math.round(node.y),allowedToMoveX:allowedToMoveX,allowedToMoveY:allowedToMoveY}); dataArray.push({id:nodeId,x:Math.round(node.x),y:Math.round(node.y),allowedToMoveX:allowedToMoveX,allowedToMoveY:allowedToMoveY});
} }
} }

+ 1
- 1
src/graph/Node.js View File

@ -855,7 +855,7 @@ Node.prototype._label = function (ctx, text, x, y, align, baseline) {
var lines = text.split('\n'), var lines = text.split('\n'),
lineCount = lines.length, lineCount = lines.length,
fontSize = (this.fontSize + 4), fontSize = (this.fontSize + 4),
yLine = y + (1 - lineCount) / 2 * fontSize;
yLine = y + (1 - lineCount) / (2 * fontSize);
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);

Loading…
Cancel
Save