Skip to content

Commit

Permalink
Merge c6b3fa3 into d019f02
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirsamdarshi committed May 23, 2018
2 parents d019f02 + c6b3fa3 commit 901e494
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 7 deletions.
5 changes: 4 additions & 1 deletion web-client/public/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ export const DEMO_INFORMATION = [
[ UNWEIGHTED_DEMO_ID, UNWEIGHTED_DEMO_PATH, UNWEIGHTED_DEMO_NAME ],
[ SCHADE_INPUT_ID, SCHADE_INPUT_PATH, SCHADE_INPUT_NAME ],
[ SCHADE_OUTPUT_ID, SCHADE_OUTPUT_PATH, SCHADE_OUTPUT_NAME ]
];
];

export const MIN_EDGE_WEIGHT_NORMALIZATION = 0.0001;
export const MAX_EDGE_WEIGHT_NORMALIZATION = 1000;
3 changes: 3 additions & 0 deletions web-client/public/js/graph.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Grid from "d3-v4-grid";
import { grnState } from "./grnstate";
const hasExpressionData = require("./node-coloring").hasExpressionData;

/* globals d3 */
Expand Down Expand Up @@ -91,6 +92,8 @@ export var drawGraph = function (network, sliderController, nodeColoring) {
document.getElementById("edge-weight-normalization-factor-menu").setAttribute("placeholder", "");
} else {
var maxWeight = d3.max(allWeights);
grnState.resetNormalizationMax = maxWeight;
grnState.normalizationMax = maxWeight;
document.getElementById("normalization-max").setAttribute("placeholder", maxWeight);
document.getElementById("edge-weight-normalization-factor-menu").setAttribute("placeholder", maxWeight);
}
Expand Down
6 changes: 3 additions & 3 deletions web-client/public/js/grnsight.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { grnState } from "./grnstate";
import { updateApp } from "./update-app";
import { setupHandlers } from "./setup-handlers";

setupHandlers(grnState);
updateApp(grnState);

container();
upload(sliderObject, sliderGroupController, drawGraph, nodeColoringController);

setupHandlers(grnState);
updateApp(grnState);
5 changes: 4 additions & 1 deletion web-client/public/js/grnstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ export const grnState = {

dashedLine: false,

annotateLinks: () => annotateLinks(currentNetwork)
annotateLinks: () => annotateLinks(currentNetwork),

normalizationMax : null,
resetNormalizationMax: null
};
15 changes: 15 additions & 0 deletions web-client/public/js/setup-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,19 @@ export const setupHandlers = grnState => {
grnState.dashedLine = !$(GREY_EDGES_DASHED_MENU).prop("checked");
updateApp(grnState);
});

$("#normalization-button").click(function () {
grnState.normalizationMax = $("#normalization-max").val();
updateApp(grnState);
});

$("#reset-normalization-factor-menu, #resetNormalizationButton").click(function () {
grnState.normalizationMax = grnState.resetNormalizationMax;
updateApp(grnState);
});

$("#edge-weight-normalization-factor-menu").on("change", function () {
grnState.normalizationMax = $("#edge-weight-normalization-factor-menu").val();
updateApp(grnState);
});
};
26 changes: 25 additions & 1 deletion web-client/public/js/update-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { displayWarnings } from "./warnings";

import {
GREY_EDGES_DASHED_MENU,
GREY_EDGES_DASHED_SIDEBAR
GREY_EDGES_DASHED_SIDEBAR,
MIN_EDGE_WEIGHT_NORMALIZATION,
MAX_EDGE_WEIGHT_NORMALIZATION
} from "./constants";

// In this transitory state, updateApp might get called before things are completely set up, so for now
Expand Down Expand Up @@ -39,6 +41,7 @@ const displayNetwork = (network, name) => {
};

export const updateApp = grnState => {

if (grnState.newNetwork) {
displayNetwork(grnState.network, grnState.name);
refreshApp();
Expand All @@ -48,6 +51,27 @@ export const updateApp = grnState => {
grnState.newNetwork = false;
}

if (grnState.normalizationMax !== null) {
var valueValidator = (min, max, value) => {
return Math.min(max, Math.max(min, value));
};

var edgeWeightNormalizationInputValidation = (value) => {
return value ===
"" ? "" : valueValidator(MIN_EDGE_WEIGHT_NORMALIZATION, MAX_EDGE_WEIGHT_NORMALIZATION, value);
};

var synchronizeNormalizationValues = (value) => {
var validated = edgeWeightNormalizationInputValidation(value);
$("#normalization-max").val(validated);
$("#edge-weight-normalization-factor-menu").val(validated);
};

synchronizeNormalizationValues(grnState.normalizationMax);
refreshApp();
}

// Dashed Line Synchronization
if (grnState.dashedLine) {
$(GREY_EDGES_DASHED_MENU + " span").addClass("glyphicon-ok");
$(GREY_EDGES_DASHED_MENU).prop("checked", "checked");
Expand Down
2 changes: 1 addition & 1 deletion web-client/public/js/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const upload = function (sliderObject, sliderGroupController, drawGraph,
var MIN_EDGE_WEIGHT_NORMALIZATION = 0.0001;
var MAX_EDGE_WEIGHT_NORMALIZATION = 1000;

var valueValidator = function (min, max, value) {
let valueValidator = (min, max, value) => {
return Math.min(max, Math.max(min, value));
};

Expand Down

0 comments on commit 901e494

Please sign in to comment.