ColdFusion MX easy to make Flash method 1th/3 page _coldfusion

Source: Internet
Author: User
Tags generator reserved

A Brief introduction
Since ColdFusion (CF) has been acquired by the Macromedia Company, MM company has upgraded CF in Flash applications, using CF to dynamically integrate with Flash. The longest use is harpoon, but the role of CF in Flash charts is rarely known. What I'm going to talk about today is one of the most promising features of Flash in CF, built-in charts.

First we need tools to dynamically generate flash charts by Macromedia Generator,generator is the engine that the Flash output server uses to start CF mapping. The general process of generator cartography is:
1 CF transmits data to generator
2) generator the data into a chart and returns it to the CF
3) Output to browser

Of course, you do not deliberately to install generator, this will be installed when you install ColdFusion automatically installed. If you have ColdFusion installed, you can download this tutorial, which contains the database and script files that will be used in this article.

Two familiar marks
CF is used to map two of the markings, namely <CFGRAPH> and <cfgraphdata>, where <CFGRAPH> is used most, and <CFGRAPHDATA> use frequency is almost less than 1%, So we just have to be familiar with <CFGRAPH>. First, introduce <CFGRAPH> several basic property fields.

<CFGRAPH> output The following parameters are required.
1.TYPE: The type of chart, there are 5 kinds, pie chart, column chart, line chart, bar chart, area chart.
2.QUERY: Used to accept CF pass data
3.VALUECOLUMN: A data query column used for drawing, for example, the sum of a class of articles
4.FILEFORMAT: In the browser output format, there are two types of Flash SWF and JPG format.

There are also some parameters, because it is not very important, we will be in the actual application in the next introduction.

Three demonstrations
This is the key, the best hands-on, you can download the tutorial in the database use, do not create a separate database, in addition to this database in the CF set data source for Cflash.
My database design is relatively simple, is entirely for this article to do, a total of two tables: File and sortfile table storage article title, details detail, article type sort, And of course there's a idsort. Contains the type SortID and name Sortname of the article.
The relationship between the two tables is: Sort in file is connected to the sort query.

We'll start below.

1. First, we set up a query in CF and then group and sort. Of course you can avoid the sort.
The contents are as follows:

<cfquery name= "Wait" datasource= "Cflash" >
SELECT Sortname, COUNT (*) as COUNT
From Sort,file
WHERE File.sort = Sort.sortid
GROUP by Sortname
ORDER BY Sortname
</CFQUERY>

The above query is about how many posts are in each type.

2. After you have done the query, you will begin to make a chart.

If you are unfamiliar with <CFGRAPH>, take a look at the basic types described earlier.

<cfgraph
Type= "Pie"
query= "Wait"
Valuecolumn= "Count"
Itemcolumn= "Sortname"
fileformat= "Flash"
Title= "The Pie"
Borderwidth= "0"
Depth= "Ten" >
</CFGRAPH>

Let me introduce you. Type is a pie chart, and query accepts the previously queried name in CF. ValueColumn is the data for the query column, and my goal is to count how many articles there are in each type.    Itemcolumn is the Display tab where I set the display sortname, type name. FileFormat is the output type. I choose flash here, if you want to use the picture display, you can change to JPG. BorderWidth: This is the chart border, 0 is not showing the border. DEPTH, for vertical depth, you don't want your chart to be a rigid floor plan? Set here can be more stereoscopic.

All right. Now combine the above into one file, the source file is as follows:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<!---
Title: Let ColdFusion to do flash<1>
Author:wait (parole@163.net)
Description:cfggraph Application
date:november,11 2002
--->
<!---query Database--->
<cfquery name= "Wait" datasource= "Cflash" >
SELECT Sortname, COUNT (*) as COUNT
From Sort,file
WHERE File.sort = Sort.sortid
GROUP by Sortname
ORDER BY Sortname
</CFQUERY>

<title> let ColdFusion to do flash</title>
<body>
TYPE4 Properties of <center><center>
<!---the application of various attributes is listed below--->
<cfgraph
Type= "Pie"
query= "Wait"
Valuecolumn= "Count"
Itemcolumn= "Sortname"
fileformat= "Flash"
Title= "The Pie"
Borderwidth= "0"
Depth= "Ten" >
</CFGRAPH>
<HR>
<center><b>power by Coldfusion</b><br><fontsize= "-1" >copyright (C) 2002 <A HREF= " MAILTParole@163.net ">WAIT</A> All Rights reserved.</font></center>
</body>

Code Copy Box

The following is a reference fragment:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
<!---
Title: Let ColdFusion do flash<1>
Author:wait (parole@163.net)
Description:cfggraph apply
date:november,11 2002
---
<!---query database-
<cfquery name= "Wait" datasource= "Cflash"
SELECT sortname, COUNT (*) as Count
from Sort,file
WHERE file.sort = Sort.sortid
GROUP by Sortname
Order by Sortname
</CFQUERY>

<title> let ColdFusion to do flash</title>
<body>
TYPE4 Properties of <center><center>
<!---the application of various attributes is listed below--->
<cfgraph
Type= "Pie"
query= "Wait"
Valuecolumn= "Count"
Itemcolumn= "Sortname"
fileformat= "Flash"
Title= "The Pie"
Borderwidth= "0"
Depth= "Ten" >
</CFGRAPH>
<HR>
<center><b>power by Coldfusion</b><br><fontsize= "-1" >copyright (C) 2002 <A HREF= " MAILTParole@163.net ">WAIT</A> All Rights reserved.</font></center>
</body>

Show pictures as follows:

Each type will be scaled to show that this is the pie chart
Of course, all you have to do is type, and you can become other graphics, like the line chart I've been looking for.
Here are 4 commonly used effect graphs.

Isn't it funny? The proportions of the charts are dynamically constructed according to the true proportions of our database, is it the effect you want? You can change according to your own needs, such as background color, font, when it comes to fonts, what you need to be reminded is that you don't support Chinese [maybe I'm ignorant]. If it is not the effect you want, please see tomorrow, tomorrow, we will make a link on the pie chart, real dynamic chart. Note that the source code and tutorials that are downloaded today do not contain what will be said tomorrow (not yet written), but the database will not change.


All rights reserved, please notify me in advance.
Parole@163.net

Current 1/3 page 123 Next read the full text

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.