我的程序中填充了变量,在最后一个表格中,我试图显示一个饼图,显示每笔费用相对于总费用的部分。我现在的代码如下:
Sub Chart()
Chart1.Series("Expenses").ChartType = SeriesChartType.Pie
Chart1.Series("Expenses").Points.Add(GlobalVariables.cellphone / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.carinsurance / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.drappointments / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.grocery / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.healthinsurance / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.medications / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.misc / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.rent / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.therapysessions / totalexpenses * 100)
Chart1.Series("Expenses").Points.Add(GlobalVariables.travel / totalexpenses * 100)
'Chart1.Width = 700
Chart1.Legends.Add("Expenses")
Chart1.Legends("Expenses").LegendStyle = LegendStyle.Table
End Sub
当我运行程序并将调用包含在子图表中时,图表根本不显示,图例仍然只显示" Series1。"我究竟做错了什么?我怎样才能做到这一点?
答案 0 :(得分:0)
默认情况下,第一个系列是'Series1',饼图是取这个系列的空白数据。如果要使用自己的系列,则需要删除它。将此代码添加为第1行: Chart1.Series.clear