XU XUv0.13.1
EN

#ui/chart

导入方式: #ui/chart

公开 API: 7 函数, 51 方法, 7 类型, 36 常量, 0 方法集

标准库包 `#ui/chart`。

示例代码 · API 声明

示例代码

以下源码来自官方 examples 仓库,可复制或下载。请在完整工程中使用本地 Xu SDK 运行;网络、数据库和桌面示例需要对应的服务或资源。

16_ui_webview/component_workshop/main.xu

所需 SDK:Xu 0.10.13-dev.3 · 完整工程 · 下载源码 · events.xu · events_tools.xu · layout.xu · model.xu · style.xu · view.xu

Xumain.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
}
Xustyle.xu
@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
}
Xuview.xu
@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
}

API 声明

struct Chart

XuAPI
pub struct Chart {
    pub now time.Instant
    pub reduced bool
}

用途

承载 now、reduced 等属性的结构体。

公开字段

now time.Instant
字段(time.Instant)
reduced bool
字段(bool)

chart

XuAPI
pub fn chart(context &draw.Context,identity &ui.CanvasEvent,id int,bounds &layout.Rect) Chart

用途

执行 chart 处理。失败时抛出错误,调用方需处理或继续传播。

参数

context &draw.Context
context(只读借用,调用方仍持有原值;类型 &draw.Context)
identity &ui.CanvasEvent
identity(只读借用,调用方仍持有原值;类型 &ui.CanvasEvent)
id int
id(int)
bounds &layout.Rect
bounds(只读借用,调用方仍持有原值;类型 &layout.Rect)

返回值

Chart — 该类型的值

(&Chart) id

XuAPI
pub fn (c &Chart) id() int

用途

返回当前控件、元素或节点的唯一标识 ID。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

int — 该类型的值

(&Chart) bounds

XuAPI
pub fn (c &Chart) bounds() layout.Rect

用途

返回当前控件或几何对象的有效外接矩形边界(Rectangle)。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

layout.Rect — 该类型的值

(&Chart) plot_bounds

XuAPI
pub fn (c &Chart) plot_bounds() layout.Rect

用途

&Chart 上的操作:执行 plot bounds 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

layout.Rect — 该类型的值

(&Chart) needs_paint

XuAPI
pub fn (c &Chart) needs_paint() bool

用途

&Chart 上的操作:执行 needs paint 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

bool — 是否成立

($&Chart) painted

XuAPI
pub fn (c $&Chart) painted()

用途

判断当前控件在上一轮渲染流程中是否已完成绘制。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

($&Chart) invalidate

XuAPI
pub fn (c $&Chart) invalidate()

用途

标记控件区域为脏,请求系统在下一帧重新绘制。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

(&Chart) is_enabled

XuAPI
pub fn (c &Chart) is_enabled() bool

用途

&Chart 上的操作:判断是否 enabled。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

bool — 是否成立

(&Chart) is_focused

XuAPI
pub fn (c &Chart) is_focused() bool

用途

&Chart 上的操作:判断是否 focused。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

bool — 是否成立

(&Chart) style_or

XuAPI
pub fn (c &Chart) style_or(styles &widgets.Styles) widgets.ControlStyle

用途

&Chart 上的操作:执行 style or 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。
styles &widgets.Styles
styles(只读借用,调用方仍持有原值;类型 &widgets.Styles)

返回值

widgets.ControlStyle — 该类型的值

($&Chart) set_style

XuAPI
pub fn (c $&Chart) set_style(style &widgets.ControlStyle) int

用途

$&Chart 上的操作:设置 style。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
style &widgets.ControlStyle
style(只读借用,调用方仍持有原值;类型 &widgets.ControlStyle)

返回值

int — 该类型的值

($&Chart) clear_style

XuAPI
pub fn (c $&Chart) clear_style()

用途

$&Chart 上的操作:执行 clear style 操作。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

($&Chart) set_locale

XuAPI
pub fn (c $&Chart) set_locale(locale &widgets.Locale) int

用途

$&Chart 上的操作:设置 locale。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
locale &widgets.Locale
locale(只读借用,调用方仍持有原值;类型 &widgets.Locale)

返回值

int — 该类型的值

($&Chart) set_appearance

XuAPI
pub fn (c $&Chart) set_appearance(appearance &ChartAppearance) int

用途

