File Cache and FileCursorCache working
This commit is contained in:
1 parent
655ba7ce47
commit
a77b89ed1c
10 files changed
+93
-32
No files matched your search
Binary file not shown.
+63
-17
@@ -9,21 +9,37 @@ function getSideDays(timePeriod) {
|
||||
}
|
||||
|
||||
if (timePeriod === _1_HOUR_IN_MILISECONDS) {
|
||||
daysOnSides = 2;
|
||||
daysOnSides = 9;
|
||||
}
|
||||
|
||||
if (timePeriod === _3_HOURS_IN_MILISECONDS) {
|
||||
daysOnSides = 6;
|
||||
}
|
||||
|
||||
if (timePeriod === _6_HOURS_IN_MILISECONDS) {
|
||||
if (timePeriod === _2_HOURS_IN_MILISECONDS) {
|
||||
daysOnSides = 10;
|
||||
}
|
||||
|
||||
if (timePeriod === _12_HOURS_IN_MILISECONDS) {
|
||||
if (timePeriod === _3_HOURS_IN_MILISECONDS) {
|
||||
daysOnSides = 12;
|
||||
}
|
||||
|
||||
if (timePeriod === _4_HOURS_IN_MILISECONDS) {
|
||||
daysOnSides = 20;
|
||||
}
|
||||
|
||||
if (timePeriod === _6_HOURS_IN_MILISECONDS) {
|
||||
daysOnSides = 35;
|
||||
}
|
||||
|
||||
if (timePeriod === _8_HOURS_IN_MILISECONDS) {
|
||||
daysOnSides = 44;
|
||||
}
|
||||
|
||||
if (timePeriod === _12_HOURS_IN_MILISECONDS) {
|
||||
daysOnSides = 56;
|
||||
}
|
||||
|
||||
if (timePeriod === ONE_DAY_IN_MILISECONDS) {
|
||||
daysOnSides = 154;
|
||||
}
|
||||
|
||||
return daysOnSides;
|
||||
}
|
||||
|
||||
@@ -54,20 +70,22 @@ function getTransparenceFactor(timePeriod) {
|
||||
|
||||
function recalculatePeriod(zoomLevel) {
|
||||
|
||||
if (zoomLevel > 600) {
|
||||
return _1_MINUTE_IN_MILISECONDS;
|
||||
}
|
||||
console.log(" recalculatePeriod > " + zoomLevel);
|
||||
|
||||
if (zoomLevel > 300) {
|
||||
if (zoomLevel > 200) {
|
||||
return _1_MINUTE_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > 120) {
|
||||
return _1_MINUTE_IN_MILISECONDS;
|
||||
return _2_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > 80) {
|
||||
return _3_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > 60) {
|
||||
return _5_MINUTES_IN_MILISECONDS;
|
||||
return _4_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > 15) {
|
||||
@@ -78,27 +96,55 @@ function recalculatePeriod(zoomLevel) {
|
||||
return _10_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 10) {
|
||||
return _15_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 13) {
|
||||
return _20_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 15) {
|
||||
return _30_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 24) {
|
||||
if (zoomLevel > - 16) {
|
||||
return _40_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 17) {
|
||||
return _45_MINUTES_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 18) {
|
||||
return _1_HOUR_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 24) {
|
||||
return _2_HOURS_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 25) {
|
||||
return _3_HOURS_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 26) {
|
||||
if (zoomLevel > - 27) {
|
||||
return _4_HOURS_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 27.5) {
|
||||
return _6_HOURS_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 27) {
|
||||
if (zoomLevel > - 27.75) {
|
||||
return _8_HOURS_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel > - 28) {
|
||||
return _12_HOURS_IN_MILISECONDS;
|
||||
}
|
||||
|
||||
if (zoomLevel <= - 27) {
|
||||
if (zoomLevel <= - 28) {
|
||||
return ONE_DAY_IN_MILISECONDS;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -50,18 +50,29 @@ const LESS_WIDHTER_VOLUME_BAR_TOP_FACTOR = 1 / 4;
|
||||
|
||||
const ONE_DAY_IN_MILISECONDS = 24 * 60 * 60 * 1000;
|
||||
const _12_HOURS_IN_MILISECONDS = 12 * 60 * 60 * 1000;
|
||||
const _8_HOURS_IN_MILISECONDS = 8 * 60 * 60 * 1000;
|
||||
const _6_HOURS_IN_MILISECONDS = 6 * 60 * 60 * 1000;
|
||||
const _4_HOURS_IN_MILISECONDS = 4 * 60 * 60 * 1000;
|
||||
const _3_HOURS_IN_MILISECONDS = 3 * 60 * 60 * 1000;
|
||||
const _2_HOURS_IN_MILISECONDS = 2 * 60 * 60 * 1000;
|
||||
const _1_HOUR_IN_MILISECONDS = 1 * 60 * 60 * 1000;
|
||||
|
||||
const _45_MINUTES_IN_MILISECONDS = 45 * 60 * 1000;
|
||||
const _40_MINUTES_IN_MILISECONDS = 40 * 60 * 1000;
|
||||
const _30_MINUTES_IN_MILISECONDS = 30 * 60 * 1000;
|
||||
const _20_MINUTES_IN_MILISECONDS = 20 * 60 * 1000;
|
||||
const _15_MINUTES_IN_MILISECONDS = 15 * 60 * 1000;
|
||||
const _10_MINUTES_IN_MILISECONDS = 10 * 60 * 1000;
|
||||
const _5_MINUTES_IN_MILISECONDS = 5 * 60 * 1000;
|
||||
const _4_MINUTES_IN_MILISECONDS = 4 * 60 * 1000;
|
||||
const _3_MINUTES_IN_MILISECONDS = 3 * 60 * 1000;
|
||||
const _2_MINUTES_IN_MILISECONDS = 2 * 60 * 1000;
|
||||
const _1_MINUTE_IN_MILISECONDS = 1 * 60 * 1000;
|
||||
|
||||
const EARLIEST_DATE = new Date(2014, 0, 18, 4, 26, 8);
|
||||
const FONT_ASPECT_RATIO = 0.60;
|
||||
const CHART_ASPECT_RATIO = 1 / 10;
|
||||
const INITIAL_TIME_PERIOD = ONE_DAY_IN_MILISECONDS;
|
||||
const INITIAL_TIME_PERIOD = _10_MINUTES_IN_MILISECONDS;
|
||||
|
||||
/* Here we list the valid Time Periods: */
|
||||
|
||||
|
||||
+4
-4
@@ -70,7 +70,7 @@ function newEcosystem() {
|
||||
codeName: "Market Candlesticks",
|
||||
displayName: "Candlesticks",
|
||||
exchangeList: ["Poloniex"],
|
||||
validPeriods: ["24-hs", "12-hs", "06-hs", "03-hs", "01-hs"],
|
||||
validPeriods: ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs"],
|
||||
plotter: {
|
||||
devTeam: "AAMasters",
|
||||
repo: "AAOlivia-Plotter",
|
||||
@@ -107,7 +107,7 @@ function newEcosystem() {
|
||||
codeName: "Market Volumes",
|
||||
displayName: "Volumes",
|
||||
exchangeList: ["Poloniex"],
|
||||
validPeriods: ["24-hs", "12-hs", "06-hs", "03-hs", "01-hs"],
|
||||
validPeriods: ["24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs"],
|
||||
plotter: {
|
||||
devTeam: "AAMasters",
|
||||
repo: "AAOlivia-Plotter",
|
||||
@@ -144,7 +144,7 @@ function newEcosystem() {
|
||||
codeName: "Daily Candlesticks",
|
||||
displayName: "Candlesticks",
|
||||
exchangeList: ["Poloniex"],
|
||||
validPeriods: ["30-min", "15-min", "10-min", "05-min", "01-min"],
|
||||
validPeriods: ["45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min"],
|
||||
plotter: {
|
||||
devTeam: "AAMasters",
|
||||
repo: "AAOlivia-Plotter",
|
||||
@@ -181,7 +181,7 @@ function newEcosystem() {
|
||||
codeName: "Daily Volumes",
|
||||
displayName: "Volumes",
|
||||
exchangeList: ["Poloniex"],
|
||||
validPeriods: ["30-min", "15-min", "10-min", "05-min", "01-min"],
|
||||
validPeriods: ["45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min"],
|
||||
plotter: {
|
||||
devTeam: "AAMasters",
|
||||
repo: "AAOlivia-Plotter",
|
||||
|
||||
+3
-1
@@ -33,12 +33,14 @@ function newFileCloud() {
|
||||
|
||||
filePath = filePath.replace("@Year", pDatetime.getUTCFullYear());
|
||||
filePath = filePath.replace("@Month", pad(pDatetime.getUTCMonth() + 1, 2));
|
||||
filePath = filePath.replace("@Month", pad(pDatetime.getUTCDate(), 2));
|
||||
filePath = filePath.replace("@Day", pad(pDatetime.getUTCDate(), 2));
|
||||
|
||||
}
|
||||
|
||||
fileService.getFileToText('data', filePath, fileName, undefined, onFileReceived);
|
||||
|
||||
console.log("File Requested > " + filePath);
|
||||
|
||||
function onFileReceived(err, text, response) {
|
||||
|
||||
let data;
|
||||
|
||||
+5
-4
@@ -12,7 +12,8 @@ function newFileCursor() {
|
||||
|
||||
fileCursor.files = files;
|
||||
|
||||
let cursorSize = 3;
|
||||
let minCursorSize = 10;
|
||||
let maxCursorSize = 30;
|
||||
|
||||
let market;
|
||||
let exchange;
|
||||
@@ -115,7 +116,7 @@ function newFileCursor() {
|
||||
|
||||
i++;
|
||||
|
||||
if (i < cursorSize) {
|
||||
if (i < minCursorSize) {
|
||||
|
||||
getNextFile();
|
||||
|
||||
@@ -128,8 +129,8 @@ function newFileCursor() {
|
||||
|
||||
date = removeTime(cursorDate);
|
||||
|
||||
let minDate = date.valueOf() - cursorSize / 2 * 24 * 60 * 60 * 1000;
|
||||
let maxDate = date.valueOf() + cursorSize / 2 * 24 * 60 * 60 * 1000;
|
||||
let minDate = date.valueOf() - maxCursorSize * ONE_DAY_IN_MILISECONDS / 2;
|
||||
let maxDate = date.valueOf() + maxCursorSize * ONE_DAY_IN_MILISECONDS / 2;
|
||||
|
||||
for (let key of fileCursor.files.keys()) {
|
||||
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ function newFileCursorCache() {
|
||||
|
||||
if (layer.validPeriods.includes(periodName) === true) {
|
||||
|
||||
let fileCursor = newFileCursos();
|
||||
let fileCursor = newFileCursor();
|
||||
fileCursor.initialize(fileCloud, product, exchange, pMarket, periodName, pDatetime, onFileReceived);
|
||||
|
||||
fileCursors.set(periodTime, fileCursor);
|
||||
@@ -78,7 +78,7 @@ function newFileCursorCache() {
|
||||
|
||||
datetime = newDatetime;
|
||||
|
||||
fileCursors.forEach(setDatetime)
|
||||
fileCursors.forEach(setDatetimeToEach)
|
||||
|
||||
function setDatetimeToEach(value, key, map) {
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@ function getDateFromPoint(point, container, plotArea) {
|
||||
|
||||
let date = new Date(point.x);
|
||||
|
||||
date = removeTime(date);
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -199,7 +199,9 @@ function newViewPort() {
|
||||
} else {
|
||||
event.type = "Zoom Out";
|
||||
}
|
||||
|
||||
|
||||
console.log("Zoom Changed > " + event.newLevel);
|
||||
|
||||
viewPort.eventHandler.raiseEvent("Zoom Changed", event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<script type="text/javascript" src="FileServer.js"></script>
|
||||
<script type="text/javascript" src="FileCloud.js"></script>
|
||||
<script type="text/javascript" src="FileCache.js"></script>
|
||||
<script type="text/javascript" src="FileCursorCache.js"></script>
|
||||
<script type="text/javascript" src="FileCursor.js"></script>
|
||||
<script type="text/javascript" src="SplashScreen.js"></script>
|
||||
<script type="text/javascript" src="Canvas.js"></script>
|
||||
|
||||
Reference in new issue
Block a user