1# Polyline 2 3The **\<Polyline>** component is used to draw a polyline. 4 5> **NOTE** 6> 7> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8 9 10## Child Components 11 12Not supported 13 14 15## APIs 16 17Polyline(value?: {width?: string | number, height?: string | number}) 18 19Since API version 9, this API is supported in ArkTS widgets. 20 21**Parameters** 22 23| Name| Type| Mandatory| Default Value| Description| 24| -------- | -------- | -------- | -------- | -------- | 25| width | string \| number | No| 0 | Width.<br>**NOTE**<br>An invalid value is handled as the default value.| 26| height | string \| number | No| 0 | Height.<br>**NOTE**<br>An invalid value is handled as the default value.| 27 28 29 30## Attributes 31 32In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. 33 34| Name| Type| Default Value| Description| 35| -------- | -------- | -------- | -------- | 36| points | Array<[Point](ts-drawing-components-polyline.md#point)> | [] | List of coordinates that the polyline passes through.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>An invalid value is handled as the default value.| 37| fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | Color of the fill area.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>An invalid value is handled as the default value.| 38| fillOpacity | [Length](ts-types.md#length) | 1 | Opacity of the fill area.<br>The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.<br>Since API version 9, this API is supported in ArkTS widgets.| 39| stroke | [ResourceColor](ts-types.md#resourcecolor) | - | Stroke color. If this attribute is not set, the component does not have any stroke.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>If the value is invalid, no stroke will be drawn.| 40| strokeDashArray | Array<[Length](ts-types.md#length)> | [] | Stroke dashes.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>Line segments may overlap when they intersect. An invalid value is handled as the default value.| 41| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>An invalid value is handled as the default value.| 42| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.| 43| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.| 44| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute works only when **strokeLineJoin** is set to **LineJoinStyle.Miter**.<br>The value must be greater than or equal to 1.0. If the value is in the [0, 1) range, the value **1.0** will be used. In other cases, the default value will be used.<br>Since API version 9, this API is supported in ArkTS widgets.| 45| strokeOpacity | [Length](ts-types.md#length) | 1 | Stroke opacity.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.| 46| strokeWidth | [Length](ts-types.md#length) | 1 | Stroke width.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>If of the string type, this parameter cannot be set in percentage. A percentage is processed as 1px.| 47| antiAlias | boolean | true | Whether anti-aliasing is enabled.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>An invalid value is handled as the default value.| 48 49 50 51## Point 52 53Describes the coordinates of a point. 54 55Since API version 9, this API is supported in ArkTS widgets. 56 57| Name | Type | Description | 58| --------- | -------------------- | ------------------------------------------------------------ | 59| Point | [number, number] | Coordinates of a point. The first parameter is the x-coordinate, and the second parameter is the y-coordinate (relative coordinate).| 60 61## Example 62 63```ts 64// xxx.ets 65@Entry 66@Component 67struct PolylineExample { 68 build() { 69 Column({ space: 10 }) { 70 // Draw a polyline in a 100 x 100 rectangle. The start point is (0, 0), the end point is (100, 100), and the passing point is (20,60). 71 Polyline({ width: 100, height: 100 }) 72 .points([[0, 0], [20, 60], [100, 100]]) 73 .fillOpacity(0) 74 .stroke(Color.Blue) 75 .strokeWidth(3) 76 // Draw a polyline in a 100 x 100 rectangle. The start point is (20, 0), the end point is (100, 90), and the passing point is (0,100). 77 Polyline() 78 .width(100) 79 .height(100) 80 .fillOpacity(0) 81 .stroke(Color.Red) 82 .strokeWidth(8) 83 .points([[20, 0], [0, 100], [100, 90]]) 84 // Set the join style of the stroke to a round corner. 85 .strokeLineJoin(LineJoinStyle.Round) 86 // Set the cap style of the stroke to a half circle. 87 .strokeLineCap(LineCapStyle.Round) 88 }.width('100%') 89 } 90} 91``` 92 93 94