Skip to content

Commit 162f97f

Browse files
committed
Added new parameter to the rendersettings options called positionAlias to define which parameters should be reported when a point is selected
1 parent b3ac2de commit 162f97f

File tree

2 files changed

+68
-7
lines changed

2 files changed

+68
-7
lines changed

dist/graphly.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/graphly.js

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,75 @@ class graphly extends EventEmitter {
521521
this.tooltip.append('div')
522522
.text(key+': '+val)
523523
}
524-
if(self.currentData.hasOwnProperty('Latitude') &&
525-
self.currentData.hasOwnProperty('Longitude') &&
526-
self.currentData.hasOwnProperty('Radius') ){
524+
// Check to see if data has set some aliases
525+
if(self.renderSettings.hasOwnProperty('positionAlias')){
526+
let posAlias = self.renderSettings.positionAlias;
527+
var lat, lon, alt;
528+
var cmobPar = self.renderSettings.combinedParameters;
529+
530+
if(cmobPar.hasOwnProperty(posAlias.latitude)){
531+
var key = cmobPar[posAlias.latitude];
532+
if(self.currentData.hasOwnProperty(key[0]) &&
533+
self.currentData.hasOwnProperty(key[1]) ){
534+
lat = [
535+
self.currentData[key[0]][nodeId.index],
536+
self.currentData[key[1]][nodeId.index]
537+
];
538+
}
539+
540+
} else {
541+
if(self.currentData.hasOwnProperty(posAlias.latitude)){
542+
lat = self.currentData[[posAlias.latitude]][nodeId.index];
543+
}
544+
}
545+
546+
if(cmobPar.hasOwnProperty(posAlias.longitude)){
547+
var key = cmobPar[posAlias.longitude];
548+
if(self.currentData.hasOwnProperty(key[0]) &&
549+
self.currentData.hasOwnProperty(key[1]) ){
550+
lon = [
551+
self.currentData[key[0]][nodeId.index],
552+
self.currentData[key[1]][nodeId.index]
553+
];
554+
}
555+
556+
} else {
557+
if(self.currentData.hasOwnProperty(posAlias.longitude)){
558+
lon = self.currentData[[posAlias.longitude]][nodeId.index];
559+
}
560+
}
561+
562+
if(cmobPar.hasOwnProperty(posAlias.altitude)){
563+
var key = cmobPar[posAlias.altitude];
564+
if(self.currentData.hasOwnProperty(key[0]) &&
565+
self.currentData.hasOwnProperty(key[1]) ){
566+
alt = [
567+
self.currentData[key[0]][nodeId.index],
568+
self.currentData[key[1]][nodeId.index]
569+
];
570+
}
571+
572+
} else {
573+
if(self.currentData.hasOwnProperty(posAlias.altitude)){
574+
alt = self.currentData[[posAlias.altitude]][nodeId.index];
575+
}
576+
}
577+
527578
this.emit('pointSelect', {
528-
Latitude: self.currentData.Latitude[nodeId.index],
529-
Longitude: self.currentData.Longitude[nodeId.index],
530-
Radius: self.currentData.Radius[nodeId.index]
579+
Latitude: lat,
580+
Longitude: lon,
581+
Radius: alt
531582
});
583+
} else {
584+
if(self.currentData.hasOwnProperty('Latitude') &&
585+
self.currentData.hasOwnProperty('Longitude') &&
586+
self.currentData.hasOwnProperty('Radius') ){
587+
this.emit('pointSelect', {
588+
Latitude: self.currentData.Latitude[nodeId.index],
589+
Longitude: self.currentData.Longitude[nodeId.index],
590+
Radius: self.currentData.Radius[nodeId.index]
591+
});
592+
}
532593
}
533594
} else {
534595
for (let key in nodeId) {

0 commit comments

Comments
 (0)