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
  • Thresholds Directives Overview
  • Examples

Was this helpful?

  1. Product & Community
  2. In Development

Thresholds

Target values added to charts to highlight if a series value has met the target.

Previous@thresholdNextSheets

Last updated 10 months ago

Was this helpful?

ChartSQL introduces @thresholds to emphasize if a series item has exceeded (or not met) a particular target value.

-- @chart: column
-- @title: Baselines - Average Baseline
-- @subtitle: An example column chart showing sales by month
-- @formats: currency
-- @series: Sales
-- @thresholds: Sales(50000)
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

Thresholds Directives Overview

  • @hresholds: Specifies the series to which the thresholds will be applied. By default, the target for a threshold is the average of the series. You can specify custom targets.

    • average (default):

    • a number: Specify a hard coded number for the series threshold

    • column: Specify a column from the dataset that sets the threshold for the series item

  • @threshold-styles(optional):

    • success (default): Series item will be green if met

    • alert: Series item will be blue if met

    • warning: Series item will be yellow if met

    • danger: Series item will be red if met

    • color: A custom color for the series item

  • @threshold-criteria(optional): By default, a threshold is activated when the series item exceeds the target value. You can also activate it when it

    • above (default): When the series item is above the threshold, then it will be activated

    • below: When the series item is below the threshold, then it will be activated

  • @threshold-lines (optional):

    • auto (default): Defaults to a baseline, unless we are using thresholds from a column, and the values within the column differ then we will use an item line.

    • baseline: Will be rendered as a line across the whole series. When the target value is from a column, the first value is used to create the line.

    • item: Will be rendered as a line across the particular series item. Used when each series item has a different threshold value

    • none: Do not render the threshold lines, only the style will be activated when the threshold is met.

Examples

A column chart showcasing sales with a threshold for the target sales we would like to hit

-- @chart: column
-- @title: Baselines - Average Baseline
-- @subtitle: An example column chart showing sales by month
-- @formats: currency
-- @series: Sales
-- @thresholds: 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 chart with multiple baselines with specified types:

-- @chart: column
-- @title: Baselines - Multiple Baseline Types on one Series
-- @subtitle: An example column chart showing sales by month
-- @formats: currency
-- @series: Sales
-- @baselines: Sales, Sales, Sales
-- @baseline-types: average, min, max
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

An example column chart with a baseline