回复 8楼iceman的帖子
非常抱歉还得麻烦您下:
我的这个柱状图原来有点击事件,这个操作是为了获取点击的那个柱状图的X 轴的值也就是日期,函数如下,现在在添加PlotElementLoaded事件后,在点击柱状图后会执行多次点击事件,去掉就没有问题了,这是为什么?
foreach (var item in c1obj.Data.Children)
{
DataSeries ds = item as C1.WPF.C1Chart.DataSeries;
if (ds != null)
{
ds.PlotElementLoaded += new EventHandler(MainPage_PlotElementLoaded);
}
}
void MainPage_PlotElementLoaded(object sender, EventArgs e)
{
var bar = (C1.WPF.C1Chart.PlotElement)sender;
bar.MouseDown += new MouseButtonEventHandler(bar_MouseButtonDown);
}
void bar_MouseButtonDown(object sender, MouseButtonEventArgs e)
{
Bar bar = sender as Bar;
if (bar != null)
{
DataPoint point = bar.DataPoint;
string dateStr = point.Name;//日期
}
catch
{
}
}
} |