Foxtable(狐表)用户栏目专家坐堂 → 求助,关于双图表


  共有4812人关注过本帖平板打印复制链接

主题:求助,关于双图表

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


加好友 发短信
等级:五尾狐 帖子:1196 积分:7051 威望:0 精华:0 注册:2013/3/4 18:02:00
求助,关于双图表  发帖心情 Post By:2013/5/20 23:05:00 [只看该作者]

想画个双图表,效果是让采购额和销售额同时做出来,左边是销售额,用Bar,右边是采购额,用XYPOTPLOT,弄了一晚上都只能一个,而且Y轴也不对,高手来指点下

Dim d1 As Date = Date.Today
Dim y As Integer = d1.Year '指定年份
Dim m As Integer = d1.Month
Dim w As Integer = d1.DayOfWeek
Dim q As Integer = (d1.Month - 1) \ 3 + 1 '计算现在是第几个季度
Dim dt1 As New Date(y, 1, 1)
Dim dt2 As New Date(y, 12, 31)
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "select * from {销售出库单主表}"
Dim dt As DataTable = cmd.ExecuteReader
Dim cmd1 As New SQLCommand
cmd1.C
cmd1.CommandText = "select * from {采购入库单主表}"
Dim dv1 As DataTable = cmd1.ExecuteReader
'===============================取时间,动态加载出入表
Dim Chart As WinForm.Chart = e.Form.Controls("统计图表")
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart.VisualEffect = True
Dim lst As List(Of String) = dt.GetUniqueValues("出库日期>= '" & dt1 & "'And 出库日期 <='" & dt2 & "'", "月份") '获得销售月份集合
Dim lst1 As List(Of String) = dv1.GetUniqueValues("到仓日期>= '" & dt1 & "'And 到仓日期 <='" & dt2 & "'", "月份") '获得采购月份集合
Chart.ChartType = ChartTypeEnum.Bar
Chart.ChartType2 = ChartTypeEnum.XYPlot
Chart.AxisX.ClearValueLabel
Chart.AxisX.AnnoWithLabels = False
Chart.SeriesList.Clear() '清除图表原来的图系
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = "销售额"
Chart.SeriesList2.Clear() '清除图表2原来的图系
Series = Chart.SeriesList2.Add() '给图表2增加一个图系
Series.Text = "采购额"
Series.Length = lst.Count '设置图系的长度
For i As Integer = 0 To lst.Count - 1 '指定每个数据点的位置
    Series.X(i) = i '指定水平坐标
    Series.Y(i) = dt.Compute("Sum(总金额)","月份 = '" & lst(i) & "'") '指定销售额垂直坐标

    For p As Integer = 0 To lst1.count -1
        Series.Y2(p) = dv1.Compute("Sum(总金额)","月份 = '" & lst1(p) & "'")‘指定采购额垂直坐标
    Next

    Chart.AxisX.SetValueLabel(i, lst(i)&"月") '指定字符表示
Next
Chart.LegendVisible =True
Series.DataLabelText = "{#YVAL}"
Series.DataLabelText = "{#Y2VAL}"
series.DataLabelCompass =LabelCompassEnum.NorthEast
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.AxisY.Text = "销售额"
Chart.AxisY2.Text = "采购额"

[此贴子已经被作者于2013-5-20 23:09:19编辑过]

 回到顶部