什麼都不說,先上一張要實現的
的地址: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來完成,謝謝!