开发者

trying to create the click event handler

So I've made this range bar chart with the MS Chart Control. I have a question:

How can I implement an event handler for w开发者_JAVA技巧hen the user clicks on red colour? I can't see one anywhere.

I am uploading the sample graph here

trying to create the click event handler

I want to show another graph if you click on red colour on this graph

so how can i create click event handler for this one


See find the region part of live using c# for similar question ... within the click handler do this

var pos = e.Location;
var results = chart1.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);
foreach (var result in results)
{
  if (result.ChartElementType == ChartElementType.DataPoint)
  {
    if (result.Series.Points[result.PointIndex].Color == Color.Red)
    {
       Console.WriteLine("success?");
    }
  }
}  

Note that color could be null on a particular point but appear red on the graph (it would be obtained from the series). As long as you manually set the color on the clickable points, that will work, but you may want to think whether the color is the thing you should be testing.


I never use this control. I think if data comes from a static source then you can use ImageMap Control to define hot spots for different parts of the graph and when the user click you can open that graph and even data comes from a dynamic source it is possible


This is an idea that I just thought of and I don't know if it will work but why not try this:

Basically, make it so that you have 3 divs that relate to each section of a single bar, and those are within a single div which is the bar itself. You can then set the div bar to be 300px high for example, and make the sections within take a percentage of that. Then you can assign a JavaScript event for the red div for an onClick event to redirect to the page.

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