5
我正在使用微软的Chart控件来绘制一些系列,但是如果我没有数据,我想在该图的区域显示“No Data Series”。如何将文本绘制到空的MS Chart ChartArea上?
像这样:
我有事情做与手动绘制一些文字到图像的预感,但我不知道从哪里开始。任何人?
我正在使用微软的Chart控件来绘制一些系列,但是如果我没有数据,我想在该图的区域显示“No Data Series”。如何将文本绘制到空的MS Chart ChartArea上?
像这样:
我有事情做与手动绘制一些文字到图像的预感,但我不知道从哪里开始。任何人?
您可以创建一个油漆后的事件处理程序,在那里你可以画你的东西:
mychart.PostPaint += new EventHandler<ChartPaintEventArgs>(PostPaintEventHandler);
...
static void PostPaintEventHandler(object sender, ChartPaintEventArgs e)
{
//sender here is the chart... you can use that too.
//use e.ChartGraphics object to paint something
e.ChartGraphics.DrawString(...);
}
使用免费ILSpy看的MSChart的DLL内。 Graphics.DrawString方法有几个重载。使用最适合你的那个。
希望这会有所帮助。
看看这个答案。 http://stackoverflow.com/questions/14051948/how-to-display-error-message-into-chart-in-asp-chart-controls – Stuart 2016-11-28 12:27:38