我使用Array
(
[0] => stdClass Object
(
[title] => Browser Name
[name] => browser
[posted] => Array (
[0] => Firefox
[1] => Chrome
)
)
[1] => stdClass Object
(
[title] => First Name
[name] => firstname
[posted] => John
)
[2] => stdClass Object
(
[title] => Last Name
[name] => lastname
[posted] => Doe
)
)
获得了for循环,我尝试通过对数据求和来向图表添加点数;但是,在运行循环时我收到此错误:
InvalidCastException未处理:来自' DateTime'的无效广播至 '的Int32'
以下是我正在尝试的for循环中的代码:
DateTime
答案 0 :(得分:1)
你实际上并不需要DateTime
,而应该做的是循环int
,如下所示:
const int intervalMinutes = 15;
const int numIntervals = 24 * (60/intervalMinutes);
for(int i = 0; i < numIntervals; ++i)
{
double sum = 0d;
//for every series in the chart collection sum the yvalues at the specified
foreach (Series s in dataSeries)
{
sum += s.Points[i].YValues[0];
}
DataPoint dp = new DataPoint();
//Add a new yvalue to the datapoint for the summed series's
//And I will get an error in this one as well
dp.XValue = dataSeries[0].Points[i].XValue;
dp.YValues[0] = sum;
sumSeries.Points.Add(dp);
}
如果你的循环内部确实需要DateTime
,请按以下方式创建:
DateTime dateTime = new DateTime().AddMinutes(intervalMinutes * i);