2
$\begingroup$

It is possible to modify TradingChart such that instead of just the date, date and time are displayed for a selected data point. Is there a "trick" that works as well for InteractiveTradingChart?

$\endgroup$

1 Answer 1

2
$\begingroup$
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}}};

itc = InteractiveTradingChart[data]

enter image description here

We can post-process itc to replace the default date string with one that includes "Hour" and "Minute":

Replace[First @ itc, HoldPattern @ DateString[a_, _] :> DateString[a,
  {"DayNameShort", ". ", "MonthNameShort", " ", "Day", ", ", "Year", 
    " ", "Hour", ":", "Minute"}], All]

enter image description here

$Version
"11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)"
$\endgroup$
4
  • $\begingroup$ Thank you. It's interesting to see how FullForm[itc] differs from FullForm[First@itc] in the sense that the latter reveals more about the internal structure. $\endgroup$ Commented Jan 4, 2021 at 19:07
  • $\begingroup$ Just a minor remark: ImageSize -> Large does not have any effect, i.e., ImageSize -> Small or having no ImageSize option set instead results in the same image size. However, setting ImageSize to a specific value does work. This is of course completely irrelevant for the actual question. $\endgroup$ Commented Jan 4, 2021 at 19:14
  • $\begingroup$ Another very minor comment is that HoldPattern@DateString[a_, _] :> ... avoids the use of Quiet. $\endgroup$ Commented Jan 4, 2021 at 19:31
  • 1
    $\begingroup$ @MathGaudium, I updated with the cleaner version per your comments. Thank you for the accept. $\endgroup$
    – kglr
    Commented Jan 5, 2021 at 0:32

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.