import plotly
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import xlrd
loc = (r'C:\Users\matmadas\Documents\newreport.xlsx')
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 0)
lables = ['Expected Closing Stock', 'Actual Closing Stock']
text = ['Expected', 'Actual']
expected = []
actual = []
Ivariance = []
Evariance = []
for i in range(sheet.nrows):
expected.append(sheet.cell_value(i, 4))
for i in range(sheet.nrows):
actual.append(sheet.cell_value(i, 5))
expected.remove(expected[0])
exp = [float(i) for i in expected[:]]
actual.remove(actual[0])
act = [float(i) for i in actual[:]]
act1 = [expected[0], actual[0]]
exp1 = [expected[1], actual[1]]
for i in range(sheet.nrows):
Ivariance.append(sheet.cell_value(i, 6))
for i in range(sheet.nrows):
Evariance.append(sheet.cell_value(i, 7))
Ivariance.remove(Ivariance[0])
Ivar = [float(i) for i in Ivariance[:]]
Evariance.remove(Evariance[0])
Evar = [float(i) for i in Evariance[:]]
var1 = [Ivar[0], Evar[0]]
var2 = [Ivar[1], Evar[1]]
vartext1 = ['%' + str(i) for i in var1]
vartext2 = ['%' + str(i) for i in var2]
colo = ['green', 'violet']
lal = ['Initial Variance', 'Ending Variance']
fig = make_subplots(rows=2, cols=2,specs=[[{'type': 'domain'}, {'type': 'domain'}], [{'type': 'domain'}, {'type': 'domain'}]])
fig.add_trace(go.Pie(labels=lables, values=act1, name="Class 1", title='Expected Vs Actual Closing Stock 1', texttemplate ="%{value:$,s}", textposition ="inside", pull=[0, 0.03]), 1, 1)
fig.add_trace(go.Pie(labels=lables, values=exp1, name="Class 2", title='Expected Vs Actual Closing Stock 2', texttemplate ="%{value:$,s}", textposition = "inside", pull=[0, 0.03]), 1, 2)
fig.add_trace(go.Pie(labels=lal, values=var1, name="Variance 1", title='Variance Change 1', texttemplate =vartext1, textposition = "inside", pull=[0, 0.03]), 2, 1)
fig.add_trace(go.Pie(labels=lal, values=var2, name="Variance 2", texttemplate = vartext2, title ='Variance Change 2', textposition = "inside", pull=[0, 0.03]), 2, 2)
Class1 = [dict(
values=act1,
)]
Class2 = [dict(
values=exp1)]
fig.update_layout(
updatemenus=[
dict(
active=0,
buttons=list([
dict(label="Class1",
method="update",
args=[{"visible": [True, False]},
{"title": "Class1",
"annotations": Class1}]),
dict(label="Class2",
method="update",
args=[{"visible": [False, True]},
{"title": "Class2",
"annotations": Class2}]),
]),
)
])
fig.update_layout(height=600, title_text='Dashboard', showlegend=True)
plotly.offline.plot(fig, filename='march.html')
# fig.show()
Hi @MathiazhaganMs welcome to the forum! Could you explain what the issue is exactly? We cannot reproduce your figure without access to your local files. It would help to attach a screenshot of the figure and explain what goes wrong.