Implementing flash reports using amchart

Source: Internet
Author: User

The flash report needs to be made on the project. I checked amchart and found that this is relatively simple (probably because I have never touched any other one). In conclusion, it mainly involves two aspects of configuration, one is the setting_file attribute, which is used to load the flash report style, that is, the general color, shape, and other configurations. It can be dynamically changed, and one side is directly written to XXX. XML file, as long as the returned XML format is the line, you do not need to actually exist in this file, so you can set the setting_file attribute to a URL request, for example: setting_file = 'xxaction? Query. Do, as long as the returned content of a file conforms to the format of its configuration file. Same. The same is true for data requests, as long as the request returns a content that meets the data file format. Data Files may not exist.

For example

Data JSP file code:

<% @ Page import = "Java. util. *, Com. trishield. prisonplat. Prisoner. entity. prisonercount, Com. trishield. prisonplat. Prisoner. Service. iprisonerservice" %>
<% @ Page contenttype = "text/XML; charset = UTF-8" %>
<Pie>
<%
// List countlist = (list) request. getattribute ("piedatalist ");
String querytype = (string) request. getattribute ("querytype ");
Int totalonreg = 10;
Int totalinhospital = 10;
Int totalcontrol = 10;
Int totalonhold = 10;
If ("status". Equals (querytype )){
List <prisonercount> countlist = (list <prisonercount>) request. getattribute ("piedatalist ");
For (prisonercount CT: countlist ){
Totalonreg + = CT. getonregcount ();
Totalinhospital+ = CT. getinhospitalcount ();
Totalcontrol + = CT. getcontrolcount ();
Totalonhold + = CT. getonholdcount ();
}
%>
<Slice Title = "" Description = "click to view the trend chart"> <% = totalonhold %> </slice>
<Slice Title = "hospitalization" Description = "click to view the trend chart"> <% = totalinhospital %> </slice>
<Slice Title = "strict control" Description = "click to view the trend chart"> <% = totalcontrol %> </slice>
<Slice Title = "registered" Description = "click to view the trend chart"> <% = totalonreg %> </slice>
<%
} Else if ("controllevel". Equals (querytype )){
List prisonerlist = (list) request. getattribute ("piedatalist ");
For (INT I = 0; I <prisonerlist. Size (); I ++ ){
Object [] valuearray = (object []) prisonerlist. Get (I );
%>
<Slice Title = "<% = valuearray [1] %>"> <% = valuearray [0] %> </slice>
<%
}
}
%>
</Pie>

Configuration file:

<%
String lable = (string) request. getattribute ("label ");
Stringbuffer SQL = new stringbuffer ();
SQL. append ("<? XML version = '1. 0' encoding = 'utf-8'?> ");
SQL. append ("<Settings> ");
SQL. append ("<data_type> XML </data_type> ");
SQL. append ("<skip_rows> 1 </skip_rows> ");
SQL. append ("<pie> ");
SQL. append ("<x> </x> ");
SQL. append ("<Y> </Y> ");
SQL. append ("<radius> 90 </radius> ");
SQL. append ("<inner_radius> 10 </inner_radius> ");
SQL. append ("SQL. append ("<angle> 0 </angle> ");
SQL. append ("<start_angle> </start_angle> ");
SQL. append ("<outline_color> </outline_color> ");
SQL. append ("<outline_alpha> </outline_alpha> ");
SQL. append ("<base_color> </base_color> ");
SQL. append ("<brightness_step> </brightness_step> ");
SQL. append ("<colors> ");
SQL. append ("[# 8e0e1b, # 0e528f, #7d9308, # 860d6c, # ffca21, # e97a04, # ff9e01]");
SQL. append ("</colors> ");
SQL. append ("<link_target> _ parent </link_target> ");
SQL. append ("<alpha> </alpha> ");
SQL. append ("SQL. append ("<gradient> </gradient> ");
SQL. append ("<gradient_ratio> </gradient_ratio> ");
SQL. append ("</pie> ");
SQL. append ("<animation> ");
SQL. append ("<start_time> 3 </start_time> ");
SQL. append ("<start_effect> regular </start_effect> ");
SQL. append ("<sequenced> true </sequenced> ");
SQL. append ("<pull_out_on_click> </pull_out_on_click> ");
SQL. append ("<pull_out_time> 0.5 </pull_out_time> ");
SQL. append ("<pull_out_effect> strong </pull_out_effect> ");
SQL. append ("</animation> ");
SQL. append ("<data_labels> ");
SQL. append ("<radius> </radius> ");
SQL. append ("<text_color> </text_color> ");
SQL. append ("<text_size> 10 </text_size> ");
SQL. append ("<max_width> </max_width> ");
SQL. append ("<show> ");
SQL. append ("<! [CDATA [{Title }:{ percents} %]> ");
SQL. append ("</show> ");
SQL. append ("<show_lines> </show_lines> ");
SQL. append ("<line_color> </line_color> ");
SQL. append ("<line_alpha> 100 </line_alpha> ");
SQL. append ("SQL. append ("<avoid_overlapping> </avoid_overlapping> ");
SQL. append ("</data_labels> ");
SQL. append ("<balloon> ");
SQL. append ("<enabled> </enabled> ");
SQL. append ("<color> </color> ");
SQL. append ("<alpha> 80 </alpha> ");
SQL. append ("</balloon> ");
SQL. append ("<legend> ");
SQL. append ("<enabled> </enabled> ");
SQL. append ("<x> </x> ");
SQL. append ("<Y> </Y> ");
SQL. append ("<width> 280 </width> ");
SQL. append ("<color> </color> ");
SQL. append ("<max_columns> </max_columns> ");
SQL. append ("<alpha> </alpha> ");
SQL. append ("<border_color> </border_color> ");
SQL. append ("<border_alpha> 20 </border_alpha> ");
SQL. append ("<text_color> </text_color> ");
SQL. append ("<text_size> </text_size> ");
SQL. append ("<spacing> 9 </spacing> ");
SQL. append ("<margins> 5 </margins> ");
SQL. append ("<reverse_order> </reverse_order> ");
SQL. append ("<align> center </align> ");
SQL. append ("</legend> ");
SQL. append ("<error_messages> ");
SQL. append ("<enabled> </enabled> ");
SQL. append ("<x> </x> ");
SQL. append ("<Y> </Y> ");
SQL. append ("<color> </color> ");
SQL. append ("<alpha> </alpha> ");
SQL. append ("<text_color> </text_color> ");
SQL. append ("<text_size> 20 </text_size> ");
SQL. append ("</error_messages> ");
SQL. append ("<labels> ");
SQL. append ("<label lid = '0'> ");
SQL. append ("<x> 0 </x> ");
SQL. append ("<Y> 0 </Y> ");
SQL. append ("<rotate> false </rotate> ");
SQL. append ("<width> </width> ");
SQL. append ("<align> center </align> ");
SQL. append ("<text_color> </text_color> ");
SQL. append ("<text_size> 12 </text_size> ");
SQL. append ("<text> ");
SQL. append ("<! [CDATA [<B> ");
SQL. append (lable );
SQL. append ("</B>]> ");
SQL. append ("</text> ");
SQL. append ("</label> ");
SQL. append ("</labels> ");
SQL. append ("</Settings> ");
Response. getwriter (). Write (SQL. tostring ());

%>

In this way, you can dynamically change the flash report based on the business data needs. There are several ways to interact with JS data (flashmovie. setdata... For details, see the API). To sum up the following sentence: very good, very powerful

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.