Foxtable(狐表)用户栏目专家坐堂 → 圆饼图表生成


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

主题:圆饼图表生成

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


加好友 发短信
等级:超级版主 帖子:110592 积分:562856 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/8/27 23:09:00 [显示全部帖子]

Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart= Forms("图表学习2").Controls("Chart1") ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
Dim nms() As String = {"支出汇总","经营汇总","负载汇总"}
Dim nms2() As String = {"支出金额","变动金额","欠款金额"}
Dim sum As Double = 0
For i As Integer = 0 To nms.Length - 1
    sum += Tables(nms(i)).Compute("sum(" & nms2(i) & ")")
Next
For i As Integer = 0 To nms.Length - 1
    Series = Chart.SeriesList.Add() '增加一个图系
    Series.Length = 1 '一个系列只能包括一个值
    Series.Text = nms(i)
    Dim cnt = Tables(nms(i)).Compute("sum(" & nms2(i) & ")")
    Series.Y(0) = cnt
    Series.DataLabelText = Math.Round(cnt*100/sum ,2) & "%"
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)

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


加好友 发短信
等级:超级版主 帖子:110592 积分:562856 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/9/18 22:28:00 [显示全部帖子]

Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Chart=e.form.Controls("Chart1") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
Dim nms1() As String = {"经营汇总","支出汇总"}
Dim nms2() As String = {"变动金额","支出金额"}
Dim nms3() As String = {"经营日期","支持日期"}
Dim nms4() As String = {"经营项目","支出项目"}
Dim cls() = {Color.red, Color.blue}
For i As Integer = 0 To nms1.Length - 1
    Dim d As Date = new Date(Date.Today.Year, Date.Today.Month, 1)
    For Each s As String In DataTables(nms1(i)).GetValues(nms4(i), nms4(i) & " Is not null And " & nms3(i) & " >= #" & d & "# and " & nms3(i) & " < #" & d.AddMonths(1) & "#")
        Dim sum As Double = DataTables(nms1(i)).compute("sum(" & nms2(i) & ")", nms4(i) & "='" & s & "' and " & nms3(i) & " >= #" & d & "# and " & nms3(i) & " < #" & d.AddMonths(1) & "#")
        Series = Chart.SeriesList.Add() '增加一个图系
        Series.Length = 1 '一个系列只能包括一个值
        Series.Text = s & "(" & sum & ")" '设置图系的标题
        Series.Y(0) = sum
        Series.TooltipText = s & " : {#YVAL}" '显示数据
        Series.DataLabelText = sum
        Series.FillColor = cls(i)
    Next
Next
For Each s As String In DataTables("负载汇总").GetValues("欠款名称",  "欠款名称 Is not null And 欠款日期 >= #" & d & "# and 欠款日期 < #" & d.AddMonths(1) & "#")
    Dim dr As DataRow = DataTables("负载汇总").Find("欠款名称 ='" & s & "' And 欠款日期 >= #" & d & "# and 欠款日期 < #" & d.AddMonths(1) & "#","欠款日期 desc")
    Series = Chart.SeriesList.Add() '增加一个图系
    Series.Length = 1 '一个系列只能包括一个值
    Series.Text = s & "(" & dr("欠款金额") & ")" '设置图系的标题
    Series.Y(0) = sum
    Series.TooltipText = s & " : {#YVAL}" '显示数据
    Series.DataLabelText = dr("欠款金额")
    'Series.FillColor = cls(i)
Next

Chart.LegendVisible = True '显示图列

 回到顶部