哪位大虾能帮忙找一下错误 如图所示 图三的总体统计图生成不了 我要怎么改写代码,感觉有问题的已标黄。如下所示
此主题相关图片如下:66666.png
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.DataFilter="检测项目='" & strItemName &
"' and 生长阶段='总体'"
'
Chart.DataSource= tblDtl.Name
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.SeriesList.Clear() '清除图表原来的图系
Dim lstDrAll As List(Of DataRow)= tblDtl.DataTable.Select("检测项目='"
& strItemName
& "' and 生长阶段='总体'")
For j As Integer=0 To lstLoad.Count-1
Series = Chart.SeriesList.Add() '增加第一个图系
Series.Length = 3 '设置图系的长度
'阳性率
Chart.AxisX.SetValueLabel(0, "阳性率") '指定字符表示
Series.X(0) = 0 '指定水平坐标
Dim strCol As String=lstCompany(j) & lstYear(j) & "阳性率"
If lstDrAll(0).IsNull(strCol) Then
Series.Y(0) = 0 '指定垂直坐标
Else
Series.Y(0) = lstDrAll(0)(strCol) '指定垂直坐标
End If
'离散度
Chart.AxisX.SetValueLabel(1, "离散度") '指定字符表示
Series.X(1) = 1 '指定水平坐标
Dim strCol2 As String=lstCompany(j) & lstYear(j) & "离散度"
If lstDrAll(0).IsNull(strCol2) Then
Series.Y(1) = 0 '指定垂直坐标
Else
Series.Y(1) = lstDrAll(0)(strCol2) '指定垂直坐标
End If
'阳性平均值
Chart.AxisX.SetValueLabel(2, "阳性平均值") '指定字符表示
Series.X(2) = 2 '指定水平坐标
Dim strCol3 As String=lstCompany(j) & lstYear(j) & "阳性平均值"
If lstDrAll(0).IsNull(strCol3) Then
Series.Y(2) = 0 '指定垂直坐标
Else
Series.Y(2) = lstDrAll(0)(strCol3) '指定垂直坐标
End If
'
Series.DataLabelVisible=True
'
Series.DataLabelText = "{#YVAL}"
Next
Chart.AxisX.AnnoWithLabels=True
Chart.LegendVisible
= True '显示图列
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 i=2 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
'If
c1Chart1.ChartGroups(x).ChartData.SeriesList(j).Y.DataField.Contains("阳性平均值") 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.LegendCompass=
Foxtable.CompassEnum.South '图列显示在东方(右方)
Catch ex As Exception
MessageBox.Show(ex.Tostring,"提示")
End Try