$&Chart 上的操作:设置 appearance。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
appearance &ChartAppearance
appearance(只读借用,调用方仍持有原值;类型 &ChartAppearance)

返回值

int — 该类型的值

($&Chart) set_bounds

XuAPI
pub fn (c $&Chart) set_bounds(bounds &layout.Rect) int

用途

$&Chart 上的操作:设置 bounds。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
bounds &layout.Rect
bounds(只读借用,调用方仍持有原值;类型 &layout.Rect)

返回值

int — 该类型的值

($&Chart) set_motion

XuAPI
pub fn (c $&Chart) set_motion(spec &widgets.MotionSpec) int

用途

$&Chart 上的操作:设置 motion。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
spec &widgets.MotionSpec
spec(只读借用,调用方仍持有原值;类型 &widgets.MotionSpec)

返回值

int — 该类型的值

($&Chart) set_animation

XuAPI
pub fn (c $&Chart) set_animation(options &widgets.AnimationOptions) int

用途

$&Chart 上的操作:设置 animation。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
options &widgets.AnimationOptions
options(只读借用,调用方仍持有原值;类型 &widgets.AnimationOptions)

返回值

int — 该类型的值

($&Chart) set_series

XuAPI
pub fn (c $&Chart) set_series(series &[]ChartSeries) int

用途

$&Chart 上的操作:设置 series。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
series &[]ChartSeries
series(只读借用,调用方仍持有原值;类型 &[]ChartSeries)

返回值

int — 该类型的值

($&Chart) set_domain

XuAPI
pub fn (c $&Chart) set_domain(domain &ChartDomain) int

用途

$&Chart 上的操作:设置 domain。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
domain &ChartDomain
domain(只读借用,调用方仍持有原值;类型 &ChartDomain)

返回值

int — 该类型的值

($&Chart) use_auto_domain

XuAPI
pub fn (c $&Chart) use_auto_domain()

用途

$&Chart 上的操作:执行 use auto domain 操作。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

(&Chart) viewport

XuAPI
pub fn (c &Chart) viewport() ChartDomain

用途

在 &Chart 上执行 viewport 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

ChartDomain — 该类型的值

($&Chart) set_viewport

XuAPI
pub fn (c $&Chart) set_viewport(view &ChartDomain) int

用途

$&Chart 上的操作:设置 viewport。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
view &ChartDomain
view(只读借用,调用方仍持有原值;类型 &ChartDomain)

返回值

int — 该类型的值

($&Chart) reset_viewport

XuAPI
pub fn (c $&Chart) reset_viewport()

用途

$&Chart 上的操作:执行 reset viewport 操作。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

(&Chart) visible_domain

XuAPI
pub fn (c &Chart) visible_domain() ChartDomain

用途

&Chart 上的操作:执行 visible domain 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

ChartDomain — 该类型的值

(&Chart) data_position

XuAPI
pub fn (c &Chart) data_position(x f64,y f64) ChartCoordinate

用途

&Chart 上的操作:执行 data position 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。
x f64
值(f64)
y f64
值(f64)

返回值

ChartCoordinate — 该类型的值

(&Chart) data_at

XuAPI
pub fn (c &Chart) data_at(x f64,y f64) ChartCoordinate

用途

&Chart 上的操作:执行 data at 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。
x f64
值(f64)
y f64
值(f64)

返回值

ChartCoordinate — 该类型的值

($&Chart) tick

XuAPI
pub fn (c $&Chart) tick(styles &widgets.Styles,now time.Instant,reduced bool) bool

用途

推进动画时间戳与状态过渡动画步进。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
styles &widgets.Styles
styles(只读借用,调用方仍持有原值;类型 &widgets.Styles)
now time.Instant
now(time.Instant)
reduced bool
reduced(bool)

返回值

bool — 是否成立

(&Chart) next_tick

XuAPI
pub fn (c &Chart) next_tick(now time.Instant) time.Instant

用途

&Chart 上的操作:执行 next tick 操作。失败时抛出错误,调用方需处理或继续传播。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。
now time.Instant
now(time.Instant)

返回值

time.Instant — 该类型的值

($&Chart) pause_animation

XuAPI
pub fn (c $&Chart) pause_animation() int

用途

$&Chart 上的操作:执行 pause animation 操作。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

int — 该类型的值

($&Chart) resume_animation

XuAPI
pub fn (c $&Chart) resume_animation()

