Charts
The chart module provides chart generation capabilities to the Boxlang language.
📊 A comprehensive charting module for BoxLang that brings beautiful, interactive charts to your web applications
This module provides powerful chart generation capabilities to the BoxLang language, making it easy to create stunning data visualizations with minimal code.
✨ Features
🎨 10 Chart Types: pie, bar, line, doughnut, radar, polar area, area, horizontal bar, scatter, and bubble charts
📱 Responsive Design: Charts automatically adapt to container sizes and screen dimensions
🎯 Easy to Use: Simple BoxLang component syntax with nested data structure
🎭 Highly Customizable: Extensive styling options including colors, fonts, axes, and grid lines
⚡ Powered by Chart.js: Built on the popular Chart.js library for modern, interactive charts
📊 Advanced Features: Stacked/clustered series, axis titles, custom scales, and tooltips
🔧 Zero Configuration: Sensible defaults get you started quickly
💪 Production Ready: Built by Ortus Solutions with enterprise-grade quality
📦 Installation
Requirements
BoxLang 1.0.0 or higher
Web support enabled (for
htmlHead()BIF)
Install via CommandBox
The module will automatically register and be available as bxcharts in your BoxLang applications.
🚧 Rewrites CAUTION
If you are using a URL rewriting mechanism (like .htaccess for Apache or URL rewrite rules in Nginx), ensure that requests to static assets (like JavaScript and CSS files) are properly routed to the boxlang_modules/bx-charts/assets/ directory. This is crucial for the Chart.js library and any other assets to load correctly. Also, make sure you are not rewriting the following directory from which assets are delivered from the module:`
The following must passthrough with no rewrites.
Local Development Setup
For local development and testing of the module itself:
This creates a symbolic link in boxlang_modules/bx-charts for local module development and testing.
🚀 Quick Start
Here's how to create your first chart in just a few lines:
That's it! 🎉 You now have a beautiful, interactive pie chart.
📊 Chart Types
The module supports 10 different chart types, each optimized for specific data visualization needs:
🥧 Pie Chart (type="pie")
Perfect for showing proportions and percentages of a whole.
Best for: Market share, budget allocation, survey results
Data structure: Single series with multiple data points
📊 Bar Chart (type="bar")
Great for comparing values across categories.
Best for: Comparing quantities, showing rankings, temporal data
Features: Supports stacking and clustering
Data structure: Single or multiple series
📈 Line Chart (type="line")
Ideal for showing trends over time.
Best for: Time series, trend analysis, continuous data
Features: Multiple series support, customizable markers
Data structure: One or more series with sequential data points
🍩 Doughnut Chart (type="doughnut")
Similar to pie charts but with a hole in the center.
Best for: Proportions with emphasis on total value
Visual style: Modern, clean look with central focus area
🕸️ Radar Chart (type="radar")
Shows multivariate data on a circular grid.
Best for: Comparing multiple variables, skill assessments, product comparisons
Data structure: Multiple data points forming a polygon
🎯 Polar Area Chart (type="polarArea")
Like a pie chart but with varying radius.
Best for: Showing proportions where magnitude matters
Visual style: Circular sectors with different radii
🏔️ Area Chart (type="area")
Line chart with filled area underneath.
Best for: Showing volume over time, cumulative data
Features: Emphasizes magnitude of change
↔️ Horizontal Bar Chart (type="horizontalbar")
Bar chart with horizontal orientation.
Best for: Long category names, rankings, comparisons
Layout: Left-to-right instead of bottom-to-top
🔵 Scatter Plot (type="scatter")
Shows relationship between two variables.
Best for: Correlation analysis, distribution patterns
Data structure: X-Y coordinate pairs
🫧 Bubble Chart (type="bubble")
Shows three-dimensional data using x, y coordinates and bubble size.
Best for: Multi-dimensional data analysis, comparative metrics, portfolio analysis
Data structure: X-Y coordinate pairs with radius (r) for bubble size
Usage: Use
x,y, andrattributes in<bx:chartdata>instead of justvalue
🎯 Choosing the Right Chart Type
Selecting the appropriate chart type is crucial for effective data visualization. Use this guide to choose the best chart for your data:
📊 Quick Selection Guide
Your Goal
Recommended Chart Type
Why
Show parts of a whole
Pie or Doughnut
Best for displaying percentage distribution of 3-6 categories
Compare values across categories
Bar or Horizontal Bar
Clear visual comparison of discrete values
Show trends over time
Line or Area
Excellent for time series and continuous data
Compare multiple variables
Radar
Perfect for multi-dimensional comparisons (e.g., product features)
Show proportions with magnitude
Polar Area
Like pie chart but size indicates importance
Display correlation
Scatter
Shows relationship between two variables
Show 3D relationships
Bubble
Displays three metrics simultaneously (x, y, size)
Compare with long labels
Horizontal Bar
Better readability for lengthy category names
Emphasize volume/magnitude
Area
Highlights total quantity over time
💡 Decision Tree
⚠️ Common Pitfalls to Avoid
Don't Use
When
Use Instead
Pie Chart
More than 6 categories
Bar Chart
Line Chart
Comparing unrelated categories
Bar Chart
3D Effects
Accuracy is important
2D charts (all types)
Radar Chart
Categories aren't comparable
Bar or Column Chart
Bubble Chart
Only 2 dimensions of data
Scatter Plot
📏 Best Practices
Pie/Doughnut Charts: Limit to 5-6 slices maximum. Order slices by size for better readability.
Bar Charts: Always start the Y-axis at zero to avoid misleading visualizations.
Line Charts: Use for continuous data only. Avoid for unrelated categories.
Radar Charts: Ensure all axes use the same scale and are comparable metrics.
Bubble Charts: Make sure bubble sizes are clearly distinguishable. Use radius (r) values that create visible differences.
Color Selection: Use consistent color schemes. Avoid red/green combinations (color blindness).
📚 Components Reference
📊 <bx:chart> Component
The main container component that renders charts using Chart.js.
Core Attributes
title
string
""
Chart title displayed at the top
chartWidth
number
400
Chart width in pixels
chartHeight
number
300
Chart height in pixels
backgroundColor
string
"#ffffff"
Background color (hex or named color)
showLegend
boolean
true
Display legend for multi-series charts
📱 Responsive Attributes
responsive
boolean
true
Enable responsive resizing
maintainAspectRatio
boolean
true
Maintain width/height ratio
aspectRatio
number
2
Aspect ratio (width/height)
resizeDelay
number
0
Delay before resize (ms)
🎨 Styling Attributes
font
string
-
Font family for chart text
fontBold
boolean
false
Bold text
fontItalic
boolean
false
Italic text
fontSize
number
12
Font size in pixels
foregroundColor
string
"#333333"
Text color
dataBackgroundColor
string
-
Data area background color
📏 Axis Configuration
xAxisTitle
string
""
X-axis title
yAxisTitle
string
""
Y-axis title
showXGridlines
boolean
false
Show X-axis grid lines
showYGridlines
boolean
true
Show Y-axis grid lines
showXLabel
boolean
true
Display X-axis labels
scaleFrom
number
-
Y-axis minimum value
scaleTo
number
-
Y-axis maximum value
sortXAxis
boolean
false
Sort labels alphabetically
🎯 Display Options
showBorder
boolean
false
Display chart border
showMarkers
boolean
true
Show data point markers
showTooltip
boolean
true
Enable tooltips
markerSize
number
4
Marker size in pixels
show3D
boolean
false
3D appearance (limited support)
📐 Advanced Options
seriesPlacement
string
"default"
Series layout: "default", "cluster", "stacked"
labelFormat
string
""
Y-axis label format (use {value} placeholder)
categoryLabelPositions
string
"horizontal"
Label rotation: "horizontal", "up_45", "up_90", "down_45", "down_90", "vertical"
url
string
""
URL to open when clicking data points
📈 <bx:chartseries> Component
Defines a data series within a chart. Must be nested inside <bx:chart>.
Attributes
type
string
✅ Yes
Chart type: "pie", "bar", "line", "doughnut", "radar", "polarArea", "area", "horizontalbar", "scatter"
colorlist
string
No
Comma-separated color list (hex or named colors)
serieslabel
string
No
Label for this data series
Example:
📍 <bx:chartdata> Component
Defines individual data points within a series. Must be nested inside <bx:chartseries>.
Attributes
item
string
✅ Yes
Data point label/name
value
number
✅ Yes*
Data point value (*Required for all chart types except bubble)
x
number
⚠️ Bubble
X-coordinate (required for bubble charts)
y
number
⚠️ Bubble
Y-coordinate (required for bubble charts)
r
number
⚠️ Bubble
Bubble radius (required for bubble charts)
Standard Example:
Bubble Chart Example:
💡 Examples
Basic Examples
🥧 Simple Pie Chart
💡 Use Case: Perfect for showing how a total is divided into parts, like disk space usage or budget allocation.
📊 Bar Chart with Grid Lines
💡 Use Case: Great for comparing different categories or metrics at a glance.
📈 Line Chart for Time Series
💡 Use Case: Ideal for displaying trends and patterns over time.
🍩 Doughnut Chart
💡 Use Case: Similar to pie charts but with a modern look, great for dashboards.
🤝 Contributing
We ❤️ contributions! This project is open source and welcomes your help to make it even better.
🐛 Found a Bug?
If you discover a bug, please:
Check existing issues at GitHub Issues
Create a new issue with:
Clear title and description
Steps to reproduce
Expected vs actual behavior
BoxLang version and environment details
Sample code that demonstrates the issue
💡 Have an Enhancement Idea?
We'd love to hear your ideas! Please:
Open a Feature Request
Describe the feature and its use case
Explain how it would benefit users
Consider if it aligns with Chart.js capabilities
🔧 Want to Contribute Code?
Excellent! Here's how to get started:
Development Setup
Fork and Clone:
Set up Local Development Environment:
This script creates a
boxlang_modules/bx-chartssymbolic link pointing to the current directory, allowing you to test the module locally before publishing.Install Dependencies:
The
npm installcommand will automatically:Download the latest Chart.js library
Copy it to the
public/folder
Update Chart.js (Optional):
To manually update Chart.js to the latest version:
Test the Module Locally:
Start a BoxLang server to test your changes:
The test files in
/tests/directory provide comprehensive examples of all chart types and features.Build the Module (Optional):
To build a distributable version of the module:
Start Format Watcher:
Pull Request Guidelines
✅ Create PRs against the
developmentbranch (NOTmaster)✅ Follow the existing code style (auto-format with cfformat)
✅ Add tests for new features
✅ Update documentation as needed
✅ Keep commits focused and atomic
✅ Link related issues in PR description
Code Standards
BoxLang/CFML: Follow cfformat settings
Formatting: Auto-format with
box run-script formatCoding Standards: Follow Ortus Coding Standards
📚 Improve Documentation
Documentation improvements are always welcome:
Fix typos or unclear explanations
Add more examples
Improve code comments
Create tutorials or guides
💰 Financial Support
You can support BoxLang and all Ortus Solutions open source projects:
Patrons get exclusive benefits like:
Priority support
Early access to new features
FORGEBOX Pro account
CFCasts account
📞 Support Channels
Need help? Don't create an issue—use our support channels:
🏆 Contributors
Thank you to all our amazing contributors! ❤️
Made with contributors-img
🔐 Security Vulnerabilities
If you discover a security vulnerability:
DO NOT create a public issue
Report in
#securitychannel on Box Team Slack
All vulnerabilities will be promptly addressed.
📄 License
This project is licensed under the Apache License 2.0.
See LICENSE file for full details.
💼 Support & Resources
📖 Documentation
Module Docs: You're reading them! 📚
BoxLang Docs: https://boxlang.ortusbooks.com/
Chart.js Docs: https://www.chartjs.org/docs/
🌐 Links
BoxLang Website: https://boxlang.io
Ortus Solutions: https://www.ortussolutions.com
GitHub Repository: https://github.com/ortus-boxlang/bx-charts
Issue Tracker: https://github.com/ortus-boxlang/bx-charts/issues
🎓 Learning Resources
BoxLang Training: https://www.ortussolutions.com/services/training
CFCasts: https://www.cfcasts.com
Last updated
Was this helpful?
