Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
use phovea/phovea_vis#45 to show labels in small heatmap
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Mar 28, 2017
1 parent e40e7e5 commit 4e1ad69
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/app_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class AppConstants {
*/
static PARSE_DATE_FORMATS = ['YYYY_MM_DD', 'YYYY-MM-DD', 'YYYY'];

static MAXIMAL_HEATMAP_LABEL_SIZE = 100;

/**
* Initial size of a heatmap cell
* @type {number}
Expand Down
19 changes: 16 additions & 3 deletions src/heat_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class HeatMap implements IAppView {
return;
}

const options = {
const options = mixin({}, this.heatMapOptions, {
initialScale: this.heatMapOptions.initialScale * scaleFactor,
color: this.heatMapOptions.color
};
labels: chooseLabel(dataset.nrow, dataset.ncol)
});

return Promise.all([plugins[0].load()])
.then((args) => {
Expand Down Expand Up @@ -117,6 +117,19 @@ class HeatMap implements IAppView {
}


function chooseLabel(nrow: number, ncol: number) {
if (nrow < AppConstants.MAXIMAL_HEATMAP_LABEL_SIZE && ncol < AppConstants.MAXIMAL_HEATMAP_LABEL_SIZE) {
return 'CELL';
}
if (nrow < AppConstants.MAXIMAL_HEATMAP_LABEL_SIZE) {
return 'ROW';
}
if (ncol < AppConstants.MAXIMAL_HEATMAP_LABEL_SIZE) {
return 'COLUMN';
}
return 'NONE';
}

/**
* Factory method to create a new HeatMap instance
* @param parent
Expand Down
16 changes: 16 additions & 0 deletions src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,19 @@ select.form-control {
}
}
}

div.phovea-heatmap .phovea-heatmap-labels {
&.row-labels {
padding-right: 0.2em;
}
&.column-labels {
padding-left: 0.2em;
text-align: left;
overflow: visible;

> div {
transform: rotate(30deg);
transform-origin: bottom left;
}
}
}

0 comments on commit 4e1ad69

Please sign in to comment.