微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – ASP.Net MS图表控制饼图:删除不需要的填充

您好

我试图使用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>

解决方法

我不熟悉饼图,但是对于一个折线图,位置需要在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来防止左侧和右侧的边距.希望这将为您工作.

原文地址:https://www.jb51.cc/csharp/93881.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