Skip to content

Commit

Permalink
Fixed Dotplot Sizing & Size Legend Issue (#27)
Browse files Browse the repository at this point in the history
* Fixed Dotplot Sizing & Size Legend Issue

* Bump up version

* Bump up version
  • Loading branch information
OssamaRafique authored Aug 31, 2023
1 parent 687de67 commit 002b0cc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "epiviz.heatmap.gl",
"version": "0.0.17",
"version": "0.0.18",
"repository": "https://github.com/jkanche/epiviz.heatmap.gl",
"homepage": "https://github.com/jkanche/epiviz.heatmap.gl",
"author": {
Expand Down
8 changes: 4 additions & 4 deletions src/DotplotGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ class DotplotGL extends BaseGL {
*/
renderSizeLegend() {
if (!this.sizeLegendData) return;
let { minSize, maxSize, steps, maxSizeInPx } = this.sizeLegendData;
let { minSize, maxSize, steps, maxSizeInPx, minSizeInPx } =
this.sizeLegendData;
const [, maxX] = getMinMax(this.input.x);
const [, maxY] = getMinMax(this.input.y);
let xlen = maxX + 1,
Expand Down Expand Up @@ -261,8 +262,8 @@ class DotplotGL extends BaseGL {
// Desired max size in pixels
const maxPx = maxSizeInPx || maxSize;

// Calculate the desired minimum size in pixels proportionally
const minPx = (minSize * maxPx) / maxSize;
// Desired min size in pixels
const minPx = minSizeInPx || minSize;

// Create a linear scale
const sizeScale = scaleLinear()
Expand Down Expand Up @@ -382,7 +383,6 @@ class DotplotGL extends BaseGL {
.style("right", "0px");
break;
}
console.log("before", this._spec.margins);

this.updateMarginsToAccountForSizeLegend();
this.plot.setSpecification(this._spec);
Expand Down
4 changes: 2 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export const DEFAULT_SIZE_LEGEND_SVG_PADDING = 10;
export const DEFAULT_SIZE_LEGEND_CIRCLE_GAP = 10;
export const DEFAULT_SIZE_LEGEND_CIRCLE_TEXT_GAP = 10;

export const DEFAULT_MIN_RADIUS_FOR_DOTPLOT = 5;
export const DEFAULT_MARGIN_BETWEEN_DOTS = 5;
export const DEFAULT_MIN_RADIUS_FOR_DOTPLOT = 3;
export const DEFAULT_MARGIN_BETWEEN_DOTS = 2;
5 changes: 4 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export const removeTooltip = (container) => {
};

export const getMaxRadiusForDotplot = (xlen, ylen, padding) => {
return Math.min(198 / (xlen + 1), 198 / (ylen + 1)) - padding;
return Math.max(
Math.min(198 / (xlen + 1), 198 / (ylen + 1)) - padding,
DEFAULT_MIN_RADIUS_FOR_DOTPLOT
);
};

export const getScaledRadiusForDotplot = (
Expand Down

0 comments on commit 002b0cc

Please sign in to comment.