Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4270f0c
Using group attribute for filtering with VisTK
romsson Apr 4, 2016
4c4f5b5
Adding active/inactive toggle and class binding
romsson Apr 5, 2016
e72d1b9
Notify upstream component it became active
romsson Apr 5, 2016
b85ca88
Toggling active key coming from downstream
romsson Apr 5, 2016
8354a79
Mapping actions and active value to keys' parent component
romsson Apr 5, 2016
5cb9eae
Keys actions binding and styling
romsson Apr 5, 2016
6689445
CSS styling for keys for affordance and to reflect currently active key
romsson Apr 5, 2016
730c158
WIP to test charts dynamic filtering
romsson Apr 5, 2016
7561afc
Cleanup
romsson Apr 5, 2016
0f2fc0a
Adding filter variable to the controller
romsson Apr 8, 2016
05a35d4
Now using controller filter variable
romsson Apr 8, 2016
54b9da0
Passing controller value to the components
romsson Apr 8, 2016
60481f6
Observing filter variable and refreshing the scatterplot
romsson Apr 8, 2016
399ce01
Support for interactive legend
romsson Apr 8, 2016
562a9a6
Cleanup
romsson Apr 8, 2016
c889a25
Using group attribute for filtering with VisTK
romsson Apr 4, 2016
5e67542
Adding active/inactive toggle and class binding
romsson Apr 5, 2016
6867aa2
Notify upstream component it became active
romsson Apr 5, 2016
87a0c29
Toggling active key coming from downstream
romsson Apr 5, 2016
321afb6
Mapping actions and active value to keys' parent component
romsson Apr 5, 2016
b4e3f4c
Keys actions binding and styling
romsson Apr 5, 2016
98e98db
CSS styling for keys for affordance and to reflect currently active key
romsson Apr 5, 2016
c4d7e99
WIP to test charts dynamic filtering
romsson Apr 5, 2016
13b99d6
Cleanup
romsson Apr 5, 2016
76145ae
Adding filter variable to the controller
romsson Apr 8, 2016
05d2f5e
Now using controller filter variable
romsson Apr 8, 2016
8c36ab3
Passing controller value to the components
romsson Apr 8, 2016
5c5d7bc
Observing filter variable and refreshing the scatterplot
romsson Apr 8, 2016
f0c18db
Support for interactive legend
romsson Apr 8, 2016
65fc896
Cleanup
romsson Apr 8, 2016
bd769d3
Merge branch 'feature/legend-filter' of github.com:cid-harvard/atlas-…
romsson Apr 15, 2016
aa2db94
Turning scatter config into variable so it can easily be re-used
romsson Apr 15, 2016
2c50df3
Making sure keyFilter array exists
romsson Apr 15, 2016
15b5446
Network config as a variable
romsson Apr 15, 2016
53475be
Making sure filter don't color non-exported products
romsson Apr 15, 2016
2469beb
Making exported products slightly more prominent
romsson Apr 15, 2016
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
2 changes: 1 addition & 1 deletion app/components/graphbuilder-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default Ember.Component.extend({
rcaAll() {
this.set('rcaFilter', 'all');
this.set('isOpen', false);
},
}
}
});

3 changes: 1 addition & 2 deletions app/components/vistk-dotplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default Ember.Component.extend({
}],
selection: [currentSelection]
});
}),
}),
draw: function() {
this.set('width', this.$().parent().width());
this.set('height', this.$().parent().height());
Expand All @@ -97,4 +97,3 @@ export default Ember.Component.extend({
});
}
});

