ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Create Hotspot in Windows Form C# .net
Posted by Amal VR on Jul-06-2010 16:20
Can you please Explain to set hotspots  in a spline Chart so that when i click on the spline it will return the value of the spline at that point.

  Re: Create Hotspot in Windows Form C# .net
Posted by Peter Kwan on Jul-07-2010 02:44
Hi Amal,

In ChartDirector, the hot spots only refer to the data points. Say if you have a spline created with 100 data points, the hot spots are for the 100 data points. If you click on a hot spot, you may obtain the information on the data point inside the hot spot.

Note that with hot spot, the information obtained is not the "value of the spline at that point". It is the value of the data point inside the hot spot, which will always be one of the data points you use to create the spline.

The sample code included in ChartDirector are all configured with clickable hot spots. (Have you tried the sample code in the "NetWinCharts" Visual Studio solution?) Basically, you just need to add a clickable image map to the chart and handle the "ClickHotSpot" event.

ChartDirector also allows you to get the value under at the mouse cursor. This does not requiring using any hot spot at all. You just need to handle the mouse click event. See:

http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1187910016#N1187953452

Note that the above method works no matter where is the mouse cursor. It works even if the mouse cursor is not on the spline curve.

Hope this can help.

Regards
Peter Kwan

  Re: Create Hotspot in Windows Form C# .net
Posted by Amal VR on Jul-07-2010 17:41
double[] curveY = { 50,54, 48, 58, 50, 90, 85, 104, 82, 96, 90, 74, 52, 35,
            58, 46, 54, 48, 52, 50};
            double[] curveX = { 0,1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7,
            7.5, 8, 8.5, 9, 9.5, 10,11,12};
These are the (x,y) coordinates of my spline curve.I clicked at the point(50,0) but ClickHot spot event is not firing. Why?
Spline curves,even though they are parametric, (50,0) is the start point,can it be a hotspot in the curve?

  Re: Create Hotspot in Windows Form C# .net
Posted by Peter Kwan on Jul-08-2010 02:48
Hi Amal,

I have just uploaded a Visual Studio 2005 project to:

http://www.advsofteng.com/WindowsApplication3.zip

In the project, there is a simple spline curve, using your data. I have configured the mouse to show a "hand cursor" when it is over a clickable hot spot, so you can see the hot spot. When you click on the hot spot, the ClickHotSpot event will be fired, and pop up a message box.

You can click on any point on the spline curve, including the point (0, 50). When you click on a point on the spline curve, it will pop up a message showing the information of the nearest data point.

If the above still does not solve the problem, would you mind to provide me with a sample code that can illustrate the problem?

Regards
Peter Kwan

  Re: Create Hotspot in Windows Form C# .net
Posted by Amal VR on Jul-08-2010 11:56
Hi Peter

Thank you for your time,Every thing works perfectly now.My problem was with getHTMLImageMap().

Regards

Amal V R

  Re: Create Hotspot in Windows Form C# .net
Posted by Amal VR on Jul-08-2010 12:26
Hi Peter

This is my code

double[] curveY = { 50,54, 48, 58, 50, 90, 85, 104, 82, 96, 90, 74, 52, 35,
            58, 46, 54, 48, 52, 50};
double[] curveX = { 0,1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7,
            7.5, 8, 8.5, 9, 9.5, 10,11,12};
XYChart c = new XYChart(600, 500, 0xcccccc, 0x000000, 1);
c.setPlotArea(55, 58, 520, 400, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
c.xAxis().setWidth(2);
c.yAxis().setWidth(2);
SplineLayer splineLayer = c.addSplineLayer(curveY, 0x800080);
splineLayer.setXData(curveX);
splineLayer.setLineWidth(2);
splineLayer.addDataSet(curveY).setDataSymbol(2, 8);
viewer.Image = c.makeImage();
viewer.ImageMap = c.getHTMLImageMap("clickable", "","title='({x}, {value})'");

I got the hotspots but they are located outside the spline............

What will be wrong with the code

  Re: Create Hotspot in Windows Form C# .net
Posted by Peter Kwan on Jul-08-2010 18:01
Attachments:
Hi Amal,

I have tried your code by copied and pasted it to the sample project I attached in my last message. It works normally. I have attached a screen shot for your reference.

Please try using the sample project I sent to you to see if it works. If the code works in my sample project, but does not work in your real project, the error may be caused by other parts of your code or your project configuration. In this case, is it possible to send a complete workable sample project to me so that I can reproduce the problem? (You may consider to modify my sample project to try to reproduce the problem, and then send me the modified project.)

Note that the forum has an upload limit of 250 Kbytes. If your sample project is above 250 Kbytes, you may email to me at pkwan@advsofteng.net.

Regards
Peter Kwan
Image2.png

  Re: Create Hotspot in Windows Form C# .net
Posted by Amal on Jul-09-2010 17:19
Hai Peter,

I solved the problem,it was a small mistake.Thanks for your help.
Another question,How many charts can be accommodate in a single winChartViewer?

example:

I have two chart one is for spline and other is for line(shows min,avg and max values of the spline),I have three lines corresponding to three splines.When I click a line in the line chart it will display the respective spline this is the requirement.I did it with two winchartViewer control,1st control holds the spline and the second holds the lines,It worked.

My question is can we accommodate the spline chart and line chart in a single winChartViewer control?.


Regards

Amal V R

  Re: Create Hotspot in Windows Form C# .net
Posted by Peter Kwan on Jul-10-2010 02:13
Hi Amal,

Do you mean you want to have two separate charts (with two different plot areas), but you want to put them in the same WinChartViewer control?

Personally, I think putting them in two separate WinChartViewer controls are a better idea. They can then be updated independently (say you can update the spline chart without updating the line chart), and can be positioned independently (eg. you can put one chart on top of the other, or under the order, or side by side, or in any other way).

Anyway, if you want to use one WinChartViewer control, you would need to combine the two charts into one chart by using a MultiChart object, then put the MultiChart object into the WinChartViewer. You may refer to the documentation of "MultiChart" for details.

Hope this can help.

Regards
Peter Kwan

  Re: Create Hotspot in Windows Form C# .net
Posted by Amal on Jul-10-2010 11:41
Hai Peter,

I tried with Multichart,but as you said we will have to update both the charts and is not optimum.
Thank you Peter for your advice

Regards
Amal V R