以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]有关甘特图 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=173573) |
||||
-- 作者:chh2321 -- 发布时间:2021/12/6 12:44:00 -- [求助]有关甘特图 请教老师: 我在窗口afterload中写了如下代码: Dim r As Row = Tables("表1").Current If r Is Nothing Then MessageBox.Show("没有记录!") Return Else Dim Chart As WinForm.Chart Dim dt As DataTable = DataTables("表1") Dim t As Table = Tables("表1") Dim n As Integer = t.Rows.Count Dim dr1 As DataRow = dt.Find("[编号] = \'" & r("编号") & "\' And [任务] Like \'%开始%\'") If dr1 Is Nothing Then MessageBox.Show("没有开始日期!") Return Else Chart= Forms("窗口1").Controls("Chart1") Chart.ChartType = ChartTypeEnum.Gantt Chart.Inverted = True \'对调X轴和Y轴位置 Chart.AxisY.DateType= True \'Y轴为日期型 Chart.AxisY.AnnoFormatString = "yyyy-MM-dd" \'设置Y轴的标示格式 Chart.AxisY.MinDate = dr1("日期") \'设置Y轴的起始日期 End If If n > 0 Then Chart.AxisY.MaxDate = t.Rows(n-1)("日期") \'设置Y轴的终止日期 Else MessageBox.Show("没有记录!") Forms("窗口1").Close End If Chart.AxisX.GridMajorVisible = False \'隐藏X轴的网格线 With Chart.SeriesList .AddGanttSeries("开始", dr1("日期"), dr1("日期").AddDays(3)) Dim dr20s As List(of DataRow) dr20s = dt.Select("[编号] = \'" & r("编号") & "\' And [任务] Like \'%任务三%\'","日期") For Each dr20 As DataRow In dr20s .AddGanttSeries("任务三", dr20("日期"), dr20("日期").AddDays(3)) Next Dim dr30s As List(of DataRow) dr30s = dt.Select("[编号] = \'" & r("编号") & "\' And [任务] Like \'%任务四%\'","日期") For Each dr30 As DataRow In dr30s .AddGanttSeries("任务四", dr30("日期"), dr30("日期").AddDays(3)) Next End With End If 效果图如下: 但我想要效果是这样的: 请问如何修改代码?
|
||||
-- 作者:有点蓝 -- 发布时间:2021/12/6 13:42:00 --
|
||||
-- 作者:chh2321 -- 发布时间:2021/12/6 13:58:00 -- 谢谢老师! |