Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have some {date, value} data:

data = Transpose[{AbsoluteTime /@ Thread[{2012, Range[12], 15}], 
   RandomInteger[10, 12]}]

Normally I do initial tests with DateListPlot and then implement with ListPlot or ListLinePlot for efficiency. However I just tried this:

DateListPlot[
 Table[With[{i = i},
   EventHandler[data[[i]], "MouseClicked" :> {Print["hello"]}]], {i, 
   12}]
 ]

and got this error message

DateListPlot::dtvals: Unable to automatically determine horizontal coordinates for the given data and DataRange.

enter image description here

Whereas if I switch to ListPlot or ListLinePlot it works fine:

ListPlot[
 Table[With[{i = i},
   EventHandler[data[[i]], 
    "MouseClicked" :> {Print["hello " <> ToString[i]]}]], {i, 12}]
 ]

enter image description here

Can anyone explain why EventHandler would not work within DateListPlot (hopefully this is not a RTFM question!)?

Problem exists with 8.0.4 and 9.0.1 on Mac 10.6.8

share|improve this question
3  
Tooltip seems to be only wrapper that works with DateListPlot. EventHandler,Button, PopupWindow ... work with ListPlot but not with DateListPlot. A workaround is to postprocess to replace Tooltip with a wrapper of your choice as in Jens' answer in this Q/A: DateListPlot[Table[With[{i = i}, Tooltip[data[[i]]]], {i, 12}]] /. Tooltip[x_, ___] :> EventHandler[x, "MouseClicked" :> {Print["hello"]}] –  kguler Feb 7 '13 at 1:15
    
@kguler I prefer to use ListPlot anyway because DateListPlot is so slow (presumably due to slow date and time functions that are called). So a workaround is unnecessary -- i.e. I'll prototype with ListPlot as well as deploy with it. Was just wondering if what I observed is known and if so whether it is by design or a bug. –  Mike Honeychurch Feb 7 '13 at 1:29
    
I have the same issues with DateListPlot on Windows (both mma versions 8.0.4 and 9.0). –  kguler Feb 7 '13 at 1:31
    
@kguler you mean same issues with slowness or with EvetnHandler? –  Mike Honeychurch Feb 7 '13 at 3:07
    
slowness mostly. –  kguler Feb 7 '13 at 4:03

1 Answer 1

up vote 3 down vote accepted

The objective of the question was to clarify whether EventHandler should work with DateListPlot (work arounds were not sought).

Wolfram tech support confirmed that EventHandler does not work with DateListPlot. This is not a bug it is just that this capability is not available for DateListPlot.

share|improve this answer
    
Now that you have explained things in terms simple enough for me to understand, I have deleted my misguided attempt to record an answer. I am pleased, though, that the question is now has an answer. –  m_goldberg Feb 14 '13 at 3:47
    
Mike, why not accept this as a conclusion (as there is no real solution) terminating the issue at hand? –  István Zachar Feb 21 '13 at 9:00
    
ok. I guess it closes it off. –  Mike Honeychurch Feb 21 '13 at 21:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.