用途

$&Chart 上的操作:执行 resume animation 操作。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

($&Chart) seek_animation

XuAPI
pub fn (c $&Chart) seek_animation(progress f64) int

用途

$&Chart 上的操作:执行 seek animation 操作。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
progress f64
progress(f64)

返回值

int — 该类型的值

(&Chart) animation_progress

XuAPI
pub fn (c &Chart) animation_progress() f64

用途

&Chart 上的操作:执行 animation progress 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

f64 — 该类型的值

($&Chart) cancel

XuAPI
pub fn (c $&Chart) cancel()

用途

$&Chart 上的操作:取消。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

($&Chart) set_focus

XuAPI
pub fn (c $&Chart) set_focus(value bool)

用途

$&Chart 上的操作:设置 focus。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
value bool
value(bool)

返回值

不返回值。

($&Chart) set_enabled

XuAPI
pub fn (c $&Chart) set_enabled(value bool)

用途

$&Chart 上的操作:设置 enabled。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
value bool
value(bool)

返回值

不返回值。

($&Chart) set_read_only

XuAPI
pub fn (c $&Chart) set_read_only(value bool)

用途

$&Chart 上的操作:设置 read only。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
value bool
value(bool)

返回值

不返回值。

($&Chart) dispose

XuAPI
pub fn (c $&Chart) dispose()

用途

释放并清理对象所持有的系统原生资源与底层句柄。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

const CHART_LINE

XuAPI
pub const CHART_LINE = 0

用途

常量 CHART_LINE,定义了相关的协议或算法配置参数。

const CHART_AREA

XuAPI
pub const CHART_AREA = 1

用途

常量 CHART_AREA,定义了相关的协议或算法配置参数。

const CHART_BAR

XuAPI
pub const CHART_BAR = 2

用途

常量 CHART_BAR,定义了相关的协议或算法配置参数。

const CHART_SCATTER

XuAPI
pub const CHART_SCATTER = 3

用途

常量 CHART_SCATTER,定义了相关的协议或算法配置参数。

const CHART_DONUT

XuAPI
pub const CHART_DONUT = 4

用途

常量 CHART_DONUT,定义了相关的协议或算法配置参数。

const CHART_STEP_LINE

XuAPI
pub const CHART_STEP_LINE = 5

用途

常量 CHART_STEP_LINE,定义了相关的协议或算法配置参数。

const CHART_STACKED_AREA

XuAPI
pub const CHART_STACKED_AREA = 6

用途

常量 CHART_STACKED_AREA,定义了相关的协议或算法配置参数。

const CHART_STACKED_BAR

XuAPI
pub const CHART_STACKED_BAR = 7

用途

常量 CHART_STACKED_BAR,定义了相关的协议或算法配置参数。

const CHART_HORIZONTAL_BAR

XuAPI
pub const CHART_HORIZONTAL_BAR = 8

用途

常量 CHART_HORIZONTAL_BAR,定义了相关的协议或算法配置参数。

const CHART_PIE

XuAPI
pub const CHART_PIE = 9

用途

常量 CHART_PIE,定义了相关的协议或算法配置参数。

const CHART_ROSE

XuAPI
pub const CHART_ROSE = 10

用途

常量 CHART_ROSE,定义了相关的协议或算法配置参数。

const CHART_RADAR

XuAPI
pub const CHART_RADAR = 11

用途

常量 CHART_RADAR,定义了相关的协议或算法配置参数。

const CHART_GAUGE

XuAPI
pub const CHART_GAUGE = 12

用途

常量 CHART_GAUGE,定义了相关的协议或算法配置参数。

const CHART_BUBBLE

XuAPI
pub const CHART_BUBBLE = 13

用途

常量 CHART_BUBBLE,定义了相关的协议或算法配置参数。

const CHART_HISTOGRAM

XuAPI
pub const CHART_HISTOGRAM = 14

用途

常量 CHART_HISTOGRAM,定义了相关的协议或算法配置参数。

const CHART_BOXPLOT

XuAPI
pub const CHART_BOXPLOT = 15

用途

常量 CHART_BOXPLOT,定义了相关的协议或算法配置参数。

const CHART_HEATMAP

XuAPI
pub const CHART_HEATMAP = 16

用途

常量 CHART_HEATMAP,定义了相关的协议或算法配置参数。

