gpt4 book ai didi

c# - 从柱形图中删除 x 和 y 轴

转载 作者:太空宇宙 更新时间:2023-11-03 19:06:11 24 4
gpt4 key购买 nike

我正在使用 System.Web.UI.DataVisualization.Charting 库在 C# 中生成柱形图。但我想删除 x 和 y 轴。只想要酒吧。我使用以下代码去除网格线

        chart.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
chart.ChartAreas[0].AxisY.MajorGrid.Enabled = false;

如何删除轴线及其值?

        var chart = new Chart
{
Width = 80,
Height = 125,
RenderType = RenderType.ImageTag,
AntiAliasing = AntiAliasingStyles.All,
TextAntiAliasingQuality = TextAntiAliasingQuality.High
};

chart.Titles.Add("50");
chart.Titles.Add("Strongly Disagree");
chart.Titles[0].Font = new Font("Arial", 8f,FontStyle.Bold);
chart.Titles[0].ForeColor = Color.DarkGray;
chart.Titles[1].Font = new Font("Arial", 7f);
chart.Titles[1].ForeColor = Color.DarkGray;

chart.Titles[0].Position.X = 50;
chart.Titles[0].Position.Y = 50;

chart.Titles[1].Position.X = 50;
chart.Titles[1].Position.Y = 90;

chart.ChartAreas.Add("");
chart.ChartAreas[0].AxisX.TitleFont = new Font("Arial", 12f);
chart.ChartAreas[0].AxisY.TitleFont = new Font("Arial", 12f);
chart.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Arial", 10f);
chart.ChartAreas[0].AxisX.LabelStyle.Angle = -90;
chart.ChartAreas[0].BackColor = Color.White;
chart.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
chart.ChartAreas[0].AxisY.MajorGrid.Enabled = false;

chart.Series.Add("");
chart.Series[0].ChartType = SeriesChartType.Column;

int i = 0;
foreach (var q in myOrderList)
{
if (i == 0)
{
chart.Series[0].Points.AddXY("", Convert.ToDouble(q.NumberOfOrders));
chart.Series[0].Points[0].Color = Color.Orchid;
}
else
{
chart.Series[0].Points.AddXY("", Convert.ToDouble(q.NumberOfOrders));
chart.Series[0].Points[1].Color = Color.DarkViolet;
}
i++;
}
using (var chartimage = new MemoryStream())
{
chart.SaveImage(chartimage, ChartImageFormat.Png);
return chartimage.GetBuffer();
}

最佳答案

我找到了解决方案..

        chart.ChartAreas[0].AxisX.MinorGrid.Enabled = false;
chart.ChartAreas[0].AxisX.MajorTickMark.Enabled = false;
chart.ChartAreas[0].AxisX.MinorTickMark.Enabled = false;
chart.ChartAreas[0].AxisX.Interval = 0;

chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
chart.ChartAreas[0].AxisY.LabelStyle.Enabled = false;

chart.ChartAreas[0].AxisY.MajorTickMark.Enabled = false;
chart.ChartAreas[0].AxisY.MinorTickMark.Enabled = false;

chart.ChartAreas[0].AxisX.LineWidth = 0;
chart.ChartAreas[0].AxisY.LineWidth = 0;

关于c# - 从柱形图中删除 x 和 y 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27226424/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com