Microsoft图表控件无法设置背景透明
我有一个微软饼图控件。我将背景设置为透明,但它保持白色。正如您所看到的,我已经设置了 BorderSkin 的 BackColor 和 PageColor 属性。我还设置了 ChartArea 的 BackColor。这是一些代码。
Chart chart = new Chart
{
Width = 190,
Height = 159,
RenderType = RenderType.BinaryStreaming,
AntiAliasing = AntiAliasingStyles.Graphics,
TextAntiAliasingQuality = TextAntiAliasingQuality.Normal
};
// turn on transparency
chart.BorderSkin.BackColor = Color.Transparent;
chart.BorderSkin.PageColor = Color.Transparent;
chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
chart.ChartAreas.Add("");
chart.ChartAreas[0].AxisX.Interval = 1; // setting this to 1 forces all items to show
chart.ChartAreas[0].AxisX.LabelStyle.Enabled = true;
chart.ChartAreas[0].AxisX.TitleFont = xLabelFont;
chart.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
chart.ChartAreas[0].AxisY.TitleFont = yLabelFont;
chart.ChartAreas[0].AxisY.LabelStyle.IsStaggered = false; // staggers axis label
chart.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Horizontal;
chart.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
chart.ChartAreas[0].AlignmentOrientation = AreaAlignmentOrientations.All;
chart.ChartAreas[0].BackColor = Color.Transparent;
chart.Series.Add("");
chart.Series[0].ChartType = SeriesChartType.Pie;
//chart.Series[0]["PieLabelStyle"] = "Disabled"; // disable labels
chart.Series[0].IsValueShownAsLabel = true; // *** super important to be able to manually set labels show point labels for value ***
chart.ChartAreas[0].Area3DStyle.Enable3D = true;
I have a microsoft pie chart control. I am setting the background transparent, but it is staying white. As you can see I've set the BackColor and PageColor properties of the BorderSkin. I've also set the BackColor of the ChartArea as well. Here's some code.
Chart chart = new Chart
{
Width = 190,
Height = 159,
RenderType = RenderType.BinaryStreaming,
AntiAliasing = AntiAliasingStyles.Graphics,
TextAntiAliasingQuality = TextAntiAliasingQuality.Normal
};
// turn on transparency
chart.BorderSkin.BackColor = Color.Transparent;
chart.BorderSkin.PageColor = Color.Transparent;
chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
chart.ChartAreas.Add("");
chart.ChartAreas[0].AxisX.Interval = 1; // setting this to 1 forces all items to show
chart.ChartAreas[0].AxisX.LabelStyle.Enabled = true;
chart.ChartAreas[0].AxisX.TitleFont = xLabelFont;
chart.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
chart.ChartAreas[0].AxisY.TitleFont = yLabelFont;
chart.ChartAreas[0].AxisY.LabelStyle.IsStaggered = false; // staggers axis label
chart.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Horizontal;
chart.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
chart.ChartAreas[0].AlignmentOrientation = AreaAlignmentOrientations.All;
chart.ChartAreas[0].BackColor = Color.Transparent;
chart.Series.Add("");
chart.Series[0].ChartType = SeriesChartType.Pie;
//chart.Series[0]["PieLabelStyle"] = "Disabled"; // disable labels
chart.Series[0].IsValueShownAsLabel = true; // *** super important to be able to manually set labels show point labels for value ***
chart.ChartAreas[0].Area3DStyle.Enable3D = true;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我没有看到这一行:
I don't see this line:
图表、图表区域、图例等的颜色是单独设置的。
请记住添加:
当您将图表的背景设置为透明时,否则您将得到可怕的低质量字体。
Colors of chart, chart's area(s), legends, etc... are set separately.
And remember add:
when you set the background of the chart to transparent, or you will get terrible low quality fonts.
我需要这两行:
I needed these two lines: