From d7216243eed6bd34e9dead7ebc1979d29b59e237 Mon Sep 17 00:00:00 2001 From: Akmal Djumakhodjaev Date: Tue, 25 Jun 2024 15:23:31 +0800 Subject: [PATCH 1/4] fix: replace app property with function --- chart_app/lib/src/chart_app.dart | 7 +++++++ chart_app/lib/src/interop/dart_interop.dart | 4 ++-- src/components/PriceLine.tsx | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/chart_app/lib/src/chart_app.dart b/chart_app/lib/src/chart_app.dart index 74283a07e..ebb5d7e25 100644 --- a/chart_app/lib/src/chart_app.dart +++ b/chart_app/lib/src/chart_app.dart @@ -43,6 +43,12 @@ class ChartApp { /// Whether chart is mounted or not. bool isMounted = false; + /// To get the width of yAxis + double getYAxisWidth() => yAxisWidth; + + /// To get the width of current tick + double getCurrentTickWidth() => currentTickWidth; + void _processChartVisibilityChange(bool showChart) { if (showChart) { /// To prevent controller functions being called before mount. @@ -74,6 +80,7 @@ class ChartApp { } /// Calculates the width of yAxis + /// HERE: feedModel might be empty void calculateTickWidth() { yAxisWidth = calculateYAxisWidth( feedModel.ticks, diff --git a/chart_app/lib/src/interop/dart_interop.dart b/chart_app/lib/src/interop/dart_interop.dart index a93deed47..afac06c75 100644 --- a/chart_app/lib/src/interop/dart_interop.dart +++ b/chart_app/lib/src/interop/dart_interop.dart @@ -33,13 +33,13 @@ JsObject _exposeApp(ChartApp app) { setProperty( jsObject, 'getYAxisWidth', - allowInterop(() => app.yAxisWidth), + allowInterop(app.getYAxisWidth), ); setProperty( jsObject, 'getCurrentTickWidth', - allowInterop(() => app.currentTickWidth), + allowInterop(app.getCurrentTickWidth), ); setProperty( diff --git a/src/components/PriceLine.tsx b/src/components/PriceLine.tsx index 24a302374..b077c4d6a 100644 --- a/src/components/PriceLine.tsx +++ b/src/components/PriceLine.tsx @@ -59,7 +59,7 @@ const PriceLine = ({ if (!showBarrier) return null; const width = priceLineWidth + 12; - const price_right_offset = (isOverlappingWithPriceLine ? width - overlappedBarrierWidth + 6 : 0) + (isMobile ? 20 : 3); + const price_right_offset = (isOverlappingWithPriceLine ? width - overlappedBarrierWidth : 0) + (isMobile ? 20 : 3); return (
Date: Tue, 25 Jun 2024 15:25:10 +0800 Subject: [PATCH 2/4] fix: remove wrong comment --- chart_app/lib/src/chart_app.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/chart_app/lib/src/chart_app.dart b/chart_app/lib/src/chart_app.dart index ebb5d7e25..ad3018f17 100644 --- a/chart_app/lib/src/chart_app.dart +++ b/chart_app/lib/src/chart_app.dart @@ -80,7 +80,6 @@ class ChartApp { } /// Calculates the width of yAxis - /// HERE: feedModel might be empty void calculateTickWidth() { yAxisWidth = calculateYAxisWidth( feedModel.ticks, From 6d47a483c24004ae74e9dd82e32bce8db92c631e Mon Sep 17 00:00:00 2001 From: Akmal Djumakhodjaev Date: Tue, 25 Jun 2024 17:18:35 +0800 Subject: [PATCH 3/4] Revert "fix: replace app property with function" This reverts commit d7216243eed6bd34e9dead7ebc1979d29b59e237. --- chart_app/lib/src/chart_app.dart | 6 ------ chart_app/lib/src/interop/dart_interop.dart | 4 ++-- src/components/PriceLine.tsx | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/chart_app/lib/src/chart_app.dart b/chart_app/lib/src/chart_app.dart index ad3018f17..74283a07e 100644 --- a/chart_app/lib/src/chart_app.dart +++ b/chart_app/lib/src/chart_app.dart @@ -43,12 +43,6 @@ class ChartApp { /// Whether chart is mounted or not. bool isMounted = false; - /// To get the width of yAxis - double getYAxisWidth() => yAxisWidth; - - /// To get the width of current tick - double getCurrentTickWidth() => currentTickWidth; - void _processChartVisibilityChange(bool showChart) { if (showChart) { /// To prevent controller functions being called before mount. diff --git a/chart_app/lib/src/interop/dart_interop.dart b/chart_app/lib/src/interop/dart_interop.dart index afac06c75..a93deed47 100644 --- a/chart_app/lib/src/interop/dart_interop.dart +++ b/chart_app/lib/src/interop/dart_interop.dart @@ -33,13 +33,13 @@ JsObject _exposeApp(ChartApp app) { setProperty( jsObject, 'getYAxisWidth', - allowInterop(app.getYAxisWidth), + allowInterop(() => app.yAxisWidth), ); setProperty( jsObject, 'getCurrentTickWidth', - allowInterop(app.getCurrentTickWidth), + allowInterop(() => app.currentTickWidth), ); setProperty( diff --git a/src/components/PriceLine.tsx b/src/components/PriceLine.tsx index b077c4d6a..24a302374 100644 --- a/src/components/PriceLine.tsx +++ b/src/components/PriceLine.tsx @@ -59,7 +59,7 @@ const PriceLine = ({ if (!showBarrier) return null; const width = priceLineWidth + 12; - const price_right_offset = (isOverlappingWithPriceLine ? width - overlappedBarrierWidth : 0) + (isMobile ? 20 : 3); + const price_right_offset = (isOverlappingWithPriceLine ? width - overlappedBarrierWidth + 6 : 0) + (isMobile ? 20 : 3); return (
Date: Tue, 25 Jun 2024 17:23:52 +0800 Subject: [PATCH 4/4] fix: add function call --- chart_app/lib/main.dart | 2 ++ src/components/PriceLine.tsx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/chart_app/lib/main.dart b/chart_app/lib/main.dart index ebc58bc9c..947011477 100644 --- a/chart_app/lib/main.dart +++ b/chart_app/lib/main.dart @@ -117,6 +117,8 @@ class _DerivChartWebAdapterState extends State<_DerivChartWebAdapter> { ); } + app.calculateTickWidth(); + return DerivChartWrapper( app: app, onVisibleAreaChanged: onVisibleAreaChanged, diff --git a/src/components/PriceLine.tsx b/src/components/PriceLine.tsx index 24a302374..b077c4d6a 100644 --- a/src/components/PriceLine.tsx +++ b/src/components/PriceLine.tsx @@ -59,7 +59,7 @@ const PriceLine = ({ if (!showBarrier) return null; const width = priceLineWidth + 12; - const price_right_offset = (isOverlappingWithPriceLine ? width - overlappedBarrierWidth + 6 : 0) + (isMobile ? 20 : 3); + const price_right_offset = (isOverlappingWithPriceLine ? width - overlappedBarrierWidth : 0) + (isMobile ? 20 : 3); return (