【发布时间】:2016-12-21 17:44:42
【问题描述】:
说,我有以下 SQLite DB:
数据类型:
DateTime Int
(with HH:MM:SS) Queue Size
2016-08-15 06:10:10 20
2016-08-15 06:11:12 30
2016-08-15 06:12:16 10
2016-08-15 06:13:12 10
2016-08-15 06:14:10 60
2016-08-15 06:15:08 20
2016-08-15 06:16:10 30
2016-08-15 06:17:12 10
2016-08-15 06:18:11 10
2016-08-15 06:19:12 10
2016-08-15 06:20:12 10
1) 如何使用 SQL 为图表创建数据源,每 5 分钟获取一次队列总数?
示例
第一个 5 分钟,总队列为:130
第 2 5 分钟,总 Queue 为:80
第三个5分钟?
2) I have this class for the Chart
public class Queue
{
public DateTime Interval { get; set; }
public int Queue { get; set; }
}
private void LoadQueue()
{
//-- how to use SQL to query the SQLite DB
List<Queue> QList = new List<Queue>();
//---code ---
(ColumnChart.Series[0] as ColumnSeries).ItemsSource = QList;
}
图表的 XAML:
<Charting:Chart x:Name="ColumnChart" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="505,100,0,0" Width="399" Height="400">
<Charting:ColumnSeries Title="Queue" Margin="0"
IndependentValuePath="Interval"
DependentValuePath="Queue" IsSelectionEnabled="True"/>
</Charting:Chart>
--------- 编辑
public class tblQueue
{
public DateTime QueueDate { get; set; }
public int QueueSize { get; set; }
}
Case : insert the data into SQLite DB using SQlite.Net-PCL
var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), DBPath);
var newItem = new tblQueue()
{
a) QueueDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
b) QueueDate = DateTime.Now,
QueueSize = intQ_Length,
};
db.Insert(newItem);
Question :
1) what dataType should I use for my tblQueue class for table ?
which dataType to use?
1a) public DateTime QueueDate { get; set; }
1b) public string QueueDate { get; set; }
------- 编辑_2: 基于上述 SQLite DB:
1) 假设数据正常。这是我想在 SQL-Select 之后显示的结果:
Interval every 5 minute ttl Queue
---------------------- ------------
2016-08-15 06:15:00 150
2016-08-15 06:20:00 70
2016-08-15 06:25:00
<Charting:Chart x:Name="ColumnChart" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="253,100,0,0" Width="651" Height="506">
<Charting:ColumnSeries Title="WaitingLine" Margin="0" IndependentValuePath="Interval"
DependentValuePath="Size" IsSelectionEnabled="True"/>
</Charting:Chart>
我需要以下图表:
2.1))IndependentValuepath ="Interval" 示例:06:15
2.2)DependentValuePath ="大小:
DependentValuePath 显示 : 150 , 70 对于 y 轴
IndependentValuePath 显示 : 06:15 , 06:20 , 06:25 for x 轴
这些值(2.1 和 2.2)来自下面的类
3) 如何在这个 Val 类中添加 Interval 的属性?
public class Val
{
?? interval
public int size { get; set; }
}
4)我似乎没有像(1)中那样按间隔得到上述数据的结果
private void LoadQueue()
{
List<Val> ints=db.Query<Val>("SELECT sum(Queue) as 'size' from Queue group by (strftime('%Y%m%d%H0',QueueDate)+strftime('%M',QueueDate)/5)");
}
请注意:我使用 QueueDate , tblQueue 中的 Queue,
谢谢
我不确定我的 XAML 是否正确。请帮忙。
谢谢。
【问题讨论】:
-
谁能提供帮助?
标签: sqlite winrt-xaml uwp uwp-xaml