ChartSQL allows you to use SQL statements to generate charts. Charts can be rendered using SVG vector charts, which can be easily embedded into webpages. ChartSQL can run and generate charts directly on the Web end through FnordMetric Server
ChartSQL features
Directly input SQL statements to generate corresponding data charts, which is very simple.
Display SVG charts on the browser side
Supports multiple chart formats, including line charts, column charts, and pie charts.
Usage of ChartSQL
Line chart with data points
SQL code:
The code is as follows: |
Copy code |
Import table city_temperatures FROM 'csv: examples/data/city_temperatures.csv? Headers = true '; DRAW LINECHART AXIS LEFT AXIS BOTTOM Legend top left inside; SELECT City AS series, Month AS x, Temperature AS y, "Avg. Temperatures in" + month + "in" + city + ":" + temperature as label, "Circle" as pointstyle FROM city_temperatures; |
Run the code:
The code is as follows: |
Copy code |
$ Fnordmetric-cli -- format = svg examples/linECharts/lines_with_points. SQL |
Effect chart:
Simple area chart
SQL code:
The code is as follows: |
Copy code |
Import table example_data FROM 'csv: examples/data/measurement.csv? Headers = true '; DRAW AREACHART AXIS BOTTOM AXIS LEFT Grid horizontal; SELECT 'data' AS series, FROM_TIMESTAMP (time) AS x, value2 * 1000 AS y, 'solid' as linestyle FROM example_data WHERE series = "measurement2 "; |
Run the code:
The code is as follows: |
Copy code |
$ Fnordmetric-cli -- format = svg examples/areacharts/simple_area. SQL |
Effect chart:
Column chart
SQL code:
The code is as follows: |
Copy code |
Import table gdp_per_capita FROM 'csv: examples/data/gdp_per_capita.csv? Headers = true '; DRAW BARCHART ORIENTATION VERTICAL AXIS BOTTOM GRID HORIZONTAL Legend top right inside; SELECT year AS series, isocode AS x, gdp AS y FROM gdp_per_capita WHERE year = "2010" OR year = '20140901' or year = '20160901' Order by gdp DESC LIMIT 9; |
Run the code:
The code is as follows: |
Copy code |
$ Fnordmetric-cli -- format = svg examples/barcharts/vertical_bars. SQL |
Effect chart:
Summary
In general, the use of ChartSQL is relatively simple. We only need to execute the corresponding SQL to display the data chart, saving the control for generating charts compiled by ourselves. Of course, ChartSQL is not suitable for all chart applications, because we do not store data in databases, such as XML and JSON.