原創|其它|編輯:郝浩|2012-11-15 10:49:12.000|閱讀 868 次
概述:ChartDirector是一種非常強大的圖表控件,擁有豐富的圖表圖形庫,本文將通過代碼介紹如何在ChartDirector創建出不同陰影效果的2D環狀圖。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
ChartDirector是一種非常強大的圖表控件,擁有豐富的圖表圖形庫,今天來來看看如何在ChartDirector創建出不同陰影效果的2D環狀圖,如下所示:
所用的源代碼如下:
ASP:
<%@ language="vbscript" %> <% Set cd = CreateObject("ChartDirector.API") ' The data for the pie chart data = Array(18, 30, 20, 15) ' The colors to use for the sectors colors = Array(&H66aaee, &Heebb22, &Hbbbbbb, &H8844ff) ' Create a PieChart object of size 200 x 220 pixels. Use a vertical gradient color ' from blue (0000cc) to deep blue (000044) as background. Use rounded corners of 16 ' pixels radius. Set c = cd.PieChart(200, 220) Call c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), &H0000cc, _ &H000044)) Call c.setRoundedFrame(&Hffffff, 16) ' Set donut center at (100, 120), and outer/inner radii as 80/40 pixels Call c.setDonutSize(100, 120, 80, 40) ' Set the pie data Call c.setData(data) ' Set the sector colors Call c.setColors2(cd.DataColor, colors) ' Demonstrates various shading modes If Request("img") = "0" Then Call c.addTitle("Default Shading", "bold", 12, &Hffffff) ElseIf Request("img") = "1" Then Call c.addTitle("Local Gradient", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.LocalGradientShading) ElseIf Request("img") = "2" Then Call c.addTitle("Global Gradient", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.GlobalGradientShading) ElseIf Request("img") = "3" Then Call c.addTitle("Concave Shading", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.ConcaveShading) ElseIf Request("img") = "4" Then Call c.addTitle("Rounded Edge", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.RoundedEdgeShading) ElseIf Request("img") = "5" Then Call c.addTitle("Radial Gradient", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.RadialShading) ElseIf Request("img") = "6" Then Call c.addTitle("Ring Shading", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.RingShading) End If ' Disable the sector labels by setting the color to Transparent Call c.setLabelStyle("", 8, cd.Transparent) ' Output the chart Response.ContentType = "image/png" Response.BinaryWrite c.makeChart2(cd.PNG) Response.End %>
VB:
Public Sub createChart(viewer As Object, img As String) Dim cd As New ChartDirector.API ' The data for the pie chart Dim data() data = Array(18, 30, 20, 15) ' The labels for the pie chart Dim labels() labels = Array("Labor", "Licenses", "Facilities", "Production") ' The colors to use for the sectors Dim colors() colors = Array(&H66aaee, &Heebb22, &Hbbbbbb, &H8844ff) ' Create a PieChart object of size 200 x 220 pixels. Use a vertical gradient ' color from blue (0000cc) to deep blue (000044) as background. Use rounded ' corners of 16 pixels radius. Dim c As PieChart Set c = cd.PieChart(200, 220) Call c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), &H0000cc, _ &H000044)) Call c.setRoundedFrame(&Hffffff, 16) ' Set donut center at (100, 120), and outer/inner radii as 80/40 pixels Call c.setDonutSize(100, 120, 80, 40) ' Set the pie data Call c.setData(data, labels) ' Set the sector colors Call c.setColors2(cd.DataColor, colors) ' Demonstrates various shading modes If img = "0" Then Call c.addTitle("Default Shading", "bold", 12, &Hffffff) ElseIf img = "1" Then Call c.addTitle("Local Gradient", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.LocalGradientShading) ElseIf img = "2" Then Call c.addTitle("Global Gradient", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.GlobalGradientShading) ElseIf img = "3" Then Call c.addTitle("Concave Shading", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.ConcaveShading) ElseIf img = "4" Then Call c.addTitle("Rounded Edge", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.RoundedEdgeShading) ElseIf img = "5" Then Call c.addTitle("Radial Gradient", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.RadialShading) ElseIf img = "6" Then Call c.addTitle("Ring Shading", "bold", 12, &Hffffff) Call c.setSectorStyle(cd.RingShading) End If ' Disable the sector labels by setting the color to Transparent Call c.setLabelStyle("", 8, cd.Transparent) ' Output the chart Set viewer.Picture = c.makePicture() 'include tool tip for the chart viewer.ImageMap = c.getHTMLImageMap("clickable", "", _ "title='{label}: US${value}K ({percent}%)'") End Sub
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件