Documente Academic
Documente Profesional
Documente Cultură
The MSChart control allows you to plot data in charts according to your specifications. You can create a chart by setting data in the controls properties page, or by retrieving data to be plotted from another source, such as a Microsoft Excel spreadsheet. The information in this topic focuses on using an Excel worksheet as a data source.
Possible Uses
To chart dynamic data, such as current prices of selected commodities. To plot stored data, such as product prices, for graphic analysis of trends.
The code above produces a simple, single-series chart. A series in a chart, is set of related data points. For example, a typical series might be the prices of a commodity over the course of a year. The chart below shows a single-series chart.
To create a more complex, multi-series chart, you must create a multi-dimensioned array, as shown in the following example:
' The number of series are determined by the second ' dimension. In this example, the chart will have two ' series, with five data points in each series.
Dim arrPriceQuantity(1 to 5, 1 to 2) Dim i as Integer For i = 1 to 5 arrPriceQuantity(i, 1) = i ' Series 1 arrPriceQuantity(i, 2) = 0 - i ' Series 2 Next i MsChart1.ChartData = arrPriceQuantity
As you can see, creating a chart using the ChartData property can be quick and simple. However, the problem with using an array is getting the data into the array. Most users of this kind of data will probably prefer to use a spreadsheet program, such as Microsoft Excel, or perhaps a database program, such as Microsoft Access, to store and retrieve the data.
If the chart has more than one series use the Column property to designate the series, then set the Row and Data properties as above.
With MSChart1 ' Set the second data point of the fourth series ' to 42. .Column = 4 .Row = 2 .Data = 42 End With