我的应用程序中有两个大小相同的列表。一个包含日期信息,另一个包含该日期的水电导率数据。我使用两个列表来绘制图表上的信息。我现在正在尝试添加一个滑块,允许用户按特定天数过滤数据。到目前为止,这是我的代码:
// Filter the date data (this works!)
var filteredDates = from n in parsedDateList[0]
where n >= beginDate.Date
select n;
//Filter the y-axis data (this does not work!)
var filteredCond = waterConductivityList[1].Where(x => parsedDateList[0].Any(y=> y.Date > beginDate));
有人可以告诉我我做错了什么吗? y轴过滤器只返回完整的信息列表而不是过滤。
答案 0 :(得分:0)
所以这就是我所做的:
Dictionary<DateTime, int> conductivityData = new Dictionary<DateTime, int>();
// Get the y-values
i=0;
foreach (var entry in waterConductivityData[1])
{
condData[i] = Convert.ToInt32(entry);
i++;
}
// Add the dates ("entry" from datelist) and the y-value (condData) to the dictionary
i=0;
foreach (var entry in parsedDateList[0])
{
conductivityData.Add(entry, condData[i]);
i++;
}
//Add the data to the plot series using "key" for dates and "value" for y-data
foreach (var entry in conductivityData)
{
filteredDateStrings[0].Add(entry.Key.ToString("M/d/yy hh:mm tt"));
filteredCondData[0].Add(entry.Value);
}
// Update plot data
i = 0;
foreach (var entry in filteredCondData[0])
{
waterSourceTwoChart.Series["conductivity"].Points.AddXY(filteredDateStrings[0].ElementAt(i), filteredCondData[0].ElementAt(i));
i++;
}
感谢大家的帮助!