sc 1 year ago
parent
commit
71e0455304
  1. 2
      View/CurveDiagramView.xaml
  2. 30
      ViewModel/CurveDiagramViewModel.cs

2
View/CurveDiagramView.xaml

@ -9,7 +9,7 @@
d:DataContext="{d:DesignInstance Type=viewmodel:CurveDiagramViewModel}" d:DataContext="{d:DesignInstance Type=viewmodel:CurveDiagramViewModel}"
d:DesignHeight="630" d:DesignWidth="1280"> d:DesignHeight="630" d:DesignWidth="1280">
<Grid> <Grid>
<lvc:CartesianChart x:Name="OscChart" MinWidth="1280" MinHeight="600" <lvc:CartesianChart x:Name="OscChart" MinWidth="1280" MinHeight="600" EasingFunction="{x:Null}"
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/> Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/>
</Grid> </Grid>
</UserControl> </UserControl>

30
ViewModel/CurveDiagramViewModel.cs

@ -146,7 +146,7 @@ namespace DyeingComputer.ViewModel
public CurveDiagramViewModel() public CurveDiagramViewModel()
{ {
// if (MainWindowViewModel.WorkNumder.ToString() != "----------") if (MainWindowViewModel.WorkNumder.ToString() != "----------")
{ {
SQLiteHelpers = new SQLiteHelper(ChartAdress); //数据库连接路径 SQLiteHelpers = new SQLiteHelper(ChartAdress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库 SQLiteHelpers.Open(); //打开数据库
@ -154,34 +154,34 @@ namespace DyeingComputer.ViewModel
CDB = SQLiteHelpers.ExecuteDataSet("select * from Chart order by Time", null).Tables[0]; CDB = SQLiteHelpers.ExecuteDataSet("select * from Chart order by Time", null).Tables[0];
SQLiteHelpers.Close(); SQLiteHelpers.Close();
CDB_Count = CDB.Rows.Count; CDB_Count = CDB.Rows.Count;
}
var items = new List<DateTimePoint>();
for (var i = 0; i < CDB_Count; i++)
{
// _current += _r.Next(-9, 10);
// CDB.Rows[i].Field<string>("varchar")
items.Add(new DateTimePoint(Convert.ToDateTime(CDB.Rows[i].Field<string>("Time")), CDB.Rows[i].Field<double>("MTT")));
}
_values = new ObservableCollection<DateTimePoint>(items);
Series = new ISeries[] var items = new List<DateTimePoint>();
{ for (var i = 0; i < CDB_Count; i++)
{
// _current += _r.Next(-9, 10);
// CDB.Rows[i].Field<string>("varchar")
items.Add(new DateTimePoint(Convert.ToDateTime(CDB.Rows[i].Field<string>("Time")), CDB.Rows[i].Field<double>("MTT")));
}
_values = new ObservableCollection<DateTimePoint>(items);
Series = new ISeries[]
{
new LineSeries<DateTimePoint> new LineSeries<DateTimePoint>
{ {
Name = Properties.Resources.Temperature +"1", Name = Properties.Resources.Temperature +"1",
Values = _values, Values = _values,
Stroke = new SolidColorPaint(s_blue, 2), Stroke = new SolidColorPaint(s_blue, 2),
GeometrySize = 2, GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue, 2), GeometryStroke = new SolidColorPaint(s_blue, 2),
Fill = null, Fill = null,
LineSmoothness = 0, LineSmoothness = 0,
ScalesYAt = 0, ScalesYAt = 0,
}, },
}; };
}
} }

Loading…
Cancel
Save