Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Tools for Java
 QCChart2D for Java
 DataToolTip customization

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List

* Forum Code is ON
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]


T O P I C    R E V I E W
rixmith Posted - 29 Jul 2011 : 12:00:57

Is there a suggested method to use to hook into the DataToolTip so that I can execute my own code when DataToolTip fails to select a ChartDataset (because the click point is too far from any plot)?

In other words, is there a way of knowning when the threshold distance test fails?

7   L A T E S T    R E P L I E S    (Newest First)
rixmith Posted - 01 Aug 2011 : 08:45:03
Thanks for your help. My DataTooltip subclass is now working as required.

quinncurtis Posted - 30 Jul 2011 : 14:09:15
That probably wouldn't work, because the actual data point is only calculated after a plot object is found.

So, to do the coordinate conversion you will need to do something like this, using the coordinate system you used for your plot objects.

class CustomToolTip extends DataToolTip {

   public CustomToolTip(ChartView component) {

   public void mousePressed(MouseEvent event) {
       if (this.getSelectedDataset() == null)
      	      ChartPoint2D mousepos = new ChartPoint2D();
       	      mousepos.setLocation(event.getX(), event.getY());

	      ChartPoint2D xvalue =    pTransform1.convertCoord(ChartConstants.PHYS_POS,mousepos , 
	      GregorianCalendar timevalue = xvalue.getCalendarX();
quinncurtis Posted - 30 Jul 2011 : 13:35:09
You can subclass the DataTooltip and override the mousePressed method, calling the base method. If the selectedDataset is null, it didn't find a point. It then gets the GregorianCalendar value of the mouse position. Hope this helps.

<Removed Code>
rixmith Posted - 30 Jul 2011 : 10:31:08
The interface is not up for debate: the user requires certain tooltip feedback when he clicks the chart, even when there is no datapoint nearby.

I understand from your response that I must roll my own tooltip
to accomplish this behaviour - and that's ok.

Can you assist with a related question: what's the best way to determine the value on the x-axis that corresponds to the mouse click location on the chart?


quinncurtis Posted - 30 Jul 2011 : 09:24:03
Seems like an inefficient user interface. Having someone click around on a line plot, using the tool tip to find out whether or not there is a data point present. Why not just use a SimpleLineMarkerPlot, instead of a line plot. In a SimpleLineMarkerPlot, a symbol is displayed at every data point, so the user know by simple inspection whether or not a data point is present. He can click on the symbol to get the associated tooltip. No wasted clicks.
rixmith Posted - 30 Jul 2011 : 07:19:40
I need the tooltip to appear every time the user clicks on the chart. When the user clicks on the chart and the tooltip threshold test fails I would determine the location on the x-axis that corresponds to the location of the mouse click and display "There is no datapoint for Monday June 23, 1985".

If I have to write my own MouseListener to handle tooltips, what is the best way to convert the x location of the mouse click to a value on the x-axis?

quinncurtis Posted - 29 Jul 2011 : 14:51:35
Not really. You can change the hit testing threshold to be whatever you want though.


The default is 15 pixels.

What is it that you want to do if the hit testing threshold fails?

Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07