Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradient Coloring Option for Feature Metadata #484

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
61f49b2
Add custom color
kwcantrell Feb 1, 2021
1f26583
checkpoint
kwcantrell Feb 10, 2021
dd2cfe6
added gradient coloring for feature metadata
kwcantrell Feb 10, 2021
20b369a
linter
kwcantrell Feb 10, 2021
6172f36
style fix
kwcantrell Feb 10, 2021
a3a1fe4
Show warning to user
kwcantrell Feb 22, 2021
3a69861
checkpoint
kwcantrell Feb 23, 2021
ca591ba
gradient feature metadata coloring
kwcantrell Feb 23, 2021
86ef3cf
fixed style issue
kwcantrell Feb 23, 2021
f2920c5
Merge branch 'master' of https://github.com/biocore/empress into grad…
kwcantrell Feb 24, 2021
a4052df
addressed comments
kwcantrell Mar 2, 2021
84d5b4a
style fix
kwcantrell Mar 2, 2021
8836260
Apply suggestions from code review
kwcantrell Mar 2, 2021
1431e2c
Merge branch 'master' of https://github.com/biocore/empress into grad…
kwcantrell Apr 9, 2021
743a32e
fix style
kwcantrell Apr 9, 2021
a90871c
fixed continuous error
kwcantrell Apr 9, 2021
305aa47
remove try-catch
kwcantrell Apr 12, 2021
d5426f6
Apply suggestions from code review
kwcantrell May 4, 2021
bf3f5fd
Merge branch 'master' of https://github.com/biocore/empress into grad…
kwcantrell Jun 10, 2021
aba2aa7
checkpoint
kwcantrell Jun 11, 2021
942f5b0
added test/fixed warning
kwcantrell Jun 11, 2021
9bd5961
fixed docs
kwcantrell Jun 11, 2021
6033e11
abstracted Legend class
kwcantrell Jun 13, 2021
1472ee4
Apply suggestions from code review
kwcantrell Aug 3, 2021
25ac9bd
address error 1
kwcantrell Aug 26, 2021
0add7c7
fixed conflicts
kwcantrell Aug 26, 2021
8206de8
fixed color bug
kwcantrell Aug 26, 2021
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
21 changes: 15 additions & 6 deletions empress/support_files/js/empress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,8 @@ define([
cat,
color,
method,
reverse = false
reverse = false,
continuous = false
fedarko marked this conversation as resolved.
Show resolved Hide resolved
) {
var fmInfo = this.getUniqueFeatureMetadataInfo(cat, method);
var sortedUniqueValues = fmInfo.sortedUniqueValues;
Expand All @@ -2275,14 +2276,19 @@ define([
var colorer = new Colorer(
color,
sortedUniqueValues,
undefined,
undefined,
continuous,
continuous ? -1 : undefined,
kwcantrell marked this conversation as resolved.
Show resolved Hide resolved
reverse
);
// colors for drawing the tree
var cm = colorer.getMapRGB();
// colors for the legend
var keyInfo = colorer.getMapHex();
var keyInfo;
if (continuous) {
keyInfo = colorer.getGradientInfo();
} else {
keyInfo = colorer.getMapHex();
}

// Do upwards propagation only if the coloring method is "tip"
if (method === "tip") {
Expand All @@ -2294,8 +2300,11 @@ define([

// color tree
this._colorTree(obs, cm);

this.updateLegendCategorical(cat, keyInfo);
if (continuous) {
this._legend.addContinuousKey(cat, keyInfo);
kwcantrell marked this conversation as resolved.
Show resolved Hide resolved
kwcantrell marked this conversation as resolved.
Show resolved Hide resolved
} else {
fedarko marked this conversation as resolved.
Show resolved Hide resolved
this.updateLegendCategorical(cat, keyInfo);
}

return keyInfo;
};
Expand Down
16 changes: 15 additions & 1 deletion empress/support_files/js/side-panel-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ define(["underscore", "Colorer", "util"], function (_, Colorer, util) {
this.fCollapseCladesChk = document.getElementById(
"feature-collapse-chk"
);
this.fContinuousDiv = document.getElementById("feature-continous-div");
this.fContinuousChk = document.getElementById(
"feature-continuous-color-chk"
);
this.fLineWidth = document.getElementById("feature-line-width");
this.fUpdateBtn = document.getElementById("feature-update");
this.fMethodChk = document.getElementById("fm-method-chk");
Expand Down Expand Up @@ -333,11 +337,15 @@ define(["underscore", "Colorer", "util"], function (_, Colorer, util) {
var col = this.fColor.value;
var coloringMethod = this.fMethodChk.checked ? "tip" : "all";
var reverse = this.fReverseColor.checked;
var continuous =
!this.fContinuousDiv.classList.contains("hidden") &&
this.fContinuousChk.checked;
this.empress.colorByFeatureMetadata(
fedarko marked this conversation as resolved.
Show resolved Hide resolved
colBy,
col,
coloringMethod,
reverse
reverse,
continuous
);
};

Expand Down Expand Up @@ -607,10 +615,16 @@ define(["underscore", "Colorer", "util"], function (_, Colorer, util) {
};

var showUpdateBtn = function () {
if (Colorer.isColorMapDiscrete(scope.fColor.value)) {
scope.fContinuousDiv.classList.add("hidden");
} else {
scope.fContinuousDiv.classList.remove("hidden");
}
scope.fUpdateBtn.classList.remove("hidden");
};
this.fSel.onchange = showUpdateBtn;
this.fColor.onchange = showUpdateBtn;
this.fContinuousChk.onchange = showUpdateBtn;
this.fReverseColor.onchange = showUpdateBtn;
this.fLineWidth.onchange = showUpdateBtn;
this.fMethodChk.onchange = function () {
Expand Down
7 changes: 7 additions & 0 deletions empress/support_files/templates/side-panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@
If checked, collapse all clades whose members share the same feature
metadata value.
</p>
<div id="feature-continous-div" class="hidden">
<p>
<label for="feature-continuous-color-chk">Continuous values?</label>
<input id="feature-continuous-color-chk" type="checkbox" value="false"
class="empress-input">
</p>
</div>
fedarko marked this conversation as resolved.
Show resolved Hide resolved
<p>
<label for="feature-line-width">Extra Line Width</label>
<input id="feature-line-width" type="number" value="0" min="0"
Expand Down