diff --git a/BottomSpace/ChartAspectRatio.js b/BottomSpace/ChartAspectRatio.js index 72bc2066d..21f06452e 100644 --- a/BottomSpace/ChartAspectRatio.js +++ b/BottomSpace/ChartAspectRatio.js @@ -72,6 +72,9 @@ thisObject.aspectRatio.y = MAX_Y_ASPECT_RATIO; } + + thisObject.container.eventHandler.raiseEvent("Chart Aspect Ratio Changed", thisObject.aspectRatio); + } function getContainer(point) { diff --git a/Scales/ChartGrid.js b/Scales/ChartGrid.js index e322c44c7..2b76be1e0 100644 --- a/Scales/ChartGrid.js +++ b/Scales/ChartGrid.js @@ -552,7 +552,7 @@ let fontSize = 10; - let label = ' ' + Math.round(j * 1000000) / 1000000; + let label = ' ' + Math.round(j * 1) / 1; label = Number(label).toLocaleString(); let labelPoint = { @@ -586,7 +586,7 @@ */ let labelValue = (j - timeLineCoordinateSystem.max.y / 2) * 200 / timeLineCoordinateSystem.max.y; - labelValue = Math.round(labelValue * 1000000) / 1000000; + labelValue = Math.round(labelValue * 1) / 1; if (labelValue > 0) { labelValue = '+' + labelValue; } if (parseInt(labelValue) > -10 && parseInt(labelValue) < 10) { labelValue = ' ' + labelValue; } if (parseInt(labelValue) === 0) { labelValue = ' ' + labelValue; } diff --git a/TimelineChart.js b/TimelineChart.js index 68e80c155..92f11a394 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -129,6 +129,44 @@ initializeCompetitionPlotters(onCompetitionPlottersInitialized); + canvas.bottomSpace.chartAspectRatio.container.eventHandler.listenToEvent("Chart Aspect Ratio Changed", onAspectRatioChanged); + + function onAspectRatioChanged(pAspectRatio) { + + thisObject.container.frame.height = CHART_SPACE_HEIGHT * pAspectRatio.y; + recalculateScale(); + + /* First the Product Plotters. */ + + for (let i = 0; i < productPlotters.length; i++) { + + let productPlotter = productPlotters[i]; + productPlotter.plotter.container.frame.width = thisObject.container.frame.width; + productPlotter.plotter.container.frame.height = thisObject.container.frame.height; + + if (productPlotter.plotter.recalculateScale !== undefined) { + + productPlotter.plotter.recalculateScale(); + + } + } + + /* Then the competition plotters. */ + + for (let i = 0; i < competitionPlotters.length; i++) { + + let competitionPlotter = competitionPlotters[i]; + competitionPlotter.plotter.container.frame.width = thisObject.container.frame.width; + competitionPlotter.plotter.container.frame.height = thisObject.container.frame.height; + + if (competitionPlotter.plotter.recalculateScale !== undefined) { + + competitionPlotter.plotter.recalculateScale(); + + } + } + } + function onCompetitionPlottersInitialized(err) { try { @@ -904,7 +942,6 @@ y: nextPorwerOf10(USDT_BTC_HTH) / 4 }; - timeLineCoordinateSystem.initialize( minValue, maxValue, @@ -946,9 +983,6 @@ if (thisObject.container.frame.isInViewPort()) { - thisObject.container.frame.height = CHART_SPACE_HEIGHT * canvas.bottomSpace.chartAspectRatio.aspectRatio.y; - recalculateScale(); - this.container.frame.draw(); drawBackground();