const CHART_CANDLESTICK

XuAPI
pub const CHART_CANDLESTICK = 17

用途

常量 CHART_CANDLESTICK,定义了相关的协议或算法配置参数。

const CHART_WATERFALL

XuAPI
pub const CHART_WATERFALL = 18

用途

常量 CHART_WATERFALL,定义了相关的协议或算法配置参数。

const CHART_FUNNEL

XuAPI
pub const CHART_FUNNEL = 19

用途

常量 CHART_FUNNEL,定义了相关的协议或算法配置参数。

const CHART_SMOOTH_LINE

XuAPI
pub const CHART_SMOOTH_LINE = 20

用途

常量 CHART_SMOOTH_LINE,定义了相关的协议或算法配置参数。

const CHART_SMOOTH_AREA

XuAPI
pub const CHART_SMOOTH_AREA = 21

用途

常量 CHART_SMOOTH_AREA,定义了相关的协议或算法配置参数。

const CHART_POLAR_BAR

XuAPI
pub const CHART_POLAR_BAR = 22

用途

常量 CHART_POLAR_BAR,定义了相关的协议或算法配置参数。

const CHART_TREEMAP

XuAPI
pub const CHART_TREEMAP = 23

用途

常量 CHART_TREEMAP,定义了相关的协议或算法配置参数。

const CHART_SANKEY

XuAPI
pub const CHART_SANKEY = 24

用途

常量 CHART_SANKEY,定义了相关的协议或算法配置参数。

const CHART_VIOLIN

XuAPI
pub const CHART_VIOLIN = 25

用途

常量 CHART_VIOLIN,定义了相关的协议或算法配置参数。

const CHART_BULLET

XuAPI
pub const CHART_BULLET = 26

用途

常量 CHART_BULLET,定义了相关的协议或算法配置参数。

const CHART_LOLLIPOP

XuAPI
pub const CHART_LOLLIPOP = 27

用途

常量 CHART_LOLLIPOP,定义了相关的协议或算法配置参数。

const CHART_DUMBBELL

XuAPI
pub const CHART_DUMBBELL = 28

用途

常量 CHART_DUMBBELL,定义了相关的协议或算法配置参数。

const CHART_PARETO

XuAPI
pub const CHART_PARETO = 29

用途

常量 CHART_PARETO,定义了相关的协议或算法配置参数。

const ACTION_CHART_HOVER

XuAPI
pub const ACTION_CHART_HOVER = 40

用途

常量 ACTION_CHART_HOVER,定义了相关的协议或算法配置参数。

const ACTION_CHART_SELECT

XuAPI
pub const ACTION_CHART_SELECT = 41

用途

常量 ACTION_CHART_SELECT,定义了相关的协议或算法配置参数。

const ACTION_CHART_VIEWPORT

XuAPI
pub const ACTION_CHART_VIEWPORT = 42

用途

常量 ACTION_CHART_VIEWPORT,定义了相关的协议或算法配置参数。

const ACTION_CHART_LEGEND

XuAPI
pub const ACTION_CHART_LEGEND = 43

用途

常量 ACTION_CHART_LEGEND,定义了相关的协议或算法配置参数。

const CHART_MAX_POINTS

XuAPI
pub const CHART_MAX_POINTS = 4096

用途

常量 CHART_MAX_POINTS,定义了相关的协议或算法配置参数。

const CHART_MAX_SERIES

XuAPI
pub const CHART_MAX_SERIES = 8

用途

常量 CHART_MAX_SERIES,定义了相关的协议或算法配置参数。

struct ChartPoint

XuAPI
pub 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
}

用途

承载 id、x、y、low、high 等属性的结构体。

公开字段

id int
字段(int)
x f64
值
y f64
值
low f64
字段(f64)
high f64
字段(f64)
close f64
字段(f64)
size f64
字段(f64)
label string
字段(string)

chart_point

XuAPI
pub fn chart_point(id int,x f64,y f64) ChartPoint

用途

执行 chart point 操作。

参数

id int
id(int)
x f64
值(f64)
y f64
值(f64)

返回值

ChartPoint — 该类型的值

查看用法示例

chart_bubble_point

XuAPI
pub fn chart_bubble_point(id int,x f64,y f64,size f64) ChartPoint

用途

执行 chart bubble point 操作。

参数

id int
id(int)
x f64
值(f64)
y f64
值(f64)
size f64
size(f64)

