DrawPolygon Method

Microsoft Office Web Components Object Model

DrawPolygon Method

       

Draws a polygon on the chart. The points for the polygon are specified in arrays containing the X and Y values that describe the segments of the polygon. Uses the current settings of the Border and Interior properties to determine the properties of the new polygon.

expression.DrawPolygon(xValues, yValues)

expression   Required. An expression that returns a ChChartDraw object.

xValues  Required Variant. An array containing the X values used to calculate the polygon.

yValues  Required Variant. An array containing the Y values used to calculate the polygon.

Example

This example uses the BeforeRender event to cancel rendering the chart title and the AfterRender event to replace the chart title with a polygon.

Sub ChartSpace1_AfterRender(drawObject, chartObject)

    Dim alXValues(9)
    Dim alYValues(9)
    Dim chConstants
    Dim iCutoff

    iCutoff = 20

    Set chConstants = ChartSpace1.Constants

    If TypeName(chartObject) = "ChTitle" Then

        ' Set the array containing the x values for
        ' the line.
        alXValues(0) = chartObject.Left + iCutoff
        alXValues(1) = chartObject.Right - iCutoff
        alXValues(2) = chartObject.Right
        alXValues(3) = chartObject.Right
        alXValues(4) = chartObject.Right - iCutoff
        alXValues(5) = chartObject.Left + iCutoff
        alXValues(6) = chartObject.Left
        alXValues(7) = chartObject.Left
        alXValues(8) = chartObject.Left + iCutoff

        ' Set the array containing the y values for
        ' the line.
        alYValues(0) = chartObject.Top
        alYValues(1) = chartObject.Top
        alYValues(2) = chartObject.Top + iCutoff
        alYValues(3) = chartObject.Bottom - iCutoff
        alYValues(4) = chartObject.Bottom
        alYValues(5) = chartObject.Bottom
        alYValues(6) = chartObject.Bottom - iCutoff
        alYValues(7) = chartObject.Top + iCutoff
        alYValues(8) = chartObject.Top

        ' Set the properties for the polygon.
        drawObject.Interior.SetTwoColorGradient chConstants.chGradientFromCenter, _
                                  chConstants.chGradientVariantStart, "Red", "Green"

        ' Draw the polygon.
        drawObject.DrawPolygon alXValues, alYValues

    End If

End Sub

Private Sub ChartSpace1_BeforeRender(chartObject,Cancel)

    If TypeName(chartObject) = "ChTitle" Then
            Cancel.Value = True
    End If

End Sub