纯 MoonBit 实现的 SVG 图表生成库,支持柱状图、折线图、饼图、散点图、雷达图、面积图、堆叠柱状图、水平柱状图、环形图共9种图表类型,零依赖,Builder API 设计。
pub(all) struct AreaChart {
title : String
x_labels : Array[String]
series_list : Array[Series]
width : Float
height : Float
config : ChartConfig
}type BarChartpub(all) struct ChartConfig {
colors : Array[String]
show_grid : Bool
title_font_size : Int
axis_font_size : Int
legend_font_size : Int
}pub(all) struct DonutChart {
title : String
slices : Array[Slice]
width : Float
height : Float
config : ChartConfig
hole_ratio : Float
}pub(all) struct HorBarChart {
title : String
y_labels : Array[String]
series_list : Array[Series]
width : Float
height : Float
config : ChartConfig
}type LineCharttype PieChartpub(all) struct RadarChart {
title : String
axis_labels : Array[String]
series_list : Array[Series]
width : Float
height : Float
config : ChartConfig
levels : Int
}pub(all) struct ScatterChart {
title : String
x_label : String
y_label : String
series_list : Array[Series]
width : Float
height : Float
config : ChartConfig
point_size : Float
}pub(all) struct Slice {
name : String
value : Float
}pub(all) struct StackedBarChart {
title : String
x_labels : Array[String]
series_list : Array[Series]
width : Float
height : Float
config : ChartConfig
}pub(all) struct Theme {
name : String
background : String
text_color : String
grid_color : String
axis_color : String
colors : Array[String]
}fn compute_y_axis(data_min : Float, data_max : Float, _height : Float, _margin_top : Float, _margin_bottom : Float) -> AxisLayoutfn line(x1 : Float, y1 : Float, x2 : Float, y2 : Float, stroke : String, stroke_width : Float) -> Stringfn polygon(points : Array[(Float, Float)], fill : String, stroke : String, stroke_width : Float) -> Stringfn polyline(points : Array[(Float, Float)], stroke : String, stroke_width : Float, fill : String) -> Stringfn text(x : Float, y : Float, content : String, font_size : Int, anchor : String) -> Stringfn wrap_html_styled(svg : String, bg_color : String, title : String) -> Stringfn x_to_svg(index : Float, count : Float, width : Float, margin_left : Float, margin_right : Float) -> Floatfn y_to_svg(value : Float, y_min : Float, y_max : Float, height : Float, margin_top : Float, margin_bottom : Float) -> Float纯 MoonBit 实现的 SVG 图表生成库,支持柱状图、折线图、饼图、散点图、雷达图、面积图、堆叠柱状图、水平柱状图、环形图共9种图表类型,零依赖,Builder API 设计。