MoonChartSVG

    纯 MoonBit 实现的 SVG 图表生成库,支持柱状图、折线图、饼图、散点图、雷达图、面积图、堆叠柱状图、水平柱状图、环形图共9种图表类型,零依赖,Builder API 设计。

    chart
    svg
    visualization
    barchart
    linechart
    piechart
    Download zip
    Version
    0.1.5
    License
    Apache-2.0
    Last updated
    3 months ago
    Downloads
    66

    No dependencies

    #Mitsuha11zz/MoonChartSVG

    Pure MoonBit SVG chart generation library with 9 chart types, zero dependencies.

    AreaChart

    pub(all) struct AreaChart {
    title : String
    x_labels : Array[String]
    series_list : Array[Series]
    width : Float
    height : Float
    config : ChartConfig
    }

    AreaChart::config

    fn AreaChart::config(self : AreaChart, c : ChartConfig) -> AreaChart

    AreaChart::height

    fn AreaChart::height(self : AreaChart, h : Float) -> AreaChart

    AreaChart::new

    fn AreaChart::new() -> AreaChart

    AreaChart::render

    fn AreaChart::render(self : AreaChart) -> String

    AreaChart::series

    fn AreaChart::series(self : AreaChart, s : Series) -> AreaChart

    AreaChart::title

    fn AreaChart::title(self : AreaChart, t : String) -> AreaChart

    AreaChart::width

    fn AreaChart::width(self : AreaChart, w : Float) -> AreaChart

    AreaChart::x_labels

    fn AreaChart::x_labels(self : AreaChart, labels : Array[String]) -> AreaChart

    AxisLayout

    type AxisLayout

    BarChart

    type BarChart

    BarChart::config

    fn BarChart::config(self : BarChart, c : ChartConfig) -> BarChart

    BarChart::height

    fn BarChart::height(self : BarChart, h : Float) -> BarChart

    BarChart::new

    fn BarChart::new() -> BarChart

    BarChart::render

    fn BarChart::render(self : BarChart) -> String

    BarChart::series

    fn BarChart::series(self : BarChart, s : Series) -> BarChart

    BarChart::title

    fn BarChart::title(self : BarChart, t : String) -> BarChart

    BarChart::width

    fn BarChart::width(self : BarChart, w : Float) -> BarChart

    BarChart::x_labels

    fn BarChart::x_labels(self : BarChart, labels : Array[String]) -> BarChart

    ChartConfig

    pub(all) struct ChartConfig {
    colors : Array[String]
    show_grid : Bool
    title_font_size : Int
    axis_font_size : Int
    legend_font_size : Int
    }

    ChartConfig::default

    fn ChartConfig::default() -> ChartConfig

    DonutChart

    pub(all) struct DonutChart {
    title : String
    slices : Array[Slice]
    width : Float
    height : Float
    config : ChartConfig
    hole_ratio : Float
    }

    DonutChart::config

    fn DonutChart::config(self : DonutChart, c : ChartConfig) -> DonutChart

    DonutChart::height

    fn DonutChart::height(self : DonutChart, h : Float) -> DonutChart

    DonutChart::hole_ratio

    fn DonutChart::hole_ratio(self : DonutChart, hr : Float) -> DonutChart

    DonutChart::new

    fn DonutChart::new() -> DonutChart

    DonutChart::render

    fn DonutChart::render(self : DonutChart) -> String

    DonutChart::slice

    fn DonutChart::slice(self : DonutChart, name : String, value : Float) -> DonutChart

    DonutChart::title

    fn DonutChart::title(self : DonutChart, t : String) -> DonutChart

    DonutChart::width

    fn DonutChart::width(self : DonutChart, w : Float) -> DonutChart

    HorBarChart

    pub(all) struct HorBarChart {
    title : String
    y_labels : Array[String]
    series_list : Array[Series]
    width : Float
    height : Float
    config : ChartConfig
    }

    HorBarChart::config

    fn HorBarChart::config(self : HorBarChart, c : ChartConfig) -> HorBarChart

    HorBarChart::height

    fn HorBarChart::height(self : HorBarChart, h : Float) -> HorBarChart

    HorBarChart::new

    HorBarChart::render

    fn HorBarChart::render(self : HorBarChart) -> String

    HorBarChart::series

    fn HorBarChart::series(self : HorBarChart, s : Series) -> HorBarChart

    HorBarChart::title

    fn HorBarChart::title(self : HorBarChart, t : String) -> HorBarChart

    HorBarChart::width

    fn HorBarChart::width(self : HorBarChart, w : Float) -> HorBarChart

    HorBarChart::y_labels

    fn HorBarChart::y_labels(self : HorBarChart, labels : Array[String]) -> HorBarChart

    LineChart

    type LineChart

    LineChart::config

    fn LineChart::config(self : LineChart, c : ChartConfig) -> LineChart

    LineChart::height

    fn LineChart::height(self : LineChart, h : Float) -> LineChart

    LineChart::new

    fn LineChart::new() -> LineChart

    LineChart::render

    fn LineChart::render(self : LineChart) -> String

    LineChart::series

    fn LineChart::series(self : LineChart, s : Series) -> LineChart

    LineChart::title

    fn LineChart::title(self : LineChart, t : String) -> LineChart

    LineChart::width

    fn LineChart::width(self : LineChart, w : Float) -> LineChart

    LineChart::x_labels

    fn LineChart::x_labels(self : LineChart, labels : Array[String]) -> LineChart

    Palette

    pub(all) struct Palette {
    name : String
    colors : Array[String]
    }

    PieChart

    type PieChart

    PieChart::height

    fn PieChart::height(self : PieChart, h : Float) -> PieChart

    PieChart::new

    fn PieChart::new() -> PieChart

    PieChart::render

    fn PieChart::render(self : PieChart) -> String

    PieChart::slice

    fn PieChart::slice(self : PieChart, name : String, value : Float) -> PieChart

    PieChart::title

    fn PieChart::title(self : PieChart, t : String) -> PieChart

    PieChart::width

    fn PieChart::width(self : PieChart, w : Float) -> PieChart

    RadarChart

    pub(all) struct RadarChart {
    title : String
    axis_labels : Array[String]
    series_list : Array[Series]
    width : Float
    height : Float
    config : ChartConfig
    levels : Int
    }

    RadarChart::axis_labels

    fn RadarChart::axis_labels(self : RadarChart, labels : Array[String]) -> RadarChart

    RadarChart::config

    fn RadarChart::config(self : RadarChart, c : ChartConfig) -> RadarChart

    RadarChart::height

    fn RadarChart::height(self : RadarChart, h : Float) -> RadarChart

    RadarChart::levels

    fn RadarChart::levels(self : RadarChart, l : Int) -> RadarChart

    RadarChart::new

    fn RadarChart::new() -> RadarChart

    RadarChart::render

    fn RadarChart::render(self : RadarChart) -> String

    RadarChart::series

    fn RadarChart::series(self : RadarChart, s : Series) -> RadarChart

    RadarChart::title

    fn RadarChart::title(self : RadarChart, t : String) -> RadarChart

    RadarChart::width

    fn RadarChart::width(self : RadarChart, w : Float) -> RadarChart

    ScatterChart

    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
    }

    ScatterChart::config

    ScatterChart::height

    fn ScatterChart::height(self : ScatterChart, h : Float) -> ScatterChart

    ScatterChart::new

    ScatterChart::point_size

    fn ScatterChart::point_size(self : ScatterChart, ps : Float) -> ScatterChart

    ScatterChart::render

    fn ScatterChart::render(self : ScatterChart) -> String

    ScatterChart::series

    fn ScatterChart::series(self : ScatterChart, s : Series) -> ScatterChart

    ScatterChart::title

    fn ScatterChart::title(self : ScatterChart, t : String) -> ScatterChart

    ScatterChart::width

    fn ScatterChart::width(self : ScatterChart, w : Float) -> ScatterChart

    ScatterChart::x_label

    fn ScatterChart::x_label(self : ScatterChart, label : String) -> ScatterChart

    ScatterChart::y_label

    fn ScatterChart::y_label(self : ScatterChart, label : String) -> ScatterChart

    Series

    pub(all) struct Series {
    name : String
    values : Array[Float]
    }

    Series::new

    fn Series::new(name : String, values : Array[Float]) -> Series

    Slice

    pub(all) struct Slice {
    name : String
    value : Float
    }

    Slice::new

    fn Slice::new(name : String, value : Float) -> Slice

    StackedBarChart

    pub(all) struct StackedBarChart {
    title : String
    x_labels : Array[String]
    series_list : Array[Series]
    width : Float
    height : Float
    config : ChartConfig
    }

    StackedBarChart::config

    StackedBarChart::height

    fn StackedBarChart::height(self : StackedBarChart, h : Float) -> StackedBarChart

    StackedBarChart::new

    StackedBarChart::render

    fn StackedBarChart::render(self : StackedBarChart) -> String

    StackedBarChart::series

    StackedBarChart::title

    fn StackedBarChart::title(self : StackedBarChart, t : String) -> StackedBarChart

    StackedBarChart::width

    fn StackedBarChart::width(self : StackedBarChart, w : Float) -> StackedBarChart

    StackedBarChart::x_labels

    fn StackedBarChart::x_labels(self : StackedBarChart, labels : Array[String]) -> StackedBarChart

    Theme

    pub(all) struct Theme {
    name : String
    background : String
    text_color : String
    grid_color : String
    axis_color : String
    colors : Array[String]
    }

    Theme::dark

    fn Theme::dark() -> Theme

    Theme::light

    fn Theme::light() -> Theme

    Theme::minimal

    fn Theme::minimal() -> Theme

    Theme::to_config

    fn Theme::to_config(self : Theme) -> ChartConfig

    Theme::warm

    fn Theme::warm() -> Theme

    circle

    fn circle(cx : Float, cy : Float, r : Float, fill : String) -> String

    compute_y_axis

    fn compute_y_axis(data_min : Float, data_max : Float, _height : Float, _margin_top : Float, _margin_bottom : Float) -> AxisLayout

    generate_demo_area

    fn generate_demo_area() -> String

    generate_demo_barchart

    fn generate_demo_barchart() -> String

    generate_demo_dashboard

    fn generate_demo_dashboard() -> String

    generate_demo_linechart

    fn generate_demo_linechart() -> String

    generate_demo_piechart

    fn generate_demo_piechart() -> String

    generate_demo_radar

    fn generate_demo_radar() -> String

    generate_demo_scatter

    fn generate_demo_scatter() -> String

    get_chart_color

    fn get_chart_color(config : ChartConfig, index : Int) -> String

    get_color

    fn get_color(index : Int) -> String

    line

    fn line(x1 : Float, y1 : Float, x2 : Float, y2 : Float, stroke : String, stroke_width : Float) -> String

    max_value

    fn max_value(values : Array[Float]) -> Float

    mean

    fn mean(values : Array[Float]) -> Float

    median

    fn median(values : Array[Float]) -> Float

    min_value

    fn min_value(values : Array[Float]) -> Float

    palette_bold

    fn palette_bold() -> Palette

    palette_forest

    fn palette_forest() -> Palette

    palette_ocean

    fn palette_ocean() -> Palette

    palette_pastel

    fn palette_pastel() -> Palette

    palette_sunset

    fn palette_sunset() -> Palette

    palette_tableau10

    fn palette_tableau10() -> Palette

    palette_to_colors

    fn palette_to_colors(p : Palette) -> Array[String]

    parse_csv

    fn parse_csv(content : String) -> (Array[String], Array[Array[String]])

    parse_csv_to_series

    fn parse_csv_to_series(content : String) -> (Array[String], Array[Series])

    parse_float_or_zero

    fn parse_float_or_zero(s : String) -> Float

    path

    fn path(d : String, fill : String, stroke : String) -> String

    polygon

    fn polygon(points : Array[(Float, Float)], fill : String, stroke : String, stroke_width : Float) -> String

    polyline

    fn polyline(points : Array[(Float, Float)], stroke : String, stroke_width : Float, fill : String) -> String

    rect

    fn rect(x : Float, y : Float, w : Float, h : Float, fill : String) -> String

    render_legend

    fn render_legend(names : Array[String], width : Float, y : Float, config : ChartConfig) -> String

    sort_asc

    fn sort_asc(values : Array[Float]) -> Array[Float]

    std_dev

    fn std_dev(values : Array[Float]) -> Float

    sum

    fn sum(values : Array[Float]) -> Float

    Data Statistics Module Utility functions for computing statistical properties of Float arrays.

    svg_close

    fn svg_close() -> String

    svg_open

    fn svg_open(width : Float, height : Float) -> String

    text

    fn text(x : Float, y : Float, content : String, font_size : Int, anchor : String) -> String

    wrap_html

    fn wrap_html(svg : String) -> String

    wrap_html_multi

    fn wrap_html_multi(svgs : Array[String], titles : Array[String]) -> String

    wrap_html_styled

    fn wrap_html_styled(svg : String, bg_color : String, title : String) -> String

    x_to_svg

    fn x_to_svg(index : Float, count : Float, width : Float, margin_left : Float, margin_right : Float) -> Float

    y_to_svg

    fn y_to_svg(value : Float, y_min : Float, y_max : Float, height : Float, margin_top : Float, margin_bottom : Float) -> Float