【问题标题】:ASP.Net MS Chart Control Pie Chart: remove unwanted paddingASP.Net MS Chart 控制饼图:删除不需要的填充
【发布时间】:2010-06-07 10:50:00
【问题描述】:

我正在尝试使用 MS Chart 控件创建简单的饼图。当我的饼图在浏览器中呈现时,我在饼图周围填充了我无法摆脱的填充物。我希望饼图靠在图像的边缘,没有填充或边距。关于我如何实现这一目标的任何想法?

在我下面的代码中,填充以蓝色突出显示。即 Chart1.BackColor = System.Drawing.Color.Blue;

 <script type="text/C#" runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            //Set the chart type
            Chart1.Series["Series1"].ChartType = SeriesChartType.Pie;

            //add points
            Chart1.Series["Series1"].Points.AddY(12);
            Chart1.Series["Series1"].Points.AddY(45);
            Chart1.Series["Series1"].Points.AddY(67);

            //set back color of chart object
            Chart1.BackColor = System.Drawing.Color.Blue;

            //set back color of chart area
            Chart1.ChartAreas["ChartArea1"].BackColor = System.Drawing.Color.Green;

        }
    </script>

    <asp:Chart ID="Chart1" runat="server">
        <Series>
            <asp:Series Name="Series1" ChartType="Pie">
            </asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1">
            </asp:ChartArea>
        </ChartAreas>
    </asp:Chart>

【问题讨论】:

  • 不抱歉,我什么都没找到

标签: c# asp.net mschart pie-chart


【解决方案1】:

我对饼图不是特别熟悉,但对于折线图,需要在 ChartArea 内设置位置:

<ChartArea Name="ChartArea1" BackColor="Transparent" BorderWidth="0" >
      <AxisX LineWidth="0" IsMarginVisible="False">
      </AxisX>
      <Position Height="100" Width="100" X="0" Y="0" />
    </ChartArea>

这将图表区域设置为从左上角开始,我相信并占据图表的整个区域(100%)。然后你需要IsMarginVisible = false来防止左右边距。希望这对你有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-12
    • 2019-11-17
    • 1970-01-01
    • 1970-01-01
    • 2018-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多