ChartSQL
AboutProductDownloadCommunity
  • Basics
    • Intro
    • Quick Start
  • CHARTS
    • Overview
    • Auto Charts
    • Area
    • Bar
    • Bubble
    • Column
    • Combo
    • Gauge
    • Heatmap
    • Line
    • Pie
    • Radar
    • Scatter
    • Formatting & Rendering
      • Baselines
      • Formats
      • Series Titles
      • Series Labels
      • Stacked Charts
      • Grouped Category
  • ChartSQL Studio
    • Overview
    • ChartSQL Studio Cloud
    • Installing Studio Desktop
    • Basic Concepts
      • Interface Overview
      • Workspace
      • SQL Scripts & Charts
      • Folders
      • Datasources
      • Thinking in ChartSQL
    • Creating Charts
      • Editor Panels
      • Column Data Types
      • Chart Types
      • Directives
      • Stacking
      • Baselines
      • Series Titles
      • Dynamic SQL Charts
      • Dynamic Data Functions
    • Presenting
    • Settings & Customization
    • Troubleshooting & Support
    • Datasources
      • Overview
      • CSV File
      • HyperSQL
      • MongoDB
      • MySQL
      • PostgreSQL
      • SQLite
      • Custom Datasources
    • Extensions
      • Overview
      • Extension Points
      • Core Extensions
      • Extensions API Reference
  • Dashboards
    • Coming Soon
  • ChartSQL JS
    • Coming Soon
  • Reference
    • Auto Charts
    • Directives
      • @baselines
      • @baseline-types
      • @chart
      • @category
      • @formats
      • @series
      • @title
      • @subtitle
      • @groups
      • @series-types
      • @series-labels
      • @stacking-mode
      • //@directive: comments
      • @dash-id
      • @overlay-series
      • @tags
      • @select-list
    • Glossary
    • Shortcuts
    • Publishing API
  • Product & Community
    • About
    • Features
    • Use Cases
      • General Uses
      • For SQL Developers
      • For Application Developers
      • For Agencies
      • For Data Science Teams
    • Community & Support
    • Roadmap
    • Release Notes
    • In Development
      • Workspaces
      • Dashboards
        • Intro
        • Dashboards
        • Packages
        • Pages
        • Charts
        • Access Control
      • Sharing & Publishing
      • ChartSQL.js
        • Overview
      • @threshold
      • Thresholds
      • Sheets
Powered by GitBook

Support

  • Discord
  • X

ChartSQL

On this page
  • Directives in SQL Code
  • Directives Editor
  • Directive Comments

Was this helpful?

  1. ChartSQL Studio
  2. Creating Charts

Directives

Directives allow precise control over all aspects of your visualization

PreviousChart TypesNextStacking

Last updated 1 year ago

Was this helpful?

Directives can be added to your SQL source code, or with the visual Directives Editor. See the reference of the various available Directives

Directives in SQL Code

-- @chart: column
-- @title: Column - Basic Column Chart
-- @subtitle: An example column chart showing sales by month
-- @formats: currency
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
GROUP BY TRUNC(date_closed, 'MONTH')
ORDER BY TRUNC(date_closed, 'MONTH') ASC

Directives are specified as a SQL comment (any line starting wtih --) followed by '@' symbol and the directive name, followed by a colon:

-- @chart: Line

Directives Editor

From any open SQL script, you can visually edit the directives. This allows you play with different directives. When you change directives in the editor, they are automatically updated in the SQL source code.

Directive Comments

When developing, sometimes you may wish to quickly toggle on/off the directive without removing it from your source code. ChartSQL supports "directive comments" which will disable that directive.

You comment a directive by adding two forward slashed directly before the @ symbol

-- @chart: column
-- @title: Directive Comments
-- @subtitle: An example of commenting out a directive
-- @formats: currency
-- @series: Sales
-- //@baselines: Sales
SELECT 
	TRUNC(date_closed, 'MONTH') as Month,
	sum(amount) as Sales
FROM sales
GROUP BY TRUNC(date_closed, 'MONTH')
ORDER BY TRUNC(date_closed, 'MONTH') ASC;
A screenshot of the directives visual editor
An example chart that has @baselines defined but it is commented out