Skip to main content
Version: v3+

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

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

const polyline = createWidget(widget.GRADKIENT_POLYLINE, Param)

Type

Param: object

PropertiesDescriptionRequiredType
xThe x-coordinate of widget.YESnumber
yThe y-coordinate of widget.YESnumber
wThe width of widget.YESnumber
hWidget height, the maximum height on a circular screen with a screen height of 480 and a square device with a screen height of 390 is 150, and the maximum height of other models is scaled proportionally according to the screen height.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
PropertiesDescriptionTypeVersion
dataCoordinate arraysArray<AxisItem>-
countCoordinate array lengthnumber-
color_fromInitial fill gradient colornumber2.1
color_toEnd fill gradient colornumber2.1
curve_styleWhether to use interpolation, smoothing curve effectboolean2.1
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

Supported Property Access List

PropertysetPropertygetPropertysettergetter
xNYNY
yNYNY
wNYNY
hNYNY
line_colorNNNN
line_widthNNNN
bg_colorNNNN

Code example

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

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