Foxtable(狐表)用户栏目专家坐堂 → [求助]甘特图的问题


  共有1782人关注过本帖树形打印复制链接

主题:[求助]甘特图的问题

帅哥哟,离线,有人找我吗?
81538475
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1287 积分:10362 威望:0 精华:1 注册:2018/1/20 12:40:00
[求助]甘特图的问题  发帖心情 Post By:2019/5/16 19:00:00 [只看该作者]

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

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


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


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1287 积分:10362 威望:0 精华:1 注册:2018/1/20 12:40:00
  发帖心情 Post By:2019/5/17 9:09:00 [只看该作者]

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

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

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

 


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

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1287 积分:10362 威望:0 精华:1 注册:2018/1/20 12:40:00
  发帖心情 Post By:2019/5/17 9:35:00 [只看该作者]

搞好了。图片点击可在新窗口打开查看

 回到顶部