Browse Source

Refactored more code from `graph` to `network`

css_transitions
jos 10 years ago
parent
commit
5d9a7d02b4
84 changed files with 78 additions and 80 deletions
  1. +1
    -1
      Jakefile.js
  2. +39
    -41
      dist/vis.js
  3. +4
    -4
      dist/vis.min.js
  4. +1
    -1
      examples/index.html
  5. +0
    -0
      examples/network/01_basic_usage.html
  6. +0
    -0
      examples/network/02_random_nodes.html
  7. +0
    -0
      examples/network/03_images.html
  8. +0
    -0
      examples/network/04_shapes.html
  9. +0
    -0
      examples/network/05_social_network.html
  10. +0
    -0
      examples/network/06_groups.html
  11. +0
    -0
      examples/network/07_selections.html
  12. +0
    -0
      examples/network/08_mobile_friendly.html
  13. +0
    -0
      examples/network/09_sizing.html
  14. +0
    -0
      examples/network/10_multiline_text.html
  15. +0
    -0
      examples/network/11_custom_style.html
  16. +0
    -0
      examples/network/12_scalable_images.html
  17. +0
    -0
      examples/network/13_dashed_lines.html
  18. +0
    -0
      examples/network/14_dot_language.html
  19. +0
    -0
      examples/network/15_dot_language_playground.html
  20. +0
    -0
      examples/network/16_dynamic_data.html
  21. +0
    -0
      examples/network/17_network_info.html
  22. +0
    -0
      examples/network/18_fully_random_nodes_clustering.html
  23. +0
    -0
      examples/network/19_scale_free_graph_clustering.html
  24. +0
    -0
      examples/network/20_navigation.html
  25. +0
    -0
      examples/network/21_data_manipulation.html
  26. +0
    -0
      examples/network/22_les_miserables.html
  27. +0
    -0
      examples/network/23_hierarchical_layout.html
  28. +0
    -0
      examples/network/24_hierarchical_layout_userdefined.html
  29. +0
    -0
      examples/network/25_physics_configuration.html
  30. +0
    -0
      examples/network/graphviz/data/fsm.gv.txt
  31. +0
    -0
      examples/network/graphviz/data/hello.gv.txt
  32. +0
    -0
      examples/network/graphviz/data/process.gv.txt
  33. +0
    -0
      examples/network/graphviz/data/siblings.gv.txt
  34. +0
    -0
      examples/network/graphviz/data/softmaint.gv.txt
  35. +0
    -0
      examples/network/graphviz/data/traffic_lights.gv.txt
  36. +0
    -0
      examples/network/graphviz/data/transparency.gv.txt
  37. +0
    -0
      examples/network/graphviz/data/twopi2.gv.txt
  38. +0
    -0
      examples/network/graphviz/data/unix.gv.txt
  39. +0
    -0
      examples/network/graphviz/data/world.gv.txt
  40. +0
    -0
      examples/network/graphviz/graphviz_gallery.html
  41. +0
    -0
      examples/network/graphviz/screenshots/fsm.png
  42. +0
    -0
      examples/network/graphviz/screenshots/hello.png
  43. +0
    -0
      examples/network/graphviz/screenshots/softmaint.png
  44. +0
    -0
      examples/network/graphviz/screenshots/traffic_lights.png
  45. +0
    -0
      examples/network/img/refresh-cl/Hardware-Fax-icon.png
  46. +0
    -0
      examples/network/img/refresh-cl/Hardware-Laptop-1-icon.png
  47. +0
    -0
      examples/network/img/refresh-cl/Hardware-Mobile-Phone-icon.png
  48. +0
    -0
      examples/network/img/refresh-cl/Hardware-My-Computer-3-icon.png
  49. +0
    -0
      examples/network/img/refresh-cl/Hardware-My-PDA-02-icon.png
  50. +0
    -0
      examples/network/img/refresh-cl/Hardware-My-PDA-04-icon.png
  51. +0
    -0
      examples/network/img/refresh-cl/Hardware-My-PDA-05-icon.png
  52. +0
    -0
      examples/network/img/refresh-cl/Hardware-My-Phone-Picture-icon.png
  53. +0
    -0
      examples/network/img/refresh-cl/Hardware-Printer-Blue-icon.png
  54. +0
    -0
      examples/network/img/refresh-cl/Misc-Scanner-default-icon.png
  55. +0
    -0
      examples/network/img/refresh-cl/Network-Drive-icon.png
  56. +0
    -0
      examples/network/img/refresh-cl/Network-Internet-Connection-icon.png
  57. +0
    -0
      examples/network/img/refresh-cl/Network-Pipe-icon.png
  58. +0
    -0
      examples/network/img/refresh-cl/System-Firewall-2-icon.png
  59. +0
    -0
      examples/network/img/refresh-cl/System-Globe-icon.png
  60. +0
    -0
      examples/network/img/refresh-cl/license.txt
  61. +0
    -0
      examples/network/img/soft-scraps-icons/Document-icon24.png
  62. +0
    -0
      examples/network/img/soft-scraps-icons/Document-icon32.png
  63. +0
    -0
      examples/network/img/soft-scraps-icons/Document-icon48.png
  64. +0
    -0
      examples/network/img/soft-scraps-icons/Email-icon24.png
  65. +0
    -0
      examples/network/img/soft-scraps-icons/Email-icon32.png
  66. +0
    -0
      examples/network/img/soft-scraps-icons/Email-icon48.png
  67. +0
    -0
      examples/network/img/soft-scraps-icons/Folder-icon24.png
  68. +0
    -0
      examples/network/img/soft-scraps-icons/Folder-icon32.png
  69. +0
    -0
      examples/network/img/soft-scraps-icons/Folder-icon48.png
  70. +0
    -0
      examples/network/img/soft-scraps-icons/Folder-icon64.png
  71. +0
    -0
      examples/network/img/soft-scraps-icons/Smiley-Angry-icon.png
  72. +0
    -0
      examples/network/img/soft-scraps-icons/Smiley-Grin-icon.png
  73. +0
    -0
      examples/network/img/soft-scraps-icons/User-Administrator-Blue-icon.png
  74. +0
    -0
      examples/network/img/soft-scraps-icons/User-Administrator-Green-icon.png
  75. +0
    -0
      examples/network/img/soft-scraps-icons/User-Coat-Blue-icon.png
  76. +0
    -0
      examples/network/img/soft-scraps-icons/User-Coat-Green-icon.png
  77. +0
    -0
      examples/network/img/soft-scraps-icons/User-Coat-Red-icon.png
  78. +0
    -0
      examples/network/img/soft-scraps-icons/User-Executive-Green-icon.png
  79. +0
    -0
      examples/network/img/soft-scraps-icons/User-Preppy-Blue-icon.png
  80. +0
    -0
      examples/network/img/soft-scraps-icons/User-Preppy-Red-icon.png
  81. +0
    -0
      examples/network/img/soft-scraps-icons/license.txt
  82. +0
    -0
      examples/network/index.html
  83. +1
    -1
      src/timeline/Graph2d.js
  84. +32
    -32
      src/timeline/component/LineGraph.js

