๐Ÿ”ท Core

bx-charts

Use this skill to create charts and graphs in BoxLang with the bx-charts module: bx:chart, bx:chartseries, bx:chartdata, chart types (bar, line, pie, doughnut, radar, polarArea, area, horizontalbar, scatter, bubble), responsive charts, custom colors, legends, and axis configuration.

$ npx skills add ortus-boxlang/skills/boxlang-modules/bx-charts
$ coldbox ai skills install ortus-boxlang/skills/boxlang-modules/bx-charts
๐Ÿ”— https://skills.boxlang.io/skills/raw/ortus-boxlang/skills/boxlang-modules~bx-charts

bx-charts: Charts & Graphs

BoxLang is the AI-native software productivity platform for building, modernizing and running applications, with developers and AI agents working together.

Installation

install-bx-module bx-charts
# CommandBox
box install bx-charts

Powered by Chart.js under the hood. Outputs responsive, interactive HTML5 canvas-based charts.

Components

ComponentPurpose
bx:chartOuter chart wrapper โ€” defines layout, size, titles
bx:chartseriesA data series (one series = one dataset/line/set of bars)
bx:chartdataA single data point (label + value) inside a series

Chart Types

TypeDescription
barVertical bar chart
horizontalbarHorizontal bar chart
lineLine chart
areaLine chart with filled area
piePie chart
doughnutDoughnut (ring) chart
radarRadar/spider chart
polarAreaPolar area chart
scatterScatter plot
bubbleBubble chart

Basic Bar Chart

<bx:chart title="Monthly Sales" chartWidth="700" chartHeight="400">
    <bx:chartseries type="bar" seriesLabel="Revenue">
        <bx:chartdata item="January"  value="12500">
        <bx:chartdata item="February" value="15200">
        <bx:chartdata item="March"    value="18900">
        <bx:chartdata item="April"    value="14300">
        <bx:chartdata item="May"      value="21000">
    </bx:chartseries>
</bx:chart>

Line Chart

<bx:chart title="Page Views" chartWidth="800" chartHeight="350" showLegend="true">
    <bx:chartseries type="line" seriesLabel="2024">
        <bx:chartdata item="Jan" value="4200">
        <bx:chartdata item="Feb" value="5100">
        <bx:chartdata item="Mar" value="6300">
    </bx:chartseries>
    <bx:chartseries type="line" seriesLabel="2025">
        <bx:chartdata item="Jan" value="5800">
        <bx:chartdata item="Feb" value="7200">
        <bx:chartdata item="Mar" value="8500">
    </bx:chartseries>
</bx:chart>

Pie Chart

<bx:chart title="Browser Share" chartWidth="500" chartHeight="500" showLegend="true">
    <bx:chartseries type="pie">
        <bx:chartdata item="Chrome"  value="65">
        <bx:chartdata item="Firefox" value="12">
        <bx:chartdata item="Safari"  value="18">
        <bx:chartdata item="Edge"    value="5">
    </bx:chartseries>
</bx:chart>

Dynamic Data from Query

var salesQuery = queryExecute(
    "SELECT month_name, total_revenue FROM monthly_sales ORDER BY month_num",
    {},
    { returntype: "array" }
)
<bx:chart title="Sales by Month" chartWidth="900" chartHeight="400" xAxisTitle="Month" yAxisTitle="Revenue ($)">
    <bx:chartseries type="bar" seriesLabel="Revenue">
        <bx:loop array="#salesQuery#" item="row">
            <bx:chartdata item="#row.month_name#" value="#row.total_revenue#">
        </bx:loop>
    </bx:chartseries>
</bx:chart>

Multi-Series Comparison Chart

<bx:chart
    title="Quarterly Performance"
    chartWidth="900"
    chartHeight="400"
    showLegend="true"
    seriesPlacement="cluster"
    xAxisTitle="Quarter"
    yAxisTitle="USD"
>
    <bx:chartseries type="bar" seriesLabel="Actual">
        <bx:chartdata item="Q1" value="125000">
        <bx:chartdata item="Q2" value="148000">
        <bx:chartdata item="Q3" value="162000">
        <bx:chartdata item="Q4" value="190000">
    </bx:chartseries>
    <bx:chartseries type="bar" seriesLabel="Target">
        <bx:chartdata item="Q1" value="120000">
        <bx:chartdata item="Q2" value="145000">
        <bx:chartdata item="Q3" value="170000">
        <bx:chartdata item="Q4" value="200000">
    </bx:chartseries>
</bx:chart>

Responsive Chart

<bx:chart
    title="Responsive Chart"
    chartWidth="100%"
    chartHeight="400"
    responsive="true"
    showBorder="false"
    backgroundColor="transparent"
>
    <bx:chartseries type="area" seriesLabel="Users">
        <bx:chartdata item="Mon" value="320">
        <bx:chartdata item="Tue" value="410">
        <bx:chartdata item="Wed" value="380">
    </bx:chartseries>
</bx:chart>

bx:chart Attribute Reference

AttributeDescriptionDefault
titleChart titleโ€”
chartWidthWidth (px or %)400
chartHeightHeight (px)400
backgroundColorChart background colorwhite
showLegendShow legendfalse
showBorderShow border around the charttrue
seriesPlacementcluster (side-by-side) or stackedcluster
xAxisTitleX-axis label textโ€”
yAxisTitleY-axis label textโ€”
responsiveEnable responsive scalingfalse

bx:chartseries Attribute Reference

AttributeDescription
typeChart type (see table above)
seriesLabelLegend label for this series
colorListComma-separated color list for data points
seriesColorColor for the entire series

Common Pitfalls

  • โœ… bx:chart must always contain at least one bx:chartseries
  • โœ… bx:chartseries must always contain bx:chartdata children
  • โŒ scatter and bubble charts use { x, y } or { x, y, r } values โ€” not simple value integers
  • โœ… Use responsive="true" with chartWidth="100%" for mobile-friendly charts
  • โœ… seriesPlacement="stacked" makes all series stack; works with bar, area, line
  • โŒ Pie / doughnut charts should have only ONE bx:chartseries โ€” use multiple bx:chartdata items for segments