最好有原码,谢谢
---------------------------------------------------------------
TChart是什么?
这里有个ms的chart
1<object classid="CLSID:0002E500-0000-0000-C000-000000000046" id="ChartSpace1" style="width:49%;height:350"></object>
1<object classid="CLSID:0002E510-0000-0000-C000-000000000046" id="Spreadsheet1" style="width:49%;height:350"></object>
1<br/>
1<small><b>Source: </b>Voters Research and Surveys</small>
1<p>
2<script language="vbs">
3Sub Window_OnLoad()
4' This example starts by putting the data into Spreadsheet1. Normally,
5' the data would already be loaded, but this code was added for completeness.
6Spreadsheet1.ActiveSheet.Cells.Clear
7Spreadsheet1.ActiveSheet.Cells(2, 1).Value = "White" & chr(10) & chr(13)
8a=Spreadsheet1.ActiveSheet.Cells(2, 1).Text & "1"
9Spreadsheet1.ActiveSheet.Cells(2, 1).Locked = False
10Spreadsheet1.ActiveSheet.Cells(3, 1).Value = "Black"
11Spreadsheet1.ActiveSheet.Cells(4, 1).Value = "Asian"
12Spreadsheet1.ActiveSheet.Cells(5, 1).Value = "Latino"
13
14Spreadsheet1.ActiveSheet.Cells(1, 2).Value = "Perot"
15Spreadsheet1.ActiveSheet.Cells(2, 2).Value = 0.2
16Spreadsheet1.ActiveSheet.Cells(3, 2).Value = 0.06
17Spreadsheet1.ActiveSheet.Cells(4, 2).Value = 0.17
18Spreadsheet1.ActiveSheet.Cells(5, 2).Value = 0.13
19
20Spreadsheet1.ActiveSheet.Cells(1, 3).Value = "Clinton"
21Spreadsheet1.ActiveSheet.Cells(2, 3).Value = 0.38
22Spreadsheet1.ActiveSheet.Cells(3, 3).Value = 0.82
23Spreadsheet1.ActiveSheet.Cells(4, 3).Value = 0.28
24Spreadsheet1.ActiveSheet.Cells(5, 3).Value = 0.62
25
26Spreadsheet1.ActiveSheet.Cells(1, 4).Value = "Bush"
27Spreadsheet1.ActiveSheet.Cells(2, 4).Value = 0.42
28Spreadsheet1.ActiveSheet.Cells(3, 4).Value = 0.12
29Spreadsheet1.ActiveSheet.Cells(4, 4).Value = 0.55
30Spreadsheet1.ActiveSheet.Cells(5, 4).Value = 0.25
31
32' Clear the contents of the chart workspace. This removes
33' any old charts that may already exist and leaves the chart workspace
34' completely empty. One chart object is then added.
35ChartSpace1.Clear
36ChartSpace1.Charts.Add
37Set c = ChartSpace1.Constants
38
39' Set the chart DataSource property to the spreadsheet.
40' It is possible to specify multiple data sources, but this example uses only one.
41ChartSpace1.DataSource = Spreadsheet1
42
43' Add three series to the chart.
44ChartSpace1.Charts(0).SeriesCollection.Add
45ChartSpace1.Charts(0).SeriesCollection.Add
46ChartSpace1.Charts(0).SeriesCollection.Add
47
48' Connect the chart to data by specifying spreadsheet cell references
49' for the different data dimensions. Notice that the SetData method uses
50' a data source index of 0; this is the first data source, which was previously
51' set to the spreadsheet. If you had created multiple data sources,
52' you could specify the index to any item in the WCDataSources collection for the
53' data source index. For example, if two spreadsheet controls were attached to this
54' chart workspace, you could set data from the first control using index 0
55' and set data from the second control using index 1.
56
57' Notice that the series name is also bound to a spreadsheet cell. Changing
58' the contents of the cell "B1" will also change the name that appears in the legend.
59' If you don't want this behavior, set SeriesCollection(0).Caption instead of
60' using the SetData method to bind the series name to the spreadsheet.
61
62' Series one contains election data for Perot.
63' Bind the series name, the category names, and the values.
64ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimSeriesNames, 0, "B1"
65ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimCategories, 0, "A2:A5"
66ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimValues, 0, "B2:B5"
67
68' Series two contains election data for Clinton.
69ChartSpace1.Charts(0).SeriesCollection(1).SetData c.chDimSeriesNames, 0, "C1"
70ChartSpace1.Charts(0).SeriesCollection(1).SetData c.chDimCategories, 0, "A2:A5"
71ChartSpace1.Charts(0).SeriesCollection(1).SetData c.chDimValues, 0, "C2:C5"
72
73' Series two contains election data for Bush.
74ChartSpace1.Charts(0).SeriesCollection(2).SetData c.chDimSeriesNames, 0, "D1"
75ChartSpace1.Charts(0).SeriesCollection(2).SetData c.chDimCategories, 0, "A2:A5"
76ChartSpace1.Charts(0).SeriesCollection(2).SetData c.chDimValues, 0, "D2:D5"
77
78' Make the chart legend visible, format the left value axis as percentage,
79' and specify that value gridlines are at 10% intervals.
80ChartSpace1.Charts(0).HasLegend = True
81ChartSpace1.Charts(0).Axes(c.chAxisPositionLeft).NumberFormat = "0%"
82ChartSpace1.Charts(0).Axes(c.chAxisPositionLeft).MajorUnit = 0.1
83End Sub
84</script></p>