Skip to content

Commit

Permalink
[Fix] 110 Unchecking BeginAtZero Resets Chart (#111)
Browse files Browse the repository at this point in the history
* [Fix] 110 Unchecking BeginAtZero Resets Chart

- fixed a bug in Chart.razor.cs which  caused wrong rerendering when BeginAtZero's value is changed

---------

Co-authored-by: Timo Schauties <[email protected]>
  • Loading branch information
Conundraah and Timo Schauties authored Jul 22, 2024
1 parent 5acb50d commit febdf61
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Nexus.UI/Charts/Chart.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public partial class Chart : IDisposable
private DateTime _zoomedBegin;
private DateTime _zoomedEnd;

private readonly SKRect _defaultZoomBox = new SKRect(0, 0, 1, 1);

/* Common */
private const float TICK_SIZE = 10;

Expand All @@ -50,7 +52,6 @@ public partial class Chart : IDisposable
private readonly TimeAxisConfig[] _timeAxisConfigs;

/* Others */
private bool _beginAtZero;
private readonly SKColor[] _colors;

public Chart()
Expand Down Expand Up @@ -133,9 +134,8 @@ public Chart()

protected override void OnParametersSet()
{
if (BeginAtZero != _beginAtZero)
if (BeginAtZero || _zoomBox == _defaultZoomBox)
{
_beginAtZero = BeginAtZero;
Task.Run(() =>
{
_axesMap = LineSeriesData.Series
Expand Down Expand Up @@ -523,8 +523,8 @@ private void ApplyZoom(SKRect zoomBox)
private void ResetZoom()
{
/* zoom box */
_oldZoomBox = new SKRect(0, 0, 1, 1);
_zoomBox = new SKRect(0, 0, 1, 1);
_oldZoomBox = _defaultZoomBox;
_zoomBox = _defaultZoomBox;

/* time range */
_zoomedBegin = LineSeriesData.Begin;
Expand Down

0 comments on commit febdf61

Please sign in to comment.