struct Chart
pub struct Chart {
pub now time.Instant
pub reduced bool
}Purpose
Structure encapsulating now, reduced.
Public fields
nowtime.Instant- field (time.Instant)
reducedbool- field (bool)
#ui/chartStandard library package `#ui/chart`.
These sources come from the official examples repository and can be copied or downloaded. Run them with a local Xu SDK in the complete project; network, database, and desktop examples require the corresponding services or assets.
16_ui_webview/component_workshop/main.xu@main
#ui
#ui/widgets
#time
demo #"github.com/xulang-org/examples/ui_demo"
fn scene(events chan ui.Event) int {
ready := demo.ready(events) or >>
if ready.kind == ui.EV_EXIT{ << 0}
$screen := widgets.screen(&ready) or >>
screen.resize(1180.0, 900.0) or(err) {screen.dispose()
>> err}
screen.set_min_size(920, 780) or(err) {screen.dispose()
>> err}
$model := create($&screen) or(err) {screen.dispose()
>> err}
workshop_loop(events, $&model, $&screen) or(err) {screen.dispose()
>> err}
screen.dispose()
<< 0
}
fn worker(events chan ui.Event) {scene(events) or(err) {demo.fail(err.msg())
<< }}
fn launch() int {
$app := demo.app("XUUI / Component Workshop", 1180, 900) or >>
xu worker(app.event_ch)
<< app.run() or >>
}
fn main() int { << launch() or(err) {eprintln(err.msg())
<< 1}}
fn next_event(events chan ui.Event, deadline time.Instant) ui.Event{
if deadline.is_zero() { << <- events}
delay := deadline.since(time.instant())
if delay.nanoseconds() <= 0 { << ui.Event{kind: ui.EV_NONE, window_id: 0, menu_id: "", width: 0, height: 0}}
timer := delay.timer()
select {event := <- events{timer.stop()
<< event}
_ := <- timer.c{timer.stop()}}
<< ui.Event{kind: ui.EV_NONE, window_id: 0, menu_id: "", width: 0, height: 0}
}
fn workshop_loop(events chan ui.Event, model $&Workshop, screen $&widgets.Screen) int {
model.apply_locale(screen) or >>
screen.set_text(model.title, "XUUI / Field") or >>
model.configure_controls(screen) or >>
model.controls_dirty = false
model.apply_appearance(screen) or >>
model.appearance_dirty = false
$dispatcher := register_events(& * model, & * screen) or >>
model.layout(screen) or >>
while screen.is_open() {
register_notice_events(& * screen, $&dispatcher) or >>
now := time.instant()
model.work(screen, now) or >>
if model.controls_dirty{model.configure_controls(screen) or >>
model.controls_dirty = false}
if model.appearance_dirty{model.apply_appearance(screen) or >>
model.appearance_dirty = false}
model.apply_page_options(screen) or >>
model.layout(screen) or >>
$deadline := screen.advance(now) or >>
$timed_actions := false
for action in screen.take_actions() {
_ := dispatcher.dispatch_or_fallback(&action, model, screen) or >>
timed_actions = true
}
// Reconcile timer-driven values/styles before computing the next wait.
if timed_actions{ -> }
_ := screen.render() or >>
if model.running &&(deadline.is_zero() || model.deadline.before(deadline)) {deadline = model.deadline}
event := next_event(events, deadline) or >>
$actions := screen.event(&event) or >>
$count := 0
while screen.is_open() && count < 128 {pending := ui.poll_chan(events)
if pending.kind == ui.EV_NONE{ <- }
more := screen.event(&pending) or >>
for action in more{actions.push(action)}
count += 1}
for action in actions{register_notice_events(& * screen, $&dispatcher) or >>
_ := dispatcher.dispatch_or_fallback(&action, model, screen) or >> }
}
<< 0
}@main
#ui/widgets
#ui/chart
#ui/draw
#ui/layout
#time
fn read_only(index int) bool { << index >= 38 ||(index >= 1 && index <= 26 && index != 8 && index != 25 && index != 26)}
fn invalid(index int) bool { << index >= 40 || index >= 1 && index <= 30 && index != 7 && index != 8 && index != 12 && index != 24 && index != 25 && index != 26 && index != 28}
fn animated(index int) bool { <<(index >= 38 && index <= 44) || index == 1 || index == 2 || index == 5 || index == 6 || index == 7 || index == 8 || index == 9 || index == 10 || index == 11 || index == 25}
fn appearance(styles &widgets.Styles, index int) widgets.ControlStyle{
if index == 0 {$c := styles.input.clone()
c.padding = layout.Insets{left: 0.0, top: 0.0, right: 0.0, bottom: 0.0}
c.align_x = 0.0
c.align_y = 0.0
<< c}
if index == 7 { << styles.tree_style()}
if index == 24 { << styles.table_style()}
if index == 9 || index == 10 || index == 11 || index == 12 { << styles.checkbox.clone()}
if index == 3 || index == 5 || index == 45 { << styles.input.clone()}
if index == 4 || index == 6 { << styles.text_area.clone()}
if index == 13 || index == 40 { << styles.slider_style()}
if index == 41 { << styles.card_style()}
if index == 14 { << styles.stepper_style()}
if index == 15 { << styles.select_style()}
if index == 21 || index == 22 { << styles.tabs_style()}
if index == 23 { << styles.list_box_style()}
if index == 27 { << styles.progress.clone()}
if index == 29 { << styles.divider_style()}
if index == 30 { << styles.badge_style()}
if index == 31 { << styles.card_style()}
if index == 32 { << styles.scroll.clone()}
<< styles.button.clone()
}
fn (m $&Workshop) apply_appearance(s $&widgets.Screen) int {
theme := s.selected(m.theme) or >>
density := s.selected(m.density) or >>
scale := s.selected(m.scale) or >>
preset :=[widgets.THEME_LIGHT, widgets.THEME_DARK, widgets.THEME_CONTRAST][theme]
$styles := widgets.preset_styles(preset) or >>
styles.density =[1.0, 0.85, 1.25][density]
styles.text_scale =[1.0, 1.4, 2.0][scale]
sheet := widgets.screen_appearance(&styles, s.toggle_value(m.reduced) or >>) or >>
s.apply_appearance(&sheet) or >>
position := m.selected
pages := &m.pages
page := &pages[position]
id := page.ids[0]
if m.selected == 30 {$avatar := styles.button_variant(widgets.BUTTON_SUBTLE) or >>
avatar.radius = 999.0
s.set_control_style(page.ids[2], &avatar) or >> }
if m.selected <= 32 || m.selected >= 40 {
s.clear_control_style(id) or >>
if m.customized{$c := appearance(&styles, m.selected)
c.radius = 14.0
c.border_width = 1.5
c.padding.left += 4.0
c.padding.right += 4.0
s.set_control_style(id, &c) or >> }
}
$spec := widgets.motion_spec()
if m.slow{spec.change = time.milliseconds(420) or >>
spec.hover = time.milliseconds(320) or >>
spec.enter = time.milliseconds(360) or >>
spec.exit = time.milliseconds(240) or >>
spec.curve = widgets.EASE_OUT_QUINT}
if animated(m.selected) {s.set_motion(id, &spec) or >> }
if m.selected == 1 {
handles :=[page.ids[0], page.ids[1], page.ids[2], page.ids[3]]
placements :=[widgets.ICON_LEADING, widgets.ICON_TRAILING, widgets.ICON_ABOVE, widgets.ICON_BELOW]
english := (s.selected(m.language) or >>) == 1
for i in 0:4 {
icon_size := s.number_value(page.ids[9 + i]) or >>
$icon_prefix := "图标 · "
if english {icon_prefix = "Icon · "}
s.set_text(page.ids[13 + i], icon_prefix + str(int(icon_size)) + " px") or >>
$c := styles.button_variant(widgets.BUTTON_OUTLINE) or >>
if i == 0 {c = styles.button_variant(widgets.BUTTON_PRIMARY) or >> }
c.icon_placement = placements[i]
c.icon_size = icon_size * styles.text_scale
if m.customized{c.radius = 14.0
c.border_width = 1.5}
s.set_control_style(handles[i], &c) or >>
s.set_motion(handles[i], &spec) or >>
}
}
if m.selected == 33 || m.selected == 34 || m.selected == 36 {s.set_motion(page.ids[1], &spec) or >>
$c := styles.overlay_style()
if m.customized{c.radius = 18.0
c.border_width = 2.0}
s.set_control_style(page.ids[1], &c) or >> }
if m.selected == 34 {
$placement := widgets.overlay_placement()
placement.side = m.tooltip_side
placement.align = widgets.OVERLAY_CENTER
s.set_tooltip_placement(page.ids[1], &placement) or >>
}
if m.selected == 35 {
s.set_notice_motion(&spec) or >>
if m.customized{$c := styles.overlay_style()
c.radius = 18.0
c.border_width = 2.0
s.set_notice_style(&c) or >> }
else {s.clear_notice_style() or >> }
}
if m.selected == 38 {
$group_appearance := widgets.button_group_appearance()
group_appearance.vertical = m.group_vertical
group_appearance.joined = m.group_joined
for i in 0:3 {s.set_button_group_appearance(page.ids[i], &group_appearance) or >>
s.clear_control_style(page.ids[i]) or >>
s.set_motion(page.ids[i], &spec) or >>
if m.customized{$c := styles.button_variant(widgets.BUTTON_OUTLINE) or >>
c.radius = 12.0
c.border_width = 1.5
s.set_control_style(page.ids[i], &c) or >> }}
}
if m.selected == 39 {
s.clear_control_style(id) or >>
$appearance := chart.chart_appearance()
appearance.y_unit = " ms"
if m.chart_kind == widgets.CHART_DONUT || m.chart_kind == widgets.CHART_PIE || m.chart_kind == widgets.CHART_ROSE ||
m.chart_kind == widgets.CHART_FUNNEL || m.chart_kind == widgets.CHART_TREEMAP || m.chart_kind == widgets.CHART_SANKEY{appearance.y_unit = ""}
else if m.chart_kind == widgets.CHART_GAUGE || m.chart_kind == widgets.CHART_POLAR_BAR{appearance.y_unit = "%"}
if m.customized{appearance.grid = false
appearance.area_opacity = 0.26
appearance.inner_radius = 0.78
appearance.palette =[draw.rgb(41, 126, 178), draw.rgb(215, 146, 42), draw.rgb(56, 153, 124)]
$c := styles.card_style()
c.radius = 18.0
s.set_control_style(id, &c) or >> }
s.set_chart_appearance(id, &appearance) or >>
$options := widgets.animation_options()
options.duration = time.milliseconds(650) or >>
options.curve = widgets.EASE_IN_OUT_CUBIC
if m.slow{options.duration = time.milliseconds(1200) or >> }
s.set_chart_animation(id, &options) or >>
if m.chart_paused{s.pause_chart_animation(id) or >> }
}
if m.selected == 40 {
$options := widgets.range_slider_options()
options.step = 5.0
options.min_distance = 10.0
if m.range_push{options.collision = widgets.RANGE_PUSH}
options.vertical = m.range_vertical
options.commit_only = m.range_commit
s.set_range_options(id, &options) or >>
$appearance := widgets.slider_appearance()
appearance.ticks = 11
appearance.show_value = true
s.set_range_appearance(id, &appearance) or >>
}
if m.selected == 41 {
$options := widgets.split_view_options()
options.vertical = m.split_vertical
options.minimum_first = 120.0 * styles.text_scale
options.minimum_second = 140.0 * styles.text_scale
s.set_split_options(id, &options) or >>
}
if m.selected >= 42 && m.selected <= 44 {
$appearance := widgets.menu_appearance()
appearance.close_on_select = !m.menu_stays_open
s.set_menu_appearance(id, &appearance) or >>
}
if m.selected == 37 {$radius := 8.0
if m.customized{radius = 18.0}
s.set_webview_radius(id, radius) or >> }
<< 0
}
// Business handlers set option flags. Appearance changes run only here.
fn (m $&Workshop) apply_page_options(s $&widgets.Screen) int {
if m.tree_options_dirty{
$appearance := widgets.tree_appearance()
appearance.guides = m.guided
s.set_tree_appearance(m.pages[7].ids[0], &appearance) or >>
m.tree_options_dirty = false
}
if m.field_options_dirty{
$decoration := widgets.field_decoration(&"Project name 项目名称")
decoration.variant =(m.variant - 1) % 3
decoration.floating =(m.variant - 1) % 4
decoration.helper = "Floating / fixed label and stable helper area"
decoration.error = "Please enter a valid name."
decoration.clearable = true
s.set_field_decoration(m.pages[m.field_options_page].ids[0], &decoration) or >>
m.field_options_dirty = false
}
if m.spinner_options_dirty{
s.set_spinner_appearance(m.pages[28].ids[0], 48.0, 4.0, time.milliseconds(1200) or >>) or >>
m.spinner_options_dirty = false
}
if m.popover_options_dirty{
$placement := widgets.overlay_placement()
placement.side = m.variant
placement.align = widgets.OVERLAY_CENTER
s.set_popover_placement(m.pages[33].ids[1], &placement) or >>
m.popover_options_dirty = false
}
<< 0
}@main
#ui
#ui/widgets
#ui/chart
#ui/draw
#time
#math
fn names()[]string { << names_locale(true) }
fn names_locale(english bool)[]string {
if english {
<<["StyledLabel", "Button", "IconButton", "Input", "TextArea", "Field", "FieldArea", "TreeView", "TaskButton", "Checkbox", "Switch", "Radio", "RadioGroup", "Slider", "Stepper", "Select", "ComboBox", "MultiSelect", "DatePicker", "TimePicker", "ColorPicker", "Tabs", "Segmented", "ListBox", "Table", "Pagination", "Breadcrumbs", "Progress", "Spinner", "Divider", "Badge", "Card", "Scroll", "Popover", "Tooltip", "ToastHost", "Modal", "WebView", "ButtonGroup", "Chart", "RangeSlider", "SplitView", "Menu", "ContextMenu", "SplitButton", "PasswordInput"]
}
<<["StyledLabel 文本", "Button 按钮", "IconButton 图标按钮", "Input 单行输入", "TextArea 多行输入", "Field 表单字段", "FieldArea 多行字段", "TreeView 树形视图", "TaskButton 任务按钮", "Checkbox 复选框", "Switch 开关", "Radio 单选框", "RadioGroup 单选组", "Slider 滑块", "Stepper 步进器", "Select 下拉选择", "ComboBox 组合框", "MultiSelect 多选框", "DatePicker 日期选择", "TimePicker 时间选择", "ColorPicker 颜色选择", "Tabs 标签页", "Segmented 分段控件", "ListBox 列表框", "Table 数据表格", "Pagination 分页器", "Breadcrumbs 面包屑", "Progress 进度条", "Spinner 加载指示", "Divider 分割线", "Badge 徽标", "Card 卡片", "Scroll 滚动容器", "Popover 气泡浮层", "Tooltip 文字提示", "ToastHost 通知队列", "Modal 模态弹窗", "WebView 网页视图", "ButtonGroup 按钮组", "Chart 图表", "RangeSlider 区间滑块", "SplitView 分栏视图", "Menu 下拉菜单", "ContextMenu 右键菜单", "SplitButton 拆分按钮", "PasswordInput 密码框"]
}
fn new_page(s $&widgets.Screen, index int) Page{
group := s.group() or >>
$ids :=[]int {}
choices :=["Workspace 工作区", "History 历史", "Output 输出"]
if index == 0 {ids.push(s.label("清晰的层级,让每个细节都服务于使用。\n中文、English 与 emoji 👩🏽💻 都使用原生排版。", 20.0, false) or >>)
s.set_label_wrapped(ids[0], true) or >>
ids.push(s.label("很长的完整内容:Cluster-safe truncation · 👨👩👧👦 family · workspace / widgets / component.xu", 16.0, false) or >>)
s.set_label_ellipsis(ids[1], true) or >>
anchor := ids[1]
ids.push(s.tooltip(anchor, "很长的完整内容:Cluster-safe truncation · 👨👩👧👦 family · workspace / widgets / component.xu") or >>)}
if index == 1 {
$sizes :=[]int {}
$labels :=[]int {}
for text in["Build project", "Open workspace · trailing", "Save changes · above", "Download SDK · below"] {
// Each inspector precedes its own button in both layout and Tab order.
inspector := s.stepper(12.0, 64.0, 4.0, 24.0) or >>
sizes.push(inspector)
_ := s.tooltip(inspector, text + " · Icon size 图标尺寸 (px)") or >>
labels.push(s.label("Icon 图标 · 24 px", 14.0, true) or >>)
ids.push(s.button_with_icon("logo.png", text) or >>)}
for text in["Secondary", "Outline", "Ghost", "Danger", "Subtle"] {ids.push(s.button(text) or >>)}
s.set_button_variant(ids[0], widgets.BUTTON_PRIMARY) or >>
for variant in 1:6 {s.set_button_variant(ids[variant + 3], variant) or >> }
for id in sizes{ids.push(id)}
for id in labels{ids.push(id)}}
if index == 2 {ids.push(s.icon_button("logo.png", "Open XU workspace") or >>)
anchor := ids[0]
ids.push(s.tooltip(anchor, "Open XU workspace · Enter") or >>)}
if index == 3 {ids.push(s.input("中文 / English / 🙂") or >>)}
if index == 4 {ids.push(s.text_area("Native text editing\n选择文字、复制、粘贴,保留输入法会话。\n👩🏽💻 family 👨👩👧👦") or >>)}
if index == 5 || index == 6 {
$decoration := widgets.field_decoration(&"Project name 项目名称")
decoration.helper = "Enter a name · Native IME / selection / clipboard"
decoration.error = "名称不能为空。Please enter a project name."
decoration.clearable = true
if index == 5 {decoration.prefix = "xu /"
ids.push(s.field("", &decoration) or >>)}
else {ids.push(s.text_field_area("Build notes\n中文与 emoji 🙂", &decoration) or >>)}
$options := widgets.field_text_options()
options.counter = true
options.character_limit = 32
if index == 6 {options.min_rows = 3
options.max_rows = 6}
s.set_field_text_options(ids[0], &options) or >>
}
if index == 7 {
ids.push(s.tree() or >>)
root := s.tree_add(ids[0], - 1, "XU workspace") or >>
src := s.tree_add(ids[0], root, "src") or >>
widgets_node := s.tree_add(ids[0], src, "widgets") or >>
for name in["tree_view.xu", "task_button.xu", "field.xu", "screen.xu"] {leaf := s.tree_add(ids[0], widgets_node, name) or >>
s.set_tree_metadata(ids[0], leaf, "Xu") or >>
s.set_tree_action(ids[0], leaf, true) or >> }
_ := s.tree_add(ids[0], root, "xu.xun") or >>
for node in[root, src, widgets_node] {s.set_expanded(ids[0], node, true) or >> }
$appearance := widgets.tree_appearance()
appearance.guides = true
s.set_tree_appearance(ids[0], &appearance) or >>
$decoration := widgets.field_decoration(&"Find a node")
decoration.clearable = true
ids.push(s.field("", &decoration) or >>)
}
if index == 8 {ids.push(s.task_button("Build project") or >>)
s.set_task_labels(ids[0], "Building", "Built · run again", "Retry build", "Build again") or >> }
if index == 9 {ids.push(s.checkbox("Keep generated files 保留产物", true) or >>)}
if index == 10 {ids.push(s.switch_control("Live preview 实时预览", true) or >>)}
if index == 11 {ids.push(s.radio("Use workspace settings", 1, true) or >>)}
if index == 12 {ids.push(s.radio_group(&choices, 0) or >>)}
if index == 13 {ids.push(s.slider(0.0, 100.0, 40.0) or >>)
$appearance := widgets.slider_appearance()
appearance.ticks = 11
appearance.show_value = true
s.set_slider_appearance(ids[0], &appearance, 10.0) or >>
s.set_slider_commit_only(ids[0], true) or >>
$decoration := widgets.field_decoration(&"Exact value / 精确数值")
decoration.helper = "0–100 · step 10 · Apply input"
decoration.error = "Enter a number between 0 and 100."
ids.push(s.field("40", &decoration) or >>)}
if index == 14 {ids.push(s.stepper(0.0, 100.0, 1.0, 24.0) or >>)
s.set_stepper_repeat(ids[0], true, time.milliseconds(400) or >>, time.milliseconds(80) or >>) or >> }
if index == 15 {$unavailable := widgets.select_option("Remote (unavailable)")
unavailable.enabled = false
options :=[widgets.select_group("LOCAL"), widgets.select_option("Workspace 工作区"), widgets.select_option("History 历史"), widgets.select_group("REMOTE"), unavailable]
ids.push(s.select_options(&options, 1) or >>)}
if index == 16 {ids.push(s.combo_box(&choices, "") or >>)
s.set_combo_custom_values(ids[0], false) or >> }
if index == 17 {ids.push(s.multi_select(&choices) or >>)
$decoration := widgets.field_decoration(&"Filter options")
decoration.clearable = true
ids.push(s.field("", &decoration) or >>)}
if index == 18 || index == 19 {value := time.date(2026, 10, 25, 14, 30, 0, 0)
if index == 18 {ids.push(s.date_picker(value) or >>)
s.set_date_options(ids[0], value, true) or >> }
else {ids.push(s.time_picker(value) or >>)
s.set_clock_format(ids[0], true, true) or >> }}
if index == 20 {ids.push(s.color_picker(draw.rgb(180, 57, 45)) or >>)
s.set_color_swatches(ids[0], &[draw.rgb(180, 57, 45), draw.rgb(50, 121, 160), draw.rgb(72, 130, 90)]) or >>
$decoration := widgets.field_decoration(&"HEX / RGBA")
decoration.helper = "#RGB, #RGBA, #RRGGBB, #RRGGBBAA"
decoration.error = "Use a valid HEX value."
ids.push(s.field("#B4392DFF", &decoration) or >>)}
if index == 21 {ids.push(s.tabs(&choices, 0) or >>)
s.set_tab_behavior(ids[0], &[180.0, 144.0, 160.0], false) or >> }
if index == 22 {ids.push(s.segmented(&["Day", "Week", "Month"], 0) or >>)}
if index == 23 {ids.push(s.list_box(&["TreeView", "TaskButton", "Field", "Table", "WebView", "Scroll", "Tabs", "Select", "ToastHost"], 0) or >>)
for row in 0:9 {$detail := widgets.list_row(["TreeView", "TaskButton", "Field", "Table", "WebView", "Scroll", "Tabs", "Select", "ToastHost"][row])
detail.description = "Native component · 原生交互"
detail.detail = "Ready"
detail.icon = widgets.TREE_ICON_FILE
s.set_list_row(ids[0], row, &detail) or >> }}
if index == 24 {ids.push(s.table(&["Component", "Build ms", "Status"], 12, 0) or >>)
components :=["Button", "TreeView", "Field", "Input", "Tabs", "Checkbox", "Switch", "Menu", "WebView", "Chart", "Table", "Badge"]
durations :=[14, 7, 120, 3, 21, 7, 45, 9, 210, 32, 18, 2]
for row in 0:12 {s.set_cell(ids[0], row, 0, components[row]) or >>
s.set_cell(ids[0], row, 1, str(durations[row])) or >>
s.set_cell(ids[0], row, 2,["Ready", "Review", "Draft"][row % 3]) or >> }
s.set_table_sort_kind(ids[0], 1, widgets.TABLE_SORT_NUMBER) or >>
s.set_table_column_min_width(ids[0], 0, 160.0) or >>
s.set_table_column(ids[0], 0, 280.0, 0.0) or >>
s.set_table_column(ids[0], 1, 160.0, 1.0) or >>
s.set_table_column(ids[0], 2, 200.0, 0.0) or >> }
if index == 25 {ids.push(s.pagination(1000, 122) or >>)
s.set_pagination_data(ids[0], 20000, 20) or >>
$decoration := widgets.field_decoration(&"Page 页码")
decoration.helper = ""
decoration.error = ""
decoration.reserve_helper = false
decoration.floating = widgets.LABEL_ALWAYS
ids.push(s.field("123", &decoration) or >>)
ids.push(s.select_box(&["10 / page", "20 / page", "50 / page", "100 / page"], 1) or >>)
ids.push(s.label("", 14.0, true) or >>)
s.set_label_wrapped(ids[3], true) or >>
ids.push(s.button("Go 跳转") or >>)
ids.push(s.label("", 13.0, true) or >>)
s.set_label_wrapped(ids[5], true) or >> }
if index == 26 {ids.push(s.breadcrumbs(&["Home", "XU workspace", "src", "ui", "widgets", "A long Chinese path 中文路径", "field.xu"]) or >>)}
if index == 27 {ids.push(s.progress(0.42) or >>)
s.set_progress_buffer(ids[0], 0.72) or >> }
if index == 28 {ids.push(s.spinner() or >>)
s.set_spinner_appearance(ids[0], 32.0, 3.0, time.milliseconds(900) or >>) or >>
s.set_running(ids[0], true) or >>
ids.push(s.label("Loading assets… 正在加载", 14.0, true) or >>)}
if index == 29 {ids.push(s.divider(widgets.AXIS_HORIZONTAL) or >>)
ids.push(s.label("SECTION / 章节", 12.0, true) or >>)}
if index == 30 {
inbox := s.button("Inbox 收件箱") or >>
count := s.badge_on(inbox, "12", widgets.BADGE_COUNT) or >>
s.set_badge_tone(count, widgets.BADGE_ERROR) or >>
avatar := s.button("LW") or >>
s.set_button_variant(avatar, widgets.BUTTON_SUBTLE) or >>
dot := s.badge_on(avatar, "", widgets.BADGE_DOT) or >>
s.set_badge_anchor(dot, avatar, 0.86, 0.86) or >>
s.set_badge_tone(dot, widgets.BADGE_SUCCESS) or >>
synced := s.badge("Synced 已同步") or >>
s.set_badge_tone(synced, widgets.BADGE_SUCCESS) or >>
beta := s.badge("BETA") or >>
s.set_badge_tone(beta, widgets.BADGE_INFO) or >>
ids =[count, inbox, avatar, dot, synced, beta,
s.label("12 unread · 点击收件箱清零,徽标随数字收紧。", 14.0, true) or >>,
s.label("林文 · Available 在线", 16.0, false) or >>,
s.label("点击头像切换在线状态;状态点不单独承担文字含义。", 13.0, true) or >>,
s.label("Workspace 工作区", 16.0, false) or >>]
}
if index == 31 {
ids.push(s.card() or >>)
sections := s.card_sections(ids[0], 36.0, 44.0) or >>
for parent in[sections.header, sections.body, sections.footer] {ids.push(parent)}
ids.push(s.label("Workspace configuration", 18.0, false) or >>)
ids.push(s.label("Header, body and footer keep distinct spacing.\n正文区域随密度与字号调整。", 14.0, true) or >>)
s.set_label_wrapped(ids[5], true) or >>
ids.push(s.button("Open workspace") or >>)
s.set_parent(ids[4], sections.header) or >>
s.set_parent(ids[5], sections.body) or >>
s.set_parent(ids[6], sections.footer) or >>
}
if index == 32 {ids.push(s.scroll_area(widgets.AXIS_VERTICAL, 1100.0) or >>)
for row in 0:14 {id := s.button("Focusable row " + str(row + 1) + " · 滚动内容") or >>
s.set_parent(id, ids[0]) or >>
ids.push(id)}}
if index >= 33 && index <= 36 {ids.push(s.button(["Open popover", "Focus or hover for help", "Enqueue notification", "Open confirmation"][index - 33]) or >>)
anchor := ids[0]
if index == 33 {
ids.push(s.popover(anchor, "") or >>)
ids.push(s.label("Workspace preferences", 18.0, false) or >>)
ids.push(s.label("Edit a draft, then apply. Escape or clicking outside dismisses.\n编辑草稿后应用;关闭不会提交。", 13.0, true) or >>)
s.set_label_wrapped(ids[3], true) or >>
$decoration := widgets.field_decoration(&"Workspace name 工作区名称")
decoration.clearable = true
decoration.error = "名称不能为空 / Enter a name"
ids.push(s.field("XU workspace", &decoration) or >>)
ids.push(s.checkbox("Keep history 保留历史", true) or >>)
ids.push(s.button("Cancel 取消") or >>)
ids.push(s.button("Apply 应用") or >>)
s.set_button_variant(ids[7], widgets.BUTTON_PRIMARY) or >>
ids.push(s.label("Current: XU workspace · history on", 14.0, true) or >>)
for i in 2:8 {s.set_parent(ids[i], ids[1]) or >> }
}
if index == 34 {ids.push(s.tooltip(anchor, "Hover waits 500 ms; keyboard focus shows help immediately.\n鼠标离开或点击收起;Escape 抑制重复提示。") or >>)}
if index == 36 {ids.push(s.modal("Apply configuration?", "Focus stays inside this confirmation. Escape returns to the trigger.") or >>)
ids.push(s.button("Cancel") or >>)
ids.push(s.button("Apply changes") or >>)
s.set_parent(ids[2], ids[1]) or >>
s.set_parent(ids[3], ids[1]) or >> }
}
if index == 37 {ids.push(s.webview() or >>)
s.load_web_html(ids[0], "<!doctype html><html><meta charset='utf-8'><style>body{font:16px system-ui;background:#f3f2ee;color:#292c30;padding:24px}input{font:inherit;padding:12px;border:1px solid #747b83;border-radius:6px;width:80%}h2{font-weight:500}</style><h2>WebView is a component.</h2><p>Native focus, clipping and independent lifecycle.</p><input aria-label='Web content' placeholder='中文 / English / 🙂'></html>") or >> }
if index == 38 {
actions :=[widgets.button_group_item(10, "Undo"), widgets.button_group_item(20, "Redo"), widgets.button_group_item(30, "Save")]
group_choices :=[widgets.button_group_item(10, "Day"), widgets.button_group_item(20, "Week"), widgets.button_group_item(30, "Month")]
formats :=[widgets.button_group_item(10, "Bold"), widgets.button_group_item(20, "Italic"), widgets.button_group_item(30, "Underline")]
ids.push(s.button_group(&actions, widgets.BUTTON_GROUP_ACTIONS) or >>)
ids.push(s.button_group(&group_choices, widgets.BUTTON_GROUP_SINGLE) or >>)
ids.push(s.button_group(&formats, widgets.BUTTON_GROUP_MULTIPLE) or >>)
ids.push(s.label("Actions / 独立操作", 12.0, true) or >>)
ids.push(s.label("Single / 单选", 12.0, true) or >>)
ids.push(s.label("Multiple / 多选", 12.0, true) or >>)
}
if index == 39 {
ids.push(s.chart() or >>)
row0 :=[widgets.button_group_item(1, "Line"), widgets.button_group_item(2, "Area"), widgets.button_group_item(3, "Bar"), widgets.button_group_item(4, "Scatter"), widgets.button_group_item(5, "Donut")]
row1 :=[widgets.button_group_item(6, "Step"), widgets.button_group_item(7, "StackArea"), widgets.button_group_item(8, "StackBar"), widgets.button_group_item(9, "H-Bar"), widgets.button_group_item(10, "Pie")]
row2 :=[widgets.button_group_item(11, "Rose"), widgets.button_group_item(12, "Radar"), widgets.button_group_item(13, "Gauge"), widgets.button_group_item(14, "Bubble"), widgets.button_group_item(15, "Histogram")]
row3 :=[widgets.button_group_item(16, "Boxplot"), widgets.button_group_item(17, "Heatmap"), widgets.button_group_item(18, "Candle"), widgets.button_group_item(19, "Waterfall"), widgets.button_group_item(20, "Funnel")]
row4 :=[widgets.button_group_item(21, "Spline"), widgets.button_group_item(22, "SplineArea"), widgets.button_group_item(23, "PolarBar"), widgets.button_group_item(24, "Treemap"), widgets.button_group_item(25, "Sankey")]
row5 :=[widgets.button_group_item(26, "Violin"), widgets.button_group_item(27, "Bullet"), widgets.button_group_item(28, "Lollipop"), widgets.button_group_item(29, "Dumbbell"), widgets.button_group_item(30, "Pareto")]
$selector := widgets.button_group_appearance()
selector.equal_width = true
selector.allow_empty = true
rows :=[row0, row1, row2, row3, row4, row5]
for r in 0:6 {
gid := s.button_group(&rows[r], widgets.BUTTON_GROUP_SINGLE) or >>
s.set_button_group_appearance(gid, &selector) or >>
ids.push(gid)
}
series := chart_data(widgets.CHART_LINE, 0)
s.set_chart_series(ids[0], &series) or >>
}
if index == 40 {
ids.push(s.range_slider(0.0, 100.0, 20.0, 80.0) or >>)
ids.push(s.label("20 – 80", 18.0, false) or >>)
ids.push(s.label("Drag either thumb or the selected band. Tab visits both thumbs. Escape cancels a pending edit.\n拖动端点或整段;Tab 访问两个端点。", 14.0, true) or >>)
s.set_label_wrapped(ids[2], true) or >>
}
if index == 41 {
ids.push(s.split_view(0.4) or >>)
split := ids[0]
ids.push(s.split_pane(split, 0) or >>)
ids.push(s.split_pane(split, 1) or >>)
ids.push(s.label("Workspace / 工作区\nPane content follows the available size.", 16.0, false) or >>)
ids.push(s.label("Preview / 预览\nDrag the handle; arrows adjust, Shift accelerates.", 16.0, false) or >>)
ids.push(s.button("Open workspace") or >>)
ids.push(s.button("Refresh preview") or >>)
for i in 0:2 {s.set_label_wrapped(ids[3 + i], true) or >>
s.set_parent(ids[3 + i], ids[1 + i]) or >>
s.set_parent(ids[5 + i], ids[1 + i]) or >> }
}
if index >= 42 && index <= 44 {
mode :=[widgets.MENU_DROPDOWN, widgets.MENU_CONTEXT, widgets.MENU_SPLIT][index - 42]
label :=["Actions", "Right click here · 右键打开菜单", "Save"][index - 42]
ids.push(s.menu(label, &workshop_menu_items(true), mode, 100) or >>)
ids.push(s.label("Choose an action · 选择操作", 16.0, false) or >>)
ids.push(s.label("Check and radio items preserve their state. Navigate submenus with arrows; Escape returns one level.\n操作文案与快捷键由应用配置。", 14.0, true) or >>)
s.set_label_wrapped(ids[1], true) or >>
s.set_label_wrapped(ids[2], true) or >>
}
if index == 45 {
ids.push(s.password_input("Xu-密码🙂") or >>)
ids.push(s.checkbox("Show password 显示密码", false) or >>)
ids.push(s.label("Password 密码", 15.0, false) or >>)
ids.push(s.label("Paste is supported. Copy and cut are blocked even when revealed.\n支持粘贴、选择和中英文输入;显隐切换保留内容与光标。", 14.0, true) or >>)
s.set_label_wrapped(ids[3], true) or >>
}
for i in 0:ids.len{
// Card slots and scroll children retain their content parent.
if index == 30 &&(i == 0 || i == 3) { -> }
if index == 31 && i > 0 { -> }
if index == 41 && i > 0 { -> }
if index == 32 && i > 0 { -> }
if index == 36 && i > 1 { -> }
if index == 33 && i >= 2 && i <= 7 { -> }
s.set_parent(ids[i], group) or >>
}
s.set_visible(group, false) or >>
<< Page{group: group, ids: ids}
}
fn description(index int) string { << description_locale(index, false) }
fn description_locale(index int, english bool) string {
if english {
if index == 45 { << "Unicode grapheme masking; reveal toggle, native editing, read-only and disabled states; copy/cut blocked."}
if index == 40 { << "Dual-thumb range: step, minimum distance, clamp/push, band dragging; independent focus and commit."}
if index == 41 { << "Resizable split panes: minimum constraints, collapse/restore, keyboard adjustment; content clipped per pane."}
if index >= 42 && index <= 44 { << "Action / check / radio / submenu items; keyboard navigation, edge flipping, shortcuts and per-item feedback."}
if index == 38 { << "Actions / single / multiple selection; per-item disable, arrow navigation, Enter or Space activation."}
if index == 39 { << "Native interactive charts (30 types): stable-ID transitions, hover/select, legend; Ctrl/⌘ + wheel zoom, drag pan, double-click reset."}
en :=["Layered body, heading and muted text; native line wrapping and font overrides.",
"Leading / trailing / above / below icons; independent size steppers and content-width wrapping.",
"Standalone hit target and action label; keyboard focus also triggers tooltip help.",
"Native single-line editing: selection, copy, paste and IME composition.",
"Native multi-line editing: paragraphs, internal scrolling and IME candidate placement.",
"Floating / fixed labels and three border variants; soft counter never truncates input.",
"Multi-line Field: min 3 rows, max 6 rows; character counter and stable helper region.",
"Hierarchy guides, vector arrows, icons, metadata, filtering and node actions.",
"Real compute batches drive progress; task ID rejects stale callbacks.",
"Full-row click target; indeterminate mixed state; interruptible check animation.",
"Track and thumb transition; interruptible rapid toggling; read-only preserves focus.",
"Single radio item and selection animation; full label hit target.",
"Arrow keys manage mutual exclusion; Tab enters the group once.",
"11 ticks, step-10 snapping, value readout; commit on release.",
"Hold to repeat and accelerate; stops cleanly at bounds.",
"Typed groups and disabled options; arrow keys skip non-selectable rows.",
"Local match highlighting and empty state; configurable free-text input.",
"Candidate filtering, removable tags, select-all and clear actions.",
"Today / Clear actions; Page Up/Down switches months, Shift switches years.",
"12/24-hour clock format; stores explicit typed time values.",
"RGBA channels, exact HEX input, swatches and recent color history.",
"Variable-width tabs; arrow keys move focus, Enter activates manually.",
"Segmented selection plate and container semantics distinct from Tabs.",
"Icon / primary & secondary text / trailing detail; hit testing scales with font size.",
"Resizable columns, horizontal & vertical scrolling, and data status messages.",
"First, last and ellipsis items; fast page jumping for large datasets.",
"Preserves current path; middle segments collapse into an interactive menu.",
"Determinate progress and buffer shown separately without fabricated percentages.",
"Configurable size, stroke width and period; static feedback under reduced motion.",
"Subtle divider paired with section heading; unified horizontal and vertical spec.",
"Badges in context: unread count, avatar status dot and status tags.",
"Header / body / footer content slots; actions use standalone Buttons.",
"True child clipping, wheel bubbling, track dragging and keyboard focus scroll-into-view.",
"Anchor placement and edge flipping; outside click or Escape dismisses.",
"Hover delay and immediate focus help; Escape suppresses repeated tooltips.",
"Up to three visible notices; queueing, deduplication, priority and undo action.",
"Modal focus loop and restoration; safe action receives initial focus.",
"Native webview child component with clipping and independent lifecycle."]
<< en[index]
}
if index == 45 { << "按 Unicode 字素掩码;显隐切换、原生编辑、只读与禁用,禁止复制或剪切密码。"}
if index == 40 { << "双端区间:步进、最小间距、端点推挤、整段拖动;独立焦点与提交。"}
if index == 41 { << "可调整分栏:尺寸约束、折叠恢复、键盘调整;内容保持在各自面板内。"}
if index >= 42 && index <= 44 { << "动作 / 勾选 / 单选 / 子菜单;键盘、边缘翻转、快捷键与可定制的逐项反馈。"}
if index == 38 { << "独立操作 / 单选 / 多选;逐项禁用,方向键导航,Enter 或空格激活。"}
if index == 39 { << "原生交互图表(30 种类型):稳定 ID 数据过渡、悬停/选中、图例;Ctrl/⌘ + 滚轮缩放,拖动平移,双击复位。"}
descriptions :=["正文、标题与辅助文字分层;原生换行与字体覆盖。",
"图标左 / 右 / 上 / 下;各自调节尺寸,按钮按内容宽度自动换行。",
"独立点击目标与动作名称;键盘焦点也能查看提示。",
"原生单行编辑:选区、复制、粘贴与 IME。",
"原生多行编辑:段落、内部滚动与输入法候选定位。",
"浮动标签 / 固定标签 / 三种边框;软计数不截断输入。",
"多行 Field:最小 3 行、最大 6 行;计数与稳定辅助区。",
"层级引导、矢量箭头、图标、元数据、筛选和节点动作。",
"真实计算批次驱动进度;任务 ID 拒绝旧回调。",
"整行点击;混合态;可中断的勾选显现。",
"轨道与圆钮过渡;快速切换可中断;只读保留焦点。",
"单项选择与选中动效;完整标签点击目标。",
"方向键管理互斥;Tab 只进入一次。",
"11 个刻度、10 步吸附、数值提示;松开才提交。",
"按住连续增加并加速;到达边界停止。",
"有类型的分组 / 禁用选项;方向键跳过不可选行。",
"本地匹配高亮与无结果;可控制是否接受自由输入。",
"候选筛选、可移除标签、全选和清空。",
"今天 / 清空;Page Up/Down 快速翻月,Shift 切年。",
"12/24 小时可选;存储保持明确的时间值。",
"RGBA 通道、HEX 精确输入、色板与最近颜色。",
"可变宽标签;方向键移动,Enter 手动激活。",
"与 Tabs 分开的选中底板和容器语义。",
"图标 / 主副文本 / 尾部信息;字体放大后命中保持一致。",
"拖动调整列宽;横向与纵向滚动;数据状态文字。",
"首页、末页与省略项;大页数仍可快速定位。",
"保留当前路径;中间段收进可交互的菜单。",
"真实确定进度与缓冲区分别显示,不伪造百分比。",
"大小 / 粗细 / 周期可配置;减少动效显示静态反馈。",
"弱分隔与章节文字组合;水平和垂直使用同一规范。",
"Badge 放入真实上下文:未读计数、头像状态点与列表标签。",
"Header / body / footer 内容槽;动作使用独立 Button。",
"真实子控件裁剪、滚轮冒泡、轨道拖动与键盘焦点滚入。",
"锚点定位、边缘翻转;外点 / Escape 关闭。",
"Hover 延迟、focus 立即显示;Escape 抑制重复提示。",
"最多三条可见通知;队列、去重、优先级与撤销动作。",
"模态焦点循环与恢复;安全动作先获得焦点。",
"原生网页子视图作为 Screen 组件,支持裁剪与独立生命周期。"]
<< descriptions[index]
}
fn tool_labels(index int)[]string { << tool_labels_locale(index, false) }
fn tool_labels_locale(index int, english bool)[]string {
if english {
if index == 45 { <<["Clear", "Reset sample", "Focus input"]}
if index == 40 { <<["Clamp / push", "Commit mode", "Orientation"]}
if index == 41 { <<["Orientation", "Collapse / restore", "Reset ratio"]}
if index >= 42 && index <= 44 { <<["Open menu", "Keep open", "Disable export"]}
if index == 38 { <<["Disable middle", "Orientation", "Joined / gap"]}
if index == 39 { <<["Update data", "Reset zoom", "Pause / resume"]}
if index == 0 { <<["Long text", "Short text", ""]}
if index == 1 || index == 2 { <<["Select", "Clear selection", ""]}
if index == 3 || index == 4 { <<["Clear", "Long text", ""]}
if index == 5 || index == 6 { <<["Clear", "Long text", "Appearance"]}
if index == 7 { <<["Guides", "Reveal last", "Clear filter"]}
if index == 8 { <<["Progress mode", "Fail next", "Cancel"]}
if index == 9 { <<["Mixed", "Checked", "Unchecked"]}
if index == 10 { <<["Pending", "Resolve", "Fail"]}
if index == 11 { <<["Select", "Deselect", ""]}
if index == 13 { <<["Apply input", "Commit only", "Live updates"]}
if index == 15 { <<["Open", "Disable option", ""]}
if index == 16 { <<["Allow custom", "Options only", "Clear"]}
if index == 17 { <<["Select all", "Clear", ""]}
if index == 18 { <<["Clear", "Set today", ""]}
if index == 19 { <<["12 hour", "24 hour", "Hide seconds"]}
if index == 20 { <<["Apply HEX", "Cinnabar", "Transparent"]}
if index == 24 { <<["Data", "Loading", "Error"]}
if index == 25 { <<["Jump", "Last page", "Empty / full"]}
if index == 27 { <<["0%", "42%", "100%"]}
if index == 28 { <<["Start", "Stop", "Large size"]}
if index == 30 { <<["+1 unread", "Clear", "99+ overflow"]}
if index == 32 { <<["Scroll top", "Scroll bottom", "Focus last"]}
if index == 33 { <<["Open", "Close", "Placement"]}
if index == 34 { <<["Focus help", "Blur", "Placement"]}
if index == 35 { <<["Enqueue", "Undo", "Burst 3"]}
if index == 36 { <<["Open", "Close", ""]}
if index == 37 { <<["Reload", "Hide", "Show"]}
<<["", "", ""]
}
if index == 45 { <<["清空", "重置示例", "聚焦输入"]}
if index == 40 { <<["端点限制 / 推挤", "提交模式", "切换方向"]}
if index == 41 { <<["切换方向", "折叠 / 恢复", "复位比例"]}
if index >= 42 && index <= 44 { <<["打开菜单", "保持展开", "禁用导出"]}
if index == 38 { <<["逐项禁用", "切换方向", "拼接 / 间距"]}
if index == 39 { <<["更新数据", "复位缩放", "暂停 / 继续"]}
if index == 0 { <<["切换长文", "切换短文", ""]}
if index == 1 || index == 2 { <<["设为选中", "取消选中", ""]}
if index == 3 || index == 4 { <<["清空内容", "填充长文", ""]}
if index == 5 || index == 6 { <<["清空内容", "填充长文", "切换外观"]}
if index == 7 { <<["引导线", "定位末项", "清空筛选"]}
if index == 8 { <<["进度外观", "下次失败", "取消任务"]}
if index == 9 { <<["混合态", "勾选", "取消勾选"]}
if index == 10 { <<["等待态", "完成切换", "失败恢复"]}
if index == 11 { <<["选中", "取消选中", ""]}
if index == 13 { <<["应用输入", "松开提交", "实时更新"]}
if index == 15 { <<["展开候选", "禁用选项", ""]}
if index == 16 { <<["允许自由输入", "仅限选项", "清空"]}
if index == 17 { <<["全选", "清空", ""]}
if index == 18 { <<["清空日期", "设为今天", ""]}
if index == 19 { <<["12 小时制", "24 小时制", "隐藏秒数"]}
if index == 20 { <<["应用 HEX", "朱砂色", "半透明"]}
if index == 24 { <<["正常数据", "正在加载", "加载错误"]}
if index == 25 { <<["页码跳转", "跳至末页", "空 / 满数据"]}
if index == 27 { <<["0%", "42%", "100%"]}
if index == 28 { <<["开始旋转", "停止旋转", "切换大号"]}
if index == 30 { <<["+1 未读", "清零未读", "99+ 溢出"]}
if index == 32 { <<["滚至顶部", "滚至底部", "聚焦末项"]}
if index == 33 { <<["打开浮层", "关闭浮层", "切换方位"]}
if index == 34 { <<["聚焦提示", "移出隐藏", "切换方位"]}
if index == 35 { <<["发送通知", "撤销通知", "连发三条"]}
if index == 36 { <<["打开确认框", "关闭确认框", ""]}
if index == 37 { <<["重新加载", "隐藏视图", "恢复显示"]}
<<["", "", ""]
}
fn workshop_menu_items(english bool)[]widgets.MenuItem{
labels :=["Open workspace", "Show grid", "Export", "PNG image", "SVG image", "Unavailable", "Save", "View density", "Compact", "Comfortable"]
$translated := labels
if !english{translated =["打开工作区", "显示网格", "导出", "PNG 图片", "SVG 图片", "暂不可用", "保存", "视图密度", "紧凑", "舒适"]}
$grid := widgets.menu_item(20, translated[1])
grid.kind = widgets.MENU_CHECK
$export := widgets.menu_item(30, translated[2])
export.kind = widgets.MENU_SUBMENU
$png := widgets.menu_item(31, translated[3])
png.parent = 30
$svg := widgets.menu_item(32, translated[4])
svg.parent = 30
$unavailable := widgets.menu_item(40, translated[5])
unavailable.enabled = false
$save := widgets.menu_item(50, translated[6])
save.shortcut_key = 115
save.shortcut_modifiers = ui.MOD_META
save.shortcut_label = "⌘S"
$separator := widgets.menu_item(60, "")
separator.kind = widgets.MENU_SEPARATOR
$heading := widgets.menu_item(70, translated[7])
heading.kind = widgets.MENU_HEADING
$compact := widgets.menu_item(80, translated[8])
compact.kind = widgets.MENU_RADIO
compact.radio_group = 1
$comfortable := widgets.menu_item(81, translated[9])
comfortable.kind = widgets.MENU_RADIO
comfortable.radio_group = 1
comfortable.checked = true
<<[widgets.menu_item(10, translated[0]), grid, export, png, svg, unavailable, save, separator, heading, compact, comfortable]
}
fn chart_data(kind int, revision int)[]chart.ChartSeries{
<< chart_data_locale(kind, revision, true)
}
fn chart_data_locale(kind int, revision int, english bool)[]chart.ChartSeries{
$result :=[]chart.ChartSeries{}
$series_count := 2
single := kind == widgets.CHART_DONUT || kind == widgets.CHART_PIE || kind == widgets.CHART_ROSE ||
kind == widgets.CHART_GAUGE || kind == widgets.CHART_HISTOGRAM || kind == widgets.CHART_BOXPLOT ||
kind == widgets.CHART_CANDLESTICK || kind == widgets.CHART_WATERFALL || kind == widgets.CHART_FUNNEL ||
(kind >= widgets.CHART_POLAR_BAR && kind <= widgets.CHART_SANKEY) || kind == widgets.CHART_VIOLIN ||
kind == widgets.CHART_BULLET || kind == widgets.CHART_DUMBBELL || kind == widgets.CHART_PARETO
if single{series_count = 1}
if kind == widgets.CHART_HEATMAP{series_count = 3}
for si in 0:series_count{
$name := "构建"
if si == 1 {name = "索引"}
if si == 2 {name = "绘制"}
if single{name = "工作量"}
if english {
name = "Build"
if si == 1 {name = "Index"}
if si == 2 {name = "Render"}
if single{name = "Workload"}
}
$series := chart.chart_series(si + 1, name, kind)
series.smooth = kind == widgets.CHART_LINE || kind == widgets.CHART_AREA || kind == widgets.CHART_STACKED_AREA ||
kind == widgets.CHART_SMOOTH_LINE || kind == widgets.CHART_SMOOTH_AREA
$count := 12 - revision % 2
if kind == widgets.CHART_SCATTER{count = 64}
else if kind == widgets.CHART_BUBBLE{count = 16}
else if kind == widgets.CHART_DONUT || kind == widgets.CHART_PIE || kind == widgets.CHART_ROSE ||
kind == widgets.CHART_FUNNEL || kind == widgets.CHART_TREEMAP || kind == widgets.CHART_SANKEY{count = 5}
else if kind == widgets.CHART_RADAR || kind == widgets.CHART_PARETO{count = 6}
else if kind == widgets.CHART_GAUGE{count = 3}
else if kind == widgets.CHART_POLAR_BAR{count = 4}
else if kind == widgets.CHART_HORIZONTAL_BAR || kind == widgets.CHART_HEATMAP || kind == widgets.CHART_BULLET ||
kind == widgets.CHART_LOLLIPOP || kind == widgets.CHART_DUMBBELL || kind == widgets.CHART_VIOLIN{count = 8}
else if kind == widgets.CHART_WATERFALL{count = 7}
for i in 0:count{
x := f64(i + 1)
phase := f64(revision) * 0.9 + f64(si) * 1.7
$y := 48.0 + f64(si) * 20.0 + math.sin(x * 0.55 + phase) * 20.0 + math.cos(x * 0.17 + phase) * 7.0
if kind == widgets.CHART_FUNNEL || kind == widgets.CHART_PARETO || kind == widgets.CHART_TREEMAP || kind == widgets.CHART_SANKEY{
y = f64((count - i) * 22 + (revision % 3) * 4)
} else if kind == widgets.CHART_GAUGE || kind == widgets.CHART_POLAR_BAR{
y = math.max(12.0, math.min(96.0, 34.0 + f64(i) * 18.0 + math.sin(phase + x) * 14.0))
} else if kind == widgets.CHART_WATERFALL{
deltas :=[42.0, 18.0, 0.0 - 14.0, 24.0, 0.0 - 11.0, 16.0, 0.0]
y = deltas[i] + math.sin(phase) * 3.0
if i == count - 1 {y = 0.0}
}
$point := chart.chart_point(i + 1, x, y)
if kind == widgets.CHART_BUBBLE{
point = chart.chart_bubble_point(i + 1, x, y, 12.0 + math.abs(math.cos(x * 0.7 + phase)) * 36.0)
} else if kind == widgets.CHART_BOXPLOT || kind == widgets.CHART_CANDLESTICK ||
kind == widgets.CHART_VIOLIN || kind == widgets.CHART_DUMBBELL || kind == widgets.CHART_BULLET{
$close := y + math.sin(x * 0.9 + phase) * 12.0
if (kind == widgets.CHART_BOXPLOT || kind == widgets.CHART_VIOLIN || kind == widgets.CHART_DUMBBELL || kind == widgets.CHART_BULLET) && close < y{
close = y + 10.0
}
low := math.min(y, close) - 8.0 - math.abs(math.cos(x + phase)) * 6.0
high := math.max(y, close) + 8.0 + math.abs(math.sin(x + phase)) * 6.0
point = chart.chart_range_point(i + 1, x, y, low, high, close)
} else if kind == widgets.CHART_WATERFALL && i == count - 1 {
point.size = 1.0
}
if english {
point.label = "Sample " + str(i + 1)
if kind == widgets.CHART_DONUT || kind == widgets.CHART_PIE || kind == widgets.CHART_ROSE ||
kind == widgets.CHART_FUNNEL || kind == widgets.CHART_TREEMAP || kind == widgets.CHART_SANKEY{
point.label =["Compile", "Index", "Render", "I/O", "Other"][i]
} else if kind == widgets.CHART_RADAR{
point.label =["Throughput", "Latency", "Memory", "Startup", "Cache", "Binary"][i]
} else if kind == widgets.CHART_GAUGE{
point.label =["CPU", "Memory", "Cache"][i]
} else if kind == widgets.CHART_POLAR_BAR{
point.label =["Core 0", "Core 1", "Core 2", "Core 3"][i]
} else if kind == widgets.CHART_WATERFALL && i == count - 1 {
point.label = "Total"
}
} else {
point.label = "样本 " + str(i + 1)
if kind == widgets.CHART_DONUT || kind == widgets.CHART_PIE || kind == widgets.CHART_ROSE ||
kind == widgets.CHART_FUNNEL || kind == widgets.CHART_TREEMAP || kind == widgets.CHART_SANKEY{
point.label =["编译", "索引", "绘制", "输入输出", "其他"][i]
} else if kind == widgets.CHART_RADAR{
point.label =["吞吐量", "延迟", "内存", "启动", "缓存", "体积"][i]
} else if kind == widgets.CHART_GAUGE{
point.label =["处理器", "内存", "缓存"][i]
} else if kind == widgets.CHART_POLAR_BAR{
point.label =["核心 0", "核心 1", "核心 2", "核心 3"][i]
} else if kind == widgets.CHART_WATERFALL && i == count - 1 {
point.label = "总计"
}
}
series.points.push(point)
}
result.push(series)
}
<< result
}struct Chartpub struct Chart {
pub now time.Instant
pub reduced bool
}Structure encapsulating now, reduced.
now time.Instantreduced boolchartpub fn chart(context &draw.Context,identity &ui.CanvasEvent,id int,bounds &layout.Rect) ChartExecute chart. Throws on failure; handle the error or propagate it to the caller.
context &draw.Contextidentity &ui.CanvasEventid intbounds &layout.RectChart — a value of this type
(&Chart) idpub fn (c &Chart) id() intReturn the unique integer ID of the element or control.
c &ChartChart instance used by this call (borrow).int — a value of this type
(&Chart) boundspub fn (c &Chart) bounds() layout.RectReturn the bounding Rectangle of the control or geometry.
c &ChartChart instance used by this call (borrow).layout.Rect — a value of this type
(&Chart) plot_boundspub fn (c &Chart) plot_bounds() layout.RectOperation on &Chart: plot bounds.
c &ChartChart instance used by this call (borrow).layout.Rect — a value of this type
(&Chart) needs_paintpub fn (c &Chart) needs_paint() boolOperation on &Chart: needs paint.
c &ChartChart instance used by this call (borrow).bool — true or false
($&Chart) paintedpub fn (c $&Chart) painted()Report whether the control was painted in the previous render pass.
c $&ChartChart instance used by this call (exclusive borrow).This call does not return a value.
($&Chart) invalidatepub fn (c $&Chart) invalidate()Invalidate the control area, requesting a repaint on next frame.
c $&ChartChart instance used by this call (exclusive borrow).This call does not return a value.
(&Chart) is_enabledpub fn (c &Chart) is_enabled() boolOperation on &Chart: whether it is enabled.
c &ChartChart instance used by this call (borrow).bool — true or false
(&Chart) is_focusedpub fn (c &Chart) is_focused() boolOperation on &Chart: whether it is focused.
c &ChartChart instance used by this call (borrow).bool — true or false
(&Chart) style_orpub fn (c &Chart) style_or(styles &widgets.Styles) widgets.ControlStyleOperation on &Chart: style or.
c &ChartChart instance used by this call (borrow).styles &widgets.Styleswidgets.ControlStyle — a value of this type
($&Chart) set_stylepub fn (c $&Chart) set_style(style &widgets.ControlStyle) intOperation on $&Chart: set style. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).style &widgets.ControlStyleint — a value of this type
($&Chart) clear_stylepub fn (c $&Chart) clear_style()Operation on $&Chart: clear style.
c $&ChartChart instance used by this call (exclusive borrow).This call does not return a value.
($&Chart) set_localepub fn (c $&Chart) set_locale(locale &widgets.Locale) intOperation on $&Chart: set locale. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).locale &widgets.Localeint — a value of this type
($&Chart) set_appearancepub fn (c $&Chart) set_appearance(appearance &ChartAppearance) intOperation on $&Chart: set appearance. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).appearance &ChartAppearanceint — a value of this type
($&Chart) set_boundspub fn (c $&Chart) set_bounds(bounds &layout.Rect) intOperation on $&Chart: set bounds. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).bounds &layout.Rectint — a value of this type
($&Chart) set_motionpub fn (c $&Chart) set_motion(spec &widgets.MotionSpec) intOperation on $&Chart: set motion. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).spec &widgets.MotionSpecint — a value of this type
($&Chart) set_animationpub fn (c $&Chart) set_animation(options &widgets.AnimationOptions) intOperation on $&Chart: set animation. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).options &widgets.AnimationOptionsint — a value of this type
($&Chart) set_seriespub fn (c $&Chart) set_series(series &[]ChartSeries) intOperation on $&Chart: set series. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).series &[]ChartSeriesint — a value of this type
($&Chart) set_domainpub fn (c $&Chart) set_domain(domain &ChartDomain) intOperation on $&Chart: set domain. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).domain &ChartDomainint — a value of this type
($&Chart) use_auto_domainpub fn (c $&Chart) use_auto_domain()Operation on $&Chart: use auto domain.
c $&ChartChart instance used by this call (exclusive borrow).This call does not return a value.
(&Chart) viewportpub fn (c &Chart) viewport() ChartDomainExecute viewport on &Chart.
c &ChartChart instance used by this call (borrow).ChartDomain — a value of this type
($&Chart) set_viewportpub fn (c $&Chart) set_viewport(view &ChartDomain) intOperation on $&Chart: set viewport. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).view &ChartDomainint — a value of this type
($&Chart) reset_viewportpub fn (c $&Chart) reset_viewport()Operation on $&Chart: reset viewport.
c $&ChartChart instance used by this call (exclusive borrow).This call does not return a value.
(&Chart) visible_domainpub fn (c &Chart) visible_domain() ChartDomainOperation on &Chart: visible domain.
c &ChartChart instance used by this call (borrow).ChartDomain — a value of this type
(&Chart) data_positionpub fn (c &Chart) data_position(x f64,y f64) ChartCoordinateOperation on &Chart: data position.
c &ChartChart instance used by this call (borrow).x f64y f64ChartCoordinate — a value of this type
(&Chart) data_atpub fn (c &Chart) data_at(x f64,y f64) ChartCoordinateOperation on &Chart: data at.
c &ChartChart instance used by this call (borrow).x f64y f64ChartCoordinate — a value of this type
($&Chart) tickpub fn (c $&Chart) tick(styles &widgets.Styles,now time.Instant,reduced bool) boolAdvance animation clock and state transition step. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).styles &widgets.Stylesnow time.Instantreduced boolbool — true or false
(&Chart) next_tickpub fn (c &Chart) next_tick(now time.Instant) time.InstantOperation on &Chart: next tick. Throws on failure; handle the error or propagate it to the caller.
c &ChartChart instance used by this call (borrow).now time.Instanttime.Instant — a value of this type
($&Chart) pause_animationpub fn (c $&Chart) pause_animation() intOperation on $&Chart: pause animation. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).int — a value of this type
($&Chart) resume_animationpub fn (c $&Chart) resume_animation()Operation on $&Chart: resume animation.
c $&ChartChart instance used by this call (exclusive borrow).This call does not return a value.
($&Chart) seek_animationpub fn (c $&Chart) seek_animation(progress f64) intOperation on $&Chart: seek animation. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).progress f64int — a value of this type
(&Chart) animation_progresspub fn (c &Chart) animation_progress() f64Operation on &Chart: animation progress.
c &ChartChart instance used by this call (borrow).f64 — a value of this type
($&Chart) cancelpub fn (c $&Chart) cancel()Execute cancel on $&Chart.
c $&ChartChart instance used by this call (exclusive borrow).This call does not return a value.
($&Chart) set_focuspub fn (c $&Chart) set_focus(value bool)Operation on $&Chart: set focus.
c $&ChartChart instance used by this call (exclusive borrow).value boolThis call does not return a value.
($&Chart) set_enabledpub fn (c $&Chart) set_enabled(value bool)Operation on $&Chart: set enabled.
c $&ChartChart instance used by this call (exclusive borrow).value boolThis call does not return a value.
($&Chart) set_read_onlypub fn (c $&Chart) set_read_only(value bool)Operation on $&Chart: set read only.
c $&ChartChart instance used by this call (exclusive borrow).value boolThis call does not return a value.
($&Chart) disposepub fn (c $&Chart) dispose()Release and dispose native resources and underlying handles.
c $&ChartChart instance used by this call (exclusive borrow).This call does not return a value.
const CHART_LINEpub const CHART_LINE = 0Constant CHART_LINE, defining protocol or algorithm parameters.
const CHART_AREApub const CHART_AREA = 1Constant CHART_AREA, defining protocol or algorithm parameters.
const CHART_BARpub const CHART_BAR = 2Constant CHART_BAR, defining protocol or algorithm parameters.
const CHART_SCATTERpub const CHART_SCATTER = 3Constant CHART_SCATTER, defining protocol or algorithm parameters.
const CHART_DONUTpub const CHART_DONUT = 4Constant CHART_DONUT, defining protocol or algorithm parameters.
const CHART_STEP_LINEpub const CHART_STEP_LINE = 5Constant CHART_STEP_LINE, defining protocol or algorithm parameters.
const CHART_STACKED_AREApub const CHART_STACKED_AREA = 6Constant CHART_STACKED_AREA, defining protocol or algorithm parameters.
const CHART_STACKED_BARpub const CHART_STACKED_BAR = 7Constant CHART_STACKED_BAR, defining protocol or algorithm parameters.
const CHART_HORIZONTAL_BARpub const CHART_HORIZONTAL_BAR = 8Constant CHART_HORIZONTAL_BAR, defining protocol or algorithm parameters.
const CHART_PIEpub const CHART_PIE = 9Constant CHART_PIE, defining protocol or algorithm parameters.
const CHART_ROSEpub const CHART_ROSE = 10Constant CHART_ROSE, defining protocol or algorithm parameters.
const CHART_RADARpub const CHART_RADAR = 11Constant CHART_RADAR, defining protocol or algorithm parameters.
const CHART_GAUGEpub const CHART_GAUGE = 12Constant CHART_GAUGE, defining protocol or algorithm parameters.
const CHART_BUBBLEpub const CHART_BUBBLE = 13Constant CHART_BUBBLE, defining protocol or algorithm parameters.
const CHART_HISTOGRAMpub const CHART_HISTOGRAM = 14Constant CHART_HISTOGRAM, defining protocol or algorithm parameters.
const CHART_BOXPLOTpub const CHART_BOXPLOT = 15Constant CHART_BOXPLOT, defining protocol or algorithm parameters.
const CHART_HEATMAPpub const CHART_HEATMAP = 16Constant CHART_HEATMAP, defining protocol or algorithm parameters.
const CHART_CANDLESTICKpub const CHART_CANDLESTICK = 17Constant CHART_CANDLESTICK, defining protocol or algorithm parameters.
const CHART_WATERFALLpub const CHART_WATERFALL = 18Constant CHART_WATERFALL, defining protocol or algorithm parameters.
const CHART_FUNNELpub const CHART_FUNNEL = 19Constant CHART_FUNNEL, defining protocol or algorithm parameters.
const CHART_SMOOTH_LINEpub const CHART_SMOOTH_LINE = 20Constant CHART_SMOOTH_LINE, defining protocol or algorithm parameters.
const CHART_SMOOTH_AREApub const CHART_SMOOTH_AREA = 21Constant CHART_SMOOTH_AREA, defining protocol or algorithm parameters.
const CHART_POLAR_BARpub const CHART_POLAR_BAR = 22Constant CHART_POLAR_BAR, defining protocol or algorithm parameters.
const CHART_TREEMAPpub const CHART_TREEMAP = 23Constant CHART_TREEMAP, defining protocol or algorithm parameters.
const CHART_SANKEYpub const CHART_SANKEY = 24Constant CHART_SANKEY, defining protocol or algorithm parameters.
const CHART_VIOLINpub const CHART_VIOLIN = 25Constant CHART_VIOLIN, defining protocol or algorithm parameters.
const CHART_BULLETpub const CHART_BULLET = 26Constant CHART_BULLET, defining protocol or algorithm parameters.
const CHART_LOLLIPOPpub const CHART_LOLLIPOP = 27Constant CHART_LOLLIPOP, defining protocol or algorithm parameters.
const CHART_DUMBBELLpub const CHART_DUMBBELL = 28Constant CHART_DUMBBELL, defining protocol or algorithm parameters.
const CHART_PARETOpub const CHART_PARETO = 29Constant CHART_PARETO, defining protocol or algorithm parameters.
const ACTION_CHART_HOVERpub const ACTION_CHART_HOVER = 40Constant ACTION_CHART_HOVER, defining protocol or algorithm parameters.
const ACTION_CHART_SELECTpub const ACTION_CHART_SELECT = 41Constant ACTION_CHART_SELECT, defining protocol or algorithm parameters.
const ACTION_CHART_VIEWPORTpub const ACTION_CHART_VIEWPORT = 42Constant ACTION_CHART_VIEWPORT, defining protocol or algorithm parameters.
const ACTION_CHART_LEGENDpub const ACTION_CHART_LEGEND = 43Constant ACTION_CHART_LEGEND, defining protocol or algorithm parameters.
const CHART_MAX_POINTSpub const CHART_MAX_POINTS = 4096Constant CHART_MAX_POINTS, defining protocol or algorithm parameters.
const CHART_MAX_SERIESpub const CHART_MAX_SERIES = 8Constant CHART_MAX_SERIES, defining protocol or algorithm parameters.
struct ChartPointpub struct ChartPoint {
pub id int
pub x f64
pub y f64
pub low f64
pub high f64
pub close f64
pub size f64
pub label string
}Structure encapsulating id, x, y, low, high.
id intx f64y f64low f64high f64close f64size f64label stringchart_pointpub fn chart_point(id int,x f64,y f64) ChartPointChart point.
id intx f64y f64ChartPoint — a value of this type
chart_bubble_pointpub fn chart_bubble_point(id int,x f64,y f64,size f64) ChartPointChart bubble point.
id intx f64y f64size f64ChartPoint — a value of this type
chart_range_pointpub fn chart_range_point(id int,x f64,open f64,low f64,high f64,close f64) ChartPointChart range point.
id intx f64open f64low f64high f64close f64ChartPoint — a value of this type
struct ChartSeriespub struct ChartSeries {
pub id int
pub name string
pub kind int
pub points []ChartPoint
pub color draw.Color
pub custom_color bool
pub visible bool
pub line_width f64
pub symbol_size f64
pub smooth bool
}Structure encapsulating id, name, kind, points, color.
id intname stringkind intpoints []ChartPointcolor draw.Colorcustom_color boolvisible boolline_width f64symbol_size f64smooth boolchart_seriespub fn chart_series(id int,name string,kind int) ChartSeriesChart series.
id intname stringkind intChartSeries — a value of this type
(&ChartSeries) clonepub fn (s &ChartSeries) clone() ChartSeriesOperation on &ChartSeries: copy into a new independent string.
s &ChartSeriesChartSeries instance used by this call (borrow).ChartSeries — a value of this type
struct ChartDomainpub struct ChartDomain {
pub x_min f64
pub x_max f64
pub y_min f64
pub y_max f64
}Structure encapsulating x_min, x_max, y_min, y_max.
x_min f64x_max f64y_min f64y_max f64chart_domainpub fn chart_domain(x_min f64,x_max f64,y_min f64,y_max f64) ChartDomainChart domain. Throws on failure; handle the error or propagate it to the caller.
x_min f64x_max f64y_min f64y_max f64ChartDomain — a value of this type
(&ChartDomain) validatepub fn (d &ChartDomain) validate() intExecute validate on &ChartDomain. Throws on failure; handle the error or propagate it to the caller.
d &ChartDomainChartDomain instance used by this call (borrow).int — a value of this type
struct ChartAppearancepub struct ChartAppearance {
pub grid bool
pub legend bool
pub tooltip bool
pub crosshair bool
pub zoom bool
pub pan bool
pub zero_baseline bool
pub ticks int
pub precision int
pub inner_radius f64
pub area_opacity f64
pub bar_ratio f64
pub hit_radius f64
pub x_unit string
pub y_unit string
pub empty_text string
pub palette []draw.Color
}Structure encapsulating grid, legend, tooltip, crosshair, zoom.
grid boollegend booltooltip boolcrosshair boolzoom boolpan boolzero_baseline boolticks intprecision intinner_radius f64area_opacity f64bar_ratio f64hit_radius f64x_unit stringy_unit stringempty_text stringpalette []draw.Colorchart_appearancepub fn chart_appearance() ChartAppearanceChart appearance.
No arguments are required.
ChartAppearance — a value of this type
(&ChartAppearance) validatepub fn (a &ChartAppearance) validate() intExecute validate on &ChartAppearance. Throws on failure; handle the error or propagate it to the caller.
a &ChartAppearanceChartAppearance instance used by this call (borrow).int — a value of this type
(&ChartAppearance) clonepub fn (a &ChartAppearance) clone() ChartAppearanceOperation on &ChartAppearance: copy into a new independent string.
a &ChartAppearanceChartAppearance instance used by this call (borrow).ChartAppearance — a value of this type
struct ChartHitpub struct ChartHit {
pub valid bool
pub series_id int
pub point_id int
pub x f64
pub y f64
pub low f64
pub high f64
pub close f64
pub size f64
pub label string
}Structure encapsulating valid, series_id, point_id, x, y.
valid boolseries_id intpoint_id intx f64y f64low f64high f64close f64size f64label stringstruct ChartCoordinatepub struct ChartCoordinate {
pub x f64
pub y f64
}Structure encapsulating x, y.
x f64y f64(&Chart) hoveredpub fn (c &Chart) hovered() ChartHitExecute hovered on &Chart.
c &ChartChart instance used by this call (borrow).ChartHit — a value of this type
(&Chart) selectionpub fn (c &Chart) selection() ChartHitExecute selection on &Chart.
c &ChartChart instance used by this call (borrow).ChartHit — a value of this type
($&Chart) select_pointpub fn (c $&Chart) select_point(series_id int,point_id int) intOperation on $&Chart: select point. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).series_id intpoint_id intint — a value of this type
($&Chart) set_series_visiblepub fn (c $&Chart) set_series_visible(series_id int,visible bool) intOperation on $&Chart: set series visible. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).series_id intvisible boolint — a value of this type
(&Chart) series_visiblepub fn (c &Chart) series_visible(series_id int) boolOperation on &Chart: series visible. Throws on failure; handle the error or propagate it to the caller.
c &ChartChart instance used by this call (borrow).series_id intbool — true or false
(&Chart) hit_testpub fn (c &Chart) hit_test(x f64,y f64) ChartHitOperation on &Chart: hit test.
c &ChartChart instance used by this call (borrow).x f64y f64ChartHit — a value of this type
($&Chart) inputpub fn (c $&Chart) input(event &ui.InputEvent) widgets.ActionProcess routed mouse, keyboard, or touch input events. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).event &ui.InputEventwidgets.Action — a value of this type
($&Chart) routepub fn (c $&Chart) route(kind int,event &ui.InputEvent) widgets.ActionRoute and dispatch the input event to matching targets. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).kind intevent &ui.InputEventwidgets.Action — a value of this type
($&Chart) apply_stylespub fn (c $&Chart) apply_styles(styles &widgets.Styles) intResolve and apply theme metrics to the control. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).styles &widgets.Stylesint — a value of this type
($&Chart) paint_styledpub fn (c $&Chart) paint_styled(frame $&draw.Frame,styles &widgets.Styles) intOperation on $&Chart: paint styled. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).frame $&draw.Framestyles &widgets.Stylesint — a value of this type
($&Chart) paintpub fn (c $&Chart) paint(frame $&draw.Frame,styles &widgets.Styles) intPaint the control visually onto the target canvas. Throws on failure; handle the error or propagate it to the caller.
c $&ChartChart instance used by this call (exclusive borrow).frame $&draw.Framestyles &widgets.Stylesint — a value of this type