返回值

ChartPoint — 该类型的值

查看用法示例

chart_range_point

XuAPI
pub fn chart_range_point(id int,x f64,open f64,low f64,high f64,close f64) ChartPoint

用途

执行 chart range point 操作。

参数

id int
id(int)
x f64
值(f64)
open f64
open(f64)
low f64
low(f64)
high f64
high(f64)
close f64
close(f64)

返回值

ChartPoint — 该类型的值

查看用法示例

struct ChartSeries

XuAPI
pub 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
}

用途

承载 id、name、kind、points、color 等属性的结构体。

公开字段

id int
字段(int)
name string
名字
kind int
类型标签
points []ChartPoint
字段([]ChartPoint)
color draw.Color
字段(draw.Color)
custom_color bool
字段(bool)
visible bool
字段(bool)
line_width f64
字段(f64)
symbol_size f64
字段(f64)
smooth bool
字段(bool)

查看用法示例

chart_series

XuAPI
pub fn chart_series(id int,name string,kind int) ChartSeries

用途

执行 chart series 操作。

参数

id int
id(int)
name string
名字(string)
kind int
类型标签(int)

返回值

ChartSeries — 该类型的值

查看用法示例

(&ChartSeries) clone

XuAPI
pub fn (s &ChartSeries) clone() ChartSeries

用途

&ChartSeries 上的操作:拷贝一份独立的 string。

参数

s &ChartSeries
本次调用使用的 ChartSeries 实例;以只读借用传入,调用方仍持有实例。

返回值

ChartSeries — 该类型的值

struct ChartDomain

XuAPI
pub struct ChartDomain {
    pub x_min f64
    pub x_max f64
    pub y_min f64
    pub y_max f64
}

用途

承载 x_min、x_max、y_min、y_max 等属性的结构体。

公开字段

x_min f64
字段(f64)
x_max f64
字段(f64)
y_min f64
字段(f64)
y_max f64
字段(f64)

chart_domain

XuAPI
pub fn chart_domain(x_min f64,x_max f64,y_min f64,y_max f64) ChartDomain

用途

执行 chart domain 操作。失败时抛出错误,调用方需处理或继续传播。

参数

x_min f64
x_min(f64)
x_max f64
x_max(f64)
y_min f64
y_min(f64)
y_max f64
y_max(f64)

返回值

ChartDomain — 该类型的值

(&ChartDomain) validate

XuAPI
pub fn (d &ChartDomain) validate() int

用途

在 &ChartDomain 上执行 validate 操作。失败时抛出错误,调用方需处理或继续传播。

参数

d &ChartDomain
本次调用使用的 ChartDomain 实例;以只读借用传入,调用方仍持有实例。

返回值

int — 该类型的值

struct ChartAppearance

XuAPI
pub 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
}

用途

承载 grid、legend、tooltip、crosshair、zoom 等属性的结构体。

公开字段

grid bool
字段(bool)
legend bool
字段(bool)
tooltip bool
字段(bool)
crosshair bool
字段(bool)
zoom bool
字段(bool)
pan bool
字段(bool)
zero_baseline bool
字段(bool)
ticks int
字段(int)
precision int
字段(int)
inner_radius f64
字段(f64)
area_opacity f64
字段(f64)
bar_ratio f64
字段(f64)
hit_radius f64
字段(f64)
x_unit string
字段(string)
y_unit string
字段(string)
empty_text string
字段(string)
palette []draw.Color
字段([]draw.Color)

chart_appearance

XuAPI
pub fn chart_appearance() ChartAppearance

用途

执行 chart appearance 操作。

参数

无需传入参数。

返回值

ChartAppearance — 该类型的值

查看用法示例

(&ChartAppearance) validate

XuAPI
pub fn (a &ChartAppearance) validate() int

用途

在 &ChartAppearance 上执行 validate 操作。失败时抛出错误,调用方需处理或继续传播。

参数

a &ChartAppearance
本次调用使用的 ChartAppearance 实例;以只读借用传入,调用方仍持有实例。

返回值

int — 该类型的值

(&ChartAppearance) clone

XuAPI
pub fn (a &ChartAppearance) clone() ChartAppearance

用途

&ChartAppearance 上的操作:拷贝一份独立的 string。

参数

