Skip to content

Commit

Permalink
Bala/fix and cleanup max current tick offset (#315)
Browse files Browse the repository at this point in the history
* chore: fix and cleanup max current tick offset

* chore: cleanup
  • Loading branch information
balakrishna-deriv authored Jun 25, 2024
1 parent 7715526 commit 752a52a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 38 deletions.
5 changes: 0 additions & 5 deletions lib/src/deriv_chart/chart/chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Chart extends StatefulWidget {
this.chartAxisConfig = const ChartAxisConfig(),
this.showCrosshair = false,
this.indicatorsRepo,
this.maxCurrentTickOffset,
this.msPerPx,
this.minIntervalWidth,
this.maxIntervalWidth,
Expand Down Expand Up @@ -134,9 +133,6 @@ class Chart extends StatefulWidget {
/// Whether the crosshair should be shown or not.
final bool showCrosshair;

/// Max distance between rightBoundEpoch and nowEpoch in pixels.
final double? maxCurrentTickOffset;

/// Specifies the zoom level of the chart.
final double? msPerPx;

Expand Down Expand Up @@ -305,7 +301,6 @@ class _ChartState extends State<Chart> with WidgetsBindingObserver {
onVisibleAreaChanged: _onVisibleAreaChanged,
isLive: widget.isLive,
startWithDataFitMode: widget.dataFitEnabled,
maxCurrentTickOffset: widget.maxCurrentTickOffset,
msPerPx: widget.msPerPx,
minIntervalWidth: widget.minIntervalWidth,
maxIntervalWidth: widget.maxIntervalWidth,
Expand Down
37 changes: 17 additions & 20 deletions lib/src/deriv_chart/chart/x_axis/widgets/x_axis_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class XAxisBase extends StatefulWidget {
this.onVisibleAreaChanged,
this.minEpoch,
this.maxEpoch,
this.maxCurrentTickOffset,
this.msPerPx,
this.minIntervalWidth,
this.maxIntervalWidth,
Expand Down Expand Up @@ -58,9 +57,6 @@ class XAxisBase extends StatefulWidget {
/// Number of digits after decimal point in price
final int pipSize;

/// Max distance between rightBoundEpoch and nowEpoch in pixels.
final double? maxCurrentTickOffset;

/// Specifies the zoom level of the chart.
final double? msPerPx;

Expand Down Expand Up @@ -111,8 +107,8 @@ class XAxisState extends State<XAxisBase> with TickerProviderStateMixin {
onScroll: _onVisibleAreaChanged,
minEpoch: widget.minEpoch,
maxEpoch: widget.maxEpoch,
maxCurrentTickOffset: chartConfig.chartAxisConfig.maxCurrentTickOffset,
defaultIntervalWidth: chartConfig.chartAxisConfig.defaultIntervalWidth,
maxCurrentTickOffset: chartConfig.chartAxisConfig.maxCurrentTickOffset,
defaultIntervalWidth: chartConfig.chartAxisConfig.defaultIntervalWidth,
msPerPx: widget.msPerPx,
minIntervalWidth: widget.minIntervalWidth,
maxIntervalWidth: widget.maxIntervalWidth,
Expand Down Expand Up @@ -176,22 +172,23 @@ class XAxisState extends State<XAxisBase> with TickerProviderStateMixin {
return Stack(
fit: StackFit.expand,
children: <Widget>[
if (context.read<ChartConfig>().chartAxisConfig.showEpochGrid)
RepaintBoundary(
child: CustomPaint(
painter: XGridPainter(
timestamps: _noOverlapGridTimestamps
.map<DateTime>((DateTime time) =>/*timeLabel(time)*/ time)
.toList(),
xCoords: _noOverlapGridTimestamps
.map<double>((DateTime time) =>
_model.xFromEpoch(time.millisecondsSinceEpoch))
.toList(),
style: _chartTheme,
msPerPx: _model.msPerPx,
if (context.read<ChartConfig>().chartAxisConfig.showEpochGrid)
RepaintBoundary(
child: CustomPaint(
painter: XGridPainter(
timestamps: _noOverlapGridTimestamps
.map<DateTime>(
(DateTime time) => /*timeLabel(time)*/ time)
.toList(),
xCoords: _noOverlapGridTimestamps
.map<double>((DateTime time) =>
_model.xFromEpoch(time.millisecondsSinceEpoch))
.toList(),
style: _chartTheme,
msPerPx: _model.msPerPx,
),
),
),
),
Padding(
padding: EdgeInsets.only(
bottom: _chartTheme.gridStyle.xLabelsAreaHeight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class XAxisMobile extends XAxisBase {
super.onVisibleAreaChanged,
super.minEpoch,
super.maxEpoch,
super.maxCurrentTickOffset,
super.msPerPx,
super.minIntervalWidth,
super.maxIntervalWidth,
Expand Down
1 change: 0 additions & 1 deletion lib/src/deriv_chart/chart/x_axis/widgets/x_axis_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class XAxisWeb extends XAxisBase {
super.onVisibleAreaChanged,
super.minEpoch,
super.maxEpoch,
super.maxCurrentTickOffset,
super.msPerPx,
super.minIntervalWidth,
super.maxIntervalWidth,
Expand Down
6 changes: 0 additions & 6 deletions lib/src/deriv_chart/chart/x_axis/x_axis_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class XAxisWrapper extends StatelessWidget {
this.onVisibleAreaChanged,
this.minEpoch,
this.maxEpoch,
this.maxCurrentTickOffset,
this.msPerPx,
this.minIntervalWidth,
this.maxIntervalWidth,
Expand Down Expand Up @@ -54,9 +53,6 @@ class XAxisWrapper extends StatelessWidget {
/// Number of digits after decimal point in price
final int pipSize;

/// Max distance between rightBoundEpoch and nowEpoch in pixels.
final double? maxCurrentTickOffset;

/// Specifies the zoom level of the chart.
final double? msPerPx;

Expand Down Expand Up @@ -86,7 +82,6 @@ class XAxisWrapper extends StatelessWidget {
onVisibleAreaChanged: onVisibleAreaChanged,
minEpoch: minEpoch,
maxEpoch: maxEpoch,
maxCurrentTickOffset: maxCurrentTickOffset,
msPerPx: msPerPx,
minIntervalWidth: minIntervalWidth,
maxIntervalWidth: maxIntervalWidth,
Expand All @@ -103,7 +98,6 @@ class XAxisWrapper extends StatelessWidget {
onVisibleAreaChanged: onVisibleAreaChanged,
minEpoch: minEpoch,
maxEpoch: maxEpoch,
maxCurrentTickOffset: maxCurrentTickOffset,
msPerPx: msPerPx,
minIntervalWidth: minIntervalWidth,
maxIntervalWidth: maxIntervalWidth,
Expand Down
6 changes: 1 addition & 5 deletions lib/src/deriv_chart/deriv_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class DerivChart extends StatefulWidget {
this.indicatorsRepo,
this.drawingToolsRepo,
this.drawingTools,
this.maxCurrentTickOffset,
this.msPerPx,
this.minIntervalWidth,
this.maxIntervalWidth,
Expand Down Expand Up @@ -120,9 +119,6 @@ class DerivChart extends StatefulWidget {
/// Whether the crosshair should be shown or not.
final bool showCrosshair;

/// Max distance between rightBoundEpoch and nowEpoch in pixels.
final double? maxCurrentTickOffset;

/// Specifies the zoom level of the chart.
final double? msPerPx;

Expand Down Expand Up @@ -334,7 +330,6 @@ class _DerivChartState extends State<DerivChart> {
annotations: widget.annotations,
showCrosshair: widget.showCrosshair,
indicatorsRepo: widget.indicatorsRepo ?? _indicatorsRepo,
maxCurrentTickOffset: widget.maxCurrentTickOffset,
msPerPx: widget.msPerPx,
minIntervalWidth: widget.minIntervalWidth,
maxIntervalWidth: widget.maxIntervalWidth,
Expand All @@ -350,6 +345,7 @@ class _DerivChartState extends State<DerivChart> {
showDataFitButton: widget.showDataFitButton,
showScrollToLastTickButton: widget.showScrollToLastTickButton,
loadingAnimationColor: widget.loadingAnimationColor,
chartAxisConfig: widget.chartAxisConfig,
),
if (widget.indicatorsRepo == null) _buildIndicatorsIcon(),
if (widget.drawingToolsRepo == null) _buildDrawingToolsIcon(),
Expand Down

0 comments on commit 752a52a

Please sign in to comment.