如何在折线系列图表 X 轴 Windows Phone 8.1 中绑定日期
本文关键字:Phone Windows 日期 绑定 折线 系列 | 更新日期: 2023-09-27 18:32:13
在折线系列图中,我想通过将日期绑定在 x 轴上来显示日期,在 y 轴上索引从 90 开始我正在使用 WCF 方法来访问日期
.xaml 代码
<Charting:Chart Name="MyChart" Title="" Margin="11,153,-2,39">
<Charting:LineSeries Margin="0" IndependentValuePath="Item1"
DependentValuePath="Item2" IsSelectionEnabled="True" Title="Blood Glucose"
Foreground="Black" ItemsSource="{Binding Measurement}" />
</Charting:Chart>
.xaml.cs
string result = await WCFRESTServiceCall("GET", "getbg1?Email=" +
emailtxtbox.Text + "");
result = result.Replace("{'"getbg1Result'":", "");
result = result.Replace("]}", "]");
List<BG> data = JsonConvert.DeserializeObject<List<BG>>(result);
int item1 = 0;
int item2 = 1;
int item3 = 2;
string a1 = "";
string b2 = "";
string c3 = "";
foreach (BG b in data)
{
item1 = b.Measurement[0];
item2 = b.Measurement[1];
item3 = b.Measurement[2];
a1 = b.Date_[0].ToString();
b2 = b.Date_[1].ToString();
c3 = b.Date_[2].ToString();
}
List<Tuple<string, int>> myList = new List<Tuple<string, int>>()
{
new Tuple<string, int>(a1, item1),
new Tuple<string, int>(b2, item2),
new Tuple<string, int>(c3, item3)
};
(MyChart.Series[0] as LineSeries).ItemsSource = myList;
}
我已经通过执行这些代码行解决了我的问题
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
string result = await WCFRESTServiceCall("GET", "getbg1?Email=" +
emailtxtbox.Text + "");
result = result.Replace("{'"getbg1Result'":", "");
result = result.Replace("]}", "]");
List<BG> data = JsonConvert.DeserializeObject<List<BG>>(result);
int item1 = 0;
int item2 = 1;
int item3 = 2;
int item4 = 0;
item1 =int.Parse( data[0].Measurement);
item2 = int.Parse(data[1].Measurement);
item3 = int.Parse(data[2].Measurement);
List<Tuple<string, int>> myList = new List<Tuple<string, int>>()
{
new Tuple<string, int>(data[0].Date_, item1),
new Tuple<string, int>(data[1].Date_, item2),
new Tuple<string, int>(data[2].Date_, item3),
};
(MyChart.Series[0] as LineSeries).ItemsSource = myList;
}