Browse Source

bugfixes (sampling, timeline)

css_transitions
Alex de Mulder 10 years ago
parent
commit
cd4d06789c
5 changed files with 17 additions and 21 deletions
  1. +7
    -9
      dist/vis.js
  2. +4
    -4
      dist/vis.min.js
  3. +1
    -1
      src/graph/graphMixins/physics/HierarchialRepulsion.js
  4. +1
    -1
      src/timeline/Timeline.js
  5. +4
    -6
      src/timeline/component/Linegraph.js

+ 7
- 9
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library. * A dynamic, browser-based visualization library.
* *
* @version 2.0.1-SNAPSHOT * @version 2.0.1-SNAPSHOT
* @date 2014-07-01
* @date 2014-07-03
* *
* @license * @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com * Copyright (C) 2011-2014 Almende B.V, http://almende.com
@ -4563,9 +4563,12 @@ Linegraph.prototype._drawPoints = function (dataset, group, JSONcontainer, svg,
*/ */
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;
} }
@ -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;
}; };
@ -15269,7 +15267,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
src/graph/graphMixins/physics/HierarchialRepulsion.js View File

@ -98,7 +98,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;

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

@ -724,7 +724,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;
}; };

+ 4
- 6
src/timeline/component/Linegraph.js View File

@ -853,9 +853,12 @@ Linegraph.prototype._drawPoints = function (dataset, group, JSONcontainer, svg,
*/ */
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;
@ -863,19 +866,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;
} }

Loading…
Cancel
Save