-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add CSV-loading mode #1597
Add CSV-loading mode #1597
Changes from 35 commits
d84a0eb
ab0e9cf
e72cbcf
3803ab7
b65f56c
77a5109
92e5a72
0611086
2758a2a
8820f4c
d1299c6
c0c8258
019e6f7
1833317
286df31
4cebc83
d37b198
9335a8b
96fe3be
e2f8e08
e350d1a
b7ad234
89f1f3b
43622f9
b86a400
083fd6c
eb5c9a4
69cae44
c8598ad
2292819
b961c3b
4e40942
5996a0b
88863ec
e30b97f
460f466
d62bfae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,8 +145,8 @@ Polymer({ | |
colors: {type: Object, computed: 'getColors(saliency)', observer: 'createLegend'}, | ||
displayMode: {type: String, value: 'grid'}, | ||
featureSearchValue: {type: String, value: '', notify: true}, | ||
filteredFeaturesList: {type: Object, computed: 'getFilteredFeaturesList(featuresList, featureSearchValue, saliency)'}, | ||
filteredSeqFeaturesList: {type: Object, computed: 'getFilteredFeaturesList(seqFeaturesList, featureSearchValue, saliency)'}, | ||
filteredFeaturesList: {type: Object}, | ||
filteredSeqFeaturesList: {type: Object}, | ||
focusedFeatureName: String, | ||
focusedFeatureValueIndex: Number, | ||
focusedSeqNumber: Number, | ||
|
@@ -173,6 +173,8 @@ Polymer({ | |
observers: [ | ||
'haveSaliency(filteredFeaturesList, saliency, colors, showSaliency, saliencyCutoff)', | ||
'seqSaliency(seqNumber, seqFeaturesList, saliency, colors, showSaliency, saliencyCutoff)', | ||
'setFilteredFeaturesList(featuresList, featureSearchValue, saliency)', | ||
'setFilteredSeqFeaturesList(seqFeaturesList, featureSearchValue, saliency)', | ||
], | ||
|
||
isExpanded: function(featName: string, expandAllFeatures: boolean) { | ||
|
@@ -274,6 +276,20 @@ Polymer({ | |
.getFeatureLists()!.getFeatureListMap(); | ||
}, | ||
|
||
setFilteredFeaturesList: function(featureList: NameAndFeature[], | ||
searchValue: string, saliency: SaliencyMap) { | ||
this.filteredFeaturesList = []; | ||
this.filteredFeaturesList = this.getFilteredFeaturesList( | ||
featureList, searchValue, saliency); | ||
}, | ||
|
||
setFilteredSeqFeaturesList: function(seqFeatureList: NameAndFeature[], | ||
searchValue: string, saliency: SaliencyMap) { | ||
this.filteredSeqFeaturesList = []; | ||
this.filteredSeqFeaturesList = this.getFilteredFeaturesList( | ||
seqFeatureList, searchValue, saliency); | ||
}, | ||
|
||
getFilteredFeaturesList: function(featureList: NameAndFeature[], | ||
searchValue: string, saliency: SaliencyMap) { | ||
let filtered = featureList; | ||
|
@@ -477,6 +493,14 @@ Polymer({ | |
} | ||
min = Math.min(0, min) * clipSaliencyRatio; | ||
max = Math.max(0, max) * clipSaliencyRatio; | ||
// Make min/max symmetric around 0 so that attribution visualization scales | ||
// for negative and positive attributions are the same, for visual | ||
// consistency. | ||
if (min < 0 && max > Math.abs(min)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you comment on this change, why are we making values symmetric around zero? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
min = -1 * max; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another style nit: -1 indent before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
} else if (max > 0 && Math.abs(min) > max) { | ||
max = -1 * min; | ||
} | ||
return [min, max]; | ||
}, | ||
|
||
|
@@ -646,27 +670,6 @@ Polymer({ | |
return false; | ||
}, | ||
|
||
/** | ||
* Gets the allowed input type for a feature value, according to its | ||
* feature type. | ||
*/ | ||
getInputType: function(feature: string) { | ||
const feat = this.features.get(feature); | ||
if (feat) { | ||
if (feat.getInt64List() || feat.getFloatList()) { | ||
return 'number' | ||
} | ||
} | ||
const seqfeat = this.seqFeatures.get(feature); | ||
if (seqfeat) { | ||
if (seqfeat.getFeatureList()[0].getInt64List() || | ||
seqfeat.getFeatureList()[0].getFloatList()) { | ||
return 'number'; | ||
} | ||
} | ||
return 'text'; | ||
}, | ||
|
||
/** | ||
* Returns the feature object from the provided json attribute for a given | ||
* feature name. | ||
|
@@ -1071,7 +1074,7 @@ Polymer({ | |
* be used in css classes/ids. | ||
*/ | ||
sanitizeFeature: function(feat: string) { | ||
let sanitized = feat; | ||
let sanitized = feat.trim(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: indentation looks off There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just saying, because of L1079, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're right, thx |
||
if (!feat.match(/^[A-Za-z].*$/)) { | ||
sanitized = '_' + feat; | ||
} | ||
|
@@ -1155,7 +1158,7 @@ Polymer({ | |
0, LEGEND_WIDTH_PX | ||
]); | ||
|
||
const legendAxis = d3.axisBottom(legendScale); | ||
const legendAxis = d3.axisBottom(legendScale).ticks(5); | ||
|
||
legendSvg.append('g') | ||
.attr('class', 'legend axis') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS style nit: please -2 indent in this function block and the one below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done