From 7424bfbfc28de94c076fd6ba7941105f9f3b98e2 Mon Sep 17 00:00:00 2001 From: wimrijnders Date: Fri, 21 Oct 2016 21:20:24 +0200 Subject: [PATCH] Graph3d: make setting dotSizeRatio public (#2202) * Graph3d: make setting dotSizeRatio public * Added method for dotSize * Fixed silly indent --- lib/graph3d/Graph3d.js | 12 +++++++++--- lib/graph3d/Settings.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/graph3d/Graph3d.js b/lib/graph3d/Graph3d.js index 896a1cdf..43ac40ec 100644 --- a/lib/graph3d/Graph3d.js +++ b/lib/graph3d/Graph3d.js @@ -50,6 +50,7 @@ var DEFAULTS = { showShadow : false, keepAspectRatio : true, verticalRatio : 0.5, // 0.1 to 1.0, where 1.0 results in a 'cube' + dotSizeRatio : 0.02, // size of the dots as a fraction of the graph width showAnimationControls: autoByDefault, animationInterval : 1000, // milliseconds @@ -897,13 +898,18 @@ Graph3d.prototype._redrawClear = function() { }; +Graph3d.prototype._dotSize = function() { + return this.frame.clientWidth * this.dotSizeRatio; +}; + + /** * Get legend width */ Graph3d.prototype._getLegendWidth = function() { var width; if (this.style === Graph3d.STYLE.DOTSIZE) { - var dotSize = this.frame.clientWidth * this.dotSizeRatio; + var dotSize = this._dotSize(); width = dotSize / 2 + dotSize * 2; } else if (this.style === Graph3d.STYLE.BARSIZE) { width = this.xBarWidth ; @@ -972,7 +978,7 @@ Graph3d.prototype._redrawLegend = function() { // draw the size legend box var widthMin; if (this.style === Graph3d.STYLE.DOTSIZE) { - var dotSize = this.frame.clientWidth * this.dotSizeRatio; + var dotSize = this._dotSize(); widthMin = dotSize / 2; // px } else if (this.style === Graph3d.STYLE.BARSIZE) { //widthMin = this.xBarWidth * 0.2 this is wrong - barwidth measures in terms of xvalues @@ -1521,7 +1527,7 @@ Graph3d.prototype._redrawDataDot = function() { this._calcTranslations(this.dataPoints); // draw the datapoints as colored circles - var dotSize = this.frame.clientWidth * this.dotSizeRatio; // px + var dotSize = this._dotSize(); for (i = 0; i < this.dataPoints.length; i++) { var point = this.dataPoints[i]; diff --git a/lib/graph3d/Settings.js b/lib/graph3d/Settings.js index f1b7da6a..98f244c3 100644 --- a/lib/graph3d/Settings.js +++ b/lib/graph3d/Settings.js @@ -58,6 +58,7 @@ var OPTIONKEYS = [ 'showShadow', 'keepAspectRatio', 'verticalRatio', + 'dotSizeRatio', 'showAnimationControls', 'animationInterval', 'animationPreload', @@ -220,7 +221,6 @@ function setDefaults(src, dst) { dst.margin = 10; // px dst.showGrayBottom = false; // TODO: this does not work correctly dst.showTooltip = false; - dst.dotSizeRatio = 0.02; // size of the dots as a fraction of the graph width dst.eye = new Point3d(0, 0, -1); // TODO: set eye.z about 3/4 of the width of the window? }