Preformance Improvements in Charts
This commit is contained in:
1 parent
6b127356c6
commit
6446556fe3
2 files changed
+4
-35
No files matched your search
+4
-9
@@ -61,11 +61,11 @@ function newAnimation () {
|
||||
try {
|
||||
if (window.canvasApp.visible === true) {
|
||||
/* We set the canvas to its normal width and height */
|
||||
browserCanvas.width = window.innerWidth
|
||||
browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN
|
||||
// browserCanvas.width = window.innerWidth
|
||||
// browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN
|
||||
|
||||
/* First thing is to clear the actual canvas */
|
||||
// clearBrowserCanvas()
|
||||
clearBrowserCanvas()
|
||||
|
||||
/* We loop through the callback functions collections and execute them all. */
|
||||
let performanceMap = new Map()
|
||||
@@ -162,12 +162,7 @@ function newAnimation () {
|
||||
}
|
||||
|
||||
function clearBrowserCanvas () {
|
||||
browserCanvasContext.beginPath()
|
||||
|
||||
browserCanvasContext.rect(0, 0, browserCanvas.width, browserCanvas.height)
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.fill()
|
||||
browserCanvasContext.clearRect(0, 0, browserCanvas.width, browserCanvas.height)
|
||||
}
|
||||
}
|
||||
-26
@@ -57,7 +57,6 @@ function newPlotter () {
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
console.log('finalize')
|
||||
try {
|
||||
/* Stop listening to the necesary events. */
|
||||
thisObject.container.eventHandler.stopListening(onMouseOverEventSuscriptionId)
|
||||
@@ -92,7 +91,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function initialize (pStorage, pDatetime, pTimeFrame, pCoordinateSystem, callBackFunction, pProductDefinition) {
|
||||
console.log('initialize')
|
||||
try {
|
||||
/* Store the information received. */
|
||||
marketFiles = pStorage.marketFiles[0]
|
||||
@@ -135,29 +133,24 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function initializeCoordinateSystem () {
|
||||
console.log('initializeCoordinateSystem')
|
||||
scaleChangedEventSubscriptionId = coordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
|
||||
}
|
||||
|
||||
function finalizeCoordinateSystem () {
|
||||
console.log('finalizeCoordinateSystem')
|
||||
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
|
||||
}
|
||||
|
||||
function onScaleChanged () {
|
||||
console.log('onScaleChanged')
|
||||
mustRecalculateDataPoints = true
|
||||
recalculate()
|
||||
}
|
||||
|
||||
function onMouseOver (event) {
|
||||
console.log('onMouseOver')
|
||||
let userPosition = getDateFromPointAtBrowserCanvas(event, thisObject.container, coordinateSystem)
|
||||
userPositionDate = userPosition.valueOf()
|
||||
}
|
||||
|
||||
function onMarketFilesUpdated () {
|
||||
console.log('onMarketFilesUpdated')
|
||||
try {
|
||||
let newMarketFile = marketFiles.getFile(timeFrame)
|
||||
if (newMarketFile !== undefined) {
|
||||
@@ -171,7 +164,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function onDailyFilesUpdated () {
|
||||
console.log('onDailyFilesUpdated')
|
||||
try {
|
||||
let newFileCursor = dailyFiles.getFileCursor(timeFrame)
|
||||
if (newFileCursor !== undefined) {
|
||||
@@ -185,7 +177,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
console.log('getContainer')
|
||||
try {
|
||||
let container
|
||||
/* First we check if this point is inside this space. */
|
||||
@@ -201,7 +192,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function setTimeFrame (pTimeFrame) {
|
||||
console.log('setTimeFrame')
|
||||
try {
|
||||
if (timeFrame !== pTimeFrame) {
|
||||
timeFrame = pTimeFrame
|
||||
@@ -228,19 +218,16 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function setDatetime (pDatetime) {
|
||||
console.log('setDatetime')
|
||||
datetime = pDatetime
|
||||
}
|
||||
|
||||
function setCoordinateSystem (pCoordinateSystem) {
|
||||
console.log('setCoordinateSystem')
|
||||
finalizeCoordinateSystem()
|
||||
coordinateSystem = pCoordinateSystem
|
||||
initializeCoordinateSystem()
|
||||
}
|
||||
|
||||
function onDailyFileLoaded (event) {
|
||||
console.log('onDailyFileLoaded')
|
||||
try {
|
||||
if (event.currentValue === event.totalValue) {
|
||||
/* This happens only when all of the files in the cursor have been loaded. */
|
||||
@@ -252,7 +239,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function draw () {
|
||||
console.log('draw')
|
||||
try {
|
||||
thisObject.container.frame.draw()
|
||||
plotChart()
|
||||
@@ -262,7 +248,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function recalculate () {
|
||||
console.log('recalculate')
|
||||
try {
|
||||
if (timeFrame >= _1_HOUR_IN_MILISECONDS) {
|
||||
recalculateUsingMarketFiles()
|
||||
@@ -276,7 +261,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function jsonifyDataFile (dataFile, recordDefinition, farLeftDate, farRightDate) {
|
||||
console.log('jsonifyDataFile')
|
||||
/*
|
||||
This function has as an input the raw data on files and creates with it an array of JSON objects
|
||||
with not calculated properties for later being consumed by Formulas
|
||||
@@ -313,7 +297,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function calculationsProcedure (jsonArray, recordDefinition, calculationsProcedure, timeFrame) {
|
||||
console.log('calculationsProcedure')
|
||||
/*
|
||||
This function has as an input an array of JSON objects, and it adds calculated properties to
|
||||
complete the set of properties that will be available.
|
||||
@@ -385,7 +368,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function recalculateUsingDailyFiles () {
|
||||
console.log('recalculateUsingDailyFiles')
|
||||
try {
|
||||
if (fileCursor === undefined) { return } // We need to wait until there is a fileCursor
|
||||
if (fileCursor.files.size === 0) { return } // We need to wait until there are files in the cursor
|
||||
@@ -440,7 +422,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function recalculateUsingMarketFiles () {
|
||||
console.log('recalculateUsingMarketFiles')
|
||||
try {
|
||||
if (marketFile === undefined) { return } // Initialization not complete yet.
|
||||
|
||||
@@ -480,7 +461,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function recalculateScale () {
|
||||
console.log('recalculateScale')
|
||||
try {
|
||||
if (coordinateSystem.maxValue > 0) { return } // Already calculated.
|
||||
/* First we calculate the default scale */
|
||||
@@ -506,7 +486,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function plotChart () {
|
||||
console.log('plotChart')
|
||||
try {
|
||||
/* Clean the pannel at places where there is no record. */
|
||||
let currentRecord = {
|
||||
@@ -798,7 +777,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function onViewportZoomChanged (event) {
|
||||
console.log('onViewportZoomChanged')
|
||||
try {
|
||||
mustRecalculateDataPoints = true
|
||||
recalculate()
|
||||
@@ -808,7 +786,6 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function onDragFinished () {
|
||||
console.log('onDragFinished')
|
||||
try {
|
||||
recalculate()
|
||||
} catch (err) {
|
||||
@@ -817,17 +794,14 @@ function newPlotter () {
|
||||
}
|
||||
|
||||
function onDisplace (event) {
|
||||
console.log('onDisplace')
|
||||
recalculateAll(event)
|
||||
}
|
||||
|
||||
function onViewportPositionChanged (event) {
|
||||
console.log('onViewportPositionChanged')
|
||||
recalculateAll(event)
|
||||
}
|
||||
|
||||
function recalculateAll (event) {
|
||||
console.log('recalculateAll')
|
||||
mustRecalculateDataPoints = true
|
||||
if (event !== undefined) {
|
||||
if (event.recalculate === true) {
|
||||
|
||||
Reference in new issue
Block a user