BasicChart Widget
OverviewDirect link to Overview
The BasicChart widget enables creating and displaying interactive charts based on the Chart.js library. It offers great flexibility in configuring data, styles, and chart types to visualize your data clearly and attractively.

Supported Chart TypesDirect link to Supported Chart Types
The widget supports several chart types:
- Line: Line chart
- Bar: Bar chart
- Doughnut: Doughnut chart
- Pie: Pie chart
- PolarArea: Polar area chart
- Radar: Radar chart
Basic ConfigurationDirect link to Basic Configuration
Global SettingsDirect link to Global Settings
Widget NameDirect link to Widget Name
- Field: Name
- Description: Display name of the widget
- Type: Text
Variable/ModelDirect link to Variable/Model
- Field: Variable/Model
- Description: Name of the variable that will store the chart data
- Type: Text
- Required: Yes
Chart ConfigurationDirect link to Chart Configuration
These fields are in the Basic Chart Config card of the configuration panel, with one Dataset #n section per dataset.
Chart TypeDirect link to Chart Type
- Field: Chart Type
- Description: Selects the type of chart to display
- Options: Line, Bar, Doughnut, Pie, PolarArea, Radar
- Default: Line
Data TypeDirect link to Data Type
- Field: Data type
- Description: Source of data for the chart
- Options:
- Collection: Data from a database collection
- Report: Data from a generated report
- External databases: Data from an external database
Data SourceDirect link to Data Source
- Field: Data
- Description: Selection of the specific source based on the chosen type
- Depends on: Data type
- Configuration:
- If "Collection": The list shows the collections of the open project first (This project), then those of the Other projects with the name of their project
- If "Report": List of available reports
- If "External databases": List of database connections
Y-Axis AnnotationDirect link to Y-Axis Annotation
- Field: Y-Axis annotation (@ prefix)
- Description: Text to display next to Y-axis values (e.g., €, $, %)
- Type: Optional text
- Example: "@€" will display "€100" instead of "100"
Dataset ConfigurationDirect link to Dataset Configuration
Each chart can contain multiple datasets to compare different data series.
Adding a DatasetDirect link to Adding a Dataset
- Click the "+ Dataset" button
- Configure each dataset individually
Dataset ConfigurationDirect link to Dataset Configuration
Dataset LabelDirect link to Dataset Label
- Field: Label
- Description: Name displayed in the legend for this dataset
- Type: Text
Fill ColorDirect link to Fill Color
- Field: Color (color picker next to the dataset label)
- Description: Color used to represent this dataset
- Type: Color with alpha transparency support
- Default: none (the picker is empty)
In a bar or line chart, a colour chosen in the widget is always used as it is.
In a pie, doughnut, polar area or radar chart, the colour of a dataset is ignored, before and since version 8.6: the slices take your brand colours if the first dataset has no colour and your account has brand colours, and colours from the built-in palette otherwise. To get your brand colours on the slices, leave the colour of the first dataset empty.
When a dataset has no fill colour:
- Your account has brand colours: if the portal design is applied to the applications (Settings › Design & colours › Apply to the applications too) and you set your own brand colours (My colours, or Banner with the Google design), the chart takes them: in a bar or line chart, the first dataset gets the primary colour, the second the secondary colour, the next ones shades derived from the primary colour, readable on a white background and distinct from each other. In a pie, doughnut, polar area or radar chart, the slices take these colours in turn.
- No brand colours (applications in the historical look, From the design colours, or a page excluded from the portal design): nothing changes. Bars and lines keep the default colour of the chart library, and the slices of a pie, doughnut, polar area or radar chart take colours picked at random from a built-in palette each time the chart is displayed.
The colours are read from the --sf-brand-primary and --sf-brand-secondary CSS variables of the page, and your client CSS keeps the last word. To change the colours of the charts, it must redefine these variables on :root, with values in the #rrggbb format: a value such as #abc or rgb(...), or a declaration on anything other than :root or html, is ignored. If only a secondary colour is set, the first series takes the main colour of the design and the second series the secondary colour.

Data QueryDirect link to Data Query
- Field: Query (Edit button)
- Description: Query to retrieve data from the source
- Format: JSON
- Example for Collection:
[
{
"$match": {
"status": "active"
}
},
{
"$group": {
"_id": "$category",
"total": { "$sum": "$amount" }
}
}
]
Data ColumnDirect link to Data Column
- Field: Data column
- Description: Name of the field containing numeric values to display
- Type: Text
- Example: "total", "count", "value"
Labels ConfigurationDirect link to Labels Configuration
- Option: Use labels (radio button per dataset)
- Description: Designates which dataset will provide labels for the X-axis
- Associated Field: Labels column name
- Example: "category", "date", "name"

