老师,例子的代码在我的另外一个帖子里面:
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=84501&replyID=&skin=1
问题1. 图表中的数值显示不居中;
问题2:窗体中的Table数据刷新要晚,必须重新打开窗体才刷新;
窗体代码如下:
DataTables("入库主表").LoadTop = "10000"
DataTables("入库主表").LoadOrder = "入库日期 Desc"
DataTables("入库主表").Load
DataTables("入库主表").LoadChildren("入库记录表", "收货fa piao号", "收货fa piao号")
Dim Filter1 As String
Filter1 = "核销 = 0"
DataTables("入库记录表").LoadFilter = Filter1
DataTables("入库记录表").Load()
'================================
Dim YMax As WinForm.TextBox = e.Form.Controls("Y最大值")
Dim YMin As WinForm.TextBox = e.Form.Controls("Y最小值")
Dim cxsj As WinForm.DateTimePicker = e.Form.Controls("查询时间")
cxsj.value=now()
Dim g As New GroupTableBuilder("实时库存统计表", DataTables("入库记录表"))
g.Groups.AddDef("料号")
g.Groups.AddDef("品名")
g.Totals.AddDef("剩余数量")
g.Totals.AddDef("库存_良品")
g.Totals.AddDef("库存_不良品")
g.Totals.AddDef("库存_待处理品")
g.Totals.AddDef("库存_冻结产品")
g.Build()
MainTable = Tables("主表")
'========================产生图表=================================
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("实时库存统计表") '定义一个变量t引用数据表
Chart= e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar
Chart.ChartType2 = ChartTypeEnum.XYPlot
Chart.AxisY.Min = YMin.text '指定Y轴的最小值
Chart.AxisY.Max =YMax.text '指定Y轴的最大值
Chart.AxisY2.Min = YMin.text '指定Y轴的最小值
Chart.AxisY2.Max =YMax.text '指定Y轴的最大值
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisY.Major = YMax.text*0.1
Series = Chart.SeriesList.Add() '给图表2增加一个图系
Series.FillColor = Color.DeepSkyBlue '设置条形图的填充颜色
Series.Length = t.Rows.Count '设置图系的长度
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = t.Rows(i)("剩余数量") '指定垂直坐标
Chart.AxisX.SetValueLabel(i, i+1) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Series.DataLabelText = "{#YVAL}"
'=====================
'--------Chart.SeriesList2.Clear() '清除图表原来的图系
Chart.SeriesList2.Clear() '清除图表原来的图系
Chart.AxisY2.Major = YMax.text*0.1
Series = Chart.SeriesList2.Add() '给图表2增加一个图系
Series.FillColor = Color.Red '设置条形图的填充颜色
Series.MarkShape = MarkShapeEnum.none
Series.Length = t.Rows.Count '设置图系的长度
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = 1000 '指定垂直坐标 (安全库存)
'Chart.AxisX.SetValueLabel(i, t.Rows(i)("料号")) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
'==========================================================
Tables("实时库存表").DataSource = DataTables("实时库存统计表")
Tables("实时库存表").sort="料号"
Tables("实时库存表").Font =New Font("微软雅黑",9,FontStyle.Regular)
此主题相关图片如下:11.jpg