Dict.CN 在线词典, 英语学习, 在线翻译

asp.net中chart中如何插入table实现混合显示

      什么都不说,先上一张要实现的效果图

效果图的地址:http://demos.telerik.com/aspnet-ajax/chart/examples/functionality/datatable/defaultcs.aspx

需要另外引用DLL才能实现!

但是在微软的demo中,实现的效果图如下:

在下方的table中的第一列,显示的是颜色,而我要的是名称:

修改前代码:

e.ChartGraphics.Graphics.FillRectangle(new SolidBrush(ser.Color),
                                            x - 10, row * (axisFont.Height) + (point1.Y), 10, axisFontSize.Height);
e.ChartGraphics.Graphics.DrawRectangle(new Pen(borderColor),
                                            x - 10, row * (axisFont.Height) + (point1.Y), 10, axisFontSize.Height);

修改后的代码:

//设置名称
Brush blackBrush = new SolidBrush(Color.White);
RectangleF textArea = new RectangleF(x - 80, row * (axisFont.Height) + (point1.Y),80, axisFontSize.Height);                                      

//设置表格
e.ChartGraphics.Graphics.DrawRectangle(new Pen(borderColor), x - 80, row * (axisFont.Height) + (point1.Y),
                                            80, axisFontSize.Height);
e.ChartGraphics.Graphics.DrawString(ser.LegendText, new Font("宋体", 12), new SolidBrush(Color.Black), textArea);  

实现的效果图如下:

效果不是很理想,毕竟还是显示出来了,另外一个问题就是:上方图形与下方table之间的间隔太宽了,如果哪位朋友在微软的chart demo示例中能修改成图一的效果,请指导下,如何修改ChartDataTableHelper.cs来完成,谢谢!

posted @ 2012-05-12 22:31  伊牛娃  阅读(1681)  评论(2编辑  收藏  举报