gpt4 book ai didi

transparency - 微软图表 : transparency

转载 作者:行者123 更新时间:2023-12-04 18:51:51 26 4
gpt4 key购买 nike

我想要一个具有透明背景的图表,因此 PNG 似乎是一个不错的选择。但是当我设置透明背景时,轴标签的质量急剧下降。我该如何解决?请参阅以下代码。就目前而言,图表具有透明背景,正如我所希望的,但文本质量很差。如果我注释掉两个“Color.Transparent”设置,那么文本质量很好,但背景不透明。

我如何获得透明度和漂亮的文字?

public static void Main(string[] args)
{
Chart c = new Chart();
c.TextAntiAliasingQuality = TextAntiAliasingQuality.High;

Series s = new Series("Series1");
c.Series.Clear();
c.Series.Add(s);
s.ChartType = SeriesChartType.Line;

s.Color = Color.Black;

ChartArea chartArea = new ChartArea("ChartArea1");
c.ChartAreas.Clear();
c.ChartAreas.Add(chartArea);

chartArea.BackColor = Color.FromArgb(255, 255, 255);
chartArea.BackSecondaryColor = Color.FromArgb(220, 220, 220);
chartArea.BackGradientStyle = GradientStyle.TopBottom;

chartArea.AxisX.LineColor = Color.Gray;
chartArea.AxisX.LineWidth = 2;
chartArea.AxisX.LineDashStyle = ChartDashStyle.Solid;

chartArea.AxisY.LineColor = Color.Gray;
chartArea.AxisY.LineWidth = 2;
chartArea.AxisY.LineDashStyle = ChartDashStyle.Solid;

chartArea.AxisX.MajorGrid.LineColor = Color.LightGray;
chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;

chartArea.AxisY.MajorGrid.LineColor = Color.LightGray;
chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;

c.BackColor = Color.Transparent;
chartArea.BackColor = Color.Transparent;


double[] x = new double[] { 1999, 2005 };
double[] y = new double[] { 3210, 13456 };

Axis ay = chartArea.AxisY;
ay.Maximum = 13456;
ay.Minimum = 3210;

Axis ax = chartArea.AxisX;
ax.Maximum = 2005;
ax.Minimum = 1999;

for (int i = 0; i < x.Length; i++)
{
double xvalue = x[i];
double yvalue = y[i];
s.Points.AddXY(xvalue, yvalue);
}

// Save chart-image to disk:
c.SaveImage("chartimage.png", ChartImageFormat.Png);
}

最佳答案

设置图表的抗锯齿 AntiAliasingStyles.Graphics 禁用文本上的抗锯齿。

取自 this thread .

关于transparency - 微软图表 : transparency,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5070395/

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