如何从饼图中为项目(点)创建鼠标单击事件? [英] How to create a mouse click event for an item (point) from a Pie chart?

查看:226
本文介绍了如何从饼图中为项目(点)创建鼠标单击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个ASP.NET / C#网站

I am creating an ASP.NET/C# website

我使用ASP.NET 4.0图表控件绘制饼状图。

I used the ASP.NET 4.0 Chart control, to draw a Pie chart.

有没有办法创建一个动作,当用户点击一个项目(点)用鼠标?
例如,一个项目被点击,它的颜色改变,或用户获得项目的名称或...

Is there a way to create an action for when the user clicks an item (point) with the mouse? For example, an item is clicked, it's color change, or the user gets the item's name or...

感谢您的帮助

还有一种方法可以在项目上创建鼠标悬停事件?

Is there also a way to create a mouse over event on an item?

推荐答案

确保在ASP.NET和Windows窗体上都有一些交互性选项。

sure there are some options for interactivity on both ASP.NET and Windows Forms.

请点击此处:交互性(图表控件)

有一个点击图例的示例:

there is an example for the click on the legend:

using System.Web.UI.DataVisualization.Charting;
...
// Set the legend cell to an image showing selection cleared
Chart1.Legends[0].CustomItems[0].Cells[0].Image = "./cleared.png";
Chart1.Legends[0].CustomItems[0].Cells[0].PostBackValue = "item 1";
// Add an ImageMapEventHandler to the Chart.Click event
this.Chart1.Click += new ImageMapEventHandler(this.Chart1_Click);
...
// Change the selection image when the user clicks on the legend cell
private void Chart1_Click(object sender, System.Web.UI.WebControls.ImageMapEventArgs e)
{
   if (e.PostBackValue == "item 1")
   {
      LegendCell cell = Chart1.Legends[0].CustomItems[0].Cells[0];
      cell.Image = (cell.Image == "./cleared.png") ? "./selected.png" : "./cleared.png";
   }

还有一个用于鼠标悬停:

and also one for the mouseover:

onmouseover=\"DisplayTooltip(' <img src=DetailedChart.aspx />');\"

这篇关于如何从饼图中为项目(点)创建鼠标单击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