InteractiveTradingChart with date and time displayed for selected data

2

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?

Math Gaudium

Posted 2021-01-04T01:45:54.657

Reputation: 55

Answers

2

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)"

kglr

Posted 2021-01-04T01:45:54.657

Reputation: 302 076

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. – Math Gaudium – 2021-01-04T19:07:47.820

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. – Math Gaudium – 2021-01-04T19:14:26.780

Another very minor comment is that HoldPattern@DateString[a_, _] :> ... avoids the use of Quiet. – Math Gaudium – 2021-01-04T19:31:29.647

1@MathGaudium, I updated with the cleaner version per your comments. Thank you for the accept. – kglr – 2021-01-05T00:32:48.690