BUI Charts 发布 号称全球最大 2D 图表库

原标题:Largest 2D Chart library in the world using BUI: BlenderUI
42AI 研判分

BUI 生态推出 bui-charts 组件库,基于 Rust 的 BlenderUI 框架,通过 rsx! 宏以声明式方式构建 XYChart、BarGauge、K 线图、火焰图、三元图等 2D 图表,并支持信号驱动的自动重绘。该项目以“全球最大 2D 图表库”为卖点,但当前材料以安装与入门示例为主,尚未给出图表数量、性能基准或与主流库的对比数据。

报道正文

本文目录5 个章节

Install

BUI Charts is a set of components for BUI. Run this command below to use it in your project.

BASH
cargo add --git https://github.com/ppmpreetham/BUI blenderui bui-charts

Two minutes

Your first chart

A chart is a component. Write it in rsx! like any other tag, style it with class, and feed it from your own state. When the signal changes, the chart redraws.

src/dashboard.rs

TYPESCRIPT
use blenderui::prelude::*;
use bui_charts::*;

#[derive(Clone, PartialEq)]
struct Reading {
    temperature: f64,
    load: f64,
}

#[component]
fn dashboard() {
    let readings = use_signal(vec![
        Reading { temperature: 18., load: 32. },
        Reading { temperature: 24., load: 51. },
        Reading { temperature: 31., load: 77. },
    ]);
    rsx! {
        <div class="flex flex-col gap-4 p-4">
            <XYChart data={readings} class="h-72">
                <Series name="Load" x={|r: &Reading| r.temperature} y={|r: &Reading| r.load} />
            </XYChart>
            <BarGauge data={readings} value={|r: &Reading| r.load} class="h-16" />
        </div>
    }
}

Good to know

What every chart shares

Your data, your shapePass a Vec, a Signal> or anything that implements Dataset. Charts read your rows through small closures like x={|r| r.load}, so you never reshape data for the chart.Hover, legends and tooltipsHovering fades the rest and opens a tooltip. Clicking a legend entry hides that series and the chart re-scales. Every chart takes tooltip, legend and class.Zoom and selectWheel and pinch zoom the plots that have axes. Drag to select a range where it makes sense.ThemingCharts read the colours of the active theme, so light, dark and your own palette all work without extra props.Cheap to redrawLayouts are cached and only recomputed when the data, the size, the hidden set or the theme changes. Hovering does not re-layout.

Orientation

How these docs work

There are 7 base charts, the ones everything else is built on, and 73 derived charts that can help you visualize your data.

Since there are a lot of charts, here are a few pages you should probably visit next:

All chartsEvery chart as a picture. Filter by name or family.Which chart to use?Start from the question you want to answer.Domain specificFinance, electronics, biology, earth science and more.

Pick a door

Or just start with one of these

[Mekko preview

Mekko](https://bui.preetham.top/charts/mekko)[![Sankey preview](/api/v1/file/hot_img_6940a887431629577186a4b18c55aa7b.webp)

Sankey](https://bui.preetham.top/charts/sankey)[![Heatmap preview](/api/v1/file/hot_img_e8d241a4874263fc1aebb667014453a6.webp)

Heatmap](https://bui.preetham.top/charts/heatmap)[![Candlestick preview](/api/v1/file/hot_img_101b6d2efed3cfc0a17d04e5735bbac6.webp)

Candlestick](https://bui.preetham.top/charts/candlestick)[![Flame Graph preview](/api/v1/file/hot_img_59555aaa69004cc248308569900dfc45.webp)

Flame Graph](https://bui.preetham.top/charts/flame-graph)[![Ternary preview](/api/v1/file/hot_img_cc2e22b01ac62e3495473873e6641257.webp)

Ternary](https://bui.preetham.top/charts/ternary)