54 changes: 49 additions & 5 deletions app/components/vistk-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default Ember.Component.extend({
d.name_short_en = datum.name_short_en + ` (${datum.code})`;
d.name_short_es = datum.name_short_es + ` (${datum.code})`;
d.color = datum.color;
d.group = datum.group;
d[this.get('varDependent')] = datum[this.get('varDependent')];
d[this.get('varRCA')] = datum[this.get('varRCA')];
}
Expand All @@ -46,8 +47,9 @@ export default Ember.Component.extend({
edges: computed('dataType', function() {
return this.get('graph').edges;
}),
network: computed('data.[]', 'varDependent', 'dataType', 'vis', 'i18n.locale', function() {
return vistk.viz().params({
config: computed('data.[]', 'varDependent', 'dataType', 'vis', 'i18n.locale', function() {
let keyFilter = this.get('keyFilter') || [];
return {
type: 'productspace',
height: this.get('height'),
width: this.get('width'),
Expand All @@ -61,17 +63,24 @@ export default Ember.Component.extend({
var_y: 'y',
radius: 5,
var_color: 'color',
var_group: 'group',
color: (d) => { return d; },
y_invert: true,
var_id: 'id',
items: [{
attr: 'name',
marks: [{
type: 'circle',
fill: (d) => {
fill: (d, i, vars) => {
//if there is no search, color products export > 0 and rca > 1
// industries if RCA > 1 ( varDependent for industries is also rca )
if(d[this.get('varRCA')] >= 1){
if(keyFilter.length > 0) {
if(d[vars.var_group] === keyFilter[0] && d[this.get('varRCA')] >= 1) {
return d.color;
} else {
return 'white';
}
} else if(d[this.get('varRCA')] >= 1) {
return d.color;
}
},
Expand Down Expand Up @@ -129,7 +138,10 @@ export default Ember.Component.extend({
translate: [0, -10]
}]
}]
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JShint complaining about a missing semicolon here

}),
network: computed('data.[]', 'varDependent', 'dataType', 'vis', 'i18n.locale', function() {
return vistk.viz().params(this.get('config'));
}),
didInsertElement: function() {
Ember.run.scheduleOnce('afterRender', this , function() {
Expand All @@ -142,6 +154,38 @@ export default Ember.Component.extend({
this.removeObserver('i18n.locale', this, this.update);
this.removeObserver('data.[]', this, this.update);
},
refresh: observer('keyFilter', function() {
if(!this.element){ return ; } //do not redraw if not there
let keyFilter = this.get('keyFilter') || [];

Ember.run.later(this , function() {
if(this.get('network')) {
d3.select(this.get('id')).call(this.get('network'));
this.get('network').params({filter: keyFilter});
this.get('network').params({
y_invert: true,
items: [{
marks: [{
type: 'circle',
fill: (d, i, vars) => {
if(keyFilter.length > 0) {
if(d[vars.var_group] === keyFilter[0] && d[this.get('varRCA')] >= 1) {
return d.color;
} else {
return 'white';
}
} else if(d[this.get('varRCA')] >= 1) {
return d.color;
}
}
}]
}]
});
this.get('network').params().refresh = true;
d3.select(this.get('id')).call(this.get('network'));
}
});
}),
update: observer('data.[]', 'varDependent', 'i18n.locale', function() {
if(!this.element){ return false; } //do not redraw if not there
d3.select(this.get('id')).select('svg').remove();
Expand Down
25 changes: 21 additions & 4 deletions app/components/vistk-scatterplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export default Ember.Component.extend({
id: computed('elementId', function() {
return `#${this.get('elementId')}`;
}),
scatter: computed('data.@each', 'dataType','eciValue','i18n.locale', function() {
config: computed('data.@each', 'dataType','eciValue','i18n.locale', function() {
let eci = this.get('eciValue');
let lang = this.get('i18n.locale') === 'en-col' ? 'en_EN': 'es_ES';
let keyFilter = this.get('keyFilter') || [];
let format = function(value) { return numeral(value).format('0.00'); };
return vistk.viz()
.params({
return {
type: 'scatterplot',
margin: {top: 10, right: 20, bottom: 30, left: 30},
height: this.get('height'),
Expand All @@ -30,6 +30,7 @@ export default Ember.Component.extend({
var_x: 'distance',
var_y: 'complexity',
var_r: this.get('varSize'),
var_group: 'group',
radius_min: 2,
radius_max: 10,
x_domain: this.get('x_domain'),
Expand Down Expand Up @@ -159,8 +160,12 @@ export default Ember.Component.extend({
}
}]
}],
filter: keyFilter,
lang: lang
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And another jshint complaint here about a missing semicolon

}),
scatter: computed('data.@each', 'dataType','eciValue','i18n.locale', function() {
return vistk.viz().params(this.get('config'));
}),
varSize: computed('dataType', function() {
if(this.get('dataType') === 'products') { return 'cog'; }
Expand Down Expand Up @@ -194,6 +199,18 @@ export default Ember.Component.extend({
this.removeObserver('i18n.locale', this, this.update);
this.removeObserver('data.[]', this, this.update);
},
refresh: observer('keyFilter', function() {
if(!this.element){ return ; } //do not redraw if not there
let keyFilter = this.get('keyFilter') || [];

Ember.run.later(this , function() {
if(this.get('scatter')) {
this.get('scatter').params({filter: keyFilter});
this.get('scatter').params().refresh = true;
d3.select(this.get('id')).call(this.get('scatter'));
}
});
}),
update: observer('data.@each', 'varRca', 'i18n.locale', 'dataType', function() {
if(!this.element){ return ; } //do not redraw if not there
d3.select(this.get('id')).select('svg').remove();
Expand Down
15 changes: 13 additions & 2 deletions app/components/visualization-legend-key.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import Ember from 'ember';
const { computed, get } = Ember;
const {computed, get} = Ember;

export default Ember.Component.extend({
color: computed.alias('key.color'),
code: computed.alias('key.code'),
name: computed('key', 'i18n.locale', function(){
let locale = get(this, 'i18n.display');
return get(this, `key.name_${locale}`);
}),
myStyle: computed('color', function() {
var color = this.get('color');
return new Ember.Handlebars.SafeString("color: " + color);
})
}),
classNameBindings: ['isActive'],
active: false,
isActive: computed('active', function() {
return this.get('code') === this.get('active');
}),
actions: {
changeKey() {
this.sendAction('action', this.get('code'));
}
}
});
15 changes: 15 additions & 0 deletions app/components/visualization-legend.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import Ember from 'ember';

export default Ember.Component.extend({
activeKey: null,
actions: {
changeKey(key) {
let code = [];

if(this.get('activeKey') === key) {
this.set('activeKey', null);
} else {
this.set('activeKey', key);
code = [key];
}

this.set('keyFilter', code);
}
}
});
1 change: 1 addition & 0 deletions app/routes/location/visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export default Ember.Route.extend({
controller.set('drawerChangeGraphIsOpen', false); // Turn off other drawers
controller.set('drawerQuestionsIsOpen', false); // Turn off other drawers
controller.set('searchText', controller.get('search'));
controller.set('keyFilter', []);
window.scrollTo(0, 0);
},
resetController(controller, isExiting) {
Expand Down
5 changes: 5 additions & 0 deletions app/styles/components/_modules/_buildermod.scss
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,15 @@
margin-left: 6rem;
}

.buildermod__legend__item .is-active {
font-weight: 800;
}

.buildermod__legend__item {
display: inline-block;
width: 100%;
white-space: nowrap;
cursor: pointer;

.fa {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion app/styles/components/_visualizations/_network.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

.node--is--highlighted {
stroke: $colorBlack;
stroke-width: 1px;
stroke-width: 1.5px;
}

.connect__line {
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/visualization-legend-key.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<i class="fa fa-circle" style={{myStyle}}></i> {{name}}
<span {{action 'changeKey'}}><i class="fa fa-circle" style={{myStyle}}></i> {{name}}</span>
4 changes: 2 additions & 2 deletions app/templates/components/visualization-legend.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="buildermod__legend">
{{#each key in legend}}
<div class="buildermod__legend__item">
{{visualization-legend-key key=key }}
{{visualization-legend-key key=key active=activeKey action='changeKey'}}
</div>
{{else}}
{{/each}}
</div>
</div>
4 changes: 3 additions & 1 deletion app/templates/visualization.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@
entityId=entityId
variable=variable
search=search
keyFilter=keyFilter
graph=graph
}}

{{#if needsLegend }}
{{component 'visualization-legend' legend=legend }}
{{component 'visualization-legend' legend=legend keyFilter=keyFilter }}
{{/if}}

<div class="buildermod__settings__wrap">
Expand All @@ -56,6 +57,7 @@
canYearToggle=canYearToggle
isScatter=isScatter
rcaFilter=rcaFilter
keyFilter=keyFilter
}}
</div>
</div>
Expand Down