asp.net中chart中如何插入table實現混合顯示

來源:互聯網
上載者:User

      什麼都不說,先上一張要實現的

的地址: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來完成,謝謝!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.