Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Graph3d: make setting dotSizeRatio public #2202

Merged
merged 3 commits into from
Oct 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/graph3d/Graph3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion lib/graph3d/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var OPTIONKEYS = [
'showShadow',
'keepAspectRatio',
'verticalRatio',
'dotSizeRatio',
'showAnimationControls',
'animationInterval',
'animationPreload',
Expand Down Expand Up @@ -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?
}

Expand Down