| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 818 人关注过本帖
标题:求助:Teechart画柱状图只显示一个柱子
只看楼主 加入收藏
zhangzhen
Rank: 2
等 级:论坛游民
帖 子:92
专家分:27
注 册:2011-3-4
结帖率:100%
收藏
 问题点数:0 回复次数:1 
求助:Teechart画柱状图只显示一个柱子
我的部分代码如下
程序代码:
 myChart.Chart.Series.Clear()
        myChart.Chart.Header.Text = ComboBox6.SelectedItem & "统计柱状图"
        '定义Y轴属性
        Dim i, j, k As Integer
        Dim max As Double
        While i < DataGridView1.RowCount
            If DataGridView1.Rows(i).Cells(2).Value IsNot DBNull.Value Then
                max = DataGridView1.Rows(i).Cells(2).Value
                j = i
                Exit While
            End If
        End While

        For k = j To DataGridView1.RowCount - 2

            If DataGridView1.Rows(k + 1).Cells(2).Value IsNot DBNull.Value Then
                If DataGridView1.Rows(k + 1).Cells(2).Value >= max Then
                    max = DataGridView1.Rows(k + 1).Cells(2).Value
                End If
            End If
        Next
        '以上求最大值max
        With myChart.Chart.Axes.Left
            .Title.Text = ComboBox2.SelectedItem
            .Title.Angle = 360
            .Automatic = True
            .Maximum = max
            .Minimum = 0

        End With
        '定义X轴属性
        With myChart.Chart.Axes.Bottom
            .Automatic = True
            .Title.Text = vbCrLf & "时间点"
            .Labels.Style = AxisLabelStyle.Text
            .DateTimeDefaultFormat(1)
            .SetMinMax(0, DataGridView1.Rows(DataGridView1.RowCount - 1).Cells(0).Value)
        End With
        Dim bar_Initiative As Bar
        bar_Initiative = New Bar()

        myChart.Chart.Series.Add(bar_Initiative)
        With bar_Initiative
            .ShowInLegend = True
            .Depth = 38
            .CustomBarWidth = 5
            .Color = Color.Blue
            .BarStyle = BarStyles.Rectangle
            .Marks.Visible = True
            .Marks.ShapeStyle = Drawing.TextShapeStyle.Rectangle
            .Marks.Transparent = True
            .Marks.Font.Color = Color.Blue
        End With
        Randomize()

        Dim myArray() As Double = New Double() {}

        For i1 As Integer = j To DataGridView1.RowCount - 1
            ReDim Preserve myArray(i1)
            If DataGridView1.Rows(i1).Cells(2).Value IsNot DBNull.Value Then
                myArray(i1) = DataGridView1.Rows(i1).Cells(2).Value
            End If
        Next
        For i2 As Integer = j To DataGridView1.RowCount - 1
            If DataGridView1.Rows(i2).Cells(2).Value IsNot DBNull.Value Then
                bar_Initiative.Add(myArray(i2))
                myChart.Chart.Axes.Bottom.Labels.Items.Add(i2, DataGridView1.Rows(i2).Cells(0).Value & " " & DataGridView1.Rows(i2).Cells(1).Value)
            End If
        Next
为什么只显示第一个柱子呢?如图:

搜索更多相关主题的帖子: 柱子 柱状图 color 
2011-07-21 22:55
zhangzhen
Rank: 2
等 级:论坛游民
帖 子:92
专家分:27
注 册:2011-3-4
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册
2011-07-21 22:55
快速回复:求助:Teechart画柱状图只显示一个柱子
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013308 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved