Skip to main content
Version: v3

HISTOGRAM

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

histogram

Draws a histogram.

Create UI widget

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

const histoGram = createWidget(widget.HISTOGRAM, Param)

Type

Param: object

PropertiesDescriptionRequiredType
xThe x-coordinate of widget.YESnumber
yThe y-coordinate of widget.YESnumber
wThe width of widget.YESnumber
hThe height of the widget.YESnumber
item_widthWidth of column.YESnumber
item_spaceSpace of column.YESnumber
item_radiusRadius of column.YESnumber
item_start_yThe starting Y point of the column, relative coordinate, default is 0 if not filled.NOnumber
item_max_heightMaximum height of column.If unfilled,default is widget height.NOnumber
item_colorColor of column.YESnumber
data_min_valueMinimum value of the column.Used to calculate the actual height of the column.YESnumber
data_max_valueMaximum value of the column.Used to calculate the actual height of the column.YESnumber
data_arrayData array of columns.YESArray<number>
data_countLength of data.YESnumber
xlineConfiguration objects for the x-axis.YESXLine
xTextConfiguration object for x-axis text.YESXText
ylineConfiguration objects for the y-axis.YESYLine
yTextConfiguration object for y-axis text.YESYText

XLine: object

PropertiesDescriptionRequiredType
padingMargin of dividing line based on x-axis.YESnumber
spaceThe interval of the dividing line.YESnumber
startThe y-axis coordinates of the start of the divider.YESnumber
endThe y-axis coordinate of the end of the divider end-start is the width of the divider.YESnumber
widthThe width of the line.YESnumber
countThe number of dividers.YESnumber
colorThe color of the dividing line.YESnumber

YLine: object

PropertiesDescriptionRequiredType
padingMargin of dividing line based on y-axis.YESnumber
spaceThe interval of the dividing line.YESnumber
startThe x-axis coordinates of the start of the divider.YESnumber
endThe x-axis coordinate of the end of the divider end-start is the width of the divider.YESnumber
widthThe width of the line.YESnumber
countThe number of dividers.YESnumber
colorThe color of the dividing line.YESnumber

XText: object

PropertiesDescriptionRequiredType
xThe initial x-coordinate of the text.YESnumber
yThe initial y-coordinate of the text.YESnumber
wThe width of the text.YESnumber
hThe height of the text.YESnumber
spaceThe spacing of the text.The x-coordinate of the nth text = x + (w + space)*(n - 1).YESnumber
colorThe color of the textYESnumber
data_arrayThe array of text.YESArray<string>
countThe length of the array.YESnumber

yText: object

PropertiesDescriptionRequiredType
xThe initial x-coordinate of the text.YESnumber
yThe initial y-coordinate of the text.YESnumber
wThe width of the text.YESnumber
hThe height of the text.YESnumber
spaceThe spacing of the text.The x-coordinate of the nth text = y + (h + space)*(n - 1).YESnumber
colorThe color of the textYESnumber
data_arrayThe array of text.YESArray<string>
countThe length of the array.YESnumber

Update item data

const view = ......;
view.setProperty(prop.UPDATE_DATA, {
data_array: [100, 100, 0, 0, 0, 100],
data_count: 6
})

Code example

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

Page({
build() {
const fillRect = createWidget(widget.FILL_RECT, {
x: 100,
y: 120,
w: 300,
h: 300,
color: 0xffffff
})

const view = createWidget(widget.HISTOGRAM, {
x: 100,
y: 120,
h: 300,
w: 300,
item_width: 20,
item_space: 10,
item_radius: 10,
item_start_y: 50,
item_max_height: 230,
item_color: 0x304ffe,
data_array: [20, 30, 40, 50, 60, 100, 80, 90, 20, 30],
data_count: 10,
data_min_value: 10,
data_max_value: 100,
xline: {
pading: 20,
space: 20,
start: 0,
end: 300,
color: 0x00c853,
width: 1,
count: 15
},
yline: {
pading: 10,
space: 10,
start: 0,
end: 300,
color: 0xff6d00,
width: 1,
count: 30
},
xText: {
x: 12,
y: 270,
w: 20,
h: 50,
space: 10,
align: align.LEFT,
color: 0x000000,
count: 10,
data_array: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
},
yText: {
x: 0,
y: 20,
w: 50,
h: 50,
space: 10,
align: align.LEFT,
color: 0x000000,
count: 6,
data_array: ['a', 'b', 'c', 'd', 'e', 'f']
}
})
}
})