回复 3楼SnailRun的帖子
在 IE11、Chrome(Version 42.0.2311.135 m)、FireFox (33.1.1)中分别作了测试,可以正常调用 Chart Click 事件,测试代码如下:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (this.FpSpread1.ActiveSheetView.Charts.Count > 0)
- this.FpSpread1.ActiveSheetView.Charts[0].Click += WebForm1_Click;
- if (IsPostBack)
- {
- return;
- }
- BarSeries series = new BarSeries();
- series.SeriesName = "Series 0";
- series.Values.Add(2.0);
- series.Values.Add(4.0);
- series.Values.Add(3.0);
- series.Values.Add(5.0);
- YPlotArea plotArea = new YPlotArea();
- plotArea.Location = new PointF(0.2f, 0.2f);
- plotArea.Size = new SizeF(0.6f, 0.6f);
- plotArea.Series.Add(series);
- LabelArea label = new LabelArea();
- label.Text = "Bar Chart";
- label.Location = new PointF(0.5f, 0.02f);
- label.AlignmentX = 0.5f;
- label.AlignmentY = 0.0f;
- LegendArea legend = new LegendArea();
- legend.Location = new PointF(0.98f, 0.5f);
- legend.AlignmentX = 1.0f;
- legend.AlignmentY = 0.5f;
- ChartModel model = new ChartModel();
- model.LabelAreas.Add(label);
- model.LegendAreas.Add(legend);
- model.PlotAreas.Add(plotArea);
- FarPoint.Web.Spread.Chart.SpreadChart chart = new FarPoint.Web.Spread.Chart.SpreadChart();
- chart.Model = model;
- FpSpread1.Sheets[0].Charts.Add(chart);
- this.FpSpread1.ActiveSheetView.Charts[0].EnableClickEvent = true;
-
- }
- void WebForm1_Click(object sender, ImageClickEventArgs e)
- {
- HitTest position = this.FpSpread1.ActiveSheetView.Charts[0].HitTest(e.X, e.Y);
- int pointIndex = ((FarPoint.Web.Chart.SeriesHitTest)(position)).PointIndex;//The index of chart bar.
- }
复制代码
测试版本为 Spread 8.1。注意需要在每次页面加载时重新注册Click时间,详细请参考代码。 |