diff --git a/Canvas.js b/Canvas.js
index 093c09d99..d211c78d4 100644
--- a/Canvas.js
+++ b/Canvas.js
@@ -1,5 +1,4 @@
-let browserCanvas; // This is the canvas object of the browser.
let browserCanvasContext; // The context of the canvas object.
let stepsInitializationCounter = 0; // This counter the initialization steps required to be able to turn off the splash screen.
@@ -228,15 +227,8 @@ function newCanvas() {
if (INFO_LOG === true) { logger.write("[INFO] initializeBrowserCanvas -> Entering function."); }
- browserCanvas = document.getElementById('canvas');
browserCanvasContext = browserCanvas.getContext('2d');
- let body = document.getElementById('body');
-
- browserCanvas.width = window.innerWidth;
- browserCanvas.height = window.innerHeight;
- browserCanvas.style.border = "none";
-
viewPort.initialize();
} catch (err) {
@@ -532,15 +524,26 @@ function newCanvas() {
if (floatingObjectIndex > 0) {
canvas.floatingSpace.floatingLayer.changeTargetRepulsion(event.wheelDelta);
+ return false; // This instructs the browser not to take the event and scroll the page.
+ }
+
+ /* Finally we try the Chart Space. */
+
+ let chartContainer = canvas.chartSpace.getContainer({ x: event.pageX, y: event.pageY });
+
+ if (chartContainer !== undefined && chartContainer.isWheeleable === true) {
+
+ chartContainer.eventHandler.raiseEvent("Mouse Wheel", event.wheelDelta);
+ return false; // This instructs the browser not to take the event and scroll the page.
} else {
+ /* If all the above fails, we fallback into applying zoom to the viewPort */
+
viewPort.applyZoom(delta);
-
+ return false; // This instructs the browser not to take the event and scroll the page.
}
- return false; // This instructs the browser not to take the event and scroll the page.
-
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onMouseWheel -> err = " + err); }
diff --git a/Globals.js b/Globals.js
index fba1a2855..bdb5f0323 100644
--- a/Globals.js
+++ b/Globals.js
@@ -129,7 +129,8 @@ const _1_MINUTE_IN_MILISECONDS = 1 * 60 * 1000;
const EARLIEST_DATE = new Date(2014, 0, 18, 4, 26, 8);
-const CHART_ASPECT_RATIO = 1 / 10;
+const MIN_CHART_ASPECT_RATIO = 2 / 10;
+let CHART_ASPECT_RATIO = MIN_CHART_ASPECT_RATIO;
const TOP_SPACE_HEIGHT = 50;
const BOTTOM_SPACE_HEIGHT = 50;
@@ -159,4 +160,11 @@ var maxDate = new Date();
maxDate.setMilliseconds(0);
maxDate.setDate(maxDate.getDate() + 10);
-const MAX_PLOTABLE_DATE = maxDate;
\ No newline at end of file
+const MAX_PLOTABLE_DATE = maxDate;
+
+/*
+We define here the size of the chartSpace. It has to bee enough big in order to accomodate all the charts we expect to display in this space.
+*/
+
+const CHART_SPACE_WIDTH = browserCanvas.width * 1000;
+const CHART_SPACE_HEIGHT = browserCanvas.height * 100;
\ No newline at end of file
diff --git a/Project.njsproj b/Project.njsproj
index e60790bf5..2770d16ab 100644
--- a/Project.njsproj
+++ b/Project.njsproj
@@ -54,6 +54,9 @@
Code
+
+ Code
+
Code
diff --git a/Scales/ChartGrid.js b/Scales/ChartGrid.js
index fd8cea146..2e2aae1eb 100644
--- a/Scales/ChartGrid.js
+++ b/Scales/ChartGrid.js
@@ -4,30 +4,46 @@
container: undefined,
draw: draw,
getContainer: getContainer,
+ initialize: initialize
};
let container = newContainer();
container.initialize();
thisObject.container = container;
- thisObject.container.frame.width = 200;
- thisObject.container.frame.height = TOP_SPACE_HEIGHT;
+ thisObject.container.frame.width = 0;
+ thisObject.container.frame.height = 0;
- container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 3;
+ container.frame.position.x = 0;
container.frame.position.y = 0;
container.isDraggeable = false;
container.isClickeable = true;
+ let rigthScale;
+
return thisObject;
+ function initialize() {
+
+ rigthScale = newRigthScale();
+ rigthScale.initialize();
+
+ }
+
function getContainer(point) {
let container;
- /* First we check if this point is inside this object UI. */
+ container = rigthScale.getContainer(point);
- if (thisObject.container.frame.isThisPointHere(point, true) === true) {
+ if (container !== undefined) {
+
+ return container;
+
+ }
+
+ if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return this.container;
@@ -527,10 +543,10 @@
/* Now we put the scale on the right side of the chart */
- rightScale();
- leftScale();
+ drawRigthScale();
+ drawLeftScale();
- function rightScale() {
+ function drawRigthScale() {
/* And now the scale. */
@@ -560,7 +576,7 @@
}
- function leftScale() {
+ function drawLeftScale() {
let fontSize = 10;
diff --git a/Scales/RightScale.js b/Scales/RightScale.js
new file mode 100644
index 000000000..64699373f
--- /dev/null
+++ b/Scales/RightScale.js
@@ -0,0 +1,74 @@
+function newRigthScale() {
+
+ let thisObject = {
+ container: undefined,
+ draw: draw,
+ getContainer: getContainer,
+ initialize: initialize
+ };
+
+ const RIGHT_MARGIN = 50;
+
+ let container = newContainer();
+ container.initialize();
+ thisObject.container = container;
+
+ thisObject.container.frame.width = RIGHT_MARGIN;
+ thisObject.container.frame.height = viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y;
+
+ container.frame.position.x = viewPort.visibleArea.bottomRight.x;
+ container.frame.position.y = TOP_SPACE_HEIGHT;
+
+ container.isDraggeable = false;
+ container.isClickeable = false;
+ container.isWheeleable = true;
+
+ return thisObject;
+
+ function initialize() {
+
+ thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel);
+
+ }
+
+ function onMouseWheel(pDelta) {
+
+ if (pDelta < 0) {
+ pDelta = -0.1;
+ } else {
+ pDelta = 0.1;
+ }
+
+ CHART_ASPECT_RATIO = CHART_ASPECT_RATIO + pDelta;
+
+ if (CHART_ASPECT_RATIO < MIN_CHART_ASPECT_RATIO) {
+
+ CHART_ASPECT_RATIO = MIN_CHART_ASPECT_RATIO;
+
+ }
+ }
+
+ function getContainer(point) {
+
+ let container;
+
+ /* First we check if this point is inside this object UI. */
+
+ if (thisObject.container.frame.isThisPointHere(point, true) === true) {
+
+ return this.container;
+
+ } else {
+
+ /* This point does not belong to this space. */
+
+ return undefined;
+ }
+ }
+
+ function draw() {
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/Scripts/AppLoader.js b/Scripts/AppLoader.js
index 0a3312d35..3a734a7e6 100644
--- a/Scripts/AppLoader.js
+++ b/Scripts/AppLoader.js
@@ -69,6 +69,7 @@
"CloudVM/CloudVM.js",
"Scales/ChartGrid.js",
+ "Scales/RightScale.js",
"BreakpointsBar.js",
"Plotter.js",
diff --git a/Scripts/AppPreLoader.js b/Scripts/AppPreLoader.js
index ca41d35ec..ff119dd11 100644
--- a/Scripts/AppPreLoader.js
+++ b/Scripts/AppPreLoader.js
@@ -28,6 +28,8 @@ GLOBAL.CUSTOM_FAIL_RESPONSE = {
message: "Custom Message"
};
+let browserCanvas; // This is the canvas object of the browser.
+
function spacePad(str, max) {
str = str.toString();
return str.length < max ? spacePad(" " + str, max) : str;
@@ -54,6 +56,12 @@ function loadAdvancedAlgosPlatform() {
let body = document.getElementsByTagName("body")[0];
body.appendChild(canvas);
+ browserCanvas = document.getElementById('canvas');
+
+ browserCanvas.width = window.innerWidth;
+ browserCanvas.height = window.innerHeight;
+ browserCanvas.style.border = "none";
+
/* The second thing to do is to send the tokenSession to the server, so that it can prepare the server side data structures needed. */
let sessionToken = window.SESSION_TOKEN;
diff --git a/Spaces/ChartSpace.js b/Spaces/ChartSpace.js
index 57119f61a..ef6c55184 100644
--- a/Spaces/ChartSpace.js
+++ b/Spaces/ChartSpace.js
@@ -26,8 +26,8 @@ function newChartSpace() {
container.initialize();
thisObject.container = container;
- thisObject.container.frame.width = browserCanvas.width * 1000;
- thisObject.container.frame.height = browserCanvas.height * 100;
+ thisObject.container.frame.width = CHART_SPACE_WIDTH;
+ thisObject.container.frame.height = CHART_SPACE_HEIGHT;
container.displacement.containerName = "Chart Space";
container.frame.containerName = "Chart Space";
@@ -108,37 +108,25 @@ function newChartSpace() {
if (INFO_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
- var container;
+ let container;
- /* First we check if this point is inside this space. */
+ /* Now we see which is the inner most container that has it */
- if (this.container.frame.isThisPointHere(point) === true) {
+ for (var i = 0; i < this.timeMachines.length; i++) {
- /* Now we see which is the inner most container that has it */
+ container = this.timeMachines[i].getContainer(point);
- for (var i = 0; i < this.timeMachines.length; i++) {
+ if (container !== undefined) {
- container = this.timeMachines[i].getContainer(point);
+ /* We found an inner container which has the point. We return it. */
- if (container !== undefined) {
-
- /* We found an inner container which has the point. We return it. */
-
- return container;
- }
+ return container;
}
-
- /* The point does not belong to any inner container, so we return the current container. */
-
- return this.container;
-
- } else {
-
- /* This point does not belong to this space. */
-
- return undefined;
}
- }
+ /* The point does not belong to any inner container, so we return the current container. */
+ return this.container;
+
+ }
}
\ No newline at end of file
diff --git a/TimeMachine.js b/TimeMachine.js
index 68c83eb8c..22010f5fd 100644
--- a/TimeMachine.js
+++ b/TimeMachine.js
@@ -159,33 +159,22 @@ function newTimeMachine() {
let container;
- /* First we check if this point is inside this space. */
+ /* Now we see which is the inner most container that has it */
- if (this.container.frame.isThisPointHere(point) === true) {
+ for (let i = 0; i < this.charts.length; i++) {
- /* Now we see which is the inner most container that has it */
+ container = this.charts[i].getContainer(point);
- for (let i = 0; i < this.charts.length; i++) {
+ if (container !== undefined) {
- container = this.charts[i].getContainer(point);
+ /* We found an inner container which has the point. We return it. */
- if (container !== undefined) {
-
- /* We found an inner container which has the point. We return it. */
-
- return container;
- }
+ return container;
}
-
- /* The point does not belong to any inner container, so we return the current container. */
-
- return this.container;
-
- } else {
-
- /* This point does not belong to this space. */
-
- return undefined;
}
+
+ /* The point does not belong to any inner container, so we return the current container. */
+
+ return this.container;
}
}
\ No newline at end of file
diff --git a/TimelineChart.js b/TimelineChart.js
index 1f18196e4..e23cabe96 100644
--- a/TimelineChart.js
+++ b/TimelineChart.js
@@ -27,8 +27,8 @@
container.initialize();
thisObject.container = container;
- container.displacement.containerName = "Time Period Chart";
- container.frame.containerName = "Time Period Chart";
+ container.displacement.containerName = "Timeline Chart";
+ container.frame.containerName = "Timeline Chart";
let marketId;
let exchangeId;
@@ -110,6 +110,8 @@
exchangeId = exchange;
chartGrid = newChartGrid();
+ chartGrid.initialize();
+
breakpointsBar = newBreakpointsBar();
breakpointsBar.initialize(container, timeLineCoordinateSystem);
@@ -878,6 +880,10 @@
let container;
+ container = chartGrid.getContainer(point);
+
+ if (container !== undefined) { return container;}
+
container = breakpointsBar.getContainer(point);
return container;
@@ -940,6 +946,8 @@
if (thisObject.container.frame.isInViewPort()) {
+ thisObject.container.frame.height = CHART_SPACE_HEIGHT * CHART_ASPECT_RATIO;
+
this.container.frame.draw();
drawBackground();