ZedGraph图形控件来生成图片,有很多东西需要继续研究。

Imports ZedGraph
Imports System.Drawing

Public Class graph
    Inherits System.Web.UI.Page

    Dim ls_projid As String = ""

    Protected Sub ZedGraphWeb2_RenderGraph(ByVal z As ZedGraph.Web.ZedGraphWeb, _
                ByVal g As System.Drawing.Graphics, _
                ByVal masterPane As ZedGraph.MasterPane) Handles ZedGraphWeb2.RenderGraph

        ' Get the GraphPane so we can work with it
        Dim myPane As GraphPane = masterPane(0)

        ' Set the titles and axis labels
        myPane.Title.Text = "项目进度报表"
        myPane.XAxis.Title.Text = "日期"
        myPane.YAxis.Title.Text = "进度"
        '进度条0 - 100
        myPane.YAxis.Scale.Min = 0
        myPane.YAxis.Scale.Max = 100
        'myPane.YAxis.Scale.MinGrace = 0.2
        'myPane.YAxis.Scale.MaxGrace = 0.2
        'myPane.Y2Axis.Scale.MinGrace = 0.2
        'myPane.Y2Axis.Scale.MaxGrace = 0.2

        ' Make up some data points from the Sine function
        Dim list As New PointPairList()
        Dim list2 As New PointPairList()

        Dim i As Integer, x As Double, y As Double, y2 As Double

        Dim d As Date

        '取得对应的ID号
        Dim ds As DataSet
        ds = Config.GetDs("select AchieveDate,TargetProgress,FactProgress from tbl_projectprogress where Id_InProject='" & ls_projid & "' order by AchieveDate")
        If ds.Tables(0).Rows.Count > 0 Then
            For i = 0 To ds.Tables(0).Rows.Count - 1
                d = ds.Tables(0).Rows(i)("AchieveDate")
                x = New XDate(d)
                y = ds.Tables(0).Rows(i)("TargetProgress")
                y2 = ds.Tables(0).Rows(i)("FactProgress")
                list.Add(x, y)
                list2.Add(x, y2)
            Next i
        End If


        'd = "2008-3-2"
        'x = New XDate(d)
        'y = 10
        'y2 = 5
        'list.Add(x, y)
        'list2.Add(x, y2)


        'For i = 0 To 35
        '    x = New XDate(1995, i + 1, 1)
        '    y = Math.Sin(i * Math.PI / 15.0)
        '    y2 = 2 * y

        '    list.Add(x, y)
        '    list2.Add(x, y2)
        'Next i

        ' Generate a blue curve with circle symbols, and "My Curve 2" in the legend
        Dim myCurve2 As LineItem = myPane.AddCurve("目标进度", list, Color.Blue, _
                                SymbolType.Circle)
        ' Fill the area under the curve with a white-red gradient at 45 degrees
        'myCurve2.Line.Fill = New Fill(Color.White, Color.Red, 45.0F)

        ' Make the symbols opaque by filling them with white
        myCurve2.Symbol.Fill = New Fill(Color.White)

        ' Generate a red curve with diamond symbols, and "My Curve" in the legend
        Dim myCurve As LineItem = myPane.AddCurve("实际进度", _
            list2, Color.MediumVioletRed, SymbolType.Diamond)

        ' Fill the area under the curve with a white-green gradient
        'myCurve.Line.Fill = New Fill(Color.White, Color.Green)

        ' Make the symbols opaque by filling them with white
        myCurve.Symbol.Fill = New Fill(Color.White)

        ' Set the XAxis to date type
        myPane.XAxis.Type = AxisType.Date
        myPane.XAxis.CrossAuto = True

        ' Fill the axis background with a color gradient
        myPane.Chart.Fill = New Fill(Color.White, Color.LightGoldenrodYellow, 45.0F)
        masterPane.AxisChange(g)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim sqlstr As String
            Dim ds As DataSet
            Dim i As Integer
            sqlstr = "select id,itemdes from dbo.tbl_project where parentid='0' and status='1'"
            ds = Config.GetDs(sqlstr)

            drpProject.Items.Add("请选择")
            drpProject.Items(0).Value = ""

            If ds.Tables(0).Rows.Count > 0 Then
                For i = 0 To ds.Tables(0).Rows.Count - 1
                    drpProject.Items.Add(ds.Tables(0).Rows(i)("itemdes"))
                    drpProject.Items(i + 1).Value = ds.Tables(0).Rows(i)("id")
                Next i
            End If
        End If
    End Sub

    Protected Sub cmdShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdShow.Click
        ls_projid = drpProject.SelectedValue
    End Sub

End Class

转载于:https://www.cnblogs.com/yqy542006/archive/2008/03/13/1103701.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值