ASP.Net MS Chart Control 饼图:删除不需要的填充
您好,
我正在尝试使用 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>
HI
im trying to create simple pie chart using the MS Chart controls. When my pie chart gets rendered in the browser i get padding around the pie chart that i cant get rid of. i would like the pie chart to sit up against the edge of the image with no padding or margin. Any ideas on how i can achieve this?
in my code below the padding is highlighted in blue. i.e 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对饼图不是特别熟悉,但对于折线图,需要在 ChartArea 内设置位置:
我相信这将图表区域设置为从左上角开始并占据图表的整个区域(100%)。那么就需要
IsMarginVisible = false
来防止左右边距。希望这对你有用。I'm not specifically familiar with the Pie chart, but for a line chart the Position needs to be set within the ChartArea:
That sets the chart area to start at the top left corner, I believe and take up the entire area of the chart (100% of it). Then you need
IsMarginVisible = false
to prevent the margin on the left and the right. Hopefully that will work for you.