以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]甘特图的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=135097)

--  作者:81538475
--  发布时间:2019/5/16 19:00:00
--  [求助]甘特图的问题

我在这个甘特图上增加了一个实际开始时间,我如何在甘特图的相应日期位置标注成绿色呢。

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:编码绘制甘特图 (1) (1).table


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20190516185841.jpg
图片点击可在新窗口打开查看


--  作者:有点甜
--  发布时间:2019/5/16 19:20:00
--  

static dic As new Dictionary(of String, brush)
If DrawGannt Then
    Dim cr As Row  = Tables("任务").Rows(e.Row.Index)
    For Each r As DataRow In cr.Table.DataTable.Select("工程名称 = \'" & cr("工程名称") & "\'", "开始日期")
        Dim dt1 As Date = r("开始日期")
        Dim dt3 As Date = r("实际开始")
        Dim dt2 As Date = r("结束日期")
        Dim dt As Date = e.Col.Name.Replace("年","-").Replace("月_","-")
       
        If dt = dt1 Then
            e.StartDraw()
            If dic.ContainsKey(dt) = False Then
                Dim br1 As Brush = New SolidBrush(Color.FromARGB(rand.Next(255),rand.Next(255),rand.Next(255),rand.Next(255)))
                dic.add(dt, br1)
            End If
            Dim sp1 As TimeSpan = dt3-dt1
            Dim sp2 As TimeSpan = dt2-dt3
            Dim sp3 As TimeSpan = dt2-dt1
            e.Graphics.FillRectangle(dic(dt),e.x ,e.y + 5, cint(e.Width*sp1.TotalDays/sp3.TotalDays), e.Height - 10)
           
            If dt3 <> Nothing Then
                Dim br2 As Brush = New SolidBrush(Color.green)
                e.Graphics.FillRectangle(br2,e.x+cint(e.Width*sp1.TotalDays/sp3.TotalDays) ,e.y + 5, cint(e.Width*sp2.TotalDays/sp3.TotalDays), e.Height - 10)
            End If
            Dim fnt As New Font("宋体",9)
            Dim msg As String = r("任务名称")
            e.Graphics.DrawString(msg,fnt,Brushes.Red,e.x,e.y+2)
            e.EndDraw()           
        End If
    Next
End If


--  作者:81538475
--  发布时间:2019/5/17 9:09:00
--  

有两个问题麻烦帮忙看看把

1.是希望在实际开始的那一天的颜色改变成绿色,而不是这整个后面都绿了。

2.其他的甘特图显示不出来了。

 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20190517090656.jpg
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2019/5/17 9:35:00
--  
static dic As new Dictionary(of String, brush)
If DrawGannt Then
    Dim cr As Row  = Tables("任务").Rows(e.Row.Index)
    For Each r As DataRow In cr.Table.DataTable.Select("工程名称 = \'" & cr("工程名称") & "\'", "开始日期")
        Dim dt1 As Date = r("开始日期")
        Dim dt3 As Date = r("实际开始")
        Dim dt2 As Date = r("结束日期")
        Dim dt As Date = e.Col.Name.Replace("年","-").Replace("月_","-")
       
        If dt = dt1 Then
            e.StartDraw()
            If dic.ContainsKey(dt) = False Then
                Dim br1 As Brush = New SolidBrush(Color.FromARGB(rand.Next(255),rand.Next(255),rand.Next(255),rand.Next(255)))
                dic.add(dt, br1)
            End If
            Dim sp1 As TimeSpan = dt3-dt1
            Dim sp2 As TimeSpan = dt2-dt3
            Dim sp3 As TimeSpan = dt2-dt1
            e.Graphics.FillRectangle(dic(dt),e.x ,e.y + 5, e.Width,e.Height - 10)
           
            If dt3 <> Nothing Then
                Dim br2 As Brush = New SolidBrush(Color.green)
                e.Graphics.FillRectangle(br2,e.x+cint(e.Width*sp1.TotalDays/sp3.TotalDays) ,e.y + 5, cint(Math.Ceiling(e.Width/sp3.TotalDays)), e.Height - 10)
            End If
            Dim fnt As New Font("宋体",9)
            Dim msg As String = r("任务名称")
            e.Graphics.DrawString(msg,fnt,Brushes.Red,e.x,e.y+2)
            e.EndDraw()           
        End If
    Next
End If

--  作者:81538475
--  发布时间:2019/5/17 9:35:00
--  
搞好了。图片点击可在新窗口打开查看