Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
Tidy up, rm superflous logging, v0.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
danwild committed Jun 5, 2018
1 parent ed43b08 commit 417d60b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 31 deletions.
16 changes: 2 additions & 14 deletions dist/leaflet-network.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({

Expand All @@ -7,11 +7,8 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
options: {
data: null,
displayMode: 'SOURCE',

// TODO fix merge options.., document, implement
scaleDomain: null,
scaleRange: [1, 100],

scaleRange: [1, 5],
onMouseEnterNode: null,
onMouseLeaveNode: null,
onMouseEnterLine: null,
Expand All @@ -33,9 +30,6 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({

var self = this;

console.log('this.options');
console.log(this.options);

// delete self-connections
var data = this.options.data.map(function (d) {
delete d.connections[d.properties.id];
Expand All @@ -48,7 +42,6 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
// calc domain range if not provided in options
var scaleDomain;
if (this.options.scaleDomain) {
console.log('use provided domain option');
scaleDomain = this.options.scaleDomain;
} else {
// get an array of all connections
Expand All @@ -58,8 +51,6 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
});
var min = d3.min(connections);
var max = d3.max(connections);

console.log('auto calc domain: ' + min + ' - ' + max);
scaleDomain = [min, max];
}

Expand All @@ -86,9 +77,7 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
this._svgGroup1.selectAll("circle").data(data.map(function (d) {
return d;
})).attr("class", "site").enter().append("circle").style("opacity", .5).style("cursor", "pointer").style("fill", "red").attr("r", 5).on('click', function (d) {

console.log(d);

// set circles all inactive style, set this active
self._svgGroup1.selectAll("circle").style("opacity", 0.5).attr("r", 5);
d3.select(this).style('opacity', '0.8').attr("r", 10);
Expand All @@ -111,7 +100,6 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
/*------------------------------------ PUBLIC METHODS ------------------------------------------*/

update: function update() {
console.log('update');
var self = this;
self._drawConnections(this._targetId);
this._svgGroup1.selectAll("circle").attr("transform", function (d) {
Expand Down
2 changes: 1 addition & 1 deletion dist/leaflet-network.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-network",
"version": "0.0.7",
"version": "0.0.8",
"description": "Leaflet plugin to visualise arbitrary network connectivity between spatial data points",
"main": "dist/leaflet-network.js",
"scripts": {
Expand Down
16 changes: 1 addition & 15 deletions src/js/L.NetworkLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
options: {
data: null,
displayMode: 'SOURCE',

// TODO fix merge options.., document, implement
scaleDomain: null,
scaleRange: [1, 100],

scaleRange: [1, 5],
onMouseEnterNode: null,
onMouseLeaveNode: null,
onMouseEnterLine: null,
Expand All @@ -31,10 +28,6 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({

var self = this;

console.log('this.options');
console.log(this.options);


// delete self-connections
var data = this.options.data.map(function(d){
delete d.connections[d.properties.id];
Expand All @@ -47,16 +40,13 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
// calc domain range if not provided in options
var scaleDomain;
if(this.options.scaleDomain){
console.log('use provided domain option');
scaleDomain = this.options.scaleDomain;
} else {
// get an array of all connections
var connections = [];
data.forEach(function(d){ connections = connections.concat(Object.values(d.connections)); });
var min = d3.min(connections);
var max = d3.max(connections);

console.log('auto calc domain: '+min + ' - '+max);
scaleDomain = [min, max];
}

Expand Down Expand Up @@ -89,9 +79,7 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
.style("fill", "red")
.attr("r", 5)
.on('click', function(d){

console.log(d);

// set circles all inactive style, set this active
self._svgGroup1.selectAll("circle").style("opacity", 0.5).attr("r", 5);
d3.select(this).style('opacity','0.8').attr("r", 10);
Expand All @@ -116,7 +104,6 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
/*------------------------------------ PUBLIC METHODS ------------------------------------------*/

update: function() {
console.log('update');
var self = this;
self._drawConnections(this._targetId);
this._svgGroup1.selectAll("circle").attr("transform",
Expand Down Expand Up @@ -224,7 +211,6 @@ L.NetworkLayer = (L.Layer ? L.Layer : L.Class).extend({
.attr("stroke-width", val)
.attr("stroke-opacity", opacity)
.attr("stroke", color);

});
});
}
Expand Down

0 comments on commit 417d60b

Please sign in to comment.