求救!!!Mschart!!!

hylmail 2003-05-14 08:55:57
请问大侠,如何将DataSet的数据关联到MsChart,我查出来的DataSet是二维表,
如:
税目 税目1 税目2 税目3
类型
类型1 34 43 65
类型2 19 23 72
类型3 31 26 90
类型4 12 34 87

中间是实纳税额。
或者我把DataSet绑到DataGrid上之后再怎么关联到MsChart?
在MsChart上,如何把柱状图分类型和税目都在X坐标表示,Y坐标表示实纳税额。
达到并排分类的形式,多谢!
...全文
60 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
eliphe 2003-07-19
  • 打赏
  • 举报
回复
推荐使用:
HSkyXChart Web统计图表 2.5

下载地址:http://www.skyec.com/cpxz.asp

附带asp、C#、VB.Net完整演示实例!

带完整演示程序,效果图和接口说明

可以生成柱型图,横柱型图,折线图,饼图,点图,区域图

完全免费
CMIC 2003-07-03
  • 打赏
  • 举报
回复
联机帮助代码
'In this example, the sales for two companies are shown for four months.
'Create the data array and bind it to the ChartData property.
Dim Sales(,) As Object = New Object(, ) _
{{"Company", "Company A", "Company B"}, _
{"June", 20, 10}, _
{"July", 10, 5}, _
{"August", 30, 15}, _
{"September", 14, 7}}
chtSales.ChartData = Sales

'Add a title and legend.
With Me.chtSales
.Title.Text = "Sales"
.Legend.Location.LocationType = _
MSChart20Lib.VtChLocationType.VtChLocationTypeBottom
.Legend.Location.Visible = True
End With

'Add titles to the axes.
With Me.chtSales.Plot
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX).AxisTitle.Text = "Year"
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = "Millions of $"
End With

'Set custom colors for the bars.
With Me.chtSales.Plot
'Yellow for Company A
' -1 selects all the datapoints.
.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set(250, 250, 0)
'Purple for Company B
.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set(200, 50, 200)
End With
Montaque 2003-07-03
  • 打赏
  • 举报
回复

真理了一段代码:

'''
'产生一个数据集
Dim ds As New DataSet
Dim dt As New DataTable
Dim dc As New DataColumn

''''''''Generate A Datatable
'Math : single
dc = New DataColumn
dc.ColumnName = "Math Score"
dc.DataType = System.Type.GetType("System.Single")
dt.Columns.Add(dc)

'English : single
dc = New DataColumn
dc.ColumnName = "English Score"
dc.DataType = System.Type.GetType("System.Single")
dt.Columns.Add(dc)

Dim dr As DataRow
Dim i As Integer
For i = 0 To 10
dr = dt.NewRow
dr.Item(0) = Rnd() * 100
dr.Item(1) = Rnd() * 100
dt.Rows.Add(dr)
Next
dt.TableName = "tblStudent"
ds.Tables.Add(dt)


'''
' Read ChartData from dataset
' Only the first Datatable
'''
Dim ChartData(,) As Object
ReDim ChartData(ds.Tables(0).Rows.Count, ds.Tables(0).Columns.Count)
Dim k, l As Integer
For k = 0 To ds.Tables(0).Rows.Count - 1
For l = 0 To ds.Tables(0).Columns.Count - 1
ChartData(k, l) = ds.Tables(0).Rows(k).Item(l)
Next
Next
Me.AxMSChart1.chartType = MSChart20Lib.VtChChartType.VtChChartType2dXY
Me.AxMSChart1.ChartData = ChartData
Montaque 2003-07-03
  • 打赏
  • 举报
回复

真理了一段代码:

'''
'产生一个数据集
Dim ds As New DataSet
Dim dt As New DataTable
Dim dc As New DataColumn

''''''''Generate A Datatable
'Math : single
dc = New DataColumn
dc.ColumnName = "Math Score"
dc.DataType = System.Type.GetType("System.Single")
dt.Columns.Add(dc)

'English : single
dc = New DataColumn
dc.ColumnName = "English Score"
dc.DataType = System.Type.GetType("System.Single")
dt.Columns.Add(dc)

Dim dr As DataRow
Dim i As Integer
For i = 0 To 10
dr = dt.NewRow
dr.Item(0) = Rnd() * 100
dr.Item(1) = Rnd() * 100
dt.Rows.Add(dr)
Next
dt.TableName = "tblStudent"
ds.Tables.Add(dt)


'''
' Read ChartData from dataset
' Only the first Datatable
'''
Dim ChartData(,) As Object
ReDim ChartData(ds.Tables(0).Rows.Count, ds.Tables(0).Columns.Count)
Dim k, l As Integer
For k = 0 To ds.Tables(0).Rows.Count - 1
For l = 0 To ds.Tables(0).Columns.Count - 1
ChartData(k, l) = ds.Tables(0).Rows(k).Item(l)
Next
Next
Me.AxMSChart1.chartType = MSChart20Lib.VtChChartType.VtChChartType2dXY
Me.AxMSChart1.ChartData = ChartData
hylmail 2003-05-15
  • 打赏
  • 举报
回复
各位大侠,如何手动设置,请具体讲解一下。
或者还可以用什么控件可以实现柱状图和圆饼图,具体讲个例子!百分感谢!
zwztu 2003-05-15
  • 打赏
  • 举报
回复
同意楼上
Montaque 2003-05-15
  • 打赏
  • 举报
回复
必须手动设置,不能直接用dataset.
szch 2003-05-15
  • 打赏
  • 举报
回复
With Me.AxMSChart1
.ColumnCount =10
.RowCount=10
'以下为设置值
.Column = 1
.Row=1
.Data = 100
'设置样式
Me.AxMSChart1.chartType = MSChart20Lib.VtChChartType.VtChChartType2dCombination
end with
szch 2003-05-15
  • 打赏
  • 举报
回复
DataSet绑到MsChart没试过
MsChart你可自己设置ROW,CLOUME对应的DATA

16,720

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