DataPoints Collection Example

The following example sets the markers for a data point in a chart.

Private Sub Command1_Click()
   With MSChart1.Plot.SeriesCollection(1).DataPoints(-1)
   ' Set DataPoint marker visible.
      .Marker.Visible = True
      .Marker.Style = VtMarkerStyleDiamond
   End With
End Sub

The Datapoints collection Item method takes a special –1 argument to designate default properties for all data points of the series. The Datapoint object returned by Item(–1) can be manipulated just like a normal Datapoint object. A property set on this default data point affects every data point in the series, except those data points that have had that property set individually. In the example, the data point label for each series is set at three different locations. It makes no difference whether individual data point settings come before or after default settings; the individual settings always override the default settings. The ResetCustom method can be used to remove any individual settings for a data point and cause it to use the default settings for the series.

Option Explicit
Option Base 1
Private Sub Command1_Click()
   With MSChart1.Plot
      .SeriesCollection(1).DataPoints.Item(-1) _
      .DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint

      .SeriesCollection(2).DataPoints.Item(-1) _
      .DataPointLabel.LocationType = VtChLabelLocationTypeCenter
       
      .SeriesCollection(3).DataPoints.Item(-1) _
      .DataPointLabel.LocationType = VtChLabelLocationTypeBase
   End With
End Sub