彩票走势图

图表控件ChartDirector使用教程:创建不同阴影效果的2D环状图

原创|其它|编辑:郝浩|2012-11-15 10:49:12.000|阅读 819 次

概述:ChartDirector是一种非常强大的图表控件,拥有丰富的图表图形库,本文将通过代码介绍如何在ChartDirector创建出不同阴影效果的2D环状图。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

ChartDirector是一种非常强大的图表控件,拥有丰富的图表图形库,今天来来看看如何在ChartDirector创建出不同阴影效果的2D环状图,如下所示:

如何在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@capbkgr.cn

文章转载自:慧都控件

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP