Overview
Easy JavaScript based charts in any web application
ChartSQL.js is currently in development. Documentation is for feedback purposes.
ChartSQL.js is an open source library to chart SQL (or any table like data) seamlessly within any web application.
We have designed ChartSQL.js to be the easiest to use JavaScript charting library available.
Key Benefits
Simple .js integration
Supports any SQL table-like or NoSQL source of data
Full rendering control with intuitive 'directives'
What You Query is What You Chart (Whikee-Whic) - Simple and declarative charting.
Minimal Example
The following is all that is required to create a basic column chart
Quick Start
Add
chartsql.js
to Your Project and setup a basic column chart
createChart({})
createChart()
allows you to render data into chart visuals at the target HTML element
The typical flow is:
Setup ChartSQL
Fetch data
call
createChart()
to render the data into a chart.
Parameters
Parameter | Required? | Description |
---|---|---|
target | no | The DOM element ID where the chart will be rendered. |
data | yes | An object containing the data to be used for rendering the chart. See Working with Data |
directives | yes | SQL string containing directives, or object of directives. |
Auto Charts
ChartSQL.js will try to automatically choose a basic chart type depending on the fields in your data.
The auto charts helps you quickly visualize and explore data and then you can Customize Charts for more control.
Auto Column Chart
When there is one string and one numeric field in the data
Auto Grouped Column Chart
When there is one string and 2 or more numeric fields the numeric fields will be grouped
Auto Date Line Chart
When there is a date field and a numeric field
Customizing Charts
You can specify exactly how to render the chart with directives (aka @directives).
Directives allow you to fully control the type of chart and the selection of the categories, series formats and other ChartSQL.js features.
Basic Directives Example
createChart()
takes a 'directives' object which contains the directives for controlling rendering of the chart.
Common Directives
chart - The type of chart: bar, column, line etc
category - The column to use for the category (primary axis) of the chart
series - The column/s to use for the data (secondary axis) of the chart
formats - The data formats to render for the series
You can See All Directives for all the ways in which you can customize your charts.
ChartSQL.js is currently in development and does not support all directives. See the Supported Directives section for current support
Directives in SQL
ChartSQL's namesake comes from the fact that you can define your chart directives within SQL source code. The same capability is provided to you in ChartSQL.js.
If your data is already coming from an executed SQL script, you can also choose to define your directives in your SQL.
You pass the full SQL script to createChart directives and it will get parsed
Chart
Category
Series
Formats
Working with Data
ChartSQL.js is designed to work with table like data of columns and rows. Typically this data will come from executing a SQL query, but data from any source can be charted.
ChartSQL.js liberally accepts table data in a few different formats that you pass to the createChart()
method.
Array of Objects
Array of Arrays
The first row in the array should be the column names
Table Object
Data Class
If desired, you can instantiate your own instance of the Data.js class that ChartSQL creates internally.
Relationship to ChartSQL Studio, Datasources, Dashboards & Extensions
ChartSQL.js is the parsing and rendering layer. It does not handle managing and executing SQL against datasources, creating dashboards, or editing SQL Charts.
Supported Features
ChartSQL.js is a subset of ChartSQL Studio and Dashboard Features. See the tables below of supported features
✔️ = fully supported
❌ = no support planned
☐ = support planned
〰️ = Partial support
Auto Charts
List of Auto Charts charts that are currently supported
Auto Chart | ChartSQL.js | ChartSQL Studio |
---|---|---|
Column | ✔️ | ✔️ |
Grouped Column | ☐ | ✔️ |
Date-based Line | ☐ | ✔️ |
Datetime based line | ☐ | ✔️ |
Stacked-Grouped Column | ☐ | ✔️ |
Scatter | ☐ | ✔️ |
Bubble (scatter with size) | ☐ | ✔️ |
Heatmap | ☐ | ✔️ |
Chart Types
List of Chart Types that are currently supported
Type | ChartSQL.js | ChartSQL Studio |
---|---|---|
Area | ☐ | ✔️ |
Bar | ☐ | ✔️ |
Bubble | ☐ | ✔️ |
Column | ☐ | ✔️ |
Combo | ☐ | ✔️ |
Gauge | ☐ | ✔️ |
Heatmap | ☐ | ✔️ |
Line | ☐ | ✔️ |
Pie | ☐ | ✔️ |
Radar | ☐ | ✔️ |
Scatter | ☐ | ✔️ |
Directives
Directive | ChartSQL.js | ChartSQL Studio | Note |
---|---|---|---|
@baselines | ☐ | ✔️ | |
@baseline-types | ☐ | ✔️ | |
@chart | ✔️ | ✔️ | |
@cateogry | ☐ | ✔️ | |
@formats | ☐ | ✔️ | |
@series | ☐ | ✔️ | |
@title | ☐ | ✔️ | |
@subtitle | ☐ | ✔️ | |
@groups | ☐ | ✔️ | |
@series-types | ☐ | ✔️ | |
@series-labels | ☐ | ✔️ | |
@stacking-mode | ☐ | ✔️ | |
@dash-id | ❌ | ✔️ | Only used for publishing to ChartSQL cloud. No use for ChartSQL.js |
@overlay-series | ☐ | ✔️ | |
@tags | ❌ | ✔️ | Used for searching inside ChartSQL Studio and dashboards. Not used by ChartSQL.js |
@mongodb-query | ❌ | ✔️ | Only used by ChartSQL Studio |
Other Capabilities
Capability | ChartSQL.js | ChartSQL Studio | Note |
---|---|---|---|
Series Assist | ✔️ | ✔️ | Assists when selecting series and no @series is defined |
Category Assist | ✔️ | ✔️ | Assists in selecting categories when no @category is defined |
Last updated