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

Message ListMessage List     Post MessagePost Message

  Manually Add HotSpots
Posted by Andrew on Nov-12-2020 02:55
I have a line graph based on vibration data. When I create the graph, I'm adding Marks to it at various X-Axis positions to indicate a tag location in the data. This mark is displayed as a vertical line with a short text label.

I want to add hotspots for each Mark that will allow me to display the mark text in a larger font size when the mouse is hovered over the mark itself.

I don't want auto-generated imagemap based on the vibration data, I want to create an imagemap based on this set of marks I'm adding.

Do you have an example of creating custom hotspots? I haven't found one yet.

Thanks.

  Re: Manually Add HotSpots
Posted by Peter Kwan on Nov-12-2020 17:11
Hi Andrew,

From your previous message, I think you are using ChartDirector for .NET in a Windows Forms application.

Yes, there is an example with hot spots for axis marks, but we have only provided the example for web applications.

https://www.advsofteng.com/doc/cdnet.htm#customclickable.htm

The same method also works for desktop application. Basically, you can create an image map for the marks to turn them into hot spots. In the MouseMoveHotSpot event handler, you can check the hot spot parameters to identify which mark the mouse points to.

In brief, it is like:

... create chart as usual ...

// display chart first
winChartViewer1.Chart = c;

string markImageMap = "<area " + markXXX.getImageCoor() + " href='clickable?m=xxx'>";

string markImageMap2 = "<area " + markYYY.getImageCoor() + " href='clickable?m=yyy'>";

string otherImageMaps = .... other image maps if any ...;

winChartViewer1.ImageMap = markImageMap + markImageMap2 + otherImageMaps;

In your MouseMoveHotSpot event handler, you can use:

string mark = e["m"];
if (null != mark)
{
     if (mark == "xxx")
     {
        // do something about it
     }
     else if (mark == "yyy")
    {
        // do something about it
    }
}

Hope this can help.

Regards
Peter Kwan

  Re: Manually Add HotSpots
Posted by Andrew on Nov-13-2020 00:08
Peter,

Thank you for the reply. I had cobbled together something that worked, using guesses for pixel coordinates to define the area. This method is much cleaner and works great.

I believe I've seen the answer to my next question, but I'm going to ask it again, just to make sure I'm clear on my options.

Is there a way to set the font size in the tool tip box that is displayed when I hover over the hotspot?  When running on a 4K monitor, the tool tip font is extremely small. I have the rest of the fonts in my app auto scale based on the resolution, so axis and title fonts sizes change based on the resolution. For the most part, this makes my graphs look good in all resolutions, but the tool tip box doesn't scale.

If there are no options to set the tool tip font, do you have an example of creating a custom tool tip pop-up based on the MouseMove / MouseHover HotSpot event handlers?

  Re: Manually Add HotSpots
Posted by Peter Kwan on Nov-13-2020 11:43
Hi Andrew,

ChartDirector determines what to display in the tooltip, and simply asks Windows Forms to display the tooltip. The tooltip style is simply the standard Windows Forms tooltip, and we cannot control its style.

For your case, there are several methods:

(a) You can use any control you like to display tooltips. For example, you can drag and drop a TextBox control in your Form and sets its Visible property to false. In the MouseMoveHotSpot event, you can move the TextBox near the mouse, set the tooltip to the TextBox, and set its Visible property to true. In the MouseLeaveHotSpot, you can set its Visible property to false to hide it.

(b) You can enable high dpi support in your Windows Forms application. In this way, the Windows Forms will follow the operating system high dpi configuration (on Windows 10, the "Settings/Display/Scale and Layout"). Generally, every control that has text will become bigger the factor set in "Settings/Display/Scale and Layout", so the tooltip will become bigger too. However, images (including the chart, which is an image to Windows Forms) will not become bigger, so you would still need to use your own code to create a bigger chart.

There are several methods to enable high dpi in Windows Forms. The method I commonly used is to insert the following code in the start up method Main. (The code must be run before the Form is loaded.)

static void Main()
{
    if (Environment.OSVersion.Version.Major >= 6)
       SetProcessDPIAware();

    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new MyStartUForm());
}


(c) Try the ChartDirector 7.0 beta. It has built-in high dpi support and will scale automatically if your Windows Forms application has enabled high dpi support. ChartDirector 7.0 also has CDML tooltip support, which means you can configure the tooltip in complex ways using a HTML like language.

https://www.advsofteng.com/doc/cdnet.htm#cdml.htm

If you are interested in the ChartDirector 7.0 method, please let me know.

Regards
Peter Kwan

  Re: Manually Add HotSpots
Posted by Andrew on Nov-14-2020 00:40
Peter,

Thank you again for the quick, and helpful, reply.

The MouseMove / MouseLeave hotspot process works perfectly. It gives me the control I want of the hotspot "tooltip" display.

My only problem now is that I can't figure out how to disable the system generated tooltip display. With my added code, I'm getting both the system tooltip box and my custom one.

How do I turn off the system tooltip display but keep the hotspot detection? Setting the InitialDelay period to a huge value doesn't appear to do anything.

  Re: Manually Add HotSpots
Posted by Andrew on Nov-14-2020 00:57
Peter,

Disregard that last message. I removed the "title" section of the imagemap and everything works as I want it to.

Thanks again for your help.

Andrew