|
public class ViewModel
{
….
public Action BeginDataUpdate;
public Action EndDataUpdate;
}
public partial class MainPage : ContentPage
{
ViewModel viewModel;
….
public MainPage()
{
InitializeComponent();
viewModel = new ViewModel();
this.BindingContext = viewModel;
viewModel.BeginDataUpdate = () => chart.SuspendSeriesNotification();
viewModel.EndDataUpdate = () => chart.ResumeSeriesNotification();
}
….
public async void LoadData()
{
await Task.Delay(500);
//dynamic change data using suspend and resume
Device.BeginInvokeOnMainThread(() =>
{
//chart.SuspendSeriesNotification() is called when using below code.
viewModel.BeginDataUpdate();
for (int i = 0; i < 128; i++)
{
//Add Data
}
//chart.ResumeSeriesNotification() is called when using below code.
viewModel.EndDataUpdate();
});
….
}
} |
Hi Devakumar,
I ran the sample provided in Visual Studio Debug Mode and after few hours ended stuck with 2GB of memory consumed. This is the usual behaviour I observed with my application too, when running in Debug. I will test also with production deployment and let you know. On the first tens of minutes when I actively watched the test the movement on the screen became slower and slower as time
passed by. One comment on this sample: although the EnableAutoIntervalOnZooming was set to true, it is not used for translation in my application as is not satisfactory. I use ZoomByRange to move the create the sensation that the window is moved back at once with 60% of the screen width. In fact later, in my code I set this parameter to false. SuspendSeriesNotification and ResumeSeriesNotification were used in the past but with poor results and they are of no practicality as the value are pushed to the screen from time to time (say 1 second) not in bulks with long time periods of inactivity.
Comments on the other suggestions:
· Try to remove the data which is not visible in view.
I do this constantly, only one or two maybe are present on the left
· Try adding bulk data instead of adding single data points with some delay.
This is not the kind of application which can do that. Values must be displayed the very second are available
· Try to update the collection in background thread instead of updating in UI main thread.
Of course, I remember that I sent you the code with the background thread
· Set the StrokeWidth of FastLineSeries to “1” by default its value is 2.
· Set the EnableAntiAliasing property as false for FastLineSeries, FastScatterSeries.
?????? I don’t understand the relationship with the observed issue
On the other hand, with Android I managed to observe for very few fractions of seconds that initially the chart displays 24 hours on datetimeaxis, not the interval indicated. Once I think I observed this phenomenon also in UWP.
If you provide me a Direct trac Channel I can show you a movie with the slow response of the application in Android when initially loading the form (delay on loading the form containing the chart)
|
<chart:SfChart.PrimaryAxis ItemMargin="0">
<chart:DateTimeAxis x:Name="dateTimeAxis" RangePadding="None"
AutoScrollingDelta="100" AutoScrollingDeltaType="Seconds"
IsVisible="True" ActualRangeChanged="DateTimeAxis_ActualRangeChanged" >
<chart:DateTimeAxis.RangeStyles>
<chart:ChartAxisRangeStyleCollection>
<chart:ChartAxisRangeStyle x:Name="dateTimeRangeStyle">
<chart:ChartAxisRangeStyle.LabelStyle>
<chart:ChartAxisLabelStyle TextColor="Red" Margin="1"
FontSize="{x:OnPlatform Android={x:OnIdiom Tablet=7,Phone=7},
iOS={x:OnIdiom Tablet=7,Phone=7}, UWP={x:OnIdiom Desktop=9,Phone=7}}"
LabelFormat="HH:mm:ss"/>
</chart:ChartAxisRangeStyle.LabelStyle>
</chart:ChartAxisRangeStyle>
</chart:ChartAxisRangeStyleCollection>
</chart:DateTimeAxis.RangeStyles>
</chart:DateTimeAxis>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis x:Name="secAxis" Minimum="-110" Maximum="0" Interval="10"
ShowMajorGridLines="True" ShowMinorGridLines="True"
CrossesAt="110" MinorTicksPerInterval="0"
RangePadding="None" IsVisible="True">
…..
<chart:NumericalAxis.RangeStyles>
<chart:ChartAxisRangeStyleCollection>
<chart:ChartAxisRangeStyle Start="-110" End="0">
<chart:ChartAxisRangeStyle.LabelStyle>
<chart:ChartAxisLabelStyle TextColor="Blue"
FontSize="{x:OnPlatform Android={x:OnIdiom Tablet=7,Phone=7},
iOS={x:OnIdiom Tablet=7,Phone=7},
UWP={x:OnIdiom Desktop=9,Phone=7}}" LabelFormat="0.00"/>
</chart:ChartAxisRangeStyle.LabelStyle>
</chart:ChartAxisRangeStyle>
</chart:ChartAxisRangeStyleCollection>
</chart:NumericalAxis.RangeStyles>
</chart:NumericalAxis>
</chart:SfChart.SecondaryAxis> |
|
public MainPage()
{
InitializeComponent();
dateTimeAxis.IntervalType = DateTimeIntervalType.Seconds;
dateTimeAxis.Interval = 5;
dateTimeAxis.EnableAutoIntervalOnZooming = true;
dateTimeAxis.ShowMajorGridLines = true;
dateTimeAxis.ShowMinorGridLines = true;
dateTimeAxis.MinorTicksPerInterval = 4;
dateTimeAxis.LabelRotationAngle = -15;
dateTimeAxis.LabelStyle = null;
secAxis.LabelStyle = null;
}
...
private void DateTimeAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e)
{
dateTimeRangeStyle.Start = e.ActualMinimum;
} |
I didn't heard news from you from a while now. In the meantime I tested extensively the chart and the conclusions are in short I’m suspecting an error in UWP version which causes a stack overflow which in turn causes either blocking or sudden crashes. This is based on observations on long drawing times (over a day long for Android and iOS) which in Windows can not be achieved in any circumstances. Depending on instance of Windows crashes will occur after few minutes or few hours, 7 at most. The same code put on iPhone, iPad, Android tablets or phones is working smoothly.