Foxtable(狐表)用户栏目专家坐堂 → 图表的绑定


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

主题:图表的绑定

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


加好友 发短信
等级:幼狐 帖子:196 积分:1357 威望:0 精华:0 注册:2015/3/25 16:42:00
图表的绑定  发帖心情 Post By:2015/8/30 19:11:00 [只看该作者]

Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "select sys_user, year(一配_日期) as 年, 一配_公猪 as 编号, count(一配_日期) as 总配种数, count(分娩_总产仔数) As 总分娩窝数, sum(分娩_总产仔数) As 总产仔数 " & _  
"f rom {母猪分娩断奶信息} where [sys_user]='" & user.Name & "' group by year(一配_日期),  一配_公猪, sys_user order by year(一配_日期), 一配_公猪 "
dt = cmd.ExecuteReader()
Tables("配种产仔分析_table1").DataSource  = dt
With DataTables("配种产仔分析_Table1").DataCols
    .Add("配种分娩率",Gettype(Double), " ISNULL([总分娩窝数],0) / IIF(IsNull([总配种数],0) = 0, null, IsNull([总配种数],0)) ")
    .Add("产仔数/窝",Gettype(Double), " ISNULL([总产仔数],0) / IIF(IsNull([总分娩窝数],0) = 0, null, IsNull([总分娩窝数],0)) ")
End With
DataTables("配种产仔分析_Table1").DataCols("产仔数/窝").SetFormat("0.00")
DataTables("配种产仔分析_Table1").DataCols("配种分娩率").SetFormat("0.0%")
Tables("配种产仔分析_Table1").DefaultColWidth = 120



Dim Chart As WinForm.Chart 
Dim Series As WinForm.ChartSeries 
Chart= e.Form.Controls("Chart1") 
Chart.SeriesList.Clear() 
Series = Chart.SeriesList.Add() 
Dim n As List(of String) = DataTables("配种产仔分析_Table1").GetValues("年")
Dim b As List(of String) = DataTables("配种产仔分析_Table1").GetValues("编号")
MessageBox.Show(1)
Series.Length = n.Count 
MessageBox.Show(2)
For bi As Integer = 0 To b.Count - 1
For ni As Integer = 0 To n.Count - 1 
MessageBox.Show(3)
Dim dr As DataRow = DataTables("配种产仔分析_Table1").find("[编号] = '" & b(bi) & "' and [年]= " & val(n(ni)) )
MessageBox.Show(4)
If dr IsNot Nothing Then
MessageBox.Show(5)
Series.X(ni) = n(ni)
MessageBox.Show(6) 
Series.Y(ni) = dr("配种分娩率")
MessageBox.Show(7)
End If
Next
Next


老师你好,我的代码执行到第5部,就提示以下错误:蓝色的代码没错,请老师帮我看一下!

.NET Framework 版本:2.0.50727.8000
Foxtable 版本:2014.11.11.1
错误所在事件:窗口,配种产仔分析,Button1,Click
详细错误信息:
Invalid data type


 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110597 积分:562881 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2015/8/30 19:47:00 [只看该作者]

参考示列2
http://www.foxtable.com/help/index.html?n=0970.htm
Dim Chart As WinForm.Chart
Dim Series As WinForm.ChartSeries
Chart= e.Form.Controls("Chart1")
Chart.SeriesList.Clear()
Series = Chart.SeriesList.Add()
Dim n As List(of String) = DataTables("配种产仔分析_Table1").GetValues("年")
Dim b As List(of String) = DataTables("配种产仔分析_Table1").GetValues("编号")
MessageBox.Show(1)
Series.Length = n.Count
MessageBox.Show(2)
For bi As Integer = 0 To b.Count - 1
    For ni As Integer = 0 To n.Count - 1
        MessageBox.Show(3)
        Dim dr As DataRow = DataTables("配种产仔分析_Table1").find("[编号] = '" & b(bi) & "' and [年]= " & val(n(ni)) )
        MessageBox.Show(4)
        If dr IsNot Nothing Then
            MessageBox.Show(5)
            Series.X(ni) = ni
            MessageBox.Show(6)
            Series.Y(ni) = dr("配种分娩率")
            MessageBox.Show(7)
        End If
    Next
    For r As Integer = 0 To n.Count - 1
        Chart.AxisX.SetValueLabel(r, n(r)) '指定字符表示
    Next
Next

 回到顶部