Drawing of change interval time series Reports

Source: Internet
Author: User

Drawing of change interval time series Reports

In addition to a fixed Statistical Chart, report development sometimes needs to generate a Statistical Chart that needs to be changed based on different data of different conditions. Images.

The key to this type of problem is actually the preparation of the report data source. How to generate the report data source of the corresponding time and Segment Based on the specified conditions is crucial for generating a Statistical Chart. It is basically difficult to use SQL, and it depends on the stored procedure. However, it is not easy to implement the stored procedure because it cannot use intermediate results or has insufficient support for Ordered Sets.

The collection and computing reports are relatively simple when they are completed. The actual business in the above link is used as an example to provide an implementation solution for the collection and computing reports.

Report background

Source data table sj dataAs follows:

 

The table contains two fields, T is the date field separated by minutes, and V is the corresponding time value.

 

The current report needs to draw a Statistical Chart Based on the following situations:

Enter the specified statistical time point and specify the statistical type. If hourly statistics are collected, the data is drawn at intervals of 5 minutes. If daily statistics are collected, the data is drawn at intervals of 2 hours; if the weekly statistics are collected, the data is drawn every one day.

 

The analysis at the beginning shows that using stored procedures and even Java custom data sources is troublesome. The computing report itself has built-in scripts suitable for structured computing, allowing you to easily write computation data preparation (equivalent to a simpler user-defined dataset ). The preceding report requirements can be completed using the set computing report as follows:

Compile the computing script

UseComputing Script Editor,Create a set computing script and set the Script Parameters: statistical time.

 

Write scripts based on input parameters to output the computed result set for the report.

 

A1: connect to the data source;

A2: NULL sequence, used to save the time period information used for statistics;

A3-B5: Judge by hour, day or week statistics, and the corresponding time period information is stored in A2;

A6: Execute SQL summary data based on the A2 period to generate a new sequence table with time and summary results;

A7: Close the database connection;

A8: return result set of the report.

Edit a Report Template

Use the computing report editor to edit a report template for data presentation. Create a parameter and set the default value.

 

Create a report and set the dataset, and call the edited script file.

 

The dfx file path can be either an absolute or relative path. The relative path is the dfx home directory configured in the relative options. The dt and d_type parameters are the report template parameters, d_date and type are the Script Parameters. In fact, they can have the same name.

 

Edit the report expression and directly use the result set returned by the Set Computing script to draw a Statistical Chart.

 

Statistical Chart definition:

 

It is worth mentioning that the integrated computing report supports HTML5 and SVG statistical graphs to meet the needs of mobile applications.

 

The report results are as follows:

 

You can use the set calculator script to quickly develop charts with such time interval changes. The external computing script has a visual editing and debugging environment, and the edited script can be reused (called by other reports or programs ). However, if the script has been debugged and does not need to be reused, It is troublesome to maintain consistency between the two files (the Set Computing script and Report Template, in this case, it is easier to directly use the script dataset of the Set Computing report.

In the script dataset, you can write scripts to complete computing tasks step by step. The syntax is the same as that of the Set calculator. You can also directly use the data sources and parameters defined in the report. In this example, the script dataset can be used as follows:

1. Click "add" in the dataset settings window. The dataset Type dialog box is displayed. Select "script dataset ";

2. Compile the script in the pop-up script dataset editing window;

 

In the script dataset, the dt and d_type parameters are defined in the report, and you do not have to manage database connections or close them. This is simpler and more direct than the separate set computing script.

3. The report template and expression are the same as those using the dataset of the cube.


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.