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

Message ListMessage List     Post MessagePost Message

  add tooltip to legend
Posted by Mark on Dec-14-2006 01:58
Hi,

I can see from the chart gallery that it's possible to add a tooltip when the mouse goes over a legend item. I didn't see a sample of this in the demo folders, where can I find it?

Thanks,
Mark

  Re: add tooltip to legend
Posted by Mark on Dec-14-2006 02:14
This is as far as I got, I just don't see how to set the HTML map for the legend - do I just append it to whatever I'm setting for the entire chart image map?

    LegendBox *plb = c->getLegend();
    if (plb->getInternalPtr() != NULL) {
        CString str = plb->getHTMLImageMap("");
        // ...?
    }

Thanks,
Mark

  Re: add tooltip to legend
Posted by Peter Kwan on Dec-14-2006 06:06
Hi Mark,

Sorry. The sample code to do this is available in all editions of ChartDirector except ChartDirector for C++.

(In all editions of ChartDirector except C++, we provide web and windows application sample code, and the clickable legend box is in the web sample code. In C++, we provide MFC and command line sample code instead, and there is no web sample code, so the sample does not appear in C++.)

Basically, you may simply append the image map together. For example:

// Create an image map for the chart
CString chartImageMap = c->getHTMLImageMap(...............)'

LegendBox *plb = c->getLegend();
if (plb->getInternalPtr() != NULL)
      chartImageMap += plb->getHTMLImageMap("", "", "title='{dataSetName}'");

Hope this can help.

Regards
Peter Kwan

  Re: add tooltip to legend
Posted by Mark on Dec-16-2006 05:15
Hi Peter,

That seemed to work, thank you. I'd like to associate some extra data with a dataset in my XY chart. Right now I am just plotting a curve. How could I associate some text items like:

    "apple"
    "$5"

with the curve's legend item, so when I mouse over its entry in the legend the tooltip could display something like:

   "Curve 1 : apple : $5"


this is all I have right now,

    pLegendBox->getHTMLImageMap("", "", "title='{dataSetName}'");


Thanks,
Mark

  Re: add tooltip to legend
Posted by Peter Kwan on Dec-16-2006 10:30
Hi Mark,

Yes. You can bind extra information to the data sets in a chart layer, and use these information in the tool tip.

For example:

//Extra information for the data sets. If you have 3 data sets in a layer, then
//arrayOfTextStrings should contain 3 text strings for the 3 data sets.
layer->addExtraField(arrayOfTextStrings);

..................

pLegendBox->getHTMLImageMap("", "", "title='{dataSetName}: {dsField0}'");

In the above, the {dsField0} will be substituted with whatever is in the extra field. You may put any text you like in the extra field, such as "apple $5", etc..

Regards
Peter Kwan

  Re: add tooltip to legend
Posted by Mark on Dec-16-2006 11:57
Ah ok I kept writing 'field0', instead of 'dsField0', thanks again,

Mark