以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  显示图列  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=153711)

--  作者:mxl810823
--  发布时间:2020/8/20 10:58:00
--  显示图列
如下图,为什么我的图列每绘图一次就会数值自动增加?可以指定我想要的图列名吗?

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


--  作者:有点蓝
--  发布时间:2020/8/20 11:05:00
--  
贴出完整代码
--  作者:mxl810823
--  发布时间:2020/8/20 11:10:00
--  
If vars("ngdraw") = True Then
    Dim ngxs As String() = {"ngs1","ngs2","ngs3","ngs4","ngs5","ngs6","ngs7","ngs8","ngs9","ngs10"}
    Dim ngxn As Integer = 0
    For Each ngx As String In ngxs
        If e.Form.controls(ngx).checked = True Then
            ngxn = 1
            Exit For
        End If
    Next
    
    Dim y As Integer = val(e.Form.controls("nian").value)
    Dim m As Integer = val(e.Form.controls("yue").value)
    Dim bm As String = ""
    Dim tm As String = ""
    Dim ht As String = ""
    Dim z As Integer = Date.daysinmonth(y,m)
    If e.Form.Controls("TabControl4").SelectedIndex = 0 Then
        bm = "LCD品质月明细统计_nglcm"
        tm = "chnglcm"
        ht = "LCM前段" & y & "年" & m & "月NG前十图表"
        If ngxn = 0 Then
            e.Form.Controls(tm).visible = False
            MessageBox.Show("当前没有选择NG项目,绘图失败")
            
        End If
    ElseIf e.Form.Controls("TabControl4").SelectedIndex = 1 Then
        bm = "LCD品质月明细统计_nglcd"
        tm = "chnglcd"
        ht = "LCD前段" & y & "年" & m & "月NG前十图表"
        If ngxn = 0 Then
            e.Form.Controls(tm).visible = False
            MessageBox.Show("当前没有选择NG项目,绘图失败")
            
        End If
    ElseIf e.Form.Controls("TabControl4").SelectedIndex = 2 Then
        bm = "LCD品质月明细统计_nghz"
        tm = "chnghz"
        ht = "前段汇总" & y & "年" & m & "月NG前十图表"
        If ngxn = 0 Then
            e.Form.Controls(tm).visible = False
            MessageBox.Show("当前没有选择NG项目,绘图失败")
            
        End If
    End If
    
    \'绘图
    Dim Chart  As WinForm.Chart  \'定义一个图表变量
    Dim Series As WinForm.ChartSeries \'定义一个图系变量
    Chart = forms("LCD品质月明细统计").controls(tm) \' 引用窗口中的图表
    Chart.HeaderText = ht
    Chart.ChartType = ChartTypeEnum.XYPlot \'图表类型该为线形
    Dim yz1s As new List(of Double)
    For i As Integer = 0 To 9
        If e.Form.controls(ngxs(i)).checked = True Then
            Dim r As Row = Tables(bm).Rows(i)
            For Each c As Col In Tables(bm).Cols
                If c.name.contains("X月") Then
                    yz1s.add(r(c.name))
                End If
            Next
        End If
    Next
    yz1s.sort
    Chart.AxisY.Min = yz1s(0)-yz1s(0)*0.1   \'指定Y轴的最小值
    Chart.AxisY.Max = yz1s(yz1s.count-1)+yz1s(yz1s.count-1)*0.1 \'指定Y轴的最大值
    Chart.SeriesList.Clear() \'清除图表原来的图系
    Chart.SeriesList2.Clear() \'清除图表原来的图系
    Chart.AxisX.ClearValueLabel
    Chart.Axisy.ClearValueLabel
    For i As Integer = 0 To 9
        If e.Form.controls(ngxs(i)).checked = True Then
            Series = Chart.SeriesList.Add() \'增加一个图系
            Series.Length = z  \'新增图系包括个数据点
            For k As Integer = 0 To z-1
                Series.X(k) = k  \'指定水平坐标
                Series.Y(k) = Tables(bm).Rows(i)(k+5) \'垂直坐标用
                Dim s As String = Format(m,"00") & "/" & Format(k + 1,"00") 
                Chart.AxisX.SetValueLabel(k, s) \'指定字符表示
            Next
        End If
    Next
    Chart.AxisX.AnnoRotation = - 45 \'X轴标示逆时针旋转45度
    Chart.AxisY.Text = "数量"
    \'  Series.DataLabelBackColor = Color.Blue \'蓝底
    \'  Series.DataLabelForeColor = Color.white \'白字
    \'  Series.DataLabelText = "{#YVAL}"
    \' Chart.VisualEffect = True
    Chart.AxisX.AnnoWithLabels = True \'启用字符标示
    Chart.LegendVisible = True \'显示图列
    Chart.LegendCompass= CompassEnum.South  \'图列显示在南方(底端)
End If

--  作者:有点蓝
--  发布时间:2020/8/20 11:28:00
--  
指定图系标题:http://www.foxtable.com/webhelp/topics/1035.htm

……
    For i As Integer = 0 To 9
        If e.Form.controls(ngxs(i)).checked = True Then
            Series = Chart.SeriesList.Add() \'增加一个图系
Series.Text = ngxs(i)
            Series.Length = z  \'新增图系包括个数据点
            For k As Integer = 0 To z-1
                Series.X(k) = k  \'指定水平坐标
                Series.Y(k) = Tables(bm).Rows(i)(k+5) \'垂直坐标用
                Dim s As String = Format(m,"00") & "/" & Format(k + 1,"00") 
                Chart.AxisX.SetValueLabel(k, s) \'指定字符表示
            Next
        End If
    Next
……
[此贴子已经被作者于2020/8/20 11:30:03编辑过]