Skip to main content
Version: v3.x

POLYLINE

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

polyline

Draws polylines that can be done on a line graph with multiple segments.

Create UI widget

const polyline = hmUI.createWidget(hmUI.widget.GRADKIENT_POLYLINE, Param)

Type

Param: object

PropertiesDescriptionRequiredType
xThe x-coordinate of component.YESnumber
yThe y-coordinate of component.YESnumber
wThe width of component.YESnumber
hThe height of the component.YESnumber
line_colorLine color, default 0xe60039NOnumber
line_widthLine width, default 2 pxNOnumber

polyline instance

polyline.clear()

() => void

Clear drawn lines

polyline.addLine()

(option: Option) => void
Option: object
PropertiesDescriptionType
dataCoordinate arraysArray<AxisItem>
countCoordinate array lengthnumber
AxisItem: object
PropertiesDescriptionType
xHorizontal coordinates, relative coordinates, distance from the left side of the widgetnumber
yVertical coordinates, relative coordinates, distance from the bottom of the widgetnumber

Code example

import { createWidget, widget } from '@zos/ui'
import { px } from '@zos/utils'

Page({
build() {
const lineDataList = [
{ x: 0, y: px(200) },
{ x: px(100), y: px(10) },
{ x: px(200), y: px(50) },
{ x: px(300), y: px(50) },
{ x: px(400), y: px(200) }
]
const polyline = createWidget(widget.GRADKIENT_POLYLINE, {
x: 0,
y: px(200),
w: px(480),
h: px(200),
line_color: 0x00ffff,
line_width: 4
})
polyline.clear()
polyline.addLine({
data: lineDataList,
count: lineDataList.length
})
}
})