From 2488756d154735516ede25f8c5279cfd0ffca3ad Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jan 2020 17:23:03 +0100 Subject: [PATCH] Timemachine Background --- ChartsSpace/TimeMachine.js | 5 +++++ ChartsSpace/TimelineChart.js | 29 +---------------------------- Utilities.js | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index f484a5cd3..30ebe0d87 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -468,6 +468,7 @@ function newTimeMachine () { } function drawBackground () { + drawChartsBackground() if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { let timelineChart = thisObject.timelineCharts[thisObject.timelineCharts.length - i - 1] @@ -476,6 +477,10 @@ function newTimeMachine () { } } + function drawChartsBackground () { + drawContainerBackground(thisObject.container, UI_COLOR.WHITE, 0.5, thisObject.fitFunction) + } + function draw () { if (thisObject.container.frame.isInViewPort()) { for (let i = 0; i < thisObject.timelineCharts.length; i++) { diff --git a/ChartsSpace/TimelineChart.js b/ChartsSpace/TimelineChart.js index e608a00a5..218bcd74a 100644 --- a/ChartsSpace/TimelineChart.js +++ b/ChartsSpace/TimelineChart.js @@ -417,34 +417,7 @@ function newTimelineChart () { } function drawChartsBackground () { - /* We will paint some transparent background here. */ - - let opacity = '0.0' - - let fromPoint = { - x: 0, - y: 0 - } - - let toPoint = { - x: thisObject.container.frame.width, - y: thisObject.container.frame.height - } - - fromPoint = transformThisPoint(fromPoint, thisObject.container) - toPoint = transformThisPoint(toPoint, thisObject.container) - - fromPoint = thisObject.fitFunction(fromPoint) - toPoint = thisObject.fitFunction(toPoint) - - browserCanvasContext.beginPath() - - browserCanvasContext.rect(fromPoint.x, fromPoint.y, toPoint.x - fromPoint.x, toPoint.y - fromPoint.y) - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ')' - - browserCanvasContext.closePath() - - browserCanvasContext.fill() + drawContainerBackground(thisObject.container, UI_COLOR.WHITE, 0, thisObject.fitFunction) } function recalculateCoordinateSystem () { diff --git a/Utilities.js b/Utilities.js index 46ae2b890..7749bc532 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,3 +1,27 @@ +function drawContainerBackground (container, color, opacity, fitFunction) { + let fromPoint = { + x: 0, + y: 0 + } + + let toPoint = { + x: container.frame.width, + y: container.frame.height + } + + fromPoint = transformThisPoint(fromPoint, container) + toPoint = transformThisPoint(toPoint, container) + + fromPoint = fitFunction(fromPoint) + toPoint = fitFunction(toPoint) + + browserCanvasContext.beginPath() + browserCanvasContext.rect(fromPoint.x, fromPoint.y, toPoint.x - fromPoint.x, toPoint.y - fromPoint.y) + browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')' + browserCanvasContext.closePath() + browserCanvasContext.fill() +} + function savePropertyAtNodeConfig (payload, propertyName, value) { try { let code = JSON.parse(payload.node.code)