ChartSQL allows you to easily generate charts using SQL statements.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.