Skip to content

Commit 55b4f5c

Browse files
Updated sample
1 parent 0c4ea8d commit 55b4f5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+9251
-2
lines changed

.vs/ProjectSettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"CurrentProjectSetting": null
3+
}

.vs/slnx.sqlite

2.05 MB
Binary file not shown.

App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:RealTimeChart"
5+
x:Class="RealTimeChart.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

App.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace RealTimeChart
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new MainPage());
13+
}
14+
}
15+
}

AppShell.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="RealTimeChart.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:RealTimeChart"
7+
Shell.FlyoutBehavior="Flyout"
8+
Title="RealTimeChart">
9+
10+
<ShellContent
11+
Title="Home"
12+
ContentTemplate="{DataTemplate local:MainPage}"
13+
Route="MainPage" />
14+
15+
</Shell>

AppShell.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace RealTimeChart
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

ChartDataModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace RealTimeChart
8+
{
9+
public class ChartDataModel
10+
{
11+
public double Value { get; set; }
12+
public double Size { get; set; }
13+
}
14+
}

MainPage.xaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:chart="clr-namespace:Syncfusion.Maui.Toolkit.Charts;assembly=Syncfusion.Maui.Toolkit"
5+
xmlns:local="clr-namespace:RealTimeChart"
6+
x:Class="RealTimeChart.MainPage">
7+
8+
<ContentPage.BindingContext>
9+
<local:RealTimeChartViewModel x:Name="realTimeChartViewModel"/>
10+
</ContentPage.BindingContext>
11+
12+
<Grid>
13+
<chart:SfCartesianChart x:Name="realTimeChart"
14+
HorizontalOptions="Fill"
15+
VerticalOptions="Fill">
16+
17+
<chart:SfCartesianChart.Title>
18+
<Label Text="Live ECG Monitor (100Hz)"
19+
Margin="0,0,0,5"
20+
Padding="0,20,0,0"
21+
HorizontalOptions="Fill"
22+
HorizontalTextAlignment="Center"
23+
VerticalOptions="Center"
24+
FontSize="16"/>
25+
</chart:SfCartesianChart.Title>
26+
27+
<chart:SfCartesianChart.XAxes>
28+
<chart:NumericalAxis ShowMajorGridLines="false"
29+
EdgeLabelsDrawingMode="Center">
30+
<chart:NumericalAxis.Title>
31+
<chart:ChartAxisTitle Text="Samples"/>
32+
</chart:NumericalAxis.Title>
33+
<chart:NumericalAxis.LabelStyle>
34+
<chart:ChartAxisLabelStyle/>
35+
</chart:NumericalAxis.LabelStyle>
36+
</chart:NumericalAxis>
37+
</chart:SfCartesianChart.XAxes>
38+
39+
<chart:SfCartesianChart.YAxes>
40+
<chart:NumericalAxis ShowMajorGridLines="false"
41+
Minimum="500"
42+
Maximum="1100">
43+
<chart:NumericalAxis.Title>
44+
<chart:ChartAxisTitle Text="Amplitude"/>
45+
</chart:NumericalAxis.Title>
46+
</chart:NumericalAxis>
47+
</chart:SfCartesianChart.YAxes>
48+
49+
<chart:SfCartesianChart.Series>
50+
<chart:FastLineSeries ItemsSource="{Binding LiveData}"
51+
EnableAntiAliasing="True"
52+
XBindingPath="Value"
53+
YBindingPath="Size">
54+
</chart:FastLineSeries>
55+
</chart:SfCartesianChart.Series>
56+
57+
</chart:SfCartesianChart>
58+
</Grid>
59+
60+
</ContentPage>

MainPage.xaml.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Microsoft.Maui.Controls;
2+
3+
namespace RealTimeChart
4+
{
5+
public partial class MainPage : ContentPage
6+
{
7+
public MainPage()
8+
{
9+
InitializeComponent();
10+
}
11+
12+
protected override void OnAppearing()
13+
{
14+
base.OnAppearing();
15+
16+
// Stop any existing timer first
17+
realTimeChartViewModel.StopTimer();
18+
19+
// Start the timer to update the chart
20+
realTimeChartViewModel.StartTimer();
21+
}
22+
23+
protected override void OnDisappearing()
24+
{
25+
base.OnDisappearing();
26+
27+
// Make sure to stop the timer when leaving the page
28+
if (realTimeChartViewModel != null)
29+
{
30+
realTimeChartViewModel.StopTimer();
31+
}
32+
33+
// Properly disconnect the chart handler to avoid memory leaks
34+
realTimeChart.Handler?.DisconnectHandler();
35+
}
36+
}
37+
}
38+
39+

0 commit comments

Comments
 (0)