Skip to content

Commit

Permalink
Merge pull request #8 from Millennium-Heap/format_xAxis
Browse files Browse the repository at this point in the history
Format x axis
  • Loading branch information
Millennium-Heap committed Feb 11, 2021
2 parents a190b9b + 3947fdd commit 6baf0e4
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 11 deletions.
Binary file modified .vs/CodeClinic/v16/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion Dashboard/ConstantChangesChart.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<lvc:CartesianChart Grid.Row="1" Grid.Column="1" Grid.RowSpan="4" DisableAnimations="False" Hoverable="False" DataTooltip="{x:Null}" Name="theCC">
<lvc:CartesianChart.Series>
<lvc:LineSeries Values="{Binding chartValues}" Name="lsEfficiency"
<lvc:LineSeries Values="{Binding ChartValues}" Name="lsEfficiency"
PointGeometry="{x:Null}"
LineSmoothness="0"
StrokeThickness="2"
Expand Down
41 changes: 34 additions & 7 deletions Dashboard/ConstantChangesChart.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CodeClinic;
using LiveCharts;
using LiveCharts.Configurations;
using System;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -14,6 +15,10 @@ namespace Dashboard
/// </summary>
public partial class ConstantChangesChart : UserControl, INotifyPropertyChanged
{
private static long tickZero = DateTime.Parse("2018-01-01T08:00:00Z").Ticks;

public Func<double, string> X_Axis_LabelFormatter { get; set; } = d => TimeSpan.FromTicks((long)d - tickZero).TotalSeconds.ToString();

public ConstantChangesChart()
{
InitializeComponent();
Expand All @@ -23,8 +28,9 @@ public ConstantChangesChart()
DataContext = this;
}

public ChartValues<FactoryTelemetry> ChartValues { get; set; } = new ChartValues<FactoryTelemetry>();

private bool readingData = false;
private ChartValues<FactoryTelemetry> chartValues { get; set; } = new ChartValues<FactoryTelemetry>();
private void Button_Click(object sender, RoutedEventArgs e)
{
if (!readingData)
Expand All @@ -36,25 +42,46 @@ private void Button_Click(object sender, RoutedEventArgs e)

private void ReadData()
{
// TODO: Populate the collection chartValues
// TODO: Populate the collection ChartValues

string fileName = @"C:\Users\Millennium Singha\Downloads\Ex_Files_Code_Clinic_C_Sharp\Ex_Files_Code_Clinic_C_Sharp\Exercise Files\Ch06\dashBoardData.csv";

foreach (var ft in FactoryTelemetry.Load(fileName))
{
chartValues.Add(ft);
ChartValues.Add(ft);

this.EngineEfficiency = ft.Efficiency;

if (chartValues.Count > 30)
chartValues.RemoveAt(0);
AdjustAxis(ft.TimeStamp.Ticks);

if (ChartValues.Count > 30)
ChartValues.RemoveAt(0);

Thread.Sleep(30);
}
}

public double AxisStep { get; set; } = TimeSpan.FromSeconds(5).Ticks;
public double AxisUnit { get; set; } = TimeSpan.FromSeconds(1).Ticks;

private double axisMax = tickZero + TimeSpan.FromSeconds(30).Ticks;
public double AxisMax { get => axisMax; set { axisMax = value; OnPropertyChanged(nameof(AxisMax)); } }

private double axisMin = tickZero;
public double AxisMin { get => axisMin; set { axisMin = value; OnPropertyChanged(nameof(AxisMin)); } }

private void AdjustAxis(long ticks)
{
var width = TimeSpan.FromSeconds(30).Ticks;

AxisMin = (ticks - tickZero < width) ? tickZero : ticks - width;
AxisMax = (ticks - tickZero < width) ? tickZero + width : ticks;
}

private double _EngineEfficiency = 65;
public double EngineEfficiency {

public double EngineEfficiency
{
get
{
return _EngineEfficiency;
Expand All @@ -63,7 +90,7 @@ private void ReadData()
{
_EngineEfficiency = value;
OnPropertyChanged(nameof(EngineEfficiency));
}
}
}

public event PropertyChangedEventHandler PropertyChanged;
Expand Down
Binary file modified Dashboard/bin/Debug/Dashboard.exe
Binary file not shown.
Binary file modified Dashboard/bin/Debug/Dashboard.pdb
Binary file not shown.
Binary file modified Dashboard/obj/Debug/ConstantChangesChart.baml
Binary file not shown.
2 changes: 1 addition & 1 deletion Dashboard/obj/Debug/ConstantChangesChart.g.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "..\..\ConstantChangesChart.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "6F13C68C8B1A38462A90A7878446B99773475BD8C2B026FD8D177D7331F08391"
#pragma checksum "..\..\ConstantChangesChart.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "03D156A73DE64AC1BEF9F001BDFE132D7B1A431B01DFB9915E5599BAFDE9313C"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
Expand Down
2 changes: 1 addition & 1 deletion Dashboard/obj/Debug/ConstantChangesChart.g.i.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "..\..\ConstantChangesChart.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "6F13C68C8B1A38462A90A7878446B99773475BD8C2B026FD8D177D7331F08391"
#pragma checksum "..\..\ConstantChangesChart.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "03D156A73DE64AC1BEF9F001BDFE132D7B1A431B01DFB9915E5599BAFDE9313C"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
Expand Down
Binary file modified Dashboard/obj/Debug/Dashboard.csprojAssemblyReference.cache
Binary file not shown.
Binary file modified Dashboard/obj/Debug/Dashboard.exe
Binary file not shown.
Binary file modified Dashboard/obj/Debug/Dashboard.g.resources
Binary file not shown.
Binary file modified Dashboard/obj/Debug/Dashboard.pdb
Binary file not shown.
3 changes: 2 additions & 1 deletion Dashboard/obj/Debug/Dashboard_MarkupCompile.i.lref
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

C:\codeClinic_c_sharp\realTimeInfo\Dashboard\obj\Debug\GeneratedInternalTypeHelper.g.i.cs

FC:\codeClinic_c_sharp\realTimeInfo\Dashboard\ConstantChangesChart.xaml;;
FC:\codeClinic_c_sharp\realTimeInfo\Dashboard\MainWindow.xaml;;

Binary file modified Data/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Binary file not shown.

0 comments on commit 6baf0e4

Please sign in to comment.