+ 1
- 1
Jakefile.js View File

@ -72,7 +72,7 @@ task('build', {async: true}, function () {
'./src/timeline/component/GraphGroup.js', './src/timeline/component/GraphGroup.js',
'./src/timeline/component/Legend.js', './src/timeline/component/Legend.js',
'./src/timeline/component/DataAxis.js', './src/timeline/component/DataAxis.js',
'./src/timeline/component/Linegraph.js',
'./src/timeline/component/LineGraph.js',
'./src/timeline/DataStep.js', './src/timeline/DataStep.js',
'./src/timeline/Stack.js', './src/timeline/Stack.js',

+ 39
- 41
dist/vis.js View File

@ -3711,13 +3711,13 @@ DataAxis.prototype.snap = function(date) {
var UNGROUPED = '__ungrouped__'; // reserved group id for ungrouped items var UNGROUPED = '__ungrouped__'; // reserved group id for ungrouped items
/** /**
* This is the constructor of the linegraph. It requires a timeline body and options.
* This is the constructor of the LineGraph. It requires a Timeline body and options.
* *
* @param body * @param body
* @param options * @param options
* @constructor * @constructor
*/ */
function Linegraph(body, options) {
function LineGraph(body, options) {
this.id = util.randomUUID(); this.id = util.randomUUID();
this.body = body; this.body = body;
@ -3835,14 +3835,14 @@ function Linegraph(body, options) {
this.body.emitter.emit("change"); this.body.emitter.emit("change");
} }
Linegraph.prototype = new Component();
LineGraph.prototype = new Component();
/** /**
* Create the HTML DOM for the ItemSet * Create the HTML DOM for the ItemSet
*/ */
Linegraph.prototype._create = function(){
LineGraph.prototype._create = function(){
var frame = document.createElement('div'); var frame = document.createElement('div');
frame.className = 'linegraph';
frame.className = 'LineGraph';
this.dom.frame = frame; this.dom.frame = frame;
// create svg element for graph drawing. // create svg element for graph drawing.
@ -3868,10 +3868,10 @@ Linegraph.prototype._create = function(){
}; };
/** /**
* set the options of the linegraph. the mergeOptions is used for subObjects that have an enabled element.
* set the options of the LineGraph. the mergeOptions is used for subObjects that have an enabled element.
* @param options * @param options
*/ */
Linegraph.prototype.setOptions = function(options) {
LineGraph.prototype.setOptions = function(options) {
if (options) { if (options) {
var fields = ['sampling','defaultGroup','graphHeight','yAxisOrientation','style','barChart','dataAxis','sort']; var fields = ['sampling','defaultGroup','graphHeight','yAxisOrientation','style','barChart','dataAxis','sort'];
util.selectiveDeepExtend(fields, this.options, options); util.selectiveDeepExtend(fields, this.options, options);
@ -3923,7 +3923,7 @@ Linegraph.prototype.setOptions = function(options) {
/** /**
* Hide the component from the DOM * Hide the component from the DOM
*/ */
Linegraph.prototype.hide = function() {
LineGraph.prototype.hide = function() {
// remove the frame containing the items // remove the frame containing the items
if (this.dom.frame.parentNode) { if (this.dom.frame.parentNode) {
this.dom.frame.parentNode.removeChild(this.dom.frame); this.dom.frame.parentNode.removeChild(this.dom.frame);
@ -3934,7 +3934,7 @@ Linegraph.prototype.hide = function() {
* Show the component in the DOM (when not already visible). * Show the component in the DOM (when not already visible).
* @return {Boolean} changed * @return {Boolean} changed
*/ */
Linegraph.prototype.show = function() {
LineGraph.prototype.show = function() {
// show frame containing the items // show frame containing the items
if (!this.dom.frame.parentNode) { if (!this.dom.frame.parentNode) {
this.body.dom.center.appendChild(this.dom.frame); this.body.dom.center.appendChild(this.dom.frame);
@ -3946,7 +3946,7 @@ Linegraph.prototype.show = function() {
* Set items * Set items
* @param {vis.DataSet | null} items * @param {vis.DataSet | null} items
*/ */
Linegraph.prototype.setItems = function(items) {
LineGraph.prototype.setItems = function(items) {
var me = this, var me = this,
ids, ids,
oldItemsData = this.itemsData; oldItemsData = this.itemsData;
@ -3993,7 +3993,7 @@ Linegraph.prototype.setItems = function(items) {
* Set groups * Set groups
* @param {vis.DataSet} groups * @param {vis.DataSet} groups
*/ */
Linegraph.prototype.setGroups = function(groups) {
LineGraph.prototype.setGroups = function(groups) {
var me = this, var me = this,
ids; ids;
@ -4036,15 +4036,15 @@ Linegraph.prototype.setGroups = function(groups) {
Linegraph.prototype._onUpdate = function(ids) {
LineGraph.prototype._onUpdate = function(ids) {
this._updateUngrouped(); this._updateUngrouped();
this._updateAllGroupData(); this._updateAllGroupData();
this._updateGraph(); this._updateGraph();
this.redraw(); this.redraw();
}; };
Linegraph.prototype._onAdd = function (ids) {this._onUpdate(ids);};
Linegraph.prototype._onRemove = function (ids) {this._onUpdate(ids);};
Linegraph.prototype._onUpdateGroups = function (groupIds) {
LineGraph.prototype._onAdd = function (ids) {this._onUpdate(ids);};
LineGraph.prototype._onRemove = function (ids) {this._onUpdate(ids);};
LineGraph.prototype._onUpdateGroups = function (groupIds) {
for (var i = 0; i < groupIds.length; i++) { for (var i = 0; i < groupIds.length; i++) {
var group = this.groupsData.get(groupIds[i]); var group = this.groupsData.get(groupIds[i]);
this._updateGroup(group, groupIds[i]); this._updateGroup(group, groupIds[i]);
@ -4053,9 +4053,9 @@ Linegraph.prototype._onUpdateGroups = function (groupIds) {
this._updateGraph(); this._updateGraph();
this.redraw(); this.redraw();
}; };
Linegraph.prototype._onAddGroups = function (groupIds) {this._onUpdateGroups(groupIds);};
LineGraph.prototype._onAddGroups = function (groupIds) {this._onUpdateGroups(groupIds);};
Linegraph.prototype._onRemoveGroups = function (groupIds) {
LineGraph.prototype._onRemoveGroups = function (groupIds) {
for (var i = 0; i < groupIds.length; i++) { for (var i = 0; i < groupIds.length; i++) {
if (!this.groups.hasOwnProperty(groupIds[i])) { if (!this.groups.hasOwnProperty(groupIds[i])) {
if (this.groups[groupIds[i]].options.yAxisOrientation == 'right') { if (this.groups[groupIds[i]].options.yAxisOrientation == 'right') {
@ -4083,7 +4083,7 @@ Linegraph.prototype._onRemoveGroups = function (groupIds) {
* @param groupId * @param groupId
* @private * @private
*/ */
Linegraph.prototype._updateGroup = function (group, groupId) {
LineGraph.prototype._updateGroup = function (group, groupId) {
if (!this.groups.hasOwnProperty(groupId)) { if (!this.groups.hasOwnProperty(groupId)) {
this.groups[groupId] = new GraphGroup(group, groupId, this.options, this.groupsUsingDefaultStyles); this.groups[groupId] = new GraphGroup(group, groupId, this.options, this.groupsUsingDefaultStyles);
if (this.groups[groupId].options.yAxisOrientation == 'right') { if (this.groups[groupId].options.yAxisOrientation == 'right') {
@ -4110,7 +4110,7 @@ Linegraph.prototype._updateGroup = function (group, groupId) {
this.legendRight.redraw(); this.legendRight.redraw();
}; };
Linegraph.prototype._updateAllGroupData = function () {
LineGraph.prototype._updateAllGroupData = function () {
if (this.itemsData != null) { if (this.itemsData != null) {
// ~450 ms @ 500k // ~450 ms @ 500k
@ -4150,7 +4150,7 @@ Linegraph.prototype._updateAllGroupData = function () {
* there are no groups specified. This anonymous group is called 'graph'. * there are no groups specified. This anonymous group is called 'graph'.
* @protected * @protected
*/ */
Linegraph.prototype._updateUngrouped = function() {
LineGraph.prototype._updateUngrouped = function() {
if (this.itemsData != null) { if (this.itemsData != null) {
// var t0 = new Date(); // var t0 = new Date();
var group = {id: UNGROUPED, content: this.options.defaultGroup}; var group = {id: UNGROUPED, content: this.options.defaultGroup};
@ -4216,7 +4216,7 @@ Linegraph.prototype._updateUngrouped = function() {
* Redraw the component, mandatory function * Redraw the component, mandatory function
* @return {boolean} Returns true if the component is resized * @return {boolean} Returns true if the component is resized
*/ */
Linegraph.prototype.redraw = function() {
LineGraph.prototype.redraw = function() {
var resized = false; var resized = false;
this.svg.style.height = ('' + this.options.graphHeight).replace('px','') + 'px'; this.svg.style.height = ('' + this.options.graphHeight).replace('px','') + 'px';
@ -4254,7 +4254,7 @@ Linegraph.prototype.redraw = function() {
* Update and redraw the graph. * Update and redraw the graph.
* *
*/ */
Linegraph.prototype._updateGraph = function () {
LineGraph.prototype._updateGraph = function () {
// reset the svg elements // reset the svg elements
DOMutil.prepareElements(this.svgElements); DOMutil.prepareElements(this.svgElements);
// // very slow... // // very slow...
@ -4363,7 +4363,7 @@ Linegraph.prototype._updateGraph = function () {
* @param {array} groupIds * @param {array} groupIds
* @private * @private
*/ */
Linegraph.prototype._updateYAxis = function (groupIds, groupRanges) {
LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
var changeCalled = false; var changeCalled = false;
var yAxisLeftUsed = false; var yAxisLeftUsed = false;
var yAxisRightUsed = false; var yAxisRightUsed = false;
@ -4437,7 +4437,7 @@ Linegraph.prototype._updateYAxis = function (groupIds, groupRanges) {
* @private * @private
* @param axis * @param axis
*/ */
Linegraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) {
LineGraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) {
var changed = false; var changed = false;
if (axisUsed == false) { if (axisUsed == false) {
if (axis.dom.frame.parentNode) { if (axis.dom.frame.parentNode) {
@ -4460,7 +4460,7 @@ Linegraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) {
* @param datapoints * @param datapoints
* @param group * @param group
*/ */
Linegraph.prototype._drawBarGraph = function (dataset, group) {
LineGraph.prototype._drawBarGraph = function (dataset, group) {
if (dataset != null) { if (dataset != null) {
if (dataset.length > 0) { if (dataset.length > 0) {
var coreDistance; var coreDistance;
@ -4495,7 +4495,7 @@ Linegraph.prototype._drawBarGraph = function (dataset, group) {
* @param datapoints * @param datapoints
* @param group * @param group
*/ */
Linegraph.prototype._drawLineGraph = function (dataset, group) {
LineGraph.prototype._drawLineGraph = function (dataset, group) {
if (dataset != null) { if (dataset != null) {
if (dataset.length > 0) { if (dataset.length > 0) {
var path, d; var path, d;
@ -4543,7 +4543,7 @@ Linegraph.prototype._drawLineGraph = function (dataset, group) {
* @param svg * @param svg
* @param group * @param group
*/ */
Linegraph.prototype._drawPoints = function (dataset, group, JSONcontainer, svg, offset) {
LineGraph.prototype._drawPoints = function (dataset, group, JSONcontainer, svg, offset) {
if (offset === undefined) {offset = 0;} if (offset === undefined) {offset = 0;}
for (var i = 0; i < dataset.length; i++) { for (var i = 0; i < dataset.length; i++) {
DOMutil.drawPoint(dataset[i].x + offset, dataset[i].y, group, JSONcontainer, svg); DOMutil.drawPoint(dataset[i].x + offset, dataset[i].y, group, JSONcontainer, svg);
@ -4561,11 +4561,14 @@ Linegraph.prototype._drawPoints = function (dataset, group, JSONcontainer, svg,
* @returns {Array} * @returns {Array}
* @private * @private
*/ */
Linegraph.prototype._preprocessData = function (datapoints, group) {
LineGraph.prototype._preprocessData = function (datapoints, group) {
var extractedData = []; var extractedData = [];
var xValue, yValue, increment;
var xValue, yValue;
var toScreen = this.body.util.toScreen; var toScreen = this.body.util.toScreen;
var increment = 1;
var amountOfPoints = datapoints.length;
var yMin = datapoints[0].y; var yMin = datapoints[0].y;
var yMax = datapoints[0].y; var yMax = datapoints[0].y;
@ -4573,19 +4576,14 @@ Linegraph.prototype._preprocessData = function (datapoints, group) {
// of width changing of the yAxis. // of width changing of the yAxis.
if (group.options.sampling == true) { if (group.options.sampling == true) {
var xDistance = this.body.util.toGlobalScreen(datapoints[datapoints.length-1].x) - this.body.util.toGlobalScreen(datapoints[0].x); var xDistance = this.body.util.toGlobalScreen(datapoints[datapoints.length-1].x) - this.body.util.toGlobalScreen(datapoints[0].x);
var amountOfPoints = datapoints.length;
var pointsPerPixel = amountOfPoints/xDistance; var pointsPerPixel = amountOfPoints/xDistance;
increment = Math.min(Math.ceil(0.2 * amountOfPoints), Math.max(1,Math.round(pointsPerPixel))); increment = Math.min(Math.ceil(0.2 * amountOfPoints), Math.max(1,Math.round(pointsPerPixel)));
} }
else {
increment = 1;
}
for (var i = 0; i < amountOfPoints; i += increment) { for (var i = 0; i < amountOfPoints; i += increment) {
xValue = toScreen(datapoints[i].x) + this.width - 1; xValue = toScreen(datapoints[i].x) + this.width - 1;
yValue = datapoints[i].y; yValue = datapoints[i].y;
extractedData.push({x: xValue, y: yValue}); extractedData.push({x: xValue, y: yValue});
yMin = yMin > yValue ? yValue : yMin; yMin = yMin > yValue ? yValue : yMin;
yMax = yMax < yValue ? yValue : yMax; yMax = yMax < yValue ? yValue : yMax;
} }
@ -4603,7 +4601,7 @@ Linegraph.prototype._preprocessData = function (datapoints, group) {
* @returns {Array} * @returns {Array}
* @private * @private
*/ */
Linegraph.prototype._convertYvalues = function (datapoints, group) {
LineGraph.prototype._convertYvalues = function (datapoints, group) {
var extractedData = []; var extractedData = [];
var xValue, yValue; var xValue, yValue;
var axis = this.yAxisLeft; var axis = this.yAxisLeft;
@ -4633,7 +4631,7 @@ Linegraph.prototype._convertYvalues = function (datapoints, group) {
* @returns {string} * @returns {string}
* @private * @private
*/ */
Linegraph.prototype._catmullRomUniform = function(data) {
LineGraph.prototype._catmullRomUniform = function(data) {
// catmull rom // catmull rom
var p0, p1, p2, p3, bp1, bp2; var p0, p1, p2, p3, bp1, bp2;
var d = Math.round(data[0].x) + "," + Math.round(data[0].y) + " "; var d = Math.round(data[0].x) + "," + Math.round(data[0].y) + " ";
@ -4680,7 +4678,7 @@ Linegraph.prototype._catmullRomUniform = function(data) {
* @returns {string} * @returns {string}
* @private * @private
*/ */
Linegraph.prototype._catmullRom = function(data, group) {
LineGraph.prototype._catmullRom = function(data, group) {
var alpha = group.options.catmullRom.alpha; var alpha = group.options.catmullRom.alpha;
if (alpha == 0 || alpha === undefined) { if (alpha == 0 || alpha === undefined) {
return this._catmullRomUniform(data); return this._catmullRomUniform(data);
@ -4757,7 +4755,7 @@ Linegraph.prototype._catmullRom = function(data, group) {
* @returns {string} * @returns {string}
* @private * @private
*/ */
Linegraph.prototype._linear = function(data) {
LineGraph.prototype._linear = function(data) {
// linear // linear
var d = ""; var d = "";
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
@ -10164,7 +10162,7 @@ Timeline.prototype._toScreen = function(time) {
* @private * @private
*/ */
// TODO: move this function to Range // TODO: move this function to Range
Graph2d.prototype._toGlobalScreen = function(time) {
Timeline.prototype._toGlobalScreen = function(time) {
var conversion = this.range.conversion(this.props.root.width); var conversion = this.range.conversion(this.props.root.width);
return (time.valueOf() - conversion.offset) * conversion.scale; return (time.valueOf() - conversion.offset) * conversion.scale;
}; };
@ -10391,7 +10389,7 @@ function Graph2d (container, items, options, groups) {
this.components.push(this.customTime); this.components.push(this.customTime);
// item set // item set
this.linegraph = new Linegraph(this.body);
this.linegraph = new LineGraph(this.body);
this.components.push(this.linegraph); this.components.push(this.linegraph);
this.itemsData = null; // DataSet this.itemsData = null; // DataSet
@ -15246,7 +15244,7 @@ var hierarchalRepulsionMixin = {
distance = 0.01; distance = 0.01;
} }
distance = Math.max(0.8*edgeLength,Math.min(1.2*edgeLength, distance));
distance = Math.max(0.8*edgeLength,Math.min(5*edgeLength, distance));
// the 1/distance is so the fx and fy can be calculated without sine or cosine. // the 1/distance is so the fx and fy can be calculated without sine or cosine.
springForce = this.constants.physics.springConstant * (edgeLength - distance) / distance; springForce = this.constants.physics.springConstant * (edgeLength - distance) / distance;

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


+ 1
- 1
examples/index.html View File

@ -12,7 +12,7 @@
<h1>vis.js examples</h1> <h1>vis.js examples</h1>
<p><a href="Network">network</a></p>
<p><a href="network">network</a></p>
<p><a href="graph2d">graph2d</a></p> <p><a href="graph2d">graph2d</a></p>
<p><a href="graph3d">graph3d</a></p> <p><a href="graph3d">graph3d</a></p>
<p><a href="timeline">timeline</a></p> <p><a href="timeline">timeline</a></p>

examples/Network/01_basic_usage.html → examples/network/01_basic_usage.html View File


examples/Network/02_random_nodes.html → examples/network/02_random_nodes.html View File


examples/Network/03_images.html → examples/network/03_images.html View File


examples/Network/04_shapes.html → examples/network/04_shapes.html View File


examples/Network/05_social_network.html → examples/network/05_social_network.html View File


examples/Network/06_groups.html → examples/network/06_groups.html View File


examples/Network/07_selections.html → examples/network/07_selections.html View File


examples/Network/08_mobile_friendly.html → examples/network/08_mobile_friendly.html View File


examples/Network/09_sizing.html → examples/network/09_sizing.html View File


examples/Network/10_multiline_text.html → examples/network/10_multiline_text.html View File


examples/Network/11_custom_style.html → examples/network/11_custom_style.html View File


examples/Network/12_scalable_images.html → examples/network/12_scalable_images.html View File


examples/Network/13_dashed_lines.html → examples/network/13_dashed_lines.html View File


examples/Network/14_dot_language.html → examples/network/14_dot_language.html View File


examples/Network/15_dot_language_playground.html → examples/network/15_dot_language_playground.html View File


examples/Network/16_dynamic_data.html → examples/network/16_dynamic_data.html View File


examples/Network/17_network_info.html → examples/network/17_network_info.html View File


examples/Network/18_fully_random_nodes_clustering.html → examples/network/18_fully_random_nodes_clustering.html View File


examples/Network/19_scale_free_graph_clustering.html → examples/network/19_scale_free_graph_clustering.html View File


examples/Network/20_navigation.html → examples/network/20_navigation.html View File


examples/Network/21_data_manipulation.html → examples/network/21_data_manipulation.html View File


examples/Network/22_les_miserables.html → examples/network/22_les_miserables.html View File


examples/Network/23_hierarchical_layout.html → examples/network/23_hierarchical_layout.html View File


examples/Network/24_hierarchical_layout_userdefined.html → examples/network/24_hierarchical_layout_userdefined.html View File


examples/Network/25_physics_configuration.html → examples/network/25_physics_configuration.html View File


examples/Network/graphviz/data/fsm.gv.txt → examples/network/graphviz/data/fsm.gv.txt View File


examples/Network/graphviz/data/hello.gv.txt → examples/network/graphviz/data/hello.gv.txt View File


examples/Network/graphviz/data/process.gv.txt → examples/network/graphviz/data/process.gv.txt View File


examples/Network/graphviz/data/siblings.gv.txt → examples/network/graphviz/data/siblings.gv.txt View File


examples/Network/graphviz/data/softmaint.gv.txt → examples/network/graphviz/data/softmaint.gv.txt View File


examples/Network/graphviz/data/traffic_lights.gv.txt → examples/network/graphviz/data/traffic_lights.gv.txt View File


examples/Network/graphviz/data/transparency.gv.txt → examples/network/graphviz/data/transparency.gv.txt View File


examples/Network/graphviz/data/twopi2.gv.txt → examples/network/graphviz/data/twopi2.gv.txt View File


examples/Network/graphviz/data/unix.gv.txt → examples/network/graphviz/data/unix.gv.txt View File


examples/Network/graphviz/data/world.gv.txt → examples/network/graphviz/data/world.gv.txt View File


examples/Network/graphviz/graphviz_gallery.html → examples/network/graphviz/graphviz_gallery.html View File


examples/Network/graphviz/screenshots/fsm.png → examples/network/graphviz/screenshots/fsm.png View File


examples/Network/graphviz/screenshots/hello.png → examples/network/graphviz/screenshots/hello.png View File


examples/Network/graphviz/screenshots/softmaint.png → examples/network/graphviz/screenshots/softmaint.png View File


examples/Network/graphviz/screenshots/traffic_lights.png → examples/network/graphviz/screenshots/traffic_lights.png View File


examples/Network/img/refresh-cl/Hardware-Fax-icon.png → examples/network/img/refresh-cl/Hardware-Fax-icon.png View File


examples/Network/img/refresh-cl/Hardware-Laptop-1-icon.png → examples/network/img/refresh-cl/Hardware-Laptop-1-icon.png View File


examples/Network/img/refresh-cl/Hardware-Mobile-Phone-icon.png → examples/network/img/refresh-cl/Hardware-Mobile-Phone-icon.png View File


examples/Network/img/refresh-cl/Hardware-My-Computer-3-icon.png → examples/network/img/refresh-cl/Hardware-My-Computer-3-icon.png View File


examples/Network/img/refresh-cl/Hardware-My-PDA-02-icon.png → examples/network/img/refresh-cl/Hardware-My-PDA-02-icon.png View File


examples/Network/img/refresh-cl/Hardware-My-PDA-04-icon.png → examples/network/img/refresh-cl/Hardware-My-PDA-04-icon.png View File


examples/Network/img/refresh-cl/Hardware-My-PDA-05-icon.png → examples/network/img/refresh-cl/Hardware-My-PDA-05-icon.png View File


examples/Network/img/refresh-cl/Hardware-My-Phone-Picture-icon.png → examples/network/img/refresh-cl/Hardware-My-Phone-Picture-icon.png View File


examples/Network/img/refresh-cl/Hardware-Printer-Blue-icon.png → examples/network/img/refresh-cl/Hardware-Printer-Blue-icon.png View File


examples/Network/img/refresh-cl/Misc-Scanner-default-icon.png → examples/network/img/refresh-cl/Misc-Scanner-default-icon.png View File


examples/Network/img/refresh-cl/Network-Drive-icon.png → examples/network/img/refresh-cl/Network-Drive-icon.png View File


examples/Network/img/refresh-cl/Network-Internet-Connection-icon.png → examples/network/img/refresh-cl/Network-Internet-Connection-icon.png View File


examples/Network/img/refresh-cl/Network-Pipe-icon.png → examples/network/img/refresh-cl/Network-Pipe-icon.png View File


examples/Network/img/refresh-cl/System-Firewall-2-icon.png → examples/network/img/refresh-cl/System-Firewall-2-icon.png View File


examples/Network/img/refresh-cl/System-Globe-icon.png → examples/network/img/refresh-cl/System-Globe-icon.png View File


examples/Network/img/refresh-cl/license.txt → examples/network/img/refresh-cl/license.txt View File


examples/Network/img/soft-scraps-icons/Document-icon24.png → examples/network/img/soft-scraps-icons/Document-icon24.png View File


examples/Network/img/soft-scraps-icons/Document-icon32.png → examples/network/img/soft-scraps-icons/Document-icon32.png View File


examples/Network/img/soft-scraps-icons/Document-icon48.png → examples/network/img/soft-scraps-icons/Document-icon48.png View File


examples/Network/img/soft-scraps-icons/Email-icon24.png → examples/network/img/soft-scraps-icons/Email-icon24.png View File


examples/Network/img/soft-scraps-icons/Email-icon32.png → examples/network/img/soft-scraps-icons/Email-icon32.png View File


examples/Network/img/soft-scraps-icons/Email-icon48.png → examples/network/img/soft-scraps-icons/Email-icon48.png View File


examples/Network/img/soft-scraps-icons/Folder-icon24.png → examples/network/img/soft-scraps-icons/Folder-icon24.png View File


examples/Network/img/soft-scraps-icons/Folder-icon32.png → examples/network/img/soft-scraps-icons/Folder-icon32.png View File


examples/Network/img/soft-scraps-icons/Folder-icon48.png → examples/network/img/soft-scraps-icons/Folder-icon48.png View File


examples/Network/img/soft-scraps-icons/Folder-icon64.png → examples/network/img/soft-scraps-icons/Folder-icon64.png View File


examples/Network/img/soft-scraps-icons/Smiley-Angry-icon.png → examples/network/img/soft-scraps-icons/Smiley-Angry-icon.png View File


examples/Network/img/soft-scraps-icons/Smiley-Grin-icon.png → examples/network/img/soft-scraps-icons/Smiley-Grin-icon.png View File


examples/Network/img/soft-scraps-icons/User-Administrator-Blue-icon.png → examples/network/img/soft-scraps-icons/User-Administrator-Blue-icon.png View File


examples/Network/img/soft-scraps-icons/User-Administrator-Green-icon.png → examples/network/img/soft-scraps-icons/User-Administrator-Green-icon.png View File


examples/Network/img/soft-scraps-icons/User-Coat-Blue-icon.png → examples/network/img/soft-scraps-icons/User-Coat-Blue-icon.png View File


examples/Network/img/soft-scraps-icons/User-Coat-Green-icon.png → examples/network/img/soft-scraps-icons/User-Coat-Green-icon.png View File


examples/Network/img/soft-scraps-icons/User-Coat-Red-icon.png → examples/network/img/soft-scraps-icons/User-Coat-Red-icon.png View File


examples/Network/img/soft-scraps-icons/User-Executive-Green-icon.png → examples/network/img/soft-scraps-icons/User-Executive-Green-icon.png View File


examples/Network/img/soft-scraps-icons/User-Preppy-Blue-icon.png → examples/network/img/soft-scraps-icons/User-Preppy-Blue-icon.png View File


examples/Network/img/soft-scraps-icons/User-Preppy-Red-icon.png → examples/network/img/soft-scraps-icons/User-Preppy-Red-icon.png View File


examples/Network/img/soft-scraps-icons/license.txt → examples/network/img/soft-scraps-icons/license.txt View File


examples/Network/index.html → examples/network/index.html View File


+ 1
- 1
src/timeline/Graph2d.js View File

@ -64,7 +64,7 @@ function Graph2d (container, items, options, groups) {
this.components.push(this.customTime); this.components.push(this.customTime);
// item set // item set
this.linegraph = new Linegraph(this.body);
this.linegraph = new LineGraph(this.body);
this.components.push(this.linegraph); this.components.push(this.linegraph);
this.itemsData = null; // DataSet this.itemsData = null; // DataSet

src/timeline/component/Linegraph.js → src/timeline/component/LineGraph.js View File

@ -1,13 +1,13 @@
var UNGROUPED = '__ungrouped__'; // reserved group id for ungrouped items var UNGROUPED = '__ungrouped__'; // reserved group id for ungrouped items
/** /**
* This is the constructor of the linegraph. It requires a timeline body and options.
* This is the constructor of the LineGraph. It requires a Timeline body and options.
* *
* @param body * @param body
* @param options * @param options
* @constructor * @constructor
*/ */
function Linegraph(body, options) {
function LineGraph(body, options) {
this.id = util.randomUUID(); this.id = util.randomUUID();
this.body = body; this.body = body;
@ -125,14 +125,14 @@ function Linegraph(body, options) {
this.body.emitter.emit("change"); this.body.emitter.emit("change");
} }
Linegraph.prototype = new Component();
LineGraph.prototype = new Component();
/** /**
* Create the HTML DOM for the ItemSet * Create the HTML DOM for the ItemSet
*/ */
Linegraph.prototype._create = function(){
LineGraph.prototype._create = function(){
var frame = document.createElement('div'); var frame = document.createElement('div');
frame.className = 'linegraph';
frame.className = 'LineGraph';
this.dom.frame = frame; this.dom.frame = frame;
// create svg element for graph drawing. // create svg element for graph drawing.
@ -158,10 +158,10 @@ Linegraph.prototype._create = function(){
}; };
/** /**
* set the options of the linegraph. the mergeOptions is used for subObjects that have an enabled element.
* set the options of the LineGraph. the mergeOptions is used for subObjects that have an enabled element.
* @param options * @param options
*/ */
Linegraph.prototype.setOptions = function(options) {
LineGraph.prototype.setOptions = function(options) {
if (options) { if (options) {
var fields = ['sampling','defaultGroup','graphHeight','yAxisOrientation','style','barChart','dataAxis','sort']; var fields = ['sampling','defaultGroup','graphHeight','yAxisOrientation','style','barChart','dataAxis','sort'];
util.selectiveDeepExtend(fields, this.options, options); util.selectiveDeepExtend(fields, this.options, options);
@ -213,7 +213,7 @@ Linegraph.prototype.setOptions = function(options) {
/** /**
* Hide the component from the DOM * Hide the component from the DOM
*/ */
Linegraph.prototype.hide = function() {
LineGraph.prototype.hide = function() {
// remove the frame containing the items // remove the frame containing the items
if (this.dom.frame.parentNode) { if (this.dom.frame.parentNode) {
this.dom.frame.parentNode.removeChild(this.dom.frame); this.dom.frame.parentNode.removeChild(this.dom.frame);
@ -224,7 +224,7 @@ Linegraph.prototype.hide = function() {
* Show the component in the DOM (when not already visible). * Show the component in the DOM (when not already visible).
* @return {Boolean} changed * @return {Boolean} changed
*/ */
Linegraph.prototype.show = function() {
LineGraph.prototype.show = function() {
// show frame containing the items // show frame containing the items
if (!this.dom.frame.parentNode) { if (!this.dom.frame.parentNode) {
this.body.dom.center.appendChild(this.dom.frame); this.body.dom.center.appendChild(this.dom.frame);
@ -236,7 +236,7 @@ Linegraph.prototype.show = function() {
* Set items * Set items
* @param {vis.DataSet | null} items * @param {vis.DataSet | null} items
*/ */
Linegraph.prototype.setItems = function(items) {
LineGraph.prototype.setItems = function(items) {
var me = this, var me = this,
ids, ids,
oldItemsData = this.itemsData; oldItemsData = this.itemsData;
@ -283,7 +283,7 @@ Linegraph.prototype.setItems = function(items) {
* Set groups * Set groups
* @param {vis.DataSet} groups * @param {vis.DataSet} groups
*/ */
Linegraph.prototype.setGroups = function(groups) {
LineGraph.prototype.setGroups = function(groups) {
var me = this, var me = this,
ids; ids;
@ -326,15 +326,15 @@ Linegraph.prototype.setGroups = function(groups) {
Linegraph.prototype._onUpdate = function(ids) {
LineGraph.prototype._onUpdate = function(ids) {
this._updateUngrouped(); this._updateUngrouped();
this._updateAllGroupData(); this._updateAllGroupData();
this._updateGraph(); this._updateGraph();
this.redraw(); this.redraw();
}; };
Linegraph.prototype._onAdd = function (ids) {this._onUpdate(ids);};
Linegraph.prototype._onRemove = function (ids) {this._onUpdate(ids);};
Linegraph.prototype._onUpdateGroups = function (groupIds) {
LineGraph.prototype._onAdd = function (ids) {this._onUpdate(ids);};
LineGraph.prototype._onRemove = function (ids) {this._onUpdate(ids);};
LineGraph.prototype._onUpdateGroups = function (groupIds) {
for (var i = 0; i < groupIds.length; i++) { for (var i = 0; i < groupIds.length; i++) {
var group = this.groupsData.get(groupIds[i]); var group = this.groupsData.get(groupIds[i]);
this._updateGroup(group, groupIds[i]); this._updateGroup(group, groupIds[i]);
@ -343,9 +343,9 @@ Linegraph.prototype._onUpdateGroups = function (groupIds) {
this._updateGraph(); this._updateGraph();
this.redraw(); this.redraw();
}; };
Linegraph.prototype._onAddGroups = function (groupIds) {this._onUpdateGroups(groupIds);};
LineGraph.prototype._onAddGroups = function (groupIds) {this._onUpdateGroups(groupIds);};
Linegraph.prototype._onRemoveGroups = function (groupIds) {
LineGraph.prototype._onRemoveGroups = function (groupIds) {
for (var i = 0; i < groupIds.length; i++) { for (var i = 0; i < groupIds.length; i++) {
if (!this.groups.hasOwnProperty(groupIds[i])) { if (!this.groups.hasOwnProperty(groupIds[i])) {
if (this.groups[groupIds[i]].options.yAxisOrientation == 'right') { if (this.groups[groupIds[i]].options.yAxisOrientation == 'right') {
@ -373,7 +373,7 @@ Linegraph.prototype._onRemoveGroups = function (groupIds) {
* @param groupId * @param groupId
* @private * @private
*/ */
Linegraph.prototype._updateGroup = function (group, groupId) {
LineGraph.prototype._updateGroup = function (group, groupId) {
if (!this.groups.hasOwnProperty(groupId)) { if (!this.groups.hasOwnProperty(groupId)) {
this.groups[groupId] = new GraphGroup(group, groupId, this.options, this.groupsUsingDefaultStyles); this.groups[groupId] = new GraphGroup(group, groupId, this.options, this.groupsUsingDefaultStyles);
if (this.groups[groupId].options.yAxisOrientation == 'right') { if (this.groups[groupId].options.yAxisOrientation == 'right') {
@ -400,7 +400,7 @@ Linegraph.prototype._updateGroup = function (group, groupId) {
this.legendRight.redraw(); this.legendRight.redraw();
}; };
Linegraph.prototype._updateAllGroupData = function () {
LineGraph.prototype._updateAllGroupData = function () {
if (this.itemsData != null) { if (this.itemsData != null) {
// ~450 ms @ 500k // ~450 ms @ 500k
@ -440,7 +440,7 @@ Linegraph.prototype._updateAllGroupData = function () {
* there are no groups specified. This anonymous group is called 'graph'. * there are no groups specified. This anonymous group is called 'graph'.
* @protected * @protected
*/ */
Linegraph.prototype._updateUngrouped = function() {
LineGraph.prototype._updateUngrouped = function() {
if (this.itemsData != null) { if (this.itemsData != null) {
// var t0 = new Date(); // var t0 = new Date();
var group = {id: UNGROUPED, content: this.options.defaultGroup}; var group = {id: UNGROUPED, content: this.options.defaultGroup};
@ -506,7 +506,7 @@ Linegraph.prototype._updateUngrouped = function() {
* Redraw the component, mandatory function * Redraw the component, mandatory function
* @return {boolean} Returns true if the component is resized * @return {boolean} Returns true if the component is resized
*/ */
Linegraph.prototype.redraw = function() {
LineGraph.prototype.redraw = function() {
var resized = false; var resized = false;
this.svg.style.height = ('' + this.options.graphHeight).replace('px','') + 'px'; this.svg.style.height = ('' + this.options.graphHeight).replace('px','') + 'px';
@ -544,7 +544,7 @@ Linegraph.prototype.redraw = function() {
* Update and redraw the graph. * Update and redraw the graph.
* *
*/ */
Linegraph.prototype._updateGraph = function () {
LineGraph.prototype._updateGraph = function () {
// reset the svg elements // reset the svg elements
DOMutil.prepareElements(this.svgElements); DOMutil.prepareElements(this.svgElements);
// // very slow... // // very slow...
@ -653,7 +653,7 @@ Linegraph.prototype._updateGraph = function () {
* @param {array} groupIds * @param {array} groupIds
* @private * @private
*/ */
Linegraph.prototype._updateYAxis = function (groupIds, groupRanges) {
LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
var changeCalled = false; var changeCalled = false;
var yAxisLeftUsed = false; var yAxisLeftUsed = false;
var yAxisRightUsed = false; var yAxisRightUsed = false;
@ -727,7 +727,7 @@ Linegraph.prototype._updateYAxis = function (groupIds, groupRanges) {
* @private * @private
* @param axis * @param axis
*/ */
Linegraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) {
LineGraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) {
var changed = false; var changed = false;
if (axisUsed == false) { if (axisUsed == false) {
if (axis.dom.frame.parentNode) { if (axis.dom.frame.parentNode) {
@ -750,7 +750,7 @@ Linegraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) {
* @param datapoints * @param datapoints
* @param group * @param group
*/ */
Linegraph.prototype._drawBarGraph = function (dataset, group) {
LineGraph.prototype._drawBarGraph = function (dataset, group) {
if (dataset != null) { if (dataset != null) {
if (dataset.length > 0) { if (dataset.length > 0) {
var coreDistance; var coreDistance;
@ -785,7 +785,7 @@ Linegraph.prototype._drawBarGraph = function (dataset, group) {
* @param datapoints * @param datapoints
* @param group * @param group
*/ */
Linegraph.prototype._drawLineGraph = function (dataset, group) {
LineGraph.prototype._drawLineGraph = function (dataset, group) {
if (dataset != null) { if (dataset != null) {
if (dataset.length > 0) { if (dataset.length > 0) {
var path, d; var path, d;
@ -833,7 +833,7 @@ Linegraph.prototype._drawLineGraph = function (dataset, group) {
* @param svg * @param svg
* @param group * @param group
*/ */
Linegraph.prototype._drawPoints = function (dataset, group, JSONcontainer, svg, offset) {
LineGraph.prototype._drawPoints = function (dataset, group, JSONcontainer, svg, offset) {
if (offset === undefined) {offset = 0;} if (offset === undefined) {offset = 0;}
for (var i = 0; i < dataset.length; i++) { for (var i = 0; i < dataset.length; i++) {
DOMutil.drawPoint(dataset[i].x + offset, dataset[i].y, group, JSONcontainer, svg); DOMutil.drawPoint(dataset[i].x + offset, dataset[i].y, group, JSONcontainer, svg);
@ -851,7 +851,7 @@ Linegraph.prototype._drawPoints = function (dataset, group, JSONcontainer, svg,
* @returns {Array} * @returns {Array}
* @private * @private
*/ */
Linegraph.prototype._preprocessData = function (datapoints, group) {
LineGraph.prototype._preprocessData = function (datapoints, group) {
var extractedData = []; var extractedData = [];
var xValue, yValue; var xValue, yValue;
var toScreen = this.body.util.toScreen; var toScreen = this.body.util.toScreen;
@ -891,7 +891,7 @@ Linegraph.prototype._preprocessData = function (datapoints, group) {
* @returns {Array} * @returns {Array}
* @private * @private
*/ */
Linegraph.prototype._convertYvalues = function (datapoints, group) {
LineGraph.prototype._convertYvalues = function (datapoints, group) {
var extractedData = []; var extractedData = [];
var xValue, yValue; var xValue, yValue;
var axis = this.yAxisLeft; var axis = this.yAxisLeft;
@ -921,7 +921,7 @@ Linegraph.prototype._convertYvalues = function (datapoints, group) {
* @returns {string} * @returns {string}
* @private * @private
*/ */
Linegraph.prototype._catmullRomUniform = function(data) {
LineGraph.prototype._catmullRomUniform = function(data) {
// catmull rom // catmull rom
var p0, p1, p2, p3, bp1, bp2; var p0, p1, p2, p3, bp1, bp2;
var d = Math.round(data[0].x) + "," + Math.round(data[0].y) + " "; var d = Math.round(data[0].x) + "," + Math.round(data[0].y) + " ";
@ -968,7 +968,7 @@ Linegraph.prototype._catmullRomUniform = function(data) {
* @returns {string} * @returns {string}
* @private * @private
*/ */
Linegraph.prototype._catmullRom = function(data, group) {
LineGraph.prototype._catmullRom = function(data, group) {
var alpha = group.options.catmullRom.alpha; var alpha = group.options.catmullRom.alpha;
if (alpha == 0 || alpha === undefined) { if (alpha == 0 || alpha === undefined) {
return this._catmullRomUniform(data); return this._catmullRomUniform(data);
@ -1045,7 +1045,7 @@ Linegraph.prototype._catmullRom = function(data, group) {
* @returns {string} * @returns {string}
* @private * @private
*/ */
Linegraph.prototype._linear = function(data) {
LineGraph.prototype._linear = function(data) {
// linear // linear
var d = ""; var d = "";
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {

Loading…
Cancel
Save