1

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 when the user clicks on red colour? I can't see one anywhere.

I am uploading the sample graph here enter image description here

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

user682417
  • 1,478
  • 4
  • 25
  • 46

3 Answers3

1

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

Waqar Janjua
  • 6,113
  • 2
  • 26
  • 36
1

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

JakeJ
  • 1,381
  • 3
  • 14
  • 34
1

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.

Community
  • 1
  • 1
zeFrenchy
  • 6,541
  • 1
  • 27
  • 36