我想用这个库创建一个图表,我创建了一个图表,但文本是像素化的,所以感觉非常难看。
我将此图表传递到带有iText Sharp的PDF文件以创建报告。
以下是代码:
private static byte[] ObtenerBarraDoble(IList<ValorBarraDTO> valores)
{
var newColor1 = Color.FromArgb(187, 189, 191);
var newColor2 = Color.FromArgb(0, 138, 209);
using (var graficoPie = new Chart { Height = 200, Width = 600, RenderType = RenderType.BinaryStreaming })
{
var chartAreaPie = new ChartArea();
chartAreaPie.AxisX.LabelStyle.Format = "dd/MMM\nhh:mm";
chartAreaPie.AxisX.MajorGrid.LineColor = Color.White;
chartAreaPie.AxisY.MajorGrid.LineColor = Color.White;
chartAreaPie.AxisX.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 2);
chartAreaPie.AxisY.LabelStyle.Font = new System.Drawing.Font("Trebuchet MS", 2);
graficoPie.ChartAreas.Add(chartAreaPie);
var serieNuevo = new Series("Cartera Actual")
{
ChartType = SeriesChartType.Column,
XValueMember = "label",
YValueMembers = "valor1",
Color = newColor1,
Legend = "Cartera Actual",
IsValueShownAsLabel = true,
};
graficoPie.Series.Add(serieNuevo);
var serie = new Series("Cartera Recomendada")
{
ChartType = SeriesChartType.Column,
XValueMember = "label",
YValueMembers = "valor2",
Color = newColor2,
Legend = "Cartera Propuesta",
IsValueShownAsLabel =true,
};
graficoPie.Series.Add(serie);
graficoPie.DataSource = valores;
return PdfHelper.ChartABinario(graficoPie);
}
}
这是ChartABinario方法:
internal static byte[] ChartABinario(Chart graficoPie)
{
using (var ms = new MemoryStream())
{
graficoPie.SaveImage(ms, ChartImageFormat.Png);
byte[] retorno = ms.ToArray();
return retorno;
}
}
这会创建图表并且显示得很好,但文字很糟糕。如果文本没有显示像素化字母,我该怎么办?