0

我正在尝试在 VB.NET 中的饼图图例中显示标签名称和百分比。下面是代码。我找不到任何库参考或代码示例来引导我在 VB.NET 中工作的正确方向。除此以外,饼图看起来和工作正常。

任何人都可以帮忙吗?

谢谢

    PieTable.Columns.Add("Status")
    PieTable.Columns.Add("Count")
    PieTable.Rows.Add("Pass", LineCounter - FailCnt - WarningCnt)
    PieTable.Rows.Add("Fail", FailCnt)
    PieTable.Rows.Add("Warning", WarningCnt)

    OverallPieChart.DataSource = PieTable
    OverallPieChart.Width = 250
    OverallPieChart.Height = 100
    OverallPieChart.Series("Series1").XValueMember = "Status"
    OverallPieChart.Series("Series1").YValueMembers = "Count"

    OverallPieChart.EnableViewState = True
    OverallPieChart.Series("Series1").ChartType = SeriesChartType.Pie
    OverallPieChart.ChartAreas("ChartArea1").BackColor = Color.Black
    OverallPieChart.ChartAreas("ChartArea1").Area3DStyle.Enable3D = True
    OverallPieChart.BackColor = Color.Black
    'OverallPieChart.Series(0)("PieLabelStyle") = "Outside (#Percent)"
    OverallPieChart.Series(0).LabelForeColor = Color.Beige
    OverallPieChart.ChartAreas("ChartArea1").InnerPlotPosition.Width = 100%
    OverallPieChart.ChartAreas("ChartArea1").InnerPlotPosition.Height = 100%
    OverallPieChart.Series(0)("PieLineColor") = "Transparent"
    OverallPieChart.Series(0)("LabelsRadialLineSize") = "0.15"
    OverallPieChart.Series(0)("LabelsHorizontalLineSize") = "0.15"
    OverallPieChart.Legends.Add("Legent1")
    OverallPieChart.Legends("Legend1").Enabled = True
    OverallPieChart.Legends("Legend1").Docking = Docking.Right
    OverallPieChart.Legends("Legend1").Alignment = System.Drawing.StringAlignment.Far
    OverallPieChart.Legends("Legend1").BackColor = Color.Black

    OverallPieChart.Series("Series1").IsVisibleInLegend = True
4

2 回答 2

2

这应该这样做:

OverallPieChart.Series(0).Label = "#PERCENT"

或者你可以使用这个:

OverallPieChart.Series(0).Label = "#PERCENT{P0}"

四舍五入到最接近的整数

对于标签和百分比:

OverallPieChart.Series(0)Label = "#VALX" & Environment.NewLine & "#PERCENT{P0}"
于 2012-07-16T23:33:43.073 回答
1

您的代码中有错字

OverallPieChart.Legends.Add("Legent1")

应该

OverallPieChart.Legends.Add("Legend1")
于 2012-05-28T22:34:21.357 回答