XU XUv0.13.1
中文

UI / WIDGETS / Data

Chart

Visualize a series of data points

Run the Xu example

The example executes in the browser using the Xu/WASM runtime.

What to try

Select a bar and use the wheel to zoom the chart.

Usage notes

Manage data series independently from chart type. Retain readable values, present again after updates, and distinguish series by more than color.

Create through Screen

The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.

Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.

#ui/widgets

fn configure(screen $&widgets.Screen) int {
    id := screen.chart() or >>
    screen.place(id,24.0,24.0,320.0,80.0) or >>
    << id
}

($&Screen) chart

XuAPI
pub fn (s $&Screen) chart() int

Purpose

Create Chart in Screen and return the component node ID; throw on creation failure.

Parameters

s $&Screen
The Screen instance used by this call (exclusive borrow).

Returns

int — component node ID for place and other Screen methods.

Placement, state and events

The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.

Action · Styles · UI lifecycle and styling guide

Screen.place · Screen.set_enabled · Screen.set_visible

Standalone control object API

These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.

Complete native example

Component Workshop · Back to Widgets