Advanced ConfigurationDirect link to Advanced Configuration
ValidationDirect link to Validation
The widget inherits standard validation options:
- Available: Controls if the widget is available according to the screen
- Visible: Controls visibility based on conditions
- Required: Not applicable for this widget type
- Disable: Controls the disabled state of the widget
StyleDirect link to Style
CSS ClassesDirect link to CSS Classes
- Field: Class
- Description: Custom CSS classes to apply to the widget
- Type: Text (class names separated by spaces)
Dynamic ClassesDirect link to Dynamic Classes
- Button: Brush icon
- Description: Allows defining conditional CSS classes
- Format: JSON object with conditions
Usage ExamplesDirect link to Usage Examples
Simple Bar ChartDirect link to Simple Bar Chart
- Chart Type: Bar
- Data Type: Collection
- Source: Select an orders collection
- Dataset 1:
- Label: "Monthly Sales"
- Color: Blue (#3498db)
- Query:

- Data column: "total"
- Use labels: Checked
- Labels column: "_id"

Pie Chart with Multiple SourcesDirect link to Pie Chart with Multiple Sources
- Chart Type: Pie
- Data Type: Collection
- Dataset 1:
- Label: "Distribution by Category"
- Query to group by category
- Data column: "count"
Temporal Line ChartDirect link to Temporal Line Chart
- Chart Type: Line
- Y-Axis Annotation: "@€"
- Multiple Datasets to compare different periods or metrics
Technical PropertiesDirect link to Technical Properties
Generated VariablesDirect link to Generated Variables
The widget automatically generates the following variables:
{model}: Contains chart data{model}_chart: Chart.js instance for advanced manipulations
Available MethodsDirect link to Available Methods
renderChart()Direct link to renderChart()
Rebuilds the chart with new data
getChart()Direct link to getChart()
Returns the current Chart.js instance
setChart(chart)Direct link to setChart(chart)
Sets a new Chart.js instance
EventsDirect link to Events
Query UpdatesDirect link to Query Updates
The chart automatically updates when query variables change.
Best PracticesDirect link to Best Practices
PerformanceDirect link to Performance
- Limit the number of data points for optimal performance
- Use optimized queries with database-side aggregations
- Avoid recreating the chart too frequently
DesignDirect link to Design
- Choose contrasting colors for readability, or leave the fill colours empty so that the charts follow your brand colours
- Use explicit labels for datasets
- Add unit annotations when necessary
DataDirect link to Data
- Ensure data columns contain numeric values
- Handle missing data cases in your queries
- Use appropriate groupings to avoid information overload
TroubleshootingDirect link to Troubleshooting
Common IssuesDirect link to Common Issues
Chart doesn't displayDirect link to Chart doesn't display
- Check that the data source is correctly configured
- Ensure the query returns data
- Verify data and label column names
Incorrect dataDirect link to Incorrect data
- Validate JSON query syntax
- Check data source access permissions
- Test the query independently of the widget
Style issuesDirect link to Style issues
- Check custom CSS classes
- Ensure colors are in valid hexadecimal format
- Control parent container dimensions
Error MessagesDirect link to Error Messages
Configuration errors are displayed directly in the interface with resolution hints.
Advanced FeaturesDirect link to Advanced Features
Multiple DatasetsDirect link to Multiple Datasets
You can add multiple datasets to compare different data series on the same chart. Each dataset can have:
- Different queries
- Different colors (bar and line charts)
- Different data sources
- Shared or individual labels
Chart ResponsivenessDirect link to Chart Responsiveness
The chart automatically adapts to its container size and provides responsive behavior across different screen sizes.
Interactive FeaturesDirect link to Interactive Features
Charts include built-in interactivity such as:
- Hover tooltips showing exact values
- Legend clicking to show/hide datasets
- Animation effects on data updates
Custom StylingDirect link to Custom Styling
Beyond basic configuration, you can:
- Apply custom CSS classes for advanced styling
- Use dynamic classes based on data conditions
- Control chart dimensions and layout
Integration with Other ComponentsDirect link to Integration with Other Components
The BasicChart widget can be integrated with other form components to create dynamic dashboards where:
- Filter components update chart queries
- Data selection affects chart display
- Chart interactions trigger other component updates