8
$\begingroup$

I am trying to use TradingChart to display some intra day data (60 s. resolution). Is there a way to modify the time displayed when moving the mouse over the data. The default setting (see top left of the chart) is to show O,H,L,C and the date without the hours, minutes and seconds. Is there a way to modify this display to include hours, minutes and seconds ? Explicitly, consider the following code:

data = {{{2015, 6, 15, 10, 51, 0.`}, {53.19`, 53.19`, 53.19`, 53.19`, 
100}}, {{2015, 6, 15, 12, 19, 0.`}, {53.3`, 53.33`, 53.3`, 53.32`,
 1200}}, {{2015, 6, 15, 13, 49, 0.`}, {53.22`, 53.24`, 53.2`, 
53.2`, 3800}}, {{2015, 6, 15, 15, 14, 0.`}, {53.395`, 53.41`, 
53.395`, 53.405`, 3500}}, {{2015, 6, 16, 10, 6, 0.`}, {53.08`, 
53.09`, 53.07`, 53.07`, 2000}}, {{2015, 6, 16, 11, 31, 
0.`}, {53.2`, 53.21`, 53.2`, 53.21`, 800}}, {{2015, 6, 16, 13, 5, 
0.`}, {53.24`, 53.26`, 53.24`, 53.26`, 1500}}, {{2015, 6, 16, 14, 
36, 0.`}, {53.26`, 53.27`, 53.26`, 53.27`, 1400}}}
TradingChart[data]

The output looks something like:enter image description here

As you can see at the top of chart, the time displayed is only for the day and does not include the time (hours,min,sec). Is there an easy command which would change this date display to include the time of the day as specified in the data ?

$\endgroup$
1
  • 1
    $\begingroup$ Please include an example of code and data that represents your problem. $\endgroup$
    – MarcoB
    Commented Jun 17, 2015 at 4:17

2 Answers 2

6
$\begingroup$

Update: In version 11.3.0 and version 12.2.0 the the following replacement rule works:

TradingChart[data, ImageSize -> Large] /. 
 {Rule[_, _String?Internal`PossibleDateQ] ..} :> 
  MapIndexed[#2[[1]] -> DateString[#[[1]]] &, data] 

enter image description here

Original answer:

Post-process TradingChart output to modify the date legend:

TradingChart[data] /. Dispatch[System`TradingChartDump`$visdates]:> 
   Dispatch[MapIndexed[#2[[1]] -> DateString[#[[1]]] &, data]]

enter image description here

In version 9, you can use

TradingChart[data] /. Dispatch[{(_ -> _String) ..}, ___] :> 
   Dispatch[MapIndexed[#2[[1]] -> DateString[#[[1]]] &, data]]
$\endgroup$
5
  • $\begingroup$ Hi, thanks for the reply. So I just checked your code and can't reproduce the same behavior. What is your Mathematica version ? $\endgroup$ Commented Nov 25, 2017 at 19:26
  • $\begingroup$ @VanillaSpinIce, i am using version 9. $\endgroup$
    – kglr
    Commented Nov 25, 2017 at 19:30
  • $\begingroup$ So for version 11, your code doesn't change the output I showed in my question. $\endgroup$ Commented Nov 26, 2017 at 16:04
  • $\begingroup$ @VanillaSpinIce, can you check if TradingChart[data] /. Dispatch[System`TradingChartDump`$visdates]:> Dispatch[MapIndexed[#2[[1]] -> DateString[#[[1]]] &, data]] works in version 11? $\endgroup$
    – kglr
    Commented Nov 26, 2017 at 16:27
  • $\begingroup$ Great it worked ! If you want to add it to your answer above, I will accept it. $\endgroup$ Commented Dec 1, 2017 at 6:01
2
$\begingroup$

Most likely this is not possible. But you can use tooltips on the chart:

TradingChart[Tooltip[#, DateString@#[[1]]] & /@ data]

I hope it will still be helpful to you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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