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

Message ListMessage List     Post MessagePost Message

  Add tooltip to zones
Posted by Florian Seywert on Apr-24-2014 20:39
Hi,

I would like to add toolTips to "zone" included in my graph. How can I do that?
If the solution is to add manually a line in the HTMLImageMap for each zone, can I have an example because I already try this solution without success ?

Thank you in advance,
Best regards,

  Re: Add tooltip to zones
Posted by Florian Seywert on Apr-24-2014 20:41
I forgot to specify that I use XYChart in C++ MFC.

  Re: Add tooltip to zones
Posted by Peter Kwan on Apr-25-2014 03:03
Hi Florian,

By "zones", I assume you are referring to a rectangular region in the chart. In this case,
the image map is like:

const char *imageMap = "<area shape='rect' coords='80,100,400,300' title='my tooltip'>";

In the above, (80,100) and (400,300) are the (x, y) pixel coordinates of the opposite
corners of the rectangular region.

Suppose your "zone" is a y-axis zone from y=40 to y=80. The code is like:

//First, create and display the chart (pass the chart to the CChartViewer). After
displaying the chart:

int leftXCoor = c->getPlotArea()->getLeftX();
int topYCoor = c->getYCoor(80);
int rightXCoor = c->getPlotArea()->getRightX();
int bottomYCoor = c->getYCoor(40);

char imageMap[1024];
sprintf(imageMap, "<area shape='rect' coords='%d,%d,%d,%d' title='my tooltip'>",
leftXCoor, topYCoor, rightXCoor, bottomYCoor);

If you have multiple image map regions, you may append the <area> tags together into a
long string.

After creating the complete image map (by appending all the regions together), you may
pass it to the CChartViewer using CChartViewer::setImageMap.

Hope this can help.

Regards
Peter Kwan

  Re: Add tooltip to zones
Posted by Florian Seywert on Apr-25-2014 21:22
Hi,
Thanks for your answer. I already tried this solution without success but I just see that I forgot to close the line I added with ">". Now it works as expected.
But I wondered if an ImageMap could be generated with "getHTMLImageMap" for the struct Zone (as it is defined for "c->xAxis()->addZone") ?

Thank you in advance,

  Re: Add tooltip to zones
Posted by Peter Kwan on Apr-26-2014 00:26
Hi Florian,

Unluckily, the addZone method does not return anything (the return type is declared as
"void" in C++), so there is no "struct Zone" or object that you can call getHTMLImageMap
on.

Regards
Peter Kwan