Foxtable(狐表)用户栏目专家坐堂 → 统计图表问题求找错


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

主题:统计图表问题求找错

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/1/11 18:04:00 [显示全部帖子]

 

单看代码看不出问题的。单独做一个实例,删除敏感数据,发上来测试。

 

 


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/1/14 10:24:00 [显示全部帖子]

请贴出完整的可以测试的例子啊。

 

你例子里面没有chart3的代码啊,你本来的问题是什么?生成的不正确还是报错?报什么错?对应的代码请写到实例里面。

 

或者说明一下要做到什么效果,逻辑是什么啊。


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/1/15 11:17:00 [显示全部帖子]

Dim strItemName As String=Args(0)
Dim tblDtl As Table=Args(1)
Dim chrt1 As WinForm.Chart=Args(2)
Dim chrt2 As WinForm.Chart=Args(3)
Dim chrt3 As WinForm.Chart=Args(4)
Dim strCaption1 As String="抗体检测阳性率及强阳性率"
Dim strCaption2 As String="抗体检测阳性平均值及离散度"
Dim strCaption3 As String="抗体检测阳性总体情况"
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Try
    chrt1.SeriesList.Clear() '清除图表原来的图系
    chrt1.SeriesList2.Clear() '清除图表原来的图系
    chrt2.SeriesList.Clear() '清除图表原来的图系
    chrt2.SeriesList2.Clear() '清除图表原来的图系
    chrt3.SeriesList.Clear() '清除图表原来的图系
    chrt3.SeriesList2.Clear() '清除图表原来的图系
    '处理第一个图表
    Chart = chrt1 ' 引用窗口中的图表
    Chart.DataFilter="检测项目='" & strItemName & "'"
    Chart.DataSource= tblDtl.Name
    Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
    Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
    Chart.SeriesList.Clear() '清除图表原来的图系
    Dim lstDr As List(Of DataRow)= tblDtl.DataTable.Select("检测项目='" & strItemName & "'")
    Series = Chart.SeriesList.Add() '增加第一个图系
    'Series.Length = lstDr.Count '设置图系的长度
    Series.Text = "阳性率"
    Series.X.DataField = "生长阶段" 'X轴绑定到产品列
    Series.Y.DataField = "阳性率" '设置Y轴的绑定列
    Chart.AxisX.AnnoRotation = - 25 'X轴标示逆时针旋转45度
    '    Series.DataLabelVisible=True
    '    Series.DataLabelText = "{#YVAL}"
    'Chart.AxisX.AnnoWithLabels = True '启用字符标示
    Series = Chart.SeriesList.Add() '增加第二个图系
    Series.Text = "强阳性率"
    Series.X.DataField = "生长阶段" 'X轴绑定到产品列
    Series.Y.DataField = "强阳性率" '设置Y轴的绑定列
    '    Series.DataLabelVisible=True
    '    Series.DataLabelText = "{#YVAL}"
    Dim c1Chart1 As C1.Win.C1Chart.C1Chart = Chart.basecontrol
    Dim lbls As C1.Win.C1Chart.ChartLabels = c1Chart1.ChartLabels
    lbls.LabelsCollection.Clear
   
    For j As Integer=0 To c1Chart1.ChartGroups.Group0.ChartData.SeriesList.Count-1
        For i As Integer = 0 To c1Chart1.ChartGroups.Group0.ChartData.SeriesList(j).X.Length-1
            Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
            If c1Chart1.ChartGroups(0).ChartData.SeriesList(j).Y.DataField="阳性平均值" Then
                lbl.Text = Format(c1Chart1.ChartGroups(0).ChartData.SeriesList(j).y(i), "0.00")
            Else
                lbl.Text = Format(c1Chart1.ChartGroups(0).ChartData.SeriesList(j).y(i), "0%")
            End If
            lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
            lbl.AttachMethodData.GroupIndex = 0
            lbl.AttachMethodData.SeriesIndex = j
            lbl.AttachMethodData.PointIndex = i
            lbl.Style.ForeColor = Color.Red
            lbl.style.font = New font("微软雅黑", 8)
            lbl.Compass = Foxtable.LabelCompassEnum.North
            lbl.Visible = True
        Next
    Next
   
    Chart.LegendVisible = True '显示图列
    Chart.AxisY.AnnoFormatString = "##.##%"
    Chart.LegendCompass= Foxtable.CompassEnum.South '图列显示在东方(右方)
    Chart.HeaderText=strItemName & strCaption1
    '处理第二个图表
    Chart = chrt2 ' 引用窗口中的图表
    Chart.DataFilter="检测项目='" & strItemName & "'"
    Chart.DataSource= tblDtl.Name
    Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
    Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
    Chart.ChartType2 = ChartTypeEnum.XYPlot '图表2类型该为线形
    Chart.SeriesList.Clear() '清除图表原来的图系
    Series = Chart.SeriesList.Add() '增加第一个图系
    Series.Text = "阳性平均值"
    Series.X.DataField = "生长阶段" 'X轴绑定到产品列
    Series.Y.DataField = "阳性平均值" '设置Y轴的绑定列
    '    Series.DataLabelVisible=True
    '    Series.DataLabelText = "{#YVAL}"
   
    Chart.AxisX.AnnoRotation = - 25 'X轴标示逆时针旋转45度
    Chart.SeriesList2.Clear() '清除图表原来的图系
    Series = Chart.SeriesList2.Add() '增加第二个图系
    Series.Text = "离散度"
    Series.X.DataField = "生长阶段" 'X轴绑定到产品列
    Series.Y.DataField = "离散度" '设置Y轴的绑定列
    '    Series.DataLabelVisible=True
    '    Series.DataLabelText = "{#YVAL}"
   
    c1Chart1 = Chart.basecontrol
    lbls = c1Chart1.ChartLabels
    lbls.LabelsCollection.Clear
    For x As Integer=0 To c1Chart1.ChartGroups.Count-1
        For j As Integer=0 To c1Chart1.ChartGroups(x).ChartData.SeriesList.Count-1
            For i As Integer = 0 To c1Chart1.ChartGroups(x).ChartData.SeriesList(j).X.Length-1
                Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
                If c1Chart1.ChartGroups(x).ChartData.SeriesList(j).Y.DataField="阳性平均值" Then
                    lbl.Text = Format(c1Chart1.ChartGroups(x).ChartData.SeriesList(j).y(i), "0.00")
                Else
                    lbl.Text = Format(c1Chart1.ChartGroups(x).ChartData.SeriesList(j).y(i), "0%")
                End If
               
               
                lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
                lbl.AttachMethodData.GroupIndex = x
                lbl.AttachMethodData.SeriesIndex = j
                lbl.AttachMethodData.PointIndex = i
                lbl.Style.ForeColor = Color.Red
                lbl.style.font = New font("微软雅黑", 8)
                lbl.Compass = Foxtable.LabelCompassEnum.North
                lbl.Visible = True
            Next
        Next
    Next
    Chart.LegendVisible = True '显示图列
    Chart.AxisY.AnnoFormatString = "##.##%"
    Chart.LegendCompass= Foxtable.CompassEnum.South '图列显示在东方(右方)
    Chart.HeaderText=strItemName & strCaption2
   
    Chart = chrt3 ' 引用窗口中的图表
    Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
    Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
    Chart.SeriesList.Clear() '清除图表原来的图系
    Dim lstDrAll As List(Of DataRow)= tblDtl.DataTable.Select("检测项目='" & strItemName & "' and 生长阶段='总体'")
   
    Series = Chart.SeriesList.Add() '增加第一个图系
    Series.Length = 3 '设置图系的长度
    '阳性率
    Chart.AxisX.SetValueLabel(0, "阳性率") '指定字符表示
    Series.X(0) = 0 '指定水平坐标
   
    Series.Y(0) = tblDtl.Compute("sum(阳性个数)", "检测项目='" & strItemName & "'") / tblDtl.Compute("sum(样品个数)", "检测项目='" & strItemName & "'")
   
   
    '离散度
    Chart.AxisX.SetValueLabel(1, "离散度") '指定字符表示
    Series.X(1) = 1 '指定水平坐标
    Series.Y(1) = cdbl(tblDtl.Compute("avg(离散度)", "检测项目='" & strItemName & "'"))
   
   
    '阳性平均值
    Chart.AxisX.SetValueLabel(2, "阳性平均值") '指定字符表示
    Series.X(2) = 2 '指定水平坐标
    Series.Y(2) = cdbl(tblDtl.Compute("avg(阳性平均值)", "检测项目='" & strItemName & "'"))
    'Series.DataLabelVisible=True
    'Series.DataLabelText = "{#YVAL}"
   
    c1Chart1 = Chart.basecontrol
    lbls = c1Chart1.ChartLabels
    lbls.LabelsCollection.Clear
    For i As Integer = 0 To 2
        Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
        lbl.Text = Format(series.y(i), "0.00%")
       
        lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
        lbl.AttachMethodData.GroupIndex = 0
        lbl.AttachMethodData.SeriesIndex = 0
        lbl.AttachMethodData.PointIndex = i
        lbl.Style.ForeColor = Color.Red
        lbl.style.font = New font("微软雅黑", 8)
        lbl.Compass = Foxtable.LabelCompassEnum.North
       
        lbl.Visible = True
    Next
   
    Chart.AxisX.AnnoWithLabels=True
    Chart.LegendVisible = True '显示图列
   
    Chart.LegendCompass= Foxtable.CompassEnum.South '图列显示在东方(右方)
Catch ex As Exception
    MessageBox.Show(ex.Tostring,"提示")
End Try

 回到顶部