a &ChartAppearance
本次调用使用的 ChartAppearance 实例;以只读借用传入,调用方仍持有实例。

返回值

ChartAppearance — 该类型的值

struct ChartHit

XuAPI
pub 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
}

用途

承载 valid、series_id、point_id、x、y 等属性的结构体。

公开字段

valid bool
字段(bool)
series_id int
字段(int)
point_id int
字段(int)
x f64
值
y f64
值
low f64
字段(f64)
high f64
字段(f64)
close f64
字段(f64)
size f64
字段(f64)
label string
字段(string)

struct ChartCoordinate

XuAPI
pub struct ChartCoordinate {
    pub x f64
    pub y f64
}

用途

承载 x、y 等属性的结构体。

公开字段

x f64
值
y f64
值

(&Chart) hovered

XuAPI
pub fn (c &Chart) hovered() ChartHit

用途

在 &Chart 上执行 hovered 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

ChartHit — 该类型的值

(&Chart) selection

XuAPI
pub fn (c &Chart) selection() ChartHit

用途

在 &Chart 上执行 selection 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。

返回值

ChartHit — 该类型的值

($&Chart) select_point

XuAPI
pub fn (c $&Chart) select_point(series_id int,point_id int) int

用途

$&Chart 上的操作:执行 select point 操作。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
series_id int
series_id(int)
point_id int
point_id(int)

返回值

int — 该类型的值

($&Chart) set_series_visible

XuAPI
pub fn (c $&Chart) set_series_visible(series_id int,visible bool) int

用途

$&Chart 上的操作:设置 series visible。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
series_id int
series_id(int)
visible bool
visible(bool)

返回值

int — 该类型的值

(&Chart) series_visible

XuAPI
pub fn (c &Chart) series_visible(series_id int) bool

用途

&Chart 上的操作:执行 series visible 操作。失败时抛出错误,调用方需处理或继续传播。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。
series_id int
series_id(int)

返回值

bool — 是否成立

(&Chart) hit_test

XuAPI
pub fn (c &Chart) hit_test(x f64,y f64) ChartHit

用途

&Chart 上的操作:执行 hit test 操作。

参数

c &Chart
本次调用使用的 Chart 实例;以只读借用传入,调用方仍持有实例。
x f64
值(f64)
y f64
值(f64)

返回值

ChartHit — 该类型的值

($&Chart) input

XuAPI
pub fn (c $&Chart) input(event &ui.InputEvent) widgets.Action

用途

接收并处理分发的鼠标、键盘或触摸交互输入事件。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
event &ui.InputEvent
event(只读借用,调用方仍持有原值;类型 &ui.InputEvent)

返回值

widgets.Action — 该类型的值

($&Chart) route

XuAPI
pub fn (c $&Chart) route(kind int,event &ui.InputEvent) widgets.Action

用途

路由并分发交互事件至命中的子节点或处理器。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
kind int
类型标签(int)
event &ui.InputEvent
event(只读借用,调用方仍持有原值;类型 &ui.InputEvent)

返回值

widgets.Action — 该类型的值

($&Chart) apply_styles

XuAPI
pub fn (c $&Chart) apply_styles(styles &widgets.Styles) int

用途

根据当前主题样式表解析并应用几何与视觉度量。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
styles &widgets.Styles
styles(只读借用,调用方仍持有原值;类型 &widgets.Styles)

返回值

int — 该类型的值

($&Chart) paint_styled

XuAPI
pub fn (c $&Chart) paint_styled(frame $&draw.Frame,styles &widgets.Styles) int

用途

$&Chart 上的操作:执行 paint styled 操作。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
frame $&draw.Frame
frame(独占借用,可修改原值;类型 $&draw.Frame)
styles &widgets.Styles
styles(只读借用,调用方仍持有原值;类型 &widgets.Styles)

返回值

int — 该类型的值

($&Chart) paint

XuAPI
pub fn (c $&Chart) paint(frame $&draw.Frame,styles &widgets.Styles) int

用途

在目标画布或渲染目标上执行控件的视觉绘制。失败时抛出错误,调用方需处理或继续传播。

参数

c $&Chart
本次调用使用的 Chart 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
frame $&draw.Frame
frame(独占借用,可修改原值;类型 $&draw.Frame)
styles &widgets.Styles
styles(只读借用,调用方仍持有原值;类型 &widgets.Styles)

返回值

int — 该类型的值