【问题标题】:Microsoft chart control failing to set background transparent微软图表控件无法设置背景透明
【发布时间】:2011-10-19 20:43:36
【问题描述】:

我有一个微软饼图控件。我将背景设置为透明,但它保持白色。如您所见,我已经设置了 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;

【问题讨论】:

标签: c# mschart


【解决方案1】:

我没有看到这条线:

chart.BackColor = Color.Transparent;

【讨论】:

  • 非常感谢。对于其他人,我还必须禁用折线图。BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
【解决方案2】:

图表的颜色、图表的区域、图例等...单独设置。 并记住添加:

chart.TextAntiAliasingQuality = TextAntiAliasingQuality.SystemDefault;

当你将图表的背景设置为透明时,你会得到糟糕的低质量字体。

【讨论】:

    【解决方案3】:

    我需要这两行:

    chart.BackColor = Color.Transparent;
    chart.ChartAreas[0].BackColor = Color.Transparent;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-25
      • 1970-01-01
      • 2018-12-25
      • 2016-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多