Integration between science map widget and data table widget
This commit is contained in:
parent
80fc455b9d
commit
d07238287e
12 changed files with 459 additions and 166 deletions
139
productMods/js/visualization/mapofscience/ScimapWidget.js
Normal file
139
productMods/js/visualization/mapofscience/ScimapWidget.js
Normal file
|
@ -0,0 +1,139 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
var DEFAULT_SLIDER_VALUE = 20;
|
||||
|
||||
var ScimapWidget = Class.extend({
|
||||
init: function(map, sliderControl) {
|
||||
this.activeManager = null;
|
||||
this.isUnloaded = true;
|
||||
this.map = map;
|
||||
this.sliderControl = sliderControl;
|
||||
this.initView();
|
||||
},
|
||||
initView: function(){
|
||||
var me = this;
|
||||
me.initMarkerManagers();
|
||||
me.sliderControl.setChangeEventHandler(function(event, ui) {
|
||||
me.updateDisplayedMarkers(ui.value);
|
||||
});
|
||||
me.show(SCIMAP_TYPE.DISCIPLINE);
|
||||
},
|
||||
initMarkerManagers: function() {
|
||||
if (this.keyToMarkerManagers == null) {
|
||||
var managers = {};
|
||||
|
||||
// Create discipline Marker Manager
|
||||
managers[SCIMAP_TYPE.DISCIPLINE] = new DisciplineMarkerManager(
|
||||
this.map,
|
||||
new DisciplineColorStrategy(),
|
||||
null
|
||||
);
|
||||
|
||||
// Create subdiscipline Marker Manager
|
||||
managers[SCIMAP_TYPE.SUBDISCIPLINE] = new SubdisciplineMarkerManager(
|
||||
this.map,
|
||||
new SubdisciplineColorStrategy(),
|
||||
null
|
||||
);
|
||||
this.keyToMarkerManagers = managers;
|
||||
}
|
||||
},
|
||||
needLoaded: function(){
|
||||
return this.isUnloaded;
|
||||
},
|
||||
loadJsonData: function(data) {
|
||||
var me = this;
|
||||
me.uri = data.uri;
|
||||
me.label = data.label;
|
||||
me.pubsWithNoJournals = data.pubsWithNoJournals;
|
||||
me.pubsWithInvalidJournals = data.pubsWithInvalidJournals;
|
||||
me.pubsMapped = data.pubsMapped;
|
||||
|
||||
$.each(this.keyToMarkerManagers, function(key, manager) {
|
||||
// Need to create the AreaSizeCoding function
|
||||
manager.setSizeCoder(new CircleSizeCoder({
|
||||
scaler: new Scaler({ maxValue: me.pubsMapped })
|
||||
}));
|
||||
//markerManager.setSiseCodingFunction(new AreaSizeCoding(0, data.pubsMapped));
|
||||
$.each(data.subdisciplineActivity, function(subdiscipline, density) {
|
||||
|
||||
// Create marker and add it to manager
|
||||
var marker = manager.createMarker(subdiscipline, density);
|
||||
|
||||
}); // end each subdisciplineActivity
|
||||
}); // end each markerManagers
|
||||
me.updateMap();
|
||||
this.isUnloaded = false;
|
||||
},
|
||||
mouseIn: function(key, childKey) {
|
||||
var manager = this.getMarkerManager(key);
|
||||
// Focus if only it is an active manager
|
||||
if (manager == this.activeManager) {
|
||||
// Focus all if no childKey is given
|
||||
if (childKey) {
|
||||
manager.mouseIn(childKey);
|
||||
} else {
|
||||
manager.mouseInAll();
|
||||
}
|
||||
}
|
||||
},
|
||||
mouseOut: function(key, childKey) {
|
||||
var manager = this.getMarkerManager(key);
|
||||
// Focus if only it is an active manager
|
||||
if (manager == this.activeManager) {
|
||||
// Unfocus all if no childKey is given
|
||||
if (childKey) {
|
||||
manager.mouseOut(childKey);
|
||||
} else {
|
||||
manager.mouseOutAll();
|
||||
}
|
||||
}
|
||||
},
|
||||
getMarkerManager: function(key) {
|
||||
return this.keyToMarkerManagers[key];
|
||||
},
|
||||
hasKey: function(key) {
|
||||
return (this.keyToMarkerManagers.hasOwnProperty(key));
|
||||
},
|
||||
show: function(key) {
|
||||
var manager = this.getMarkerManager(key);
|
||||
if (manager) {
|
||||
this._switchActiveManager(manager);
|
||||
}
|
||||
},
|
||||
hide: function(key) {
|
||||
var manager = this.getMarkerManager(key);
|
||||
if (this.activeManager == manager) {
|
||||
this.cleanup();
|
||||
}
|
||||
},
|
||||
_switchActiveManager: function(manager) {
|
||||
if (this.activeManager != manager) {
|
||||
this.cleanUp();
|
||||
manager.addMarkersToMap();
|
||||
this.activeManager = manager;
|
||||
this.updateMap();
|
||||
}
|
||||
},
|
||||
cleanUp: function() {
|
||||
if (this.activeManager) {
|
||||
this.activeManager.removeMarkersFromMap();
|
||||
}
|
||||
},
|
||||
updateDisplayedMarkers: function(numberOfMarkers) {
|
||||
this.activeManager.display(numberOfMarkers);
|
||||
},
|
||||
updateMap: function() {
|
||||
var manager = this.activeManager;
|
||||
if (manager) {
|
||||
var length = manager.length();
|
||||
var slider = this.sliderControl;
|
||||
slider.setMin(Math.min(1, length));
|
||||
slider.setMax(length);
|
||||
slider.setValue(Math.min(DEFAULT_SLIDER_VALUE, length));
|
||||
}
|
||||
},
|
||||
changeFilter: function(filterType) {
|
||||
this.show(filterType);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue