# Time range selector à la InteractiveTradingChart

I have time series data and I would like to interactively select a part of it. This problem is beautifully solved in the lower part of the InteractiveTradingChart command:

I would like to be able to do the same for my own data. Before I reinvent the wheel I would like to know if this is already available somewhere. In case I do have to reinvent it, this is what I have already done:

data=Map[{#,RandomChoice[{.75,.15,.05,.04,.01}->{0,1,2,3,5}]}&,DateRange[{2013,1,1},{2013,12,31}]];

g=DateListPlot[data,Joined->True,Filling->Bottom,AspectRatio->1/10,Frame->None,Axes->{True,True},PlotRange->{0,5},ImageSize->640];

Module[{windowSize=QuantityMagnitude@UnitConvert[Quantity[3,"Month"],"Second"]},
Grid[
{{Dynamic@Show[g,
Epilog->{EdgeForm[Gray], FaceForm[Cyan], Opacity[0.5],
Rectangle[{x-windowSize/2, 0},
{x+windowSize/2, Max[Last/@data]}],
FaceForm[LightGray], Opacity[1],
Rectangle[{x-1.05windowSize/2, .25Max[Last/@data]},
{x-0.95windowSize/2, .75Max[Last/@data]}],
Rectangle[{x+0.95windowSize/2, .25Max[Last/@data]},
{x+1.05windowSize/2, .75Max[Last/@data]}]
}]},
{Slider[Dynamic[x],
{AbsoluteTime[{2013,1,1}], AbsoluteTime[{2013,12,31}]},
Appearance->"UpArrow", ImageSize->640]}}]]


-
I think "Second" needs to become "Seconds" for the UnitConvert to work. –  Jagra Mar 15 '13 at 13:37
This will take someone sometime to develop a solution. I think any of us will get there faster if we have more specifics about what you want to do. Your supplied code gives a nice window on the data that moves with the slider. It looks like you may want to adjust the size of this window and then link this complex control to the display of another set of data, essentially zooming in and out on the data. I like this idea a lot and have implemented some similar things. Let's make certain about what you want from your question. Please clarify the question before anyone heads down a wrong path. –  Jagra Mar 15 '13 at 13:45
Mike Honeychurch has an interesting blog post about this. –  Leonid Shifrin Mar 15 '13 at 13:52
@LeonidShifrin - Mike's blog post looks more than interesting! He nails it. Now if Mr. Wizard took up the challenge he might just render the entire code in 27 characters, but short of that Mike deserves credit for the answer ;-)> –  Jagra Mar 15 '13 at 14:50
@LeonidShifrin Thank you. This is what I needed. –  Gustavo Delfino Mar 15 '13 at 16:10