MVC3 System.Web.UI.DataVisualization.Charting 字体不呈现,但样式呈现
我正在与 .net 4.0 图表控件作斗争,目前我很困惑为什么字体只是拒绝渲染。它显示为几乎无法读取的重叠字符。我确定该字体已安装在我的系统中。
奇怪的是,字体样式会根据设置而变化。![屏幕截图][1]
我也很难发现 Interval 属性,它会删除计数超过 9 的标签,直到 Interval 设置为 1。interval 属性也行为与 System.Web.Helpers.Chart() 控件不同,后者似乎忽略了该设置。瘸!
感谢您的任何帮助。
剃刀代码..
<img src="@Url.Action("ChartSample")" alt="image" />//In Razer
控制器代码...
public ActionResult ChartSample()
{
var chart = new System.Web.UI.DataVisualization.Charting.Chart();
chart.BackColor = Color.Transparent;
chart.Width = Unit.Pixel(250);
chart.Height = Unit.Pixel(2500);
var series = new Series();
series.ChartArea = "ca1";
series.ChartType = SeriesChartType.Bar;
//series.Font = new Font("Verdana", 8.25f, FontStyle.Regular);
var myRandom = new Random();
for (int i = 0; i < 100; i++)
{
var dp = new DataPoint();
dp.AxisLabel = String.Format("{0}-{1}", i, Guid.NewGuid().ToString().Substring(0, 4));
dp.YValues = new double[] { myRandom.Next(5, 100) };
series.Points.Add(dp);
}
chart.Series.Add(series);
var area = new ChartArea("ca1");
area.Area3DStyle.Enable3D = false;
area.AxisX.Interval = 1;
//area.BackColor = Color.Transparent;
//var labelStyle = new LabelStyle();
//labelStyle.Enabled = true;
//labelStyle.Font = new Font("Arial", 3f);
area.AxisX.LabelStyle.Font = new Font("Verdana", 8.25f, FontStyle.Underline);//Why does it recognize the style but not the font!!!???
chart.ChartAreas.Add(area);
using (var ms = new MemoryStream())
{
chart.SaveImage(ms, ChartImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
return File(ms.ToArray(), "image/png", "mychart.png");
}
}
I am battling with the .net 4.0 Chart Controls and am currently stuck on why the font simply refuses to render. It shows as near unreadable overlapping characters. I'm sure the font is installed in my system.
Oddly the font stlye changes in accordance with the setting.![screen shot][1]
I also had a hard time discovering the Interval property where it was removing labels above the count of 9 until Interval was set to 1. The interval property also behaved differently than the System.Web.Helpers.Chart() control which seems to ignore the setting. Lame!
Thanks for any help.
Razor Code..
<img src="@Url.Action("ChartSample")" alt="image" />//In Razer
Controller Code...
public ActionResult ChartSample()
{
var chart = new System.Web.UI.DataVisualization.Charting.Chart();
chart.BackColor = Color.Transparent;
chart.Width = Unit.Pixel(250);
chart.Height = Unit.Pixel(2500);
var series = new Series();
series.ChartArea = "ca1";
series.ChartType = SeriesChartType.Bar;
//series.Font = new Font("Verdana", 8.25f, FontStyle.Regular);
var myRandom = new Random();
for (int i = 0; i < 100; i++)
{
var dp = new DataPoint();
dp.AxisLabel = String.Format("{0}-{1}", i, Guid.NewGuid().ToString().Substring(0, 4));
dp.YValues = new double[] { myRandom.Next(5, 100) };
series.Points.Add(dp);
}
chart.Series.Add(series);
var area = new ChartArea("ca1");
area.Area3DStyle.Enable3D = false;
area.AxisX.Interval = 1;
//area.BackColor = Color.Transparent;
//var labelStyle = new LabelStyle();
//labelStyle.Enabled = true;
//labelStyle.Font = new Font("Arial", 3f);
area.AxisX.LabelStyle.Font = new Font("Verdana", 8.25f, FontStyle.Underline);//Why does it recognize the style but not the font!!!???
chart.ChartAreas.Add(area);
using (var ms = new MemoryStream())
{
chart.SaveImage(ms, ChartImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
return File(ms.ToArray(), "image/png", "mychart.png");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需给图表设置背景颜色,如下所示:
Just give your chart a back color as follows: