Skip to main content

Your First Chart in 30 Seconds

Let’s create a beautiful scatter plot with just a few lines of code.
1

Import Cristalyse

Add the import to your Dart file:
2

Prepare Your Data

Create a simple dataset:
3

Build Your Chart

Create the chart with grammar of graphics:

Complete Example

Here’s the full widget ready to use:
Result: A beautiful, animated scatter plot with color-coded categories!
Your First Chart Result

Formatting Axis Labels

You’ll often want formatted axis labels. The labels parameter takes any function that converts a number to a string:
For robust, locale-aware formatting, use NumberFormat:

Adding a Legend

New in v1.5.0: Built-in legend support with zero configuration!
When your chart has color categories, add a professional legend with one line:
Key Benefits:
  • Zero Config: Just add .legend() and it works
  • Smart Positioning: Defaults to top-right, 8 position options available
  • Dark Mode Ready: Text automatically adapts to theme colors
  • Auto-Symbols: Squares for bars, circles for points, lines for line charts
Requirement: Legends need a color parameter in your .mapping() call to detect categories.

Quick Legend Positioning

Learn more about legend customization and styling.

Understanding the Grammar

Cristalyse follows the Grammar of Graphics pattern:
.data() - Your dataset as a List of Map objects
.mapping() - Connect data columns to visual properties (x, y, color, size)
.geomPoint(), .geomLine(), .geomBar() - How to visualize the data
.scaleXContinuous(), .scaleYContinuous() - Transform data to screen coordinates
.theme() - Colors, fonts, and visual styling