Example:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import plotly.graph_objs as go
import plotly.offline as py
import datetime
n = 20
open = 2 + np.abs(np.random.randn(n))
high = open + 1
low = open - 1
close = open + np.random.randn(n)
df = pd.DataFrame(
{
'open': open,
'high': high,
'low': low,
'close': close
},
index=pd.date_range(
'2010-01-01',
pd.to_datetime('2010-01-01') + datetime.timedelta(days=n - 1)))
hovertext = []
for i in range(len(df.open)):
hovertext.append('Point' + str(i))
trace = go.Candlestick(
x=df.index,
open=df.open,
high=df.high,
low=df.low,
close=df.close,
text=hovertext,
hoverinfo='all')
data = [trace]
py.plot(data, filename='ohlc_custom_hover.html')
However, turning the line trace = go.Candlestick( to trace = go.Ohlc( works just fine.
The plotly version is 2.2.3.
In js: https://codepen.io/etpinard/pen/OvWYNQ?editors=1010
Thanks for the report.
Hmm. Here's another very annoying finance chart bug. Candlestick traces generate box traces. Box traces have a text attribute, but those text values correspond to the box' sample values and are shown only when hovering over box points. In other words, text values do no appear in hover labels over boxes. So there's no way to just push text info the generate box traces like we do for OHLC traces.
It feels like I've been saying this a million times, but really, we should get rid of our transform trace hacks.
Fixed by #2510 - this is working now on master.