Share via


DrawPolyLine Method

Draws a line containing multiple segments. The points for the line are specified in arrays containing the X and Y values that describe the segments of the line. Uses the current settings of the Line property to determine the properties of the new line.

expression.DrawPolyLine(xValues, yValues)

*expression   * Required. An expression that returns a ChChartDraw object.

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

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

Example

This example uses the AfterRender event to draw a custom border around Chartspace1.

Sub ChartSpace1_AfterRender(drawObject, chartObject)

    Dim alXValues(9)
    Dim alYValues(9)
    Dim iCutOff
    Dim chConstants

    iCutOff = 10

    Set chConstants = ChartSpace1.Constants

    If TypeName(chartObject) = "ChChart" 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 line.
        drawObject.Line.Color = "blue"
        drawObject.Line.Weight = chConstants.owcLineWeightThick
        drawObject.Line.DashStyle = chConstants.chLineLongDashDot

        ' Draw the line.
        drawObject.DrawPolyLine alXValues, alYValues

    End If

End Sub

Applies to | ChChartDraw Object

See Also | AfterRender Event | BeforeRender Event | DrawEllipse Method | DrawLine Method | DrawRectangle Method | DrawText Method | Line Property