Charts
图表

Paw ships chart helpers for time-series and bar-style data. They wrap ECharts while keeping the API in normal Go structs.

Paw 提供了时序图和柱状图辅助类型,它们底层封装 ECharts,但 API 仍保持普通 Go 结构体风格。
paw.ChartLineTimepaw.ChartBarpaw.ChartDataTypeBytepaw.ChartDataTypeBitRate
Covered APIs
涵盖 API
API
接口
Description
说明
ChartLineTime + TimeFloat
Time-series chart and its point type.
时序图及其点类型。
ChartBar + StringFloat
Bar chart and its categorical point type.
柱状图及其分类点类型。
ChartDataTypeByte + ChartDataTypeBitRate
Optional value-formatting helpers for byte-oriented data.
面向字节类数据的可选值格式化辅助常量。
Minimal Example: Default line chart
最小示例:默认折线图

A line chart only needs labels and per-series time/value pairs.

折线图只需要标签和每条序列的时间/数值点。

chart := paw.ChartLineTime{
	Title:  "Request rate",
	Labels: []string{"app", "worker"},
	Lines: [][]paw.TimeFloat{
		{
			{X: time.Now().Add(-time.Minute), Y: 12},
			{X: time.Now(), Y: 18},
		},
	},
}
Advanced Example: Stacking, datatype formatting, and bars
进阶示例:堆叠、数据格式化与柱状图

Stacked charts, data type formatting, and bar charts all use the same declarative struct style.

堆叠图、数据类型格式化和柱状图都使用相同的声明式结构体风格。


line.Stacked = true
line.StackedSum = true
line.DataTypes = []string{"", paw.ChartDataTypeByte, paw.ChartDataTypeBitRate}
line.LineTypes = []string{"scatter", "line", "scatter"}
line.LineSymbols = []string{"triangle", "pin", "diamond"}

bar := paw.ChartBar{
	Title:   "Deployments",
	Stacked: true,
	Bars:    [][]paw.StringFloat{...},
}
Notes and Related Docs
说明与相关文档

Notes

说明

When StackedSum is true, Paw automatically enables Stacked as well.

当 StackedSum 为 true 时,Paw 会自动同时开启 Stacked。

If a chart has no data, Paw renders a compact No Data state instead of an empty canvas.

如果图表没有数据,Paw 会渲染紧凑的 No Data 状态,而不是空画布。

Related Pages

相关页面
Status and Media
状态与媒体
Show alerts, badges, icons, images, and the shared color tokens used across Paw.
展示提示框、徽章、图标、图片,以及 Paw 里通用的颜色常量。
Math
数学
Render TeX formulae with the built-in KaTeX integration.
通过内置的 KaTeX 集成渲染 TeX 数学公式。
Source and References
源码与参考资料