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

Message ListMessage List     Post MessagePost Message

  Disabling Tooltip
Posted by James on Mar-28-2011 20:42
Hi

Currently using ChartDirector in a c# windows forms App.  Im looking to disable the tooltip for standard XYChart but keep the data from the hotspots to display in a custom popup.  Please advise.

Thanks

James

  Re: Disabling Tooltip
Posted by Peter Kwan on Mar-29-2011 00:11
Hi James,

To disable the tooltip, please simply remove the title attribute in getHTMLImageMap.

For example, if you are using something like:

viewer.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: US${value}K'");

please change it to:

viewer.ImageMap = c.getHTMLImageMap("clickable", "", "");

Hope this can help.

Regards
Peter Kwan

  Re: Disabling Tooltip
Posted by James on Mar-29-2011 16:03
Hi

Unfortunately that removes the information from the hotspot that i display in my own custom popup.  Im trying to stop the popup and the tooltip information appearing at the same time.


This is a cut down version of the code that displays my popup, its in the mouse move function.

Hashtable d = graph.GetHotSpot(e.X, l.Bottom - 1);
   if (d != null)
   {
        double hotSpot = Convert.ToDouble(d["x"]);
        int val = Convert.ToInt32(d["value"]);
        if (val == 0)
        {
             HideToolTip();
             break;
        }

       //Point pt1 = new Point(e.X + 100, e.Y);
       string tt = Convert.ToString(d["title"]);
       point.X = point.X + 100;
       textPopup.ShowTextPopup(this, tt, false, point);
}

The popup is always displayed and gets its information by interrogating the hotspot hashtable

This is the code where i set the tool tip information in my draw function

string tooltip;
if (this.tooltipString != null)
{
tooltip = this.tooltipString;
}
else
{
tooltip = "title='{field0}'";
}
this.ImageMap = chart.getHTMLImageMap("clickable", "", tooltip);

Setting

this.ImageMap = chart.getHTMLImageMap("clickable", "", "");

Removes the "title" information from the hashtable which i diplay in my popup.

I want to keep this information but disable the graph from displaying its own tooltip.  Rightnow my workaround is to display the toolip after a 30 seconds wait which is obviously not ideal.

Please advise

James

  Re: Disabling Tooltip
Posted by Peter Kwan on Mar-30-2011 02:28
Hi James,

You may use another parameter other than "title" to pass the {field0}. For example:

this.ImageMap = chart.getHTMLImageMap("clickable", "x={x}&value={value}&abc={field0}", "");

Now you can use:

string tt = Convert.ToString(d["abc"]);

to get the {field0}.

Hope this can help.

Regards
Peter Kwan

  Re: Disabling Tooltip
Posted by James on Mar-30-2011 22:32
Thanks Peter

That solved one problem but another problem has appeared.  In one graph 2 layers are added.  A Bar layer containing the data and a Line Layer which is a sine wave representation purly for display only at the background of the graph.

The Hot spots for this line layer is interfering with the graph.  I have added layerId={layerId} value to image map to allow for correct interrogation of a hot spot but I have found that the hot spot attributes dont always come back with the correct values for the layer.

Ideally id like to disable hot spots for a specific line layer ive added.  Is this possible?
Or can a sine wave background be added without adding a layer?

A bottom and top graph, the highlight bar is diplayed on both and are kept in synch via the mouse position in the mouseenterhotspot.  layer 1 = line layer which i dont want to respond to

Hashtable TGH = graphTop.GetHotSpot(e.X, l.Bottom - 1);
if (TGH != null)
{
      layer = Convert.ToInt32(d["layerId"]);
      if (layer == 1)
          return;
      coords = Convert.ToString(TGH["coords"]);
      split = coords.Split(new Char[] { ',' });
      width = Convert.ToInt32(split[2]) - Convert.ToInt32(split[0]) + 1;
      height = Convert.ToInt32(split[3]) - Convert.ToInt32(split[1]);
      pt2 = new Point(Convert.ToInt32(split[0]), Convert.ToInt32(split[1]));
      sz2 = new Size(width, height);
}

The above sometimes give me the area of the line graph even though im checking the layer value and returning if its the wrong one.

My layers are added in a draw function.

//add my bar dat alayer
BarLayer layer = null;
if (this.graphData != null && (this.graphData.Count > 0))
{
double[] data = this.graphData.Values;
layer = chart.addBarLayer(data,color);
if (layer != null)
{
layer.setBorderColor(ChartDirector.Chart.SameAsMainColor);
if (this.field0 != null)
{
layer.addExtraField(this.field0);
if (this.field1 != null)
{
layer.addExtraField(this.field1);
}
}
}
}

//add background sine wave layer
//Maybe a sine wave could be displayed without adding a layer?

double[] sine = this.CreateSineWave(points, this.MaxValue);
LineLayer lineLayer = chart.addLineLayer(sine, gridColor);
if (lineLayer != null)
{
lineLayer.setLineWidth(1);
}
chart.layout();

and my new code for image map, which does work ok

string popupinfo;//, temp;
if (this.tooltipString != null)
{
         popupinfo = "layerId={layerId}&x={x}&value={value}&";
         popupinfo += this.tooltipString;
         popupinfo = popupinfo.Replace("title", "abc");

}
else
{
         popupinfo = "x={x}&value={value}&abc='{field0}'";
}

this.ImageMap = chart.getHTMLImageMap("clickable", popupinfo, "");
this.ParseCoordinates();

Any help would be apreciated as ive been working to get CD ready for a project for 2 weeks now and believe this to be the last issue.

Thanks

James

  Re: Disabling Tooltip
Posted by James on Mar-30-2011 23:48
Aplogies code should have read

if (TGH != null)
{
      layer = Convert.ToInt32(TGH["layerId"]);
      if (layer == 1)
          return;
      coords = Convert.ToString(TGH["coords"]);
      split = coords.Split(new Char[] { ',' });
      width = Convert.ToInt32(split[2]) - Convert.ToInt32(split[0]) + 1;
      height = Convert.ToInt32(split[3]) - Convert.ToInt32(split[1]);
      pt2 = new Point(Convert.ToInt32(split[0]), Convert.ToInt32(split[1]));
      sz2 = new Size(width, height);
}

The main issue is the number of new hots spots that my changes to the image map calculation does

this.ImageMap = chart.getHTMLImageMap("clickable", popupinfo, "");

Not sure how to add popupinfo and disable the linebars hotspots.

James

  Re: Disabling Tooltip
Posted by Peter Kwan on Mar-31-2011 01:09
Hi James,

If you would like to disable image map for a particular layer, please use Layer.setHTMLImageMap. For example:

layer.setHTMLImageMap("{disable}");

Hope this can help.

Regards
Peter Kwan

  Re: Disabling Tooltip
Posted by James on Mar-31-2011 16:14
That done the trick.  Thanks for your help Peter.

James