静岡理工科大学 菅沼ホーム ActionScript目次 索引

グラフの描画

      1. データベースと表&グラフ
      2. 一般的なグラフ

  1. データベースと表&グラフ

      データベースの内容を表やグラフで表したい場合がしばしば発生します.表&グラフ(ソースプログラム database_action.php は以下に示すとおり)は,データベースに保存されている内容を取り出し,その結果を表とグラフで表現しています.このプログラムでは,データベースのテーブルを作成し,データを挿入する操作を行っていますが,これは,あくまでテスト用であり,一般的には必要ありません.

    database_action.php

    001	<!DOCTYPE HTML>
    002	<HTML>
    003	<HEAD>
    004		<TITLE>表&グラフ</TITLE>
    005		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
    006		<LINK REL="stylesheet" TYPE="text/css" HREF="../master.css">
    007	</HEAD>
    008	<BODY CLASS="white" STYLE="text-align: center">
    009		<H1 CLASS="center">表&グラフ</H3>
    010	<?php
    011						// データベースへの追加
    012		$db = mysql_connect("*****", "*****", "*****");
    013		if (!$db)
    014			exit("<h1>データベースへ接続できません</h1>\n");
    015						// テーブルの削除
    016		mysql_select_db("WEB_SHOP", $db);
    017		$result = mysql_query("SHOW TABLES", $db);
    018		if (mysql_num_rows($result) > 0) {
    019			while ($row = mysql_fetch_row($result)) {
    020				if (strcmp($row[0], "commodity") == 0) {
    021					mysql_query("DROP TABLE commodity", $db);
    022					break;
    023				}
    024			}
    025			mysql_free_result($result);
    026		}
    027						// テーブルの生成とデータの追加
    028		$str = "(id INT AUTO_INCREMENT PRIMARY KEY,itemname varchar(100) not null,stock INT NOT NULL)";
    029		mysql_query("CREATE TABLE commodity ".$str, $db);
    030		if (mysql_errno($db) != 0)
    031			exit("<h1>テーブル commodity を作成できません</h1>\n");
    032		mysql_query("INSERT INTO commodity VALUES(NULL,'商品1',10)", $db);
    033		mysql_query("INSERT INTO commodity VALUES(NULL,'商品2',20)", $db);
    034		mysql_query("INSERT INTO commodity VALUES(NULL,'商品3',4)", $db);
    035		mysql_query("INSERT INTO commodity VALUES(NULL,'商品4',40)", $db);
    036		mysql_query("INSERT INTO commodity VALUES(NULL,'商品5',35)", $db);
    037		mysql_query("INSERT INTO commodity VALUES(NULL,'商品6',4)", $db);
    038		mysql_query("INSERT INTO commodity VALUES(NULL,'商品7',3)", $db);
    039		mysql_query("INSERT INTO commodity VALUES(NULL,'商品8',2)", $db);
    040		mysql_query("INSERT INTO commodity VALUES(NULL,'商品9',15)", $db);
    041		mysql_query("INSERT INTO commodity VALUES(NULL,'商品10',20)", $db);
    042						// データの削除とすべてのデータの出力
    043		mysql_query("DELETE FROM commodity WHERE id IN (1,8)", $db);
    044		$result = mysql_query("SELECT * FROM commodity", $db);
    045		echo "id = 1, 8 を削除\n";
    046		echo "	<DL>\n";
    047		while ($row = mysql_fetch_row($result))
    048			echo "<DT>".$row[0]." ".$row[1]." ".$row[2]."<BR>\n";
    049		echo "	</DL><P>\n";
    050						// データの追加とすべてのデータの出力
    051		mysql_query("INSERT INTO commodity VALUES(NULL,'商品1',10)", $db);
    052		$result = mysql_query("SELECT * FROM commodity", $db);
    053		echo "商品 1 を追加\n";
    054		echo "	<DL>\n";
    055		while ($row = mysql_fetch_row($result))
    056			echo "<DT>".$row[0]." ".$row[1]." ".$row[2]."<BR>\n";
    057		echo "	</DL><P>\n";
    058						// データの修正とすべてのデータの出力
    059		mysql_query("UPDATE commodity SET stock = 50 WHERE id = 11", $db);
    060		$result = mysql_query("SELECT * FROM commodity", $db);
    061		echo "商品 1 のデータを修正\n";
    062		echo "	<DL>\n";
    063		while ($row = mysql_fetch_row($result))
    064			echo "<DT>".$row[0]." ".$row[1]." ".$row[2]."<BR>\n";
    065		echo "	</DL><P>\n";
    066						// データの出力
    067								// グラフ表示の準備
    068		$gp      = "0,在庫の多い商品,商品名,商品在庫,1,在庫";
    069		$x_title = array();
    070		$data    = array();
    071		$n       = 0;
    072		$max     = 0;
    073								// 表の作成
    074		echo "	<TABLE BORDER='1' STYLE='margin-right: auto; margin-left: auto'>\n";
    075		echo "		<TR>\n";
    076		echo "			<TH>商品名</TH>\n";
    077		echo "			<TH>商品在庫</TH>\n";
    078		echo "		</TR>\n";
    079		$result = mysql_query("SELECT * FROM commodity WHERE stock >= 10 ORDER BY stock", $db);
    080		while ($row = mysql_fetch_row($result)) {
    081			echo "		<TR>\n";
    082			echo "			<TD>".$row[1]."</TD>\n";
    083			echo "			<TD>".$row[2]."</TD>\n";
    084			echo "		</TR>\n";
    085			$x_title[$n] = $row[1];
    086			$data[$n] = $row[2];
    087			if ($row[2] > $max)
    088				$max = $row[2];
    089			$n++;
    090		}
    091		echo "	</TABLE>\n";
    092	
    093		mysql_free_result($result);
    094								// グラフ表示データの作成
    095		$gp = $gp.",".$n;   // データの数
    096		for ($i1 = 0; $i1 < $n; $i1++)
    097			$gp = $gp.",".$x_title[$i1];   // x軸タイトル
    098		if ($max > 50) {
    099			$step = 20;
    100			$max  = 100;
    101		}
    102		else {
    103			$step = 10;
    104			$max  = 50;
    105		}
    106		$gp = $gp.",0,".$max.",".$step.",0";  // 最小値,最大値,刻み幅,小数点以下桁数
    107		for ($i1 = 0; $i1 < $n; $i1++)
    108			$gp = $gp.",".$data[$i1];   // データ
    109		$gp = $gp.",1,0";   // グラフタイトルと凡例の表示
    110		$gp = "par=".$gp;
    111						// データベースへの接続を切る
    112		mysql_close ($db);
    113								// 描画
    114		printf("	<br>\n");
    115		printf("	<div class=\"center\">\n");
    116		printf("		<object type=\"application/x-shockwave-flash\" width=\"900\" height=\"600\" data=\"Graph.swf\">\n");
    117		printf("			<param name=\"movie\" value=\"Graph.swf\">\n");
    118		printf("			<param name=\"quality\" value=\"high\">\n");
    119		printf("			<param name=\"bgcolor\" value=\"#e1ffe1\">\n");
    120		printf("			<param name=\"FlashVars\" value=\"%s\">\n", $gp);
    121		printf("		</object>\n");
    122		printf("	</div>\n");
    123	?>
    124	</BODY>
    125	</HTML>
    			
    012 行目

      MySQL と接続している.

    016 行目~ 026 行目

      データベース WEB_SHOP に,テーブル commodity が存在した場合は,それを削除している.このプログラムで,テーブルの生成やデータの追加方法を示したいために行っている処理であり,一般的には必要ない.

    028 行目~ 029 行目

      テーブル commodity を作成している.この処理も,一般的には必要ない.

    032 行目~ 041 行目

      テーブル commodity にデータを追加している.この処理も,一般的には必要ない.

    043 行目~ 049 行目

      id が 1 と 8 であるデータを削除し,その結果を表示している.他のデータの id は変化していないことに注意すること.この処理も,一般的には必要ない.

    051 行目~ 057 行目

      上で削除した商品1に対するデータを追加し,その結果を表示している.追加されたデータの id に注意すること.この処理も,一般的には必要ない.

    059 行目~ 065 行目

      商品1に対するデータを修正し,その結果を表示している.この処理も,一般的には必要ない.

    068 行目

      116 行目~ 121 行目に記述してある Graph.swf は,グラフを描画するために必要な情報をカンマ「 , 」で区切った文字列として受け取り( 120 行目),その内容に従って様々なグラフを描画する.変数 $gp には,グラフを描画するために必要な情報が設定される.ここでは,「グラフの種類( 0 は棒グラフを示す),グラフタイトル, x 軸タイトル, y 軸タイトル,グラフの数,各グラフのタイトル(グラフの数だけ入力)」を設定している.

    069 行目~ 072 行目

      このプログラムでは,在庫数が多い商品に対して,商品毎の在庫数を棒グラフで表すことを目的としている.配列変数 $x_title には各商品の商品名,配列変数 $data にはその在庫数,変数 $n には商品の数,及び,変数 $max には最大在庫数が入る.

    074 行目~ 091 行目

      079 行目の SQL 文によって,在庫数が 10 以上の商品を選び,上で述べた変数に必要なデータを設定すると共に,商品名とその在庫数を表で表している.

    095 行目

      データ数(商品数)を変数 $gp に追加している.

    096 行目~ 097 行目

      各商品の商品名を変数 $gp に追加している.

    098 行目~ 105 行目

      $max の値に基づき,縦軸に対する刻み幅と最大値を設定している.

    106 行目

      変数 $gp に,「縦軸の最小値,縦軸の最大値,縦軸の刻み幅,縦軸に表示する数値の小数点以下桁数」を追加している.

    107 行目~ 108 行目

      各商品に対する在庫数を変数 $gp に追加している.グラフの数が複数の場合は,その数だけ,これらの行を繰り返すことになる.

    109 行目

      変数 $gp に,「グラフタイトルを表示するか否か( 1:表示,0:表示しない),凡例を表示するか否か( 1:表示,0:表示しない)」を追加している.

    110 行目

      送信するパラメータの名前 par を,変数 $gp の前に追加している.

    116 行目~ 121 行目

      変数 $gp をパラメータとして,Graph.swf を起動している.

      上のプログラムで使用している Graph.as は,NAME 属性の値が "FlashVars" である PARAM 要素を通して与えられたパラメータに基づき,必要なグラフを描くための汎用プログラムです.実際問題では,PHP プログラムなどによって必要なデータを収集し,描くグラフを決定し,それらをパラメータとして Graph.as に渡してグラフを描くことになります.Graph.as では,与えられたデータに基づき,グラフの種類によって異なるプログラムを呼び出します.Graph.as の下には,実際に各グラフを描くプログラムを載せておきます.以下のプログラムを見れば,描きたいグラフによって,どのようなデータを,どのような順番でパラメータとして渡される文字列に記述すべきかが分かると思います.

      各グラフにおいて,右上の「横」または「縦」と記述された部分をクリックすると縦表示と横表示が切り替わります.また,「色」と記述された部分をクリックすると,グラフの色,折れ線グラフ等の線の太さやマークの有無等を変更するための領域が表示されると共に,「色」の部分が「設」の表示に変化します.色や線の太さ等を設定した後,「設」の部分をクリックすることによって,変更結果を反映したグラフが表示されます.

    Graph.sa
    /****************************/
    /* グラフの描画             */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.display.StageScaleMode;
    
    	[SWF(backgroundColor="0xe1ffe1", width="900", height="600", frameRate="30")]
    
    	public class Graph extends Sprite {
    
    		private var draw:Sprite;
    
    		public function Graph()
    		{
    			stage.scaleMode = StageScaleMode.SHOW_ALL;
    					// 描画領域
    			draw = new Sprite();
    			addChild(draw);
    					// データの分離とグラフの選択
    			var str : String = loaderInfo.parameters.par;
    			var a : Array = str.split(",");
    			var kind : int = parseInt(a[0]);   // グラフの種類
    			var k : int = 1;
    			var i1 : int;
    			var i2 : int;
    			var title : Array;   // グラフタイトル, x軸タイトル, y軸タイトル
    			var n_g : int;   // グラフの数
    			var g_title : Array;   // 各グラフのタイトル(凡例)
    			var n_p : int;   // データの数
    			var x_title : Array;   // x軸への表示内容
    			var x_scale : Array;   // x軸の最小値, x軸の最大値, x軸の刻み幅
    			var place_x : int;   // x軸の小数点以下桁数
    			var y_scale : Array;   // y軸の最小値, y軸の最大値, y軸の刻み幅
    			var place_y : int;   // y軸の小数点以下桁数
    			var data_x : Array;   // x軸のデータ(n_g×n_p個)
    			var data_y : Array;   // y軸のデータ(n_g×n_p個)
    			var d_t : Boolean = true;   // グラフタイトル表示の有無
    			var d_g : Boolean = true;   // 凡例表示の有無
    							//
    							// 棒グラフ
    							//
    			if (kind == 0) {
    				title = new Array(3);   // グラフタイトル, x軸タイトル, y軸タイトル
    				for (i1 = 0; i1 < 3; i1++) {
    					title[i1] = a[k];
    					k++;
    				}
    				n_g = parseInt(a[k]);   // グラフの数
    				g_title = new Array(n_g);   // 各グラフのタイトル(凡例)
    				k++;
    				for (i1 = 0; i1 < n_g; i1++) {
    					g_title[i1] = a[k];
    					k++;
    				}
    				n_p = parseInt(a[k]);   // データの数
    				x_title = new Array(n_p);   // x軸への表示内容
    				k++;
    				for (i1 = 0; i1 < n_p; i1++) {
    					x_title[i1] = a[k];
    					k++;
    				}
    				y_scale = new Array(3);   // y軸の最小値, y軸の最大値, y軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					y_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_y = parseInt(a[k]);   // y軸の小数点以下桁数
    				k++;
    				data_y = new Array(n_g);   // データ(n_g×n_p個)
    				for (i1 = 0; i1 < n_g; i1++) {
    					data_y[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_y[i1][i2] = Number(a[k]);
    						k++;
    					}
    				}
    				if (parseInt(a[k]) == 0)
    					d_t = false;
    				if (parseInt(a[k+1]) == 0)
    					d_g = false;
    				var graph0 : BarGraph = new BarGraph(title, g_title, x_title, y_scale, place_y, data_y, d_t, d_g, draw, stage.stageWidth, stage.stageHeight);
    			}
    							//
    							// 折れ線グラフ(1)
    							//
    			else if (kind == 1) {
    				title = new Array(3);   // グラフタイトル, x軸タイトル, y軸タイトル
    				for (i1 = 0; i1 < 3; i1++) {
    					title[i1] = a[k];
    					k++;
    				}
    				n_g = parseInt(a[k]);   // グラフの数
    				g_title = new Array(n_g);   // 各グラフのタイトル(凡例)
    				k++;
    				for (i1 = 0; i1 < n_g; i1++) {
    					g_title[i1] = a[k];
    					k++;
    				}
    				n_p = parseInt(a[k]);   // データの数
    				x_title = new Array(n_p);   // x軸への表示内容
    				k++;
    				for (i1 = 0; i1 < n_p; i1++) {
    					x_title[i1] = a[k];
    					k++;
    				}
    				y_scale = new Array(3);   // y軸の最小値, y軸の最大値, y軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					y_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_y = parseInt(a[k]);   // y軸の小数点以下桁数
    				k++;
    				data_y = new Array(n_g);   // データ(n_g×n_p個)
    				for (i1 = 0; i1 < n_g; i1++) {
    					data_y[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_y[i1][i2] = Number(a[k]);
    						k++;
    					}
    				}
    				if (parseInt(a[k]) == 0)
    					d_t = false;
    				if (parseInt(a[k+1]) == 0)
    					d_g = false;
    				var graph1 : LineGraph1 = new LineGraph1(title, g_title, x_title, y_scale, place_y, data_y, d_t, d_g, draw, stage.stageWidth, stage.stageHeight);
    			}
    							//
    							// 折れ線グラフ(2)
    							//
    			else if (kind == 2) {
    				title = new Array(3);   // グラフタイトル, x軸タイトル, y軸タイトル
    				for (i1 = 0; i1 < 3; i1++) {
    					title[i1] = a[k];
    					k++;
    				}
    				n_g = parseInt(a[k]);   // グラフの数
    				g_title = new Array(n_g);   // 各グラフのタイトル(凡例)
    				k++;
    				for (i1 = 0; i1 < n_g; i1++) {
    					g_title[i1] = a[k];
    					k++;
    				}
    				x_scale = new Array(3);   // x軸の最小値, x軸の最大値, x軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					x_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_x = parseInt(a[k]);   // x軸の小数点以下桁数
    				k++;
    				y_scale = new Array(3);   // y軸の最小値, y軸の最大値, y軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					y_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_y = parseInt(a[k]);   // y軸の小数点以下桁数
    				k++;
    				n_p = parseInt(a[k]);   // データの数
    				k++;
    				data_x = new Array(n_g);   // x軸のデータ(n_g×n_p個)
    				data_y = new Array(n_g);   // y軸のデータ(n_g×n_p個)
    				for (i1 = 0; i1 < n_g; i1++) {
    					data_x[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_x[i1][i2] = Number(a[k]);
    						k++;
    					}
    					data_y[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_y[i1][i2] = Number(a[k]);
    						k++;
    					}
    				}
    				if (parseInt(a[k]) == 0)
    					d_t = false;
    				if (parseInt(a[k+1]) == 0)
    					d_g = false;
    				var graph2 : LineGraph2 = new LineGraph2(title, g_title, x_scale, place_x, y_scale, place_y, data_x, data_y, d_t, d_g, draw, stage.stageWidth, stage.stageHeight);
    			}
    							//
    							// 積み上げ棒グラフ
    							//
    			else if (kind == 3) {
    				title = new Array(3);   // グラフタイトル, x軸タイトル, y軸タイトル
    				for (i1 = 0; i1 < 3; i1++) {
    					title[i1] = a[k];
    					k++;
    				}
    				n_g = parseInt(a[k]);   // グラフの数
    				g_title = new Array(n_g);   // 各グラフのタイトル(凡例)
    				k++;
    				for (i1 = 0; i1 < n_g; i1++) {
    					g_title[i1] = a[k];
    					k++;
    				}
    				n_p = parseInt(a[k]);   // データの数
    				x_title = new Array(n_p);   // x軸への表示内容(凡例)
    				k++;
    				for (i1 = 0; i1 < n_p; i1++) {
    					x_title[i1] = a[k];
    					k++;
    				}
    				y_scale = new Array(3);   // y軸の最小値, y軸の最大値, y軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					y_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_y = parseInt(a[k]);   // y軸の小数点以下桁数
    				k++;
    				data_y = new Array(n_g);   // データ(n_g×n_p個)
    				for (i1 = 0; i1 < n_g; i1++) {
    					data_y[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_y[i1][i2] = Number(a[k]);
    						k++;
    					}
    				}
    				if (parseInt(a[k]) == 0)
    					d_t = false;
    				if (parseInt(a[k+1]) == 0)
    					d_g = false;
    				var graph3 : StackGraph = new StackGraph(title, g_title, x_title, y_scale, place_y, data_y, d_t, d_g, draw, stage.stageWidth, stage.stageHeight);
    			}
    							//
    							// 円グラフ
    							//
    			else if (kind == 4) {
    				title = new Array();   // グラフタイトル
    				title[0] = a[k];
    				k++;
    				n_p = parseInt(a[k]);   // データの数
    				x_title = new Array(n_p);   // 凡例
    				k++;
    				for (i1 = 0; i1 < n_p; i1++) {
    					x_title[i1] = a[k];
    					k++;
    				}
    				data_y = new Array();   // データ(n_p個)
    				for (i1 = 0; i1 < n_p; i1++) {
    					data_y[i1] = Number(a[k]);
    					k++;
    				}
    				if (parseInt(a[k]) == 0)
    					d_t = false;
    				var graph4 : PieGraph = new PieGraph(title[0], x_title, data_y, d_t, draw, stage.stageWidth, stage.stageHeight);
    			}
    							//
    							// 散布図
    							//
    			else if (kind == 5) {
    				title = new Array(3);   // グラフタイトル, x軸タイトル, y軸タイトル
    				for (i1 = 0; i1 < 3; i1++) {
    					title[i1] = a[k];
    					k++;
    				}
    				x_scale = new Array(3);   // x軸の最小値, x軸の最大値, x軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					x_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_x = parseInt(a[k]);   // x軸の小数点以下桁数
    				k++;
    				y_scale = new Array(3);   // y軸の最小値, y軸の最大値, y軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					y_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_y = parseInt(a[k]);   // y軸の小数点以下桁数
    				k++;
    				n_p = parseInt(a[k]);   // データの数
    				k++;
    				data_y = new Array(2);   // データ(2×n_p個)
    				for (i1 = 0; i1 < 2; i1++) {
    					data_y[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_y[i1][i2] = Number(a[k]);
    						k++;
    					}
    				}
    				if (parseInt(a[k]) == 0)
    					d_t = false;
    				var graph5 : ScatterDiagram = new ScatterDiagram(title, x_scale, y_scale, place_x, place_y, data_y, d_t, draw, stage.stageWidth, stage.stageHeight);
    			}
    							//
    							// レーダーチャート
    							//
    			else if (kind == 6) {
    				title    = new Array(1);   // グラフタイトル
    				title[0] = a[k];
    				k++;
    				n_g = parseInt(a[k]);   // グラフの数
    				g_title = new Array(n_g);   // 各グラフのタイトル(凡例)
    				k++;
    				for (i1 = 0; i1 < n_g; i1++) {
    					g_title[i1] = a[k];
    					k++;
    				}
    				n_p = parseInt(a[k]);   // データの数
    				x_title = new Array(n_p);   // x軸への表示内容
    				k++;
    				for (i1 = 0; i1 < n_p; i1++) {
    					x_title[i1] = a[k];
    					k++;
    				}
    				y_scale = new Array(3);   // y軸の最小値, y軸の最大値, y軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					y_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_y = parseInt(a[k]);   // y軸の小数点以下桁数
    				k++;
    				data_y = new Array(n_g);   // データ(n_g×n_p個)
    				for (i1 = 0; i1 < n_g; i1++) {
    					data_y[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_y[i1][i2] = Number(a[k]);
    						k++;
    					}
    				}
    				if (parseInt(a[k]) == 0)
    					d_t = false;
    				if (parseInt(a[k+1]) == 0)
    					d_g = false;
    				var graph6 : RadarChart = new RadarChart(title[0], g_title, x_title, y_scale, place_y, data_y, d_t, d_g, draw, stage.stageWidth, stage.stageHeight);
    			}
    							//
    							// ボード線図(片対数グラフ)
    							//
    			else {
    				title = new Array(3);   // グラフタイトル, x軸タイトル, y軸タイトル
    				for (i1 = 0; i1 < 3; i1++) {
    					title[i1] = a[k];
    					k++;
    				}
    				n_g = parseInt(a[k]);   // グラフの数
    				g_title = new Array(n_g);   // 各グラフのタイトル(凡例)
    				k++;
    				for (i1 = 0; i1 < n_g; i1++) {
    					g_title[i1] = a[k];
    					k++;
    				}
    				x_scale = new Array(3);   // x軸の最小値, x軸の最大値, x軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					x_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_x = parseInt(a[k]);   // x軸の小数点以下桁数
    				k++;
    				y_scale = new Array(3);   // y軸の最小値, y軸の最大値, y軸の刻み幅
    				for (i1 = 0; i1 < 3; i1++) {
    					y_scale[i1] = Number(a[k]);
    					k++;
    				}
    				place_y = parseInt(a[k]);   // y軸の小数点以下桁数
    				k++;
    				n_p = parseInt(a[k]);   // データの数
    				k++;
    				data_x = new Array(n_g);   // x軸のデータ(n_g×n_p個)
    				data_y = new Array(n_g);   // y軸のデータ(n_g×n_p個)
    				for (i1 = 0; i1 < n_g; i1++) {
    					data_x[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_x[i1][i2] = Number(a[k]);
    						k++;
    					}
    					data_y[i1] = new Array(n_p);
    					for (i2 = 0; i2 < n_p; i2++) {
    						data_y[i1][i2] = Number(a[k]);
    						k++;
    					}
    				}
    				if (parseInt(a[k]) == 0)
    					d_t = false;
    				if (parseInt(a[k+1]) == 0)
    					d_g = false;
    				var graph7 : Bode = new Bode(title, g_title, x_scale, place_x, y_scale, place_y, data_x, data_y, d_t, d_g, draw, stage.stageWidth, stage.stageHeight);
    			}
    		}
    	}
    }
    			
    棒グラフ( BarGraph.as と Modify_bar.as )
    /****************************/
    /* 棒グラフの描画           */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.text.TextLineMetrics;
    
    	public class BarGraph {
    
    		private var title : Array;   // グラフタイトル, x軸タイトル, y軸タイトル
    		private var g_title : Array;   // 各グラフのタイトル(凡例)
    		private var n_p : int;   // データの数
    		private var x_title : Array;   // x軸への表示内容
    		private var y_scale : Array;   // y軸の最小値, y軸の最大値, y軸の刻み幅
    		private var data : Array;   // データ(n_g×n_p個)
    		private var d_t : Boolean = true;   // グラフタイトル表示の有無
    		private var d_g : Boolean = true;   // 凡例表示の有無
    		private var draw : Sprite;   // 表示画面
    		private var width : int;   // ステージの幅
    		private var height : int;   // ステージの高さ
    		private var x_l : int;   // 描画領域(横左)
    		private var x_r : int;   // 描画領域(横右)
    		private var y_u : int;   // 描画領域(縦上)
    		private var y_d : int;   // 描画領域(舘下)
    		private var ver : Boolean = true;   // 縦か横か( true が縦)
    		private var c_l : Boolean = false;   // 色設定領域が表示?( true がYes)
    		private var place_y : int;   // 小数点以下の桁数
    		private var tx : Array = new Array();   // TextField
    		private var n : int = 0;   // TextField の数
    		private var change1 : String = "横";   // 縦表示/横表示切り替えボタン
    		private var change2 : String = "色";   // 色や線の太さの切り替えボタン
    		private var c_l_n : int;   // 色や線の太さの切り替えボタンの位置
    		private var md : Modify_bar;   // 色や線の太さの切り替え領域
    		public var cl : Array;   // グラフの色
    		public var n_g : int;   // グラフの数
    					// コンストラクタ
    		public function BarGraph(title1:Array, g_title1:Array, x_title1:Array, y_scale1:Array, place_y1:int, data1:Array, d_t1:Boolean, d_g1:Boolean, draw1:Sprite, width1:int, height1:int)		{
    							// データの保存
    			title   = title1;
    			n_g     = g_title1.length;
    			g_title = g_title1;
    			n_p     = x_title1.length;
    			x_title = x_title1;
    			y_scale = y_scale1;
    			place_y = place_y1;
    			data    = data1;
    			d_t     = d_t1;
    			d_g     = d_g1;
    			draw    = draw1;
    			width   = width1;
    			height  = height1;
    							// 初期設定
    			cl = new Array(10);
    			cl[0] = 0x000000;
    			cl[1] = 0xFF00FF;
    			cl[2] = 0x0000FF;
    			cl[3] = 0x800080;
    			cl[4] = 0x00FFFF;
    			cl[5] = 0x008080;
    			cl[6] = 0x008000;
    			cl[7] = 0xC0C0C0;
    			cl[8] = 0xFF0000;
    			cl[9] = 0x800000;
    							// グラフの描画
    			graph_draw();
    		}
    					// グラフの描画
    		public function graph_draw() : void
    		{
    			var r : Number;
    			var tf : TextFormat;
    			var f_size : uint;
    			var mt : TextLineMetrics;
    			var i1 : int;
    			var i2 : int;
    			var k : int;
    			var k1 : int;
    			var k2 : int;
    			var kx : int;
    			var ky : int;
    			var len : int;
    			var g_w : int;
    			var sp : Number;
    			var x1 : Number;
    			var y1 : Number;
    							//
    							// 描画領域の設定
    							//
    			draw.graphics.beginFill(0xFFFFFF);
    			draw.graphics.drawRect(10, 10, width-20, height-20);
    			draw.graphics.endFill();
    			x_l    = 5;
    			x_r    = draw.width - 5;
    			y_u    = 5;
    			y_d    = draw.height - 5;
    							//
    							// グラフタイトルの表示
    							//
    			r      = 0.05;   // タイトル領域の割合
    			f_size = ((y_d - y_u) < (x_r - x_l)) ? (int)((y_d - y_u) * r) : (int)((x_r - x_l) * r);
    			if (f_size < 5)
    				f_size = 5;
    			if (d_t) {
    				tf         = new TextFormat();
    				tf.size    = f_size;
    				tf.bold    = true;
    				tx[n]      = new TextField();
    				tx[n].text = title[0];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - f_size;
    				draw.addChild(tx[n]);
    				y_d -= (f_size + 10);
    				n++;
    			}
    			else
    				y_d -= 5;
    							//
    							// 表示変更ボタンの設置
    							//
    									// 縦表示/横表示
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			tx[n]      = new TextField();
    			tx[n].text = change1;
    			tx[n].setTextFormat(tf);
    			mt                    = tx[n].getLineMetrics(0);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - 2 * tx[n].width - 10;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick1);
    			draw.addChild(tx[n]);
    			n++;
    									// 色や線の太さ
    			c_l_n      = n;
    			tx[n]      = new TextField();
    			tx[n].text = change2;
    			tx[n].setTextFormat(tf);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - tx[n].width - 5;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick2);
    			draw.addChild(tx[n]);
    			n++;
    							//
    							// 凡例の表示
    							//
    			if (d_g) {
    				var han : int = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = g_title[i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > han)
    						han = mt.width;
    				}
    				han += 15;
    				r    = 0.2;   // 凡例領域の割合
    				k1   = (int)((x_r - x_l) * r);
    				if (han > k1)
    					han = k1;
    				kx = x_r - han;
    				ky = y_u + 3 * f_size + 5;
    				k  = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					draw.graphics.beginFill(cl[k]);
    					draw.graphics.drawRect(kx, ky-1, 10, 7);
    					draw.graphics.endFill();
    					tx[n].width  = tx[n].getLineMetrics(0).width + 5;
    					tx[n].height = tx[n].getLineMetrics(0).height + 5;
    					tx[n].x      = kx + 15;
    					tx[n].y      = ky - 0.5 * f_size;
    					draw.addChild(tx[n]);
    					n++;
    					k++;
    					if (k > 9)
    						k = 0;
    					ky += (f_size + 5);
    				}
    				x_r -= (han + 10);
    			}
    			else
    				x_r -= (int)(0.03 * (x_r - x_l));
    							//
    							// x軸及びy軸のタイトルの表示
    							//
    									// 縦表示
    			if (ver) {
    				if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    					tx[n].y      = y_d - 4 * f_size / 5;
    					draw.addChild(tx[n]);
    					y_d -= (7 * f_size / 4 + 5);
    					n++;
    				}
    				else
    					y_d -= (f_size / 2 + 5);
    				if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[2];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = x_l + 10;
    					tx[n].y      = y_u + f_size / 5;
    					draw.addChild(tx[n]);
    					y_u += (f_size + 5);
    					n++;
    				}
    			}
    									// 横表示
    			else {
    				if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[2];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    					tx[n].y      = y_d - 4 * f_size / 5;
    					draw.addChild(tx[n]);
    					y_d -= (7 * f_size / 4 + 5);
    					n++;
    				}
    				else
    					y_d -= f_size / 2;
    				if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = x_l + 10;
    					tx[n].y      = y_u + f_size / 5;
    					draw.addChild(tx[n]);
    					y_u += (f_size + 5);
    					n++;
    				}
    			}
    							//
    							// x軸,y軸,及び,各軸の目盛り
    							//
    			draw.graphics.lineStyle(1, 0x000000);  
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf       = new TextFormat();
    			tf.size  = f_size;
    			y_u     += 10;
    									// 縦表示
    			if (ver) {
    											// y軸
    				y1  = y_scale[0];
    				k   = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    				len = 0;
    				for (i1 = 0; i1 < k+1; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = y1.toFixed(place_y);
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > len)
    						len = mt.width;
    					y1 += y_scale[2];
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_l+len+10, y_d);
    				draw.graphics.moveTo(x_r, y_u);
    				draw.graphics.lineTo(x_r, y_d);
    				y1 = y_scale[0];
    				x1 = y_d;
    				sp = (Number)(y_d - y_u) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					ky           = (int)(Math.round(x1));
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = tx[n].width;
    					tx[n].x      = x_l + len - k1 + 10;
    					tx[n].y      = ky - f_size / 2;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(x_l+len+10, ky);
    					draw.graphics.lineTo(x_r, ky);
    					y1 += y_scale[2];
    					x1 -= sp;
    					n++;
    				}
    				x_l += (len + 10);
    											// x軸
    				sp  = (Number)(x_r - x_l) / n_p;
    				x1  = x_l + sp / 2.0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					kx         = (int)(Math.round(x1));
    					tx[n]      = new TextField();
    					tx[n].text = x_title[i1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = mt.width;
    					tx[n].x      = kx - k1 / 2;
    					tx[n].y      = y_d + f_size / 5;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(kx, y_d);
    					draw.graphics.lineTo(kx, y_d-5);
    					x1 += sp;
    					n++;
    				}
    			}
    									// 横表示
    			else {
    											// y軸
    				len = 0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = x_title[n_p-1-i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > len)
    						len = mt.width;
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_l+len+10, y_d);
    				draw.graphics.moveTo(x_r, y_u);
    				draw.graphics.lineTo(x_r, y_d);
    				sp = (Number)(y_d - y_u) / n_p;
    				y1 = y_d - sp / 2.0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					ky = (int)(Math.round(y1));
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = tx[n].width;
    					tx[n].x      = x_l + len - k1 + 10;
    					tx[n].y      = ky - f_size / 2;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(x_l+len+10, ky);
    					draw.graphics.lineTo(x_l+len+15, ky);
    					y1 -= sp;
    					n++;
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_r, y_u);
    				draw.graphics.moveTo(x_l+len+10, y_d);
    				draw.graphics.lineTo(x_r, y_d);
    				x_l += (len + 5);
    											// x軸
    				k  = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    				x1 = y_scale[0];
    				y1 = x_l;
    				sp = (Number)(x_r - x_l) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					kx         = (int)(Math.round(y1));
    					tx[n]      = new TextField();
    					tx[n].text = x1.toFixed(place_y);
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = mt.width;
    					tx[n].x      = kx - k1 / 2;
    					tx[n].y      = y_d + f_size / 5;
    					draw.addChild(tx[n]);
    					if (i1 < k) {
    						draw.graphics.moveTo(kx+5, y_d);
    						draw.graphics.lineTo(kx+5, y_u);
    					}
    					x1 += y_scale[2];
    					y1 += sp;
    					n++;
    				}
    			}
    							//
    							// グラフの表示
    							//
    									// 縦表示
    			if (ver) {
    				g_w = (int)(0.8 * (x_r - x_l) / (n_g * n_p));
    				sp  = (Number)(x_r - x_l) / n_p;
    				x1  = x_l + sp / 2.0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					kx  = (int)(Math.round(x1));
    					k1 = 0;
    					k2 = kx - n_g * g_w / 2;
    					for (i2 = 0; i2 < n_g; i2++) {
    						ky = y_d - (int)((y_d - y_u) * (data[i2][i1] - y_scale[0]) / (y_scale[1] - y_scale[0]));
    						draw.graphics.beginFill(cl[k1]);
    						draw.graphics.drawRect(k2, ky, g_w, y_d-ky);
    						draw.graphics.endFill();
    						k2 += g_w;
    						k1++;
    						if (k1 > 9)
    							k1 = 0;
    					}
    					x1 += sp;
    				}
    			}
    									// 横表示
    			else {
    				g_w = (int)(0.8 * (y_d - y_u) / (n_g * n_p));
    				sp  = (Number)(y_d - y_u) / n_p;
    				y1  = y_d - sp / 2.0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					ky = (int)(Math.round(y1));
    					k1 = 0;
    					k2 = ky - n_g * g_w / 2;
    					for (i2 = 0; i2 < n_g; i2++) {
    						kx = (int)((x_r - x_l) * (data[i2][n_p-1-i1] - y_scale[0]) / (y_scale[1] - y_scale[0]));
    						draw.graphics.beginFill(cl[k1]);
    						draw.graphics.drawRect(x_l+5, k2, kx, g_w);
    						draw.graphics.endFill();
    						k2 += g_w;
    						k1++;
    						if (k1 > 9)
    							k1 = 0;
    					}
    					y1 -= sp;
    				}
    			}
    		}
    					// 縦表示,横表示の切り替え
    		private function onClick1(event:MouseEvent):void
    		{
    			if (!c_l) {
    				draw.graphics.clear();
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				if (ver) {
    					ver    = false;
    					change1 = "縦";
    				}
    				else {
    					ver    = true;
    					change1 = "横";
    				}
    				graph_draw();
    			}
    		}
    					// 色や線の太さの切り替え
    		private function onClick2(event:MouseEvent):void
    		{
    			if (c_l) {
    				c_l = false;
    				change2 = "色";
    				draw.graphics.clear();
    				draw.removeChild(md);
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				graph_draw();
    			}
    			else {
    				c_l = true;
    				change2 = "設";
    				tx[c_l_n].text = change2;
    				var n : int = (n_g > 10) ? 10 : n_g;
    				var w : int = 310;
    				var h : int = 30 + 23 * n;
    				md = new Modify_bar(this, w, h);
    				md.width  = w;
    				md.height = h;
    				md.x = 0;
    				md.y = 0;
    				draw.addChild(md);
    			}
    		}
    	}
    }
    
    /***********************************/
    /* 色及び線の太さの変更(棒グラフ)*/
    /*      coded by Y.Suganuma        */
    /***********************************/
    package {
    	import flash.display.Sprite;
    	import flash.display.Shape;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.events.FocusEvent;
    
    	public class Modify_bar extends Sprite {
    		public var tx : Array = new Array();
    		private var BAR : BarGraph;
    		private var sp : Shape;
    		private var rd1 : Sprite;
    		private var rd2 : Sprite;
    		private var n : int;
    
    		public function Modify_bar (bar:BarGraph, width:int, height:int)
    		{
    			BAR = bar;
    							// 表示領域
    			graphics.beginFill(0x00FF00);
    			graphics.drawRect(0, 0, width, height);
    			graphics.endFill();
    			graphics.beginFill(0xFFFFFF);
    			graphics.drawRect(10, 10, width-20, height-20);
    			graphics.endFill();
    							// 設定エリア
    			var tf: TextFormat = new TextFormat();
    			tf.size = 20;
    			tf.bold = true;
    			n = (BAR.n_g > 10) ? 10 : BAR.n_g;
    									// 色
    			for (var i1 : int = 0; i1 < n; i1++) {
    
    				tx[i1] = new Array();
    
    				tx[i1][0] = new TextField();
    				tx[i1][0].text = "   ";
    				tx[i1][0].setTextFormat(tf);
    				tx[i1][0].x = 15;
    				tx[i1][0].y = 15 + 23 * i1;
    				tx[i1][0].width  = 30;
    				tx[i1][0].height = 20;
    				tx[i1][0].background = true;
    				tx[i1][0].backgroundColor = BAR.cl[i1];
    				addChild(tx[i1][0]);
    
    				tx[i1][1] = new TextField();
    				tx[i1][1].text  = "赤";
    				tx[i1][1].setTextFormat(tf);
    				tx[i1][1].x = 55;
    				tx[i1][1].y = 15 + 23 * i1;
    				tx[i1][1].width  = 25;
    				tx[i1][1].height = 20;
    				addChild(tx[i1][1]);
    
    				tx[i1][2] = new TextField();
    				tx[i1][2].name = "tx" + i1 + 2;
    				tx[i1][2].text  = (int)(BAR.cl[i1] / (256 * 256));
    				tx[i1][2].setTextFormat(tf);
    				tx[i1][2].type = TextFieldType.INPUT;
    				tx[i1][2].x = 85;
    				tx[i1][2].y = 14 + 23 * i1;
    				tx[i1][2].width  = 35;
    				tx[i1][2].height = 22;
    				tx[i1][2].background = true;
    				tx[i1][2].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][2]);
    				tx[i1][2].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][3] = new TextField();
    				tx[i1][3].text  = "緑";
    				tx[i1][3].setTextFormat(tf);
    				tx[i1][3].x = 130;
    				tx[i1][3].y = 15 + 23 * i1;
    				tx[i1][3].width  = 25;
    				tx[i1][3].height = 20;
    				addChild(tx[i1][3]);
    
    				tx[i1][4] = new TextField();
    				tx[i1][4].name = "tx" + i1 + 4;
    				tx[i1][4].text  = (int)((BAR.cl[i1] % (256 * 256)) / 256);
    				tx[i1][4].setTextFormat(tf);
    				tx[i1][4].type = TextFieldType.INPUT;
    				tx[i1][4].x = 160;
    				tx[i1][4].y = 14 + 23 * i1;
    				tx[i1][4].width  = 35;
    				tx[i1][4].height = 22;
    				tx[i1][4].background = true;
    				tx[i1][4].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][4]);
    				tx[i1][4].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][5] = new TextField();
    				tx[i1][5].text  = "青";
    				tx[i1][5].setTextFormat(tf);
    				tx[i1][5].x = 205;
    				tx[i1][5].y = 15 + 23 * i1;
    				tx[i1][5].width  = 25;
    				tx[i1][5].height = 20;
    				addChild(tx[i1][5]);
    
    				tx[i1][6] = new TextField();
    				tx[i1][6].name = "tx" + i1 + 6;
    				tx[i1][6].text  = (int)(BAR.cl[i1] % 256);
    				tx[i1][6].setTextFormat(tf);
    				tx[i1][6].type = TextFieldType.INPUT;
    				tx[i1][6].x = 235;
    				tx[i1][6].y = 14 + 23 * i1;
    				tx[i1][6].width  = 35;
    				tx[i1][6].height = 22;
    				tx[i1][6].background = true;
    				tx[i1][6].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][6]);
    				tx[i1][6].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    			}
    		}
    					// テキストフィールドの変更
    		private function onFocusOut(event:FocusEvent):void
    		{
    			for (var i1 : int = 0; i1 < n; i1++) {
    				var str : String = "tx" + i1;
    				if ((event.target.name).search(str) >= 0) {
    					var v : String = "0x";
    					var s : String;
    					for (var i2 : int = 2; i2 <= 6; i2+=2) {
    						if (tx[i1][i2].text.length > 0) {
    							s = ((int)(tx[i1][i2].text)).toString(16);
    							if (s.length <= 1)
    								s = "0" + s;
    							v += s;
    						}
    						else
    							v += "00";
    					}
    					tx[i1][0].backgroundColor = v;
    					BAR.cl[i1] = v;
    					break;
    				}
    			}
    		}
    	}
    }
    			
    折れ線グラフ(1)( LineGraph1.as と Modify_line1.as )
    /****************************/
    /* 折れ線グラフ(1)の描画 */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.text.TextLineMetrics;
    
    	public class LineGraph1 {
    
    		private var title : Array;   // グラフタイトル, x軸タイトル, y軸タイトル
    		private var g_title : Array;   // 各グラフのタイトル(凡例)
    		private var n_p : int;   // データの数
    		private var x_title : Array;   // x軸への表示内容
    		private var x_scale : Array;   // x軸の最小値, x軸の最大値, x軸の刻み幅
    		private var y_scale : Array;   // y軸の最小値, y軸の最大値, y軸の刻み幅
    		private var data_y : Array;   // データ(y軸,n_g×n_p個)
    		private var d_t : Boolean = true;   // グラフタイトル表示の有無
    		private var d_g : Boolean = true;   // 凡例表示の有無
    		private var draw : Sprite;   // 表示画面
    		private var width : int;   // ステージの幅
    		private var height : int;   // ステージの高さ
    		private var x_l : int;   // 描画領域(横左)
    		private var x_r : int;   // 描画領域(横右)
    		private var y_u : int;   // 描画領域(縦上)
    		private var y_d : int;   // 描画領域(舘下)
    		private var ver : Boolean = true;   // 縦か横か( true が縦)
    		private var c_l : Boolean = false;   // 色設定領域が表示?( true がYes)
    		private var place_y : int;   // 小数点以下の桁数(y軸)
    		private var tx : Array = new Array();   // TextField
    		private var n : int = 0;   // TextField の数
    		private var change1 : String = "横";   // 縦表示/横表示切り替えボタン
    		private var change2 : String = "色";   // 色や線の太さの切り替えボタン
    		private var c_l_n : int;   // 色や線の太さの切り替えボタンの位置
    		private var md : Modify_line1;   // 色や線の太さの切り替え領域
    		public var line_w : int = 2;   // 折れ線グラフ等の線の太さ
    		public var line_m : Boolean = true;   // 折れ線グラフ等にマークを付けるか否か
    		public var cl : Array;   // グラフの色
    		public var n_g : int;   // グラフの数
    					// コンストラクタ
    		public function LineGraph1(title1:Array, g_title1:Array, x_title1:Array, y_scale1:Array, place_y1:int, data1:Array, d_t1:Boolean, d_g1:Boolean, draw1:Sprite, width1:int, height1:int)
    		{
    							// データの保存
    			title   = title1;
    			n_g     = g_title1.length;
    			g_title = g_title1;
    			n_p     = x_title1.length;
    			x_title = x_title1;
    			y_scale = y_scale1;
    			place_y = place_y1;
    			data_y  = data1;
    			d_t     = d_t1;
    			d_g     = d_g1;
    			draw    = draw1;
    			width   = width1;
    			height  = height1;
    							// 初期設定
    			cl = new Array(10);
    			cl[0] = 0x000000;
    			cl[1] = 0xFF00FF;
    			cl[2] = 0x0000FF;
    			cl[3] = 0x800080;
    			cl[4] = 0x00FFFF;
    			cl[5] = 0x008080;
    			cl[6] = 0x008000;
    			cl[7] = 0xC0C0C0;
    			cl[8] = 0xFF0000;
    			cl[9] = 0x800000;
    							// グラフの描画
    			graph_draw();
    		}
    					// グラフの描画
    		public function graph_draw() : void
    		{
    			var r : Number;
    			var tf : TextFormat;
    			var f_size : uint;
    			var mt : TextLineMetrics;
    			var i1 : int;
    			var i2 : int;
    			var k : int;
    			var k1 : int;
    			var k2 : int;
    			var kx : int;
    			var ky : int;
    			var kx1 : int;
    			var ky1 : int;
    			var len : int;
    			var cr : int;
    			var sp : Number;
    			var x1 : Number;
    			var y1 : Number;
    							//
    							// 描画領域の設定
    							//
    			draw.graphics.beginFill(0xFFFFFF);
    			draw.graphics.drawRect(10, 10, width-20, height-20);
    			draw.graphics.endFill();
    			x_l    = 5;
    			x_r    = draw.width - 5;
    			y_u    = 5;
    			y_d    = draw.height - 5;
    							//
    							// グラフタイトルの表示
    							//
    			r      = 0.05;   // タイトル領域の割合
    			f_size = ((y_d - y_u) < (x_r - x_l)) ? (int)((y_d - y_u) * r) : (int)((x_r - x_l) * r);
    			if (f_size < 5)
    				f_size = 5;
    			if (d_t) {
    				tf         = new TextFormat();
    				tf.size    = f_size;
    				tf.bold    = true;
    				tx[n]      = new TextField();
    				tx[n].text = title[0];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - f_size;
    				draw.addChild(tx[n]);
    				y_d -= (f_size + 10);
    				n++;
    			}
    			else
    				y_d -= 5;
    							//
    							// 表示変更ボタンの設置
    							//
    									// 縦表示/横表示
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			tx[n]      = new TextField();
    			tx[n].text = change1;
    			tx[n].setTextFormat(tf);
    			mt                    = tx[n].getLineMetrics(0);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - 2 * tx[n].width - 10;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick1);
    			draw.addChild(tx[n]);
    			n++;
    									// 色や線の太さ
    			c_l_n      = n;
    			tx[n]      = new TextField();
    			tx[n].text = change2;
    			tx[n].setTextFormat(tf);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - tx[n].width - 5;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick2);
    			draw.addChild(tx[n]);
    			n++;
    							//
    							// 凡例の表示
    							//
    			if (d_g) {
    				var han : int = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = g_title[i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > han)
    						han = mt.width;
    				}
    				han += 15;
    				r    = 0.2;   // 凡例領域の割合
    				k1   = (int)((x_r - x_l) * r);
    				if (han > k1)
    					han = k1;
    				kx = x_r - han;
    				ky = y_u + 3 * f_size + 5;
    				k  = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					draw.graphics.beginFill(cl[k]);
    					draw.graphics.drawRect(kx, ky-1, 10, 7);
    					draw.graphics.endFill();
    					tx[n].width  = tx[n].getLineMetrics(0).width + 5;
    					tx[n].height = tx[n].getLineMetrics(0).height + 5;
    					tx[n].x      = kx + 15;
    					tx[n].y      = ky - 0.5 * f_size;
    					draw.addChild(tx[n]);
    					n++;
    					k++;
    					if (k > 9)
    						k = 0;
    					ky += (f_size + 5);
    				}
    				x_r -= (han + 10);
    			}
    			else
    				x_r -= (int)(0.03 * (x_r - x_l));
    							//
    							// x軸及びy軸のタイトルの表示
    							//
    									// 縦表示
    			if (ver) {
    				if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    					tx[n].y      = y_d - 4 * f_size / 5;
    					draw.addChild(tx[n]);
    					y_d -= (7 * f_size / 4 + 5);
    					n++;
    				}
    				else
    					y_d -= (f_size / 2 + 5);
    				if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[2];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = x_l + 10;
    					tx[n].y      = y_u + f_size / 5;
    					draw.addChild(tx[n]);
    					y_u += (f_size + 5);
    					n++;
    				}
    			}
    									// 横表示
    			else {
    				if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[2];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    					tx[n].y      = y_d - 4 * f_size / 5;
    					draw.addChild(tx[n]);
    					y_d -= (7 * f_size / 4 + 5);
    					n++;
    				}
    				else
    					y_d -= f_size / 2;
    				if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = x_l + 10;
    					tx[n].y      = y_u + f_size / 5;
    					draw.addChild(tx[n]);
    					y_u += (f_size + 5);
    					n++;
    				}
    			}
    							//
    							// x軸,y軸,及び,各軸の目盛り
    							//
    			draw.graphics.lineStyle(1, 0x000000);  
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf       = new TextFormat();
    			tf.size  = f_size;
    			y_u     += 10;
    									// 縦表示
    			if (ver) {
    											// y軸
    				y1  = y_scale[0];
    				k   = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    				len = 0;
    				for (i1 = 0; i1 < k+1; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = y1.toFixed(place_y);
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > len)
    						len = mt.width;
    					y1 += y_scale[2];
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_l+len+10, y_d);
    				draw.graphics.moveTo(x_r, y_u);
    				draw.graphics.lineTo(x_r, y_d);
    				y1 = y_scale[0];
    				x1 = y_d;
    				sp = (Number)(y_d - y_u) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					ky           = (int)(Math.round(x1));
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = tx[n].width;
    					tx[n].x      = x_l + len - k1 + 10;
    					tx[n].y      = ky - f_size / 2;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(x_l+len+10, ky);
    					draw.graphics.lineTo(x_r, ky);
    					y1 += y_scale[2];
    					x1 -= sp;
    					n++;
    				}
    				x_l += (len + 10);
    											// x軸
    				sp  = (Number)(x_r - x_l) / n_p;
    				x1  = x_l + sp / 2.0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					kx         = (int)(Math.round(x1));
    					tx[n]      = new TextField();
    					tx[n].text = x_title[i1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = mt.width;
    					tx[n].x      = kx - k1 / 2;
    					tx[n].y      = y_d + f_size / 5;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(kx, y_d);
    					draw.graphics.lineTo(kx, y_d-5);
    					x1 += sp;
    					n++;
    				}
    			}
    									// 横表示
    			else {
    											// y軸
    				len = 0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = x_title[n_p-1-i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > len)
    						len = mt.width;
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_l+len+10, y_d);
    				draw.graphics.moveTo(x_r, y_u);
    				draw.graphics.lineTo(x_r, y_d);
    				sp = (Number)(y_d - y_u) / n_p;
    				y1 = y_d - sp / 2.0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					ky = (int)(Math.round(y1));
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = tx[n].width;
    					tx[n].x      = x_l + len - k1 + 10;
    					tx[n].y      = ky - f_size / 2;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(x_l+len+10, ky);
    					draw.graphics.lineTo(x_l+len+15, ky);
    					y1 -= sp;
    					n++;
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_r, y_u);
    				draw.graphics.moveTo(x_l+len+10, y_d);
    				draw.graphics.lineTo(x_r, y_d);
    				x_l += (len + 5);
    											// x軸
    				k  = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    				x1 = y_scale[0];
    				y1 = x_l;
    				sp = (Number)(x_r - x_l) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					kx         = (int)(Math.round(y1));
    					tx[n]      = new TextField();
    					tx[n].text = x1.toFixed(place_y);
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = mt.width;
    					tx[n].x      = kx - k1 / 2;
    					tx[n].y      = y_d + f_size / 5;
    					draw.addChild(tx[n]);
    					if (i1 < k) {
    						draw.graphics.moveTo(kx+5, y_d);
    						draw.graphics.lineTo(kx+5, y_u);
    					}
    					x1 += y_scale[2];
    					y1 += sp;
    					n++;
    				}
    			}
    							//
    							// グラフの表示
    							//
    			cr = line_w / 2 + 2;
    									// 縦表示
    			if (ver) {
    				sp  = (Number)(x_r - x_l) / n_p;
    				k1  = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					x1  = x_l + sp / 2.0;
    					kx1 = 0;
    					ky1 = 0;
    					draw.graphics.lineStyle(line_w, cl[k1]);  
    					for (i2 = 0; i2 < n_p; i2++) {
    						kx = (int)(Math.round(x1));
    						ky = y_d - (int)((y_d - y_u) * (data_y[i1][i2] - y_scale[0]) / (y_scale[1] - y_scale[0]));
    						if (line_m) {
    							draw.graphics.beginFill(cl[k1]);
    							draw.graphics.drawCircle(kx, ky, cr);
    							draw.graphics.endFill();
    						}
    						if (i2 > 0) {
    							draw.graphics.moveTo(kx1, ky1);
    							draw.graphics.lineTo(kx, ky);
    						}
    						kx1  = kx;
    						ky1  = ky;
    						x1  += sp;
    					}
    					k1++;
    					if (k1 > 9)
    						k1 = 0;
    				}
    			}
    									// 横表示
    			else {
    				sp = (Number)(y_d - y_u) / n_p;
    				k1 = 0;
    				draw.graphics.lineStyle(2, cl[k1]);  
    				for (i1 = 0; i1 < n_g; i1++) {
    					y1  = y_d - sp / 2.0;
    					kx1 = 0;
    					ky1 = 0;
    					draw.graphics.lineStyle(line_w, cl[k1]);  
    					for (i2 = 0; i2 < n_p; i2++) {
    						ky = (int)(Math.round(y1));
    						kx = x_l + (int)((x_r - x_l) * (data_y[i1][n_p-1-i2] - y_scale[0]) / (y_scale[1] - y_scale[0]));
    						if (line_m) {
    							draw.graphics.beginFill(cl[k1]);
    							draw.graphics.drawCircle(kx, ky, cr);
    							draw.graphics.endFill();
    						}
    						if (i2 > 0) {
    							draw.graphics.moveTo(kx1, ky1);
    							draw.graphics.lineTo(kx, ky);
    						}
    						kx1  = kx;
    						ky1  = ky;
    						y1  -= sp;
    					}
    					k1++;
    					if (k1 > 9)
    						k1 = 0;
    				}
    			}
    		}
    					// 縦表示,横表示の切り替え
    		private function onClick1(event:MouseEvent):void
    		{
    			if (!c_l) {
    				draw.graphics.clear();
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				if (ver) {
    					ver     = false;
    					change1 = "縦";
    				}
    				else {
    					ver     = true;
    					change1 = "横";
    				}
    				graph_draw();
    			}
    		}
    					// 色や線の太さの切り替え
    		private function onClick2(event:MouseEvent):void
    		{
    			if (c_l) {
    				c_l = false;
    				change2 = "色";
    				draw.graphics.clear();
    				draw.removeChild(md);
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				graph_draw();
    			}
    			else {
    				c_l = true;
    				change2 = "設";
    				tx[c_l_n].text = change2;
    				var n : int = (n_g > 10) ? 10 : n_g;
    				var w : int = 310;
    				var h : int = 30 + 23 * (n + 2);
    				md = new Modify_line1(this, w, h);
    				md.width  = w;
    				md.height = h;
    				md.x = 0;
    				md.y = 0;
    				draw.addChild(md);
    			}
    		}
    	}
    }
    
    /*****************************************/
    /* 色及び線の太さの変更(折れ線グラフ1)*/
    /*      coded by Y.Suganuma              */
    /*****************************************/
    package {
    	import flash.display.Sprite;
    	import flash.display.Shape;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.events.FocusEvent;
    
    	public class Modify_line1 extends Sprite {
    		public var tx : Array = new Array();
    		private var LG1 : LineGraph1;
    		private var sp : Shape;
    		private var rd1 : Sprite;
    		private var rd2 : Sprite;
    		private var n : int;
    
    		public function Modify_line1 (lg1:LineGraph1, width:int, height:int)
    		{
    			LG1 = lg1;
    							// 表示領域
    			graphics.beginFill(0x00FF00);
    			graphics.drawRect(0, 0, width, height);
    			graphics.endFill();
    			graphics.beginFill(0xFFFFFF);
    			graphics.drawRect(10, 10, width-20, height-20);
    			graphics.endFill();
    							// 設定エリア
    			var tf: TextFormat = new TextFormat();
    			tf.size = 20;
    			tf.bold = true;
    			n = (LG1.n_g > 10) ? 10 : LG1.n_g;
    									// 色
    			for (var i1 : int = 0; i1 < n; i1++) {
    
    				tx[i1] = new Array();
    
    				tx[i1][0] = new TextField();
    				tx[i1][0].text = "   ";
    				tx[i1][0].setTextFormat(tf);
    				tx[i1][0].x = 15;
    				tx[i1][0].y = 15 + 23 * i1;
    				tx[i1][0].width  = 30;
    				tx[i1][0].height = 20;
    				tx[i1][0].background = true;
    				tx[i1][0].backgroundColor = LG1.cl[i1];
    				addChild(tx[i1][0]);
    
    				tx[i1][1] = new TextField();
    				tx[i1][1].text  = "赤";
    				tx[i1][1].setTextFormat(tf);
    				tx[i1][1].x = 55;
    				tx[i1][1].y = 15 + 23 * i1;
    				tx[i1][1].width  = 25;
    				tx[i1][1].height = 20;
    				addChild(tx[i1][1]);
    
    				tx[i1][2] = new TextField();
    				tx[i1][2].name = "tx" + i1 + 2;
    				tx[i1][2].text  = (int)(LG1.cl[i1] / (256 * 256));
    				tx[i1][2].setTextFormat(tf);
    				tx[i1][2].type = TextFieldType.INPUT;
    				tx[i1][2].x = 85;
    				tx[i1][2].y = 14 + 23 * i1;
    				tx[i1][2].width  = 35;
    				tx[i1][2].height = 22;
    				tx[i1][2].background = true;
    				tx[i1][2].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][2]);
    				tx[i1][2].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][3] = new TextField();
    				tx[i1][3].text  = "緑";
    				tx[i1][3].setTextFormat(tf);
    				tx[i1][3].x = 130;
    				tx[i1][3].y = 15 + 23 * i1;
    				tx[i1][3].width  = 25;
    				tx[i1][3].height = 20;
    				addChild(tx[i1][3]);
    
    				tx[i1][4] = new TextField();
    				tx[i1][4].name = "tx" + i1 + 4;
    				tx[i1][4].text  = (int)((LG1.cl[i1] % (256 * 256)) / 256);
    				tx[i1][4].setTextFormat(tf);
    				tx[i1][4].type = TextFieldType.INPUT;
    				tx[i1][4].x = 160;
    				tx[i1][4].y = 14 + 23 * i1;
    				tx[i1][4].width  = 35;
    				tx[i1][4].height = 22;
    				tx[i1][4].background = true;
    				tx[i1][4].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][4]);
    				tx[i1][4].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][5] = new TextField();
    				tx[i1][5].text  = "青";
    				tx[i1][5].setTextFormat(tf);
    				tx[i1][5].x = 205;
    				tx[i1][5].y = 15 + 23 * i1;
    				tx[i1][5].width  = 25;
    				tx[i1][5].height = 20;
    				addChild(tx[i1][5]);
    
    				tx[i1][6] = new TextField();
    				tx[i1][6].name = "tx" + i1 + 6;
    				tx[i1][6].text  = (int)(LG1.cl[i1] % 256);
    				tx[i1][6].setTextFormat(tf);
    				tx[i1][6].type = TextFieldType.INPUT;
    				tx[i1][6].x = 235;
    				tx[i1][6].y = 14 + 23 * i1;
    				tx[i1][6].width  = 35;
    				tx[i1][6].height = 22;
    				tx[i1][6].background = true;
    				tx[i1][6].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][6]);
    				tx[i1][6].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    			}
    									// マーク
    			tx[n] = new Array();
    			tx[n][0] = new TextField();
    			tx[n][0].text  = "マーク:";
    			tx[n][0].setTextFormat(tf);
    			tx[n][0].x = 15;
    			tx[n][0].y = 16 + 23 * n;
    			tx[n][0].width  = 80;
    			tx[n][0].height = 22;
    			addChild(tx[n][0]);
    
    			rd1 = new Sprite();
    			rd1.name = "rd1";
    			rd1.x = 95;
    			rd1.y = 16 + 23 * n;
    			rd1.graphics.beginFill(0xe1ffe1);
    			rd1.graphics.drawCircle(11, 11, 11);
    			rd1.graphics.endFill();
    			if (LG1.line_m) {
    				sp = new Shape();
    				sp.graphics.beginFill(0x000000);
    				sp.graphics.drawCircle(11, 11, 5);
    				sp.graphics.endFill();
    				rd1.addChild(sp);
    			}
    			addChild(rd1);
    			rd1.addEventListener(MouseEvent.CLICK, onClick);
    
    			tx[n][1] = new TextField();
    			tx[n][1].text  = "付ける";
    			tx[n][1].setTextFormat(tf);
    			tx[n][1].x = 117;
    			tx[n][1].y = 16 + 23 * n;
    			tx[n][1].width  = 60;
    			tx[n][1].height = 22;
    			addChild(tx[n][1]);
    
    			rd2 = new Sprite();
    			rd2.name = "rd2";
    			rd2.x = 187;
    			rd2.y = 16 + 23 * n;
    			rd2.graphics.beginFill(0xe1ffe1);
    			rd2.graphics.drawCircle(11, 11, 11);
    			rd2.graphics.endFill();
    			if (!LG1.line_m) {
    				sp = new Shape();
    				sp.graphics.beginFill(0x000000);
    				sp.graphics.drawCircle(11, 11, 5);
    				sp.graphics.endFill();
    				rd2.addChild(sp);
    			}
    			addChild(rd2);
    			rd2.addEventListener(MouseEvent.CLICK, onClick);
    
    			tx[n][2] = new TextField();
    			tx[n][2].text  = "付けない";
    			tx[n][2].setTextFormat(tf);
    			tx[n][2].x = 209;
    			tx[n][2].y = 16 + 23 * n;
    			tx[n][2].width  = 90;
    			tx[n][2].height = 22;
    			addChild(tx[n][2]);
    									// 線の太さ
    			tx[n+1] = new Array();
    			tx[n+1][0] = new TextField();
    			tx[n+1][0].text  = "線の太さ:";
    			tx[n+1][0].setTextFormat(tf);
    			tx[n+1][0].x = 15;
    			tx[n+1][0].y = 18 + 23 * (n + 1);
    			tx[n+1][0].width  = 100;
    			tx[n+1][0].height = 22;
    			addChild(tx[n+1][0]);
    
    			tx[n+1][1] = new TextField();
    			tx[n+1][1].name = "line";
    			tx[n+1][1].text  = LG1.line_w;
    			tx[n+1][1].setTextFormat(tf);
    			tx[n+1][1].type = TextFieldType.INPUT;
    			tx[n+1][1].x = 125;
    			tx[n+1][1].y = 18 + 23 * (n + 1);
    			tx[n+1][1].width  = 30;
    			tx[n+1][1].height = 22;
    			tx[n+1][1].background = true;
    			tx[n+1][1].backgroundColor = "0xe1ffe1";
    			addChild(tx[n+1][1]);
    			tx[n+1][1].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    		}
    					// マークの選択
    		private function onClick(event:MouseEvent):void
    		{
    			if (event.target.name == "rd1") {
    				if (rd1.numChildren == 0) {
    					rd1.addChild(sp);
    					LG1.line_m = true;
    				}
    			}
    			else {
    				if (rd2.numChildren == 0) {
    					rd2.addChild(sp);
    					LG1.line_m = false;
    				}
    			}
    		}
    					// テキストフィールドの変更
    		private function onFocusOut(event:FocusEvent):void
    		{
    							// 線の太さ
    			if (event.target.name == "line") {
    				if (tx[n+1][1].text.length > 0)
    					LG1.line_w = (int)(tx[n+1][1].text);
    			}
    							// 色
    			else {
    				for (var i1 : int = 0; i1 < n; i1++) {
    					var str : String = "tx" + i1;
    					if ((event.target.name).search(str) >= 0) {
    						var v : String = "0x";
    						var s : String;
    						for (var i2 : int = 2; i2 <= 6; i2+=2) {
    							if (tx[i1][i2].text.length > 0) {
    								s = ((int)(tx[i1][i2].text)).toString(16);
    								if (s.length <= 1)
    									s = "0" + s;
    								v += s;
    							}
    							else
    								v += "00";
    						}
    						tx[i1][0].backgroundColor = v;
    						LG1.cl[i1] = v;
    						break;
    					}
    				}
    			}
    		}
    	}
    }
    			
    折れ線グラフ(2)( LineGraph2.as と Modify_line2.as )
    /****************************/
    /* 折れ線グラフの描画(2) */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.text.TextLineMetrics;
    
    	public class LineGraph2 {
    
    		private var title : Array;   // グラフタイトル, x軸タイトル, y軸タイトル
    		private var g_title : Array;   // 各グラフのタイトル(凡例)
    		private var n_p : int;   // データの数
    		private var x_scale : Array;   // x軸の最小値, x軸の最大値, x軸の刻み幅
    		private var y_scale : Array;   // y軸の最小値, y軸の最大値, y軸の刻み幅
    		private var place : int;   // y軸の小数点以下桁数
    		private var data_x : Array;   // データ(x軸,n_g×n_p個)
    		private var data_y : Array;   // データ(y軸,n_g×n_p個)
    		private var d_t : Boolean = true;   // グラフタイトル表示の有無
    		private var d_g : Boolean = true;   // 凡例表示の有無
    		private var draw : Sprite;   // 表示画面
    		private var width : int;   // ステージの幅
    		private var height : int;   // ステージの高さ
    		private var x_l : int;   // 描画領域(横左)
    		private var x_r : int;   // 描画領域(横右)
    		private var y_u : int;   // 描画領域(縦上)
    		private var y_d : int;   // 描画領域(舘下)
    		private var ver : Boolean = true;   // 縦か横か( true が縦)
    		private var c_l : Boolean = false;   // 色設定領域が表示?( true がYes)
    		private var place_x : int;   // 小数点以下の桁数(x軸)
    		private var place_y : int;   // 小数点以下の桁数(y軸)
    		private var tx : Array = new Array();   // TextField
    		private var n : int = 0;   // TextField の数
    		private var change1 : String = "横";   // 縦表示/横表示切り替えボタン
    		private var change2 : String = "色";   // 色や線の太さの切り替えボタン
    		private var c_l_n : int;   // 色や線の太さの切り替えボタンの位置
    		private var md : Modify_line2;   // 色や線の太さの切り替え領域
    		public var line_w : int = 2;   // 折れ線グラフ等の線の太さ
    		public var line_m : Boolean = true;   // 折れ線グラフ等にマークを付けるか否か
    		public var cl : Array;   // グラフの色
    		public var n_g : int;   // グラフの数
    					// コンストラクタ
    		public function LineGraph2(title1:Array, g_title1:Array, x_scale1:Array, place_x1:int, y_scale1:Array, place_y1:int, data1:Array, data2:Array, d_t1:Boolean, d_g1:Boolean, draw1:Sprite, width1:int, height1:int)
    		{
    							// データの保存
    			title   = title1;
    			n_g     = g_title1.length;
    			g_title = g_title1;
    			x_scale = x_scale1;
    			place_x = place_x1;
    			y_scale = y_scale1;
    			place_y = place_y1;
    			n_p     = data1[0].length;
    			data_x  = data1;
    			data_y  = data2;
    			d_t     = d_t1;
    			d_g     = d_g1;
    			draw    = draw1;
    			width   = width1;
    			height  = height1;
    							// 初期設定
    			cl = new Array(10);
    			cl[0] = 0x000000;
    			cl[1] = 0xFF00FF;
    			cl[2] = 0x0000FF;
    			cl[3] = 0x800080;
    			cl[4] = 0x00FFFF;
    			cl[5] = 0x008080;
    			cl[6] = 0x008000;
    			cl[7] = 0xC0C0C0;
    			cl[8] = 0xFF0000;
    			cl[9] = 0x800000;
    							// グラフの描画
    			graph_draw();
    		}
    					// グラフの描画
    		public function graph_draw() : void
    		{
    			var r : Number;
    			var tf : TextFormat;
    			var f_size : uint;
    			var mt : TextLineMetrics;
    			var i1 : int;
    			var i2 : int;
    			var k : int;
    			var k1 : int;
    			var k2 : int;
    			var kx : int;
    			var ky : int;
    			var kx1 : int;
    			var ky1 : int;
    			var len : int;
    			var cr : int;
    			var sp : Number;
    			var x1 : Number;
    			var y1 : Number;
    							//
    							// 描画領域の設定
    							//
    			draw.graphics.beginFill(0xFFFFFF);
    			draw.graphics.drawRect(10, 10, width-20, height-20);
    			draw.graphics.endFill();
    			x_l    = 5;
    			x_r    = draw.width - 5;
    			y_u    = 5;
    			y_d    = draw.height - 5;
    							//
    							// グラフタイトルの表示
    							//
    			r      = 0.05;   // タイトル領域の割合
    			f_size = ((y_d - y_u) < (x_r - x_l)) ? (int)((y_d - y_u) * r) : (int)((x_r - x_l) * r);
    			if (f_size < 5)
    				f_size = 5;
    			if (d_t) {
    				tf         = new TextFormat();
    				tf.size    = f_size;
    				tf.bold    = true;
    				tx[n]      = new TextField();
    				tx[n].text = title[0];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - f_size;
    				draw.addChild(tx[n]);
    				y_d -= (f_size + 10);
    				n++;
    			}
    			else
    				y_d -= 5;
    							//
    							// 表示変更ボタンの設置
    							//
    									// 縦表示/横表示
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			tx[n]      = new TextField();
    			tx[n].text = change1;
    			tx[n].setTextFormat(tf);
    			mt                    = tx[n].getLineMetrics(0);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - 2 * tx[n].width - 10;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick1);
    			draw.addChild(tx[n]);
    			n++;
    									// 色や線の太さ
    			c_l_n      = n;
    			tx[n]      = new TextField();
    			tx[n].text = change2;
    			tx[n].setTextFormat(tf);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - tx[n].width - 5;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick2);
    			draw.addChild(tx[n]);
    			n++;
    							//
    							// 凡例の表示
    							//
    			if (d_g) {
    				var han : int = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = g_title[i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > han)
    						han = mt.width;
    				}
    				han += 15;
    				r    = 0.2;   // 凡例領域の割合
    				k1   = (int)((x_r - x_l) * r);
    				if (han > k1)
    					han = k1;
    				kx = x_r - han;
    				ky = y_u + 3 * f_size + 5;
    				k  = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					draw.graphics.beginFill(cl[k]);
    					draw.graphics.drawRect(kx, ky-1, 10, 7);
    					draw.graphics.endFill();
    					tx[n].width  = tx[n].getLineMetrics(0).width + 5;
    					tx[n].height = tx[n].getLineMetrics(0).height + 5;
    					tx[n].x      = kx + 15;
    					tx[n].y      = ky - 0.5 * f_size;
    					draw.addChild(tx[n]);
    					n++;
    					k++;
    					if (k > 9)
    						k = 0;
    					ky += (f_size + 5);
    				}
    				x_r -= (han + 10);
    			}
    			else
    				x_r -= (int)(0.03 * (x_r - x_l));
    							//
    							// x軸及びy軸のタイトルの表示
    							//
    									// 縦表示
    			if (ver) {
    				if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    					tx[n].y      = y_d - 4 * f_size / 5;
    					draw.addChild(tx[n]);
    					y_d -= (7 * f_size / 4 + 5);
    					n++;
    				}
    				else
    					y_d -= (f_size / 2 + 5);
    				if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[2];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = x_l + 10;
    					tx[n].y      = y_u + f_size / 5;
    					draw.addChild(tx[n]);
    					y_u += (f_size + 5);
    					n++;
    				}
    			}
    									// 横表示
    			else {
    				if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[2];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    					tx[n].y      = y_d - 4 * f_size / 5;
    					draw.addChild(tx[n]);
    					y_d -= (7 * f_size / 4 + 5);
    					n++;
    				}
    				else
    					y_d -= f_size / 2;
    				if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = x_l + 10;
    					tx[n].y      = y_u + f_size / 5;
    					draw.addChild(tx[n]);
    					y_u += (f_size + 5);
    					n++;
    				}
    			}
    							//
    							// x軸,y軸,及び,各軸の目盛り
    							//
    			draw.graphics.lineStyle(1, 0x000000);  
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf       = new TextFormat();
    			tf.size  = f_size;
    			y_u     += 10;
    									// 縦表示
    			if (ver) {
    											// y軸
    				y1  = y_scale[0];
    				k   = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    				len = 0;
    				for (i1 = 0; i1 < k+1; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = y1.toFixed(place_y);
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > len)
    						len = mt.width;
    					y1 += y_scale[2];
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_l+len+10, y_d);
    				draw.graphics.moveTo(x_r, y_u);
    				draw.graphics.lineTo(x_r, y_d);
    				y1 = y_scale[0];
    				x1 = y_d;
    				sp = (Number)(y_d - y_u) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					ky           = (int)(Math.round(x1));
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = tx[n].width;
    					tx[n].x      = x_l + len - k1 + 10;
    					tx[n].y      = ky - f_size / 2;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(x_l+len+10, ky);
    					draw.graphics.lineTo(x_r, ky);
    					y1 += y_scale[2];
    					x1 -= sp;
    					n++;
    				}
    				x_l += (len + 10);
    											// x軸
    				k  = (int)((x_scale[1] - x_scale[0]) / (0.99 * x_scale[2]));
    				x1 = x_scale[0];
    				y1 = x_l;
    				sp = (Number)(x_r - x_l) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					kx         = (int)(Math.round(y1));
    					tx[n]      = new TextField();
    					tx[n].text = x1.toFixed(place_x);
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = mt.width;
    					tx[n].x      = kx - k1 / 2;
    					tx[n].y      = y_d + f_size / 5;
    					draw.addChild(tx[n]);
    					if (i1 < k) {
    						draw.graphics.moveTo(kx, y_d);
    						draw.graphics.lineTo(kx, y_u);
    					}
    					x1 += x_scale[2];
    					y1 += sp;
    					n++;
    				}
    			}
    									// 横表示
    			else {
    											// y軸
    				y1  = x_scale[0];
    				k   = (int)((x_scale[1] - x_scale[0]) / (0.99 * x_scale[2]));
    				len = 0;
    				for (i1 = 0; i1 < k+1; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = y1.toFixed(place_x);
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > len)
    						len = mt.width;
    					y1 += x_scale[2];
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_l+len+10, y_d);
    				draw.graphics.moveTo(x_r, y_u);
    				draw.graphics.lineTo(x_r, y_d);
    				y1 = x_scale[0];
    				x1 = y_d;
    				sp = (Number)(y_d - y_u) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					ky           = (int)(Math.round(x1));
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = tx[n].width;
    					tx[n].x      = x_l + len - k1 + 10;
    					tx[n].y      = ky - f_size / 2;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(x_l+len+10, ky);
    					draw.graphics.lineTo(x_r, ky);
    					y1 += x_scale[2];
    					x1 -= sp;
    					n++;
    				}
    				x_l += (len + 10);
    											// x軸
    				k  = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    				x1 = y_scale[0];
    				y1 = x_l;
    				sp = (Number)(x_r - x_l) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					kx         = (int)(Math.round(y1));
    					tx[n]      = new TextField();
    					tx[n].text = x1.toFixed(place_y);
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = mt.width;
    					tx[n].x      = kx - k1 / 2;
    					tx[n].y      = y_d + f_size / 5;
    					draw.addChild(tx[n]);
    					if (i1 < k) {
    						draw.graphics.moveTo(kx, y_d);
    						draw.graphics.lineTo(kx, y_u);
    					}
    					x1 += y_scale[2];
    					y1 += sp;
    					n++;
    				}
    			}
    							//
    							// グラフの表示
    							//
    			cr = line_w / 2 + 2;
    									// 縦表示
    			if (ver) {
    				k1 = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					kx1 = 0;
    					ky1 = 0;
    					draw.graphics.lineStyle(line_w, cl[k1]);  
    					for (i2 = 0; i2 < n_p; i2++) {
    						kx = x_l + (int)((x_r - x_l) * (data_x[i1][i2] - x_scale[0]) / (x_scale[1] - x_scale[0]));
    						ky = y_d - (int)((y_d - y_u) * (data_y[i1][i2] - y_scale[0]) / (y_scale[1] - y_scale[0]));
    						if (line_m) {
    							draw.graphics.beginFill(cl[k1]);
    							draw.graphics.drawCircle(kx, ky, cr);
    							draw.graphics.endFill();
    						}
    						if (i2 > 0) {
    							draw.graphics.moveTo(kx1, ky1);
    							draw.graphics.lineTo(kx, ky);
    						}
    						kx1 = kx;
    						ky1 = ky;
    					}
    					k1++;
    					if (k1 > 9)
    						k1 = 0;
    				}
    			}
    									// 横表示
    			else {
    				k1  = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					kx1 = 0;
    					ky1 = 0;
    					draw.graphics.lineStyle(line_w, cl[k1]);  
    					for (i2 = 0; i2 < n_p; i2++) {
    						kx = x_l + (int)((x_r - x_l) * (data_y[i1][i2] - y_scale[0]) / (y_scale[1] - y_scale[0]));
    						ky = y_d - (int)((y_d - y_u) * (data_x[i1][i2] - x_scale[0]) / (x_scale[1] - x_scale[0]));
    						if (line_m) {
    							draw.graphics.beginFill(cl[k1]);
    							draw.graphics.drawCircle(kx, ky, cr);
    							draw.graphics.endFill();
    						}
    						if (i2 > 0) {
    							draw.graphics.moveTo(kx1, ky1);
    							draw.graphics.lineTo(kx, ky);
    						}
    						kx1 = kx;
    						ky1 = ky;
    					}
    					k1++;
    					if (k1 > 9)
    						k1 = 0;
    				}
    			}
    		}
    					// 縦表示,横表示の切り替え
    		private function onClick1(event:MouseEvent):void
    		{
    			if (!c_l) {
    				draw.graphics.clear();
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				if (ver) {
    					ver     = false;
    					change1 = "縦";
    				}
    				else {
    					ver     = true;
    					change1 = "横";
    				}
    				graph_draw();
    			}
    		}
    					// 色や線の太さの切り替え
    		private function onClick2(event:MouseEvent):void
    		{
    			if (c_l) {
    				c_l = false;
    				change2 = "色";
    				draw.graphics.clear();
    				draw.removeChild(md);
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				graph_draw();
    			}
    			else {
    				c_l = true;
    				change2 = "設";
    				tx[c_l_n].text = change2;
    				var n : int = (n_g > 10) ? 10 : n_g;
    				var w : int = 310;
    				var h : int = 30 + 23 * (n + 2);
    				md = new Modify_line2(this, w, h);
    				md.width  = w;
    				md.height = h;
    				md.x = 0;
    				md.y = 0;
    				draw.addChild(md);
    			}
    		}
    	}
    }
    
    /*****************************************/
    /* 色及び線の太さの変更(折れ線グラフ2)*/
    /*      coded by Y.Suganuma              */
    /*****************************************/
    package {
    	import flash.display.Sprite;
    	import flash.display.Shape;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.events.FocusEvent;
    
    	public class Modify_line2 extends Sprite {
    		public var tx : Array = new Array();
    		private var LG2 : LineGraph2;
    		private var sp : Shape;
    		private var rd1 : Sprite;
    		private var rd2 : Sprite;
    		private var n : int;
    
    		public function Modify_line2 (lg2:LineGraph2, width:int, height:int)
    		{
    			LG2 = lg2;
    							// 表示領域
    			graphics.beginFill(0x00FF00);
    			graphics.drawRect(0, 0, width, height);
    			graphics.endFill();
    			graphics.beginFill(0xFFFFFF);
    			graphics.drawRect(10, 10, width-20, height-20);
    			graphics.endFill();
    							// 設定エリア
    			var tf: TextFormat = new TextFormat();
    			tf.size = 20;
    			tf.bold = true;
    			n = (LG2.n_g > 10) ? 10 : LG2.n_g;
    									// 色
    			for (var i1 : int = 0; i1 < n; i1++) {
    
    				tx[i1] = new Array();
    
    				tx[i1][0] = new TextField();
    				tx[i1][0].text = "   ";
    				tx[i1][0].setTextFormat(tf);
    				tx[i1][0].x = 15;
    				tx[i1][0].y = 15 + 23 * i1;
    				tx[i1][0].width  = 30;
    				tx[i1][0].height = 20;
    				tx[i1][0].background = true;
    				tx[i1][0].backgroundColor = LG2.cl[i1];
    				addChild(tx[i1][0]);
    
    				tx[i1][1] = new TextField();
    				tx[i1][1].text  = "赤";
    				tx[i1][1].setTextFormat(tf);
    				tx[i1][1].x = 55;
    				tx[i1][1].y = 15 + 23 * i1;
    				tx[i1][1].width  = 25;
    				tx[i1][1].height = 20;
    				addChild(tx[i1][1]);
    
    				tx[i1][2] = new TextField();
    				tx[i1][2].name = "tx" + i1 + 2;
    				tx[i1][2].text  = (int)(LG2.cl[i1] / (256 * 256));
    				tx[i1][2].setTextFormat(tf);
    				tx[i1][2].type = TextFieldType.INPUT;
    				tx[i1][2].x = 85;
    				tx[i1][2].y = 14 + 23 * i1;
    				tx[i1][2].width  = 35;
    				tx[i1][2].height = 22;
    				tx[i1][2].background = true;
    				tx[i1][2].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][2]);
    				tx[i1][2].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][3] = new TextField();
    				tx[i1][3].text  = "緑";
    				tx[i1][3].setTextFormat(tf);
    				tx[i1][3].x = 130;
    				tx[i1][3].y = 15 + 23 * i1;
    				tx[i1][3].width  = 25;
    				tx[i1][3].height = 20;
    				addChild(tx[i1][3]);
    
    				tx[i1][4] = new TextField();
    				tx[i1][4].name = "tx" + i1 + 4;
    				tx[i1][4].text  = (int)((LG2.cl[i1] % (256 * 256)) / 256);
    				tx[i1][4].setTextFormat(tf);
    				tx[i1][4].type = TextFieldType.INPUT;
    				tx[i1][4].x = 160;
    				tx[i1][4].y = 14 + 23 * i1;
    				tx[i1][4].width  = 35;
    				tx[i1][4].height = 22;
    				tx[i1][4].background = true;
    				tx[i1][4].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][4]);
    				tx[i1][4].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][5] = new TextField();
    				tx[i1][5].text  = "青";
    				tx[i1][5].setTextFormat(tf);
    				tx[i1][5].x = 205;
    				tx[i1][5].y = 15 + 23 * i1;
    				tx[i1][5].width  = 25;
    				tx[i1][5].height = 20;
    				addChild(tx[i1][5]);
    
    				tx[i1][6] = new TextField();
    				tx[i1][6].name = "tx" + i1 + 6;
    				tx[i1][6].text  = (int)(LG2.cl[i1] % 256);
    				tx[i1][6].setTextFormat(tf);
    				tx[i1][6].type = TextFieldType.INPUT;
    				tx[i1][6].x = 235;
    				tx[i1][6].y = 14 + 23 * i1;
    				tx[i1][6].width  = 35;
    				tx[i1][6].height = 22;
    				tx[i1][6].background = true;
    				tx[i1][6].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][6]);
    				tx[i1][6].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    			}
    									// マーク
    			tx[n] = new Array();
    			tx[n][0] = new TextField();
    			tx[n][0].text  = "マーク:";
    			tx[n][0].setTextFormat(tf);
    			tx[n][0].x = 15;
    			tx[n][0].y = 16 + 23 * n;
    			tx[n][0].width  = 80;
    			tx[n][0].height = 22;
    			addChild(tx[n][0]);
    
    			rd1 = new Sprite();
    			rd1.name = "rd1";
    			rd1.x = 95;
    			rd1.y = 16 + 23 * n;
    			rd1.graphics.beginFill(0xe1ffe1);
    			rd1.graphics.drawCircle(11, 11, 11);
    			rd1.graphics.endFill();
    			if (LG2.line_m) {
    				sp = new Shape();
    				sp.graphics.beginFill(0x000000);
    				sp.graphics.drawCircle(11, 11, 5);
    				sp.graphics.endFill();
    				rd1.addChild(sp);
    			}
    			addChild(rd1);
    			rd1.addEventListener(MouseEvent.CLICK, onClick);
    
    			tx[n][1] = new TextField();
    			tx[n][1].text  = "付ける";
    			tx[n][1].setTextFormat(tf);
    			tx[n][1].x = 117;
    			tx[n][1].y = 16 + 23 * n;
    			tx[n][1].width  = 60;
    			tx[n][1].height = 22;
    			addChild(tx[n][1]);
    
    			rd2 = new Sprite();
    			rd2.name = "rd2";
    			rd2.x = 187;
    			rd2.y = 16 + 23 * n;
    			rd2.graphics.beginFill(0xe1ffe1);
    			rd2.graphics.drawCircle(11, 11, 11);
    			rd2.graphics.endFill();
    			if (!LG2.line_m) {
    				sp = new Shape();
    				sp.graphics.beginFill(0x000000);
    				sp.graphics.drawCircle(11, 11, 5);
    				sp.graphics.endFill();
    				rd2.addChild(sp);
    			}
    			addChild(rd2);
    			rd2.addEventListener(MouseEvent.CLICK, onClick);
    
    			tx[n][2] = new TextField();
    			tx[n][2].text  = "付けない";
    			tx[n][2].setTextFormat(tf);
    			tx[n][2].x = 209;
    			tx[n][2].y = 16 + 23 * n;
    			tx[n][2].width  = 90;
    			tx[n][2].height = 22;
    			addChild(tx[n][2]);
    									// 線の太さ
    			tx[n+1] = new Array();
    			tx[n+1][0] = new TextField();
    			tx[n+1][0].text  = "線の太さ:";
    			tx[n+1][0].setTextFormat(tf);
    			tx[n+1][0].x = 15;
    			tx[n+1][0].y = 18 + 23 * (n + 1);
    			tx[n+1][0].width  = 100;
    			tx[n+1][0].height = 22;
    			addChild(tx[n+1][0]);
    
    			tx[n+1][1] = new TextField();
    			tx[n+1][1].name = "line";
    			tx[n+1][1].text  = LG2.line_w;
    			tx[n+1][1].setTextFormat(tf);
    			tx[n+1][1].type = TextFieldType.INPUT;
    			tx[n+1][1].x = 125;
    			tx[n+1][1].y = 18 + 23 * (n + 1);
    			tx[n+1][1].width  = 30;
    			tx[n+1][1].height = 22;
    			tx[n+1][1].background = true;
    			tx[n+1][1].backgroundColor = "0xe1ffe1";
    			addChild(tx[n+1][1]);
    			tx[n+1][1].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    		}
    					// マークの選択
    		private function onClick(event:MouseEvent):void
    		{
    			if (event.target.name == "rd1") {
    				if (rd1.numChildren == 0) {
    					rd1.addChild(sp);
    					LG2.line_m = true;
    				}
    			}
    			else {
    				if (rd2.numChildren == 0) {
    					rd2.addChild(sp);
    					LG2.line_m = false;
    				}
    			}
    		}
    					// テキストフィールドの変更
    		private function onFocusOut(event:FocusEvent):void
    		{
    							// 線の太さ
    			if (event.target.name == "line") {
    				if (tx[n+1][1].text.length > 0)
    					LG2.line_w = (int)(tx[n+1][1].text);
    			}
    							// 色
    			else {
    				for (var i1 : int = 0; i1 < n; i1++) {
    					var str : String = "tx" + i1;
    					if ((event.target.name).search(str) >= 0) {
    						var v : String = "0x";
    						var s : String;
    						for (var i2 : int = 2; i2 <= 6; i2+=2) {
    							if (tx[i1][i2].text.length > 0) {
    								s = ((int)(tx[i1][i2].text)).toString(16);
    								if (s.length <= 1)
    									s = "0" + s;
    								v += s;
    							}
    							else
    								v += "00";
    						}
    						tx[i1][0].backgroundColor = v;
    						LG2.cl[i1] = v;
    						break;
    					}
    				}
    			}
    		}
    	}
    }
    			
    積み上げ式棒グラフ( StackGraph.as と Modify_stack.as )
    /****************************/
    /* 積み上げ棒グラフの描画   */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.text.TextLineMetrics;
    
    	public class StackGraph {
    
    		private var title : Array;   // グラフタイトル, x軸タイトル, y軸タイトル
    		private var n_g : int;   // グラフの数
    		private var g_title : Array;   // 各グラフのタイトル(凡例)
    		private var x_title : Array;   // x軸への表示内容
    		private var y_scale : Array;   // y軸の最小値, y軸の最大値, y軸の刻み幅
    		private var data : Array;   // データ(n_g×n_p個)
    		private var d_t : Boolean = true;   // グラフタイトル表示の有無
    		private var d_g : Boolean = true;   // 凡例表示の有無
    		private var draw : Sprite;   // 表示画面
    		private var width : int;   // ステージの幅
    		private var height : int;   // ステージの高さ
    		private var x_l : int;   // 描画領域(横左)
    		private var x_r : int;   // 描画領域(横右)
    		private var y_u : int;   // 描画領域(縦上)
    		private var y_d : int;   // 描画領域(舘下)
    		private var ver : Boolean = true;   // 縦か横か( true が縦)
    		private var c_l : Boolean = false;   // 色設定領域が表示?( true がYes)
    		private var place_y : int;   // 小数点以下の桁数
    		private var tx : Array = new Array();   // TextField
    		private var n : int = 0;   // TextField の数
    		private var change1 : String = "横";   // 縦表示/横表示切り替えボタン
    		private var change2 : String = "色";   // 色や線の太さの切り替えボタン
    		private var c_l_n : int;   // 色や線の太さの切り替えボタンの位置
    		private var md : Modify_stack;   // 色や線の太さの切り替え領域
    		public var cl : Array;   // グラフの色
    		public var n_p : int;   // データの数
    					// コンストラクタ
    		public function StackGraph(title1:Array, g_title1:Array, x_title1:Array, y_scale1:Array, place_y1:int, data1:Array, d_t1:Boolean, d_g1:Boolean, draw1:Sprite, width1:int, height1:int)		{
    							// データの保存
    			title   = title1;
    			n_g     = g_title1.length;
    			g_title = g_title1;
    			n_p     = x_title1.length;
    			x_title = x_title1;
    			y_scale = y_scale1;
    			place_y = place_y1;
    			data    = data1;
    			d_t     = d_t1;
    			d_g     = d_g1;
    			draw    = draw1;
    			width   = width1;
    			height  = height1;
    							// 初期設定
    			cl = new Array(10);
    			cl[0] = 0x000000;
    			cl[1] = 0xFF00FF;
    			cl[2] = 0x0000FF;
    			cl[3] = 0x800080;
    			cl[4] = 0x00FFFF;
    			cl[5] = 0x008080;
    			cl[6] = 0x008000;
    			cl[7] = 0xC0C0C0;
    			cl[8] = 0xFF0000;
    			cl[9] = 0x800000;
    							// グラフの描画
    			graph_draw();
    		}
    					// グラフの描画
    		public function graph_draw() : void
    		{
    			var r : Number;
    			var tf : TextFormat;
    			var f_size : uint;
    			var mt : TextLineMetrics;
    			var i1 : int;
    			var i2 : int;
    			var k : int;
    			var k1 : int;
    			var k2 : int;
    			var kx : int;
    			var ky : int;
    			var len : int;
    			var g_w : int;
    			var sp : Number;
    			var x1 : Number;
    			var y1 : Number;
    			var y2 : Number;
    							//
    							// 描画領域の設定
    							//
    			draw.graphics.beginFill(0xFFFFFF);
    			draw.graphics.drawRect(10, 10, width-20, height-20);
    			draw.graphics.endFill();
    			x_l    = 5;
    			x_r    = draw.width - 5;
    			y_u    = 5;
    			y_d    = draw.height - 5;
    							//
    							// グラフタイトルの表示
    							//
    			r      = 0.05;   // タイトル領域の割合
    			f_size = ((y_d - y_u) < (x_r - x_l)) ? (int)((y_d - y_u) * r) : (int)((x_r - x_l) * r);
    			if (f_size < 5)
    				f_size = 5;
    			if (d_t) {
    				tf         = new TextFormat();
    				tf.size    = f_size;
    				tf.bold    = true;
    				tx[n]      = new TextField();
    				tx[n].text = title[0];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - f_size;
    				draw.addChild(tx[n]);
    				y_d -= (f_size + 10);
    				n++;
    			}
    			else
    				y_d -= 5;
    							//
    							// 表示変更ボタンの設置
    							//
    									// 縦表示/横表示
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			tx[n]      = new TextField();
    			tx[n].text = change1;
    			tx[n].setTextFormat(tf);
    			mt                    = tx[n].getLineMetrics(0);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - 2 * tx[n].width - 10;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick1);
    			draw.addChild(tx[n]);
    			n++;
    									// 色や線の太さ
    			c_l_n      = n;
    			tx[n]      = new TextField();
    			tx[n].text = change2;
    			tx[n].setTextFormat(tf);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - tx[n].width - 5;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick2);
    			draw.addChild(tx[n]);
    			n++;
    							//
    							// 凡例の表示
    							//
    			if (d_g) {
    				var han : int = 0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = x_title[i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > han)
    						han = mt.width;
    				}
    				han += 15;
    				r    = 0.2;   // 凡例領域の割合
    				k1   = (int)((x_r - x_l) * r);
    				if (han > k1)
    					han = k1;
    				kx = x_r - han;
    				ky = y_u + 3 * f_size + 5;
    				k  = 0;
    				for (i1 = 0; i1 < n_p; i1++) {
    					draw.graphics.beginFill(cl[k]);
    					draw.graphics.drawRect(kx, ky-1, 10, 7);
    					draw.graphics.endFill();
    					tx[n].width  = tx[n].getLineMetrics(0).width + 5;
    					tx[n].height = tx[n].getLineMetrics(0).height + 5;
    					tx[n].x      = kx + 15;
    					tx[n].y      = ky - 0.5 * f_size;
    					draw.addChild(tx[n]);
    					n++;
    					k++;
    					if (k > 9)
    						k = 0;
    					ky += (f_size + 5);
    				}
    				x_r -= (han + 10);
    			}
    			else
    				x_r -= (int)(0.03 * (x_r - x_l));
    							//
    							// x軸及びy軸のタイトルの表示
    							//
    									// 縦表示
    			if (ver) {
    				if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    					tx[n].y      = y_d - 4 * f_size / 5;
    					draw.addChild(tx[n]);
    					y_d -= (7 * f_size / 4 + 5);
    					n++;
    				}
    				else
    					y_d -= (f_size / 2 + 5);
    				if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[2];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = x_l + 10;
    					tx[n].y      = y_u + f_size / 5;
    					draw.addChild(tx[n]);
    					y_u += (f_size + 5);
    					n++;
    				}
    			}
    									// 横表示
    			else {
    				if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[2];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    					tx[n].y      = y_d - 4 * f_size / 5;
    					draw.addChild(tx[n]);
    					y_d -= (7 * f_size / 4 + 5);
    					n++;
    				}
    				else
    					y_d -= f_size / 2;
    				if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    					tx[n]      = new TextField();
    					tx[n].text = title[1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = x_l + 10;
    					tx[n].y      = y_u + f_size / 5;
    					draw.addChild(tx[n]);
    					y_u += (f_size + 5);
    					n++;
    				}
    			}
    							//
    							// x軸,y軸,及び,各軸の目盛り
    							//
    			draw.graphics.lineStyle(1, 0x000000);  
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf       = new TextFormat();
    			tf.size  = f_size;
    			y_u     += 10;
    									// 縦表示
    			if (ver) {
    											// y軸
    				y1  = y_scale[0];
    				k   = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    				len = 0;
    				for (i1 = 0; i1 < k+1; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = y1.toFixed(place_y);
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > len)
    						len = mt.width;
    					y1 += y_scale[2];
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_l+len+10, y_d);
    				draw.graphics.moveTo(x_r, y_u);
    				draw.graphics.lineTo(x_r, y_d);
    				y1 = y_scale[0];
    				x1 = y_d;
    				sp = (Number)(y_d - y_u) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					ky           = (int)(Math.round(x1));
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = tx[n].width;
    					tx[n].x      = x_l + len - k1 + 10;
    					tx[n].y      = ky - f_size / 2;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(x_l+len+10, ky);
    					draw.graphics.lineTo(x_r, ky);
    					y1 += y_scale[2];
    					x1 -= sp;
    					n++;
    				}
    				x_l += (len + 10);
    											// x軸
    				sp  = (Number)(x_r - x_l) / n_g;
    				x1  = x_l + sp / 2.0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					kx         = (int)(Math.round(x1));
    					tx[n]      = new TextField();
    					tx[n].text = g_title[i1];
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = mt.width;
    					tx[n].x      = kx - k1 / 2;
    					tx[n].y      = y_d + f_size / 5;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(kx, y_d);
    					draw.graphics.lineTo(kx, y_d-5);
    					x1 += sp;
    					n++;
    				}
    			}
    									// 横表示
    			else {
    											// y軸
    				len = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = g_title[n_g-1-i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > len)
    						len = mt.width;
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_l+len+10, y_d);
    				draw.graphics.moveTo(x_r, y_u);
    				draw.graphics.lineTo(x_r, y_d);
    				sp = (Number)(y_d - y_u) / n_g;
    				y1 = y_d - sp / 2.0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					ky = (int)(Math.round(y1));
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = tx[n].width;
    					tx[n].x      = x_l + len - k1 + 10;
    					tx[n].y      = ky - f_size / 2;
    					draw.addChild(tx[n]);
    					draw.graphics.moveTo(x_l+len+10, ky);
    					draw.graphics.lineTo(x_l+len+15, ky);
    					y1 -= sp;
    					n++;
    				}
    				draw.graphics.moveTo(x_l+len+10, y_u);
    				draw.graphics.lineTo(x_r, y_u);
    				draw.graphics.moveTo(x_l+len+10, y_d);
    				draw.graphics.lineTo(x_r, y_d);
    				x_l += (len + 5);
    											// x軸
    				k  = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    				x1 = y_scale[0];
    				y1 = x_l;
    				sp = (Number)(x_r - x_l) / k;
    				for (i1 = 0; i1 < k+1; i1++) {
    					kx         = (int)(Math.round(y1));
    					tx[n]      = new TextField();
    					tx[n].text = x1.toFixed(place_y);
    					tx[n].setTextFormat(tf);
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					k1           = mt.width;
    					tx[n].x      = kx - k1 / 2;
    					tx[n].y      = y_d + f_size / 5;
    					draw.addChild(tx[n]);
    					if (i1 < k) {
    						draw.graphics.moveTo(kx+5, y_d);
    						draw.graphics.lineTo(kx+5, y_u);
    					}
    					x1 += y_scale[2];
    					y1 += sp;
    					n++;
    				}
    			}
    							//
    							// グラフの表示
    							//
    									// 縦表示
    			if (ver) {
    				g_w = (int)(0.8 * (x_r - x_l) / n_g);
    				sp  = (Number)(x_r - x_l) / n_g;
    				x1  = x_l + sp / 2.0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					kx = (int)(Math.round(x1));
    					k1 = 0;
    					y1 = y_d;
    					for (i2 = 0; i2 < n_p; i2++) {
    						ky = (int)(Math.round(y1));
    						y2 = (y_d - y_u) * (data[i1][i2] - y_scale[0]) / (y_scale[1] - y_scale[0]);
    						k2 = (int)(Math.round(y2));
    						draw.graphics.beginFill(cl[k1]);
    						draw.graphics.drawRect(kx-g_w/2, ky-k2, g_w, k2);
    						draw.graphics.endFill();
    						y1 -= y2;
    						k1++;
    						if (k1 > 9)
    							k1 = 0;
    					}
    					x1 += sp;
    				}
    			}
    									// 横表示
    			else {
    				g_w = (int)(0.8 * (y_d - y_u) / n_g);
    				sp  = (Number)(y_d - y_u) / n_g;
    				y1  = y_d - sp / 2.0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					ky = (int)(Math.round(y1));
    					k1 = 0;
    					x1 = x_l + 5;
    					for (i2 = 0; i2 < n_p; i2++) {
    						kx = (int)(Math.round(x1));
    						y2 = (x_r - x_l) * (data[n_g-1-i1][i2] - y_scale[0]) / (y_scale[1] - y_scale[0]);
    						k2 = (int)(Math.round(y2));
    						draw.graphics.beginFill(cl[k1]);
    						draw.graphics.drawRect(kx, ky-g_w/2, k2, g_w);
    						draw.graphics.endFill();
    						x1 += y2;
    						k1++;
    						if (k1 > 9)
    							k1 = 0;
    					}
    					y1 -= sp;
    				}
    			}
    		}
    					// 縦表示,横表示の切り替え
    		private function onClick1(event:MouseEvent):void
    		{
    			if (!c_l) {
    				draw.graphics.clear();
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				if (ver) {
    					ver     = false;
    					change1 = "縦";
    				}
    				else {
    					ver     = true;
    					change1 = "横";
    				}
    				graph_draw();
    			}
    		}
    					// 色や線の太さの切り替え
    		private function onClick2(event:MouseEvent):void
    		{
    			if (c_l) {
    				c_l = false;
    				change2 = "色";
    				draw.graphics.clear();
    				draw.removeChild(md);
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				graph_draw();
    			}
    			else {
    				c_l = true;
    				change2 = "設";
    				tx[c_l_n].text = change2;
    				var n : int = (n_p > 10) ? 10 : n_p;
    				var w : int = 310;
    				var h : int = 30 + 23 * n;
    				md = new Modify_stack(this, w, h);
    				md.width  = w;
    				md.height = h;
    				md.x = 0;
    				md.y = 0;
    				draw.addChild(md);
    			}
    		}
    	}
    }
    
    /*******************************************/
    /* 色及び線の太さの変更(積み上げ棒グラフ)*/
    /*      coded by Y.Suganuma                */
    /*******************************************/
    package {
    	import flash.display.Sprite;
    	import flash.display.Shape;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.events.FocusEvent;
    
    	public class Modify_stack extends Sprite {
    		public var tx : Array = new Array();
    		private var ST : StackGraph;
    		private var sp : Shape;
    		private var rd1 : Sprite;
    		private var rd2 : Sprite;
    		private var n : int;
    
    		public function Modify_stack (st:StackGraph, width:int, height:int)
    		{
    			ST = st;
    							// 表示領域
    			graphics.beginFill(0x00FF00);
    			graphics.drawRect(0, 0, width, height);
    			graphics.endFill();
    			graphics.beginFill(0xFFFFFF);
    			graphics.drawRect(10, 10, width-20, height-20);
    			graphics.endFill();
    							// 設定エリア
    			var tf: TextFormat = new TextFormat();
    			tf.size = 20;
    			tf.bold = true;
    			n = (ST.n_p > 10) ? 10 : ST.n_p;
    									// 色
    			for (var i1 : int = 0; i1 < n; i1++) {
    
    				tx[i1] = new Array();
    
    				tx[i1][0] = new TextField();
    				tx[i1][0].text = "   ";
    				tx[i1][0].setTextFormat(tf);
    				tx[i1][0].x = 15;
    				tx[i1][0].y = 15 + 23 * i1;
    				tx[i1][0].width  = 30;
    				tx[i1][0].height = 20;
    				tx[i1][0].background = true;
    				tx[i1][0].backgroundColor = ST.cl[i1];
    				addChild(tx[i1][0]);
    
    				tx[i1][1] = new TextField();
    				tx[i1][1].text  = "赤";
    				tx[i1][1].setTextFormat(tf);
    				tx[i1][1].x = 55;
    				tx[i1][1].y = 15 + 23 * i1;
    				tx[i1][1].width  = 25;
    				tx[i1][1].height = 20;
    				addChild(tx[i1][1]);
    
    				tx[i1][2] = new TextField();
    				tx[i1][2].name = "tx" + i1 + 2;
    				tx[i1][2].text  = (int)(ST.cl[i1] / (256 * 256));
    				tx[i1][2].setTextFormat(tf);
    				tx[i1][2].type = TextFieldType.INPUT;
    				tx[i1][2].x = 85;
    				tx[i1][2].y = 14 + 23 * i1;
    				tx[i1][2].width  = 35;
    				tx[i1][2].height = 22;
    				tx[i1][2].background = true;
    				tx[i1][2].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][2]);
    				tx[i1][2].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][3] = new TextField();
    				tx[i1][3].text  = "緑";
    				tx[i1][3].setTextFormat(tf);
    				tx[i1][3].x = 130;
    				tx[i1][3].y = 15 + 23 * i1;
    				tx[i1][3].width  = 25;
    				tx[i1][3].height = 20;
    				addChild(tx[i1][3]);
    
    				tx[i1][4] = new TextField();
    				tx[i1][4].name = "tx" + i1 + 4;
    				tx[i1][4].text  = (int)((ST.cl[i1] % (256 * 256)) / 256);
    				tx[i1][4].setTextFormat(tf);
    				tx[i1][4].type = TextFieldType.INPUT;
    				tx[i1][4].x = 160;
    				tx[i1][4].y = 14 + 23 * i1;
    				tx[i1][4].width  = 35;
    				tx[i1][4].height = 22;
    				tx[i1][4].background = true;
    				tx[i1][4].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][4]);
    				tx[i1][4].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][5] = new TextField();
    				tx[i1][5].text  = "青";
    				tx[i1][5].setTextFormat(tf);
    				tx[i1][5].x = 205;
    				tx[i1][5].y = 15 + 23 * i1;
    				tx[i1][5].width  = 25;
    				tx[i1][5].height = 20;
    				addChild(tx[i1][5]);
    
    				tx[i1][6] = new TextField();
    				tx[i1][6].name = "tx" + i1 + 6;
    				tx[i1][6].text  = (int)(ST.cl[i1] % 256);
    				tx[i1][6].setTextFormat(tf);
    				tx[i1][6].type = TextFieldType.INPUT;
    				tx[i1][6].x = 235;
    				tx[i1][6].y = 14 + 23 * i1;
    				tx[i1][6].width  = 35;
    				tx[i1][6].height = 22;
    				tx[i1][6].background = true;
    				tx[i1][6].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][6]);
    				tx[i1][6].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    			}
    		}
    					// テキストフィールドの変更
    		private function onFocusOut(event:FocusEvent):void
    		{
    			for (var i1 : int = 0; i1 < n; i1++) {
    				var str : String = "tx" + i1;
    				if ((event.target.name).search(str) >= 0) {
    					var v : String = "0x";
    					var s : String;
    					for (var i2 : int = 2; i2 <= 6; i2+=2) {
    						if (tx[i1][i2].text.length > 0) {
    							s = ((int)(tx[i1][i2].text)).toString(16);
    							if (s.length <= 1)
    								s = "0" + s;
    							v += s;
    						}
    						else
    							v += "00";
    					}
    					tx[i1][0].backgroundColor = v;
    					ST.cl[i1] = v;
    					break;
    				}
    			}
    		}
    	}
    }
    			
    円グラフ( PieGraph.as と Modify_pie.as )
    /****************************/
    /* 円グラフの描画           */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.text.TextLineMetrics;
    	import flash.events.MouseEvent;
    
    	public class PieGraph {
    
    		private var title : String;   // グラフタイトル
    		private var x_title : Array;   // 凡例
    		private var data : Array;   // データ(n_g×n_p個)
    		private var d_t : Boolean = true;   // グラフタイトル表示の有無
    		private var draw : Sprite;   // 表示画面
    		private var width : int;   // ステージの幅
    		private var height : int;   // ステージの高さ
    		private var x_l : int;   // 描画領域(横左)
    		private var x_r : int;   // 描画領域(横右)
    		private var y_u : int;   // 描画領域(縦上)
    		private var y_d : int;   // 描画領域(舘下)
    		private var tx : Array = new Array();   // TextField
    		private var n : int = 0;   // TextField の数
    		private var change : String = "色";   // 色や線の太さの切り替えボタン
    		private var c_l : Boolean = false;   // 色設定領域が表示?( true がYes)
    		private var c_l_n : int;   // 色や線の太さの切り替えボタンの位置
    		private var md : Modify_pie;   // 色や線の太さの切り替え領域
    		public var cl : Array;   // グラフの色
    		public var n_p : int;   // データの数
    					// コンストラクタ
    		public function PieGraph(title1:String, x_title1:Array, data1:Array, d_t1:Boolean, draw1:Sprite, width1:int, height1:int)		{
    							// データの保存
    			title   = title1;
    			n_p     = x_title1.length;
    			x_title = x_title1;
    			data    = data1;
    			d_t     = d_t1;
    			draw    = draw1;
    			width   = width1;
    			height  = height1;
    							// 初期設定
    			cl = new Array(10);
    			cl[0] = 0x000000;
    			cl[1] = 0xFF00FF;
    			cl[2] = 0x0000FF;
    			cl[3] = 0x800080;
    			cl[4] = 0x00FFFF;
    			cl[5] = 0x008080;
    			cl[6] = 0x008000;
    			cl[7] = 0xC0C0C0;
    			cl[8] = 0xFF0000;
    			cl[9] = 0x800000;
    							// グラフの描画
    			graph_draw();
    		}
    					// グラフの描画
    		public function graph_draw() : void
    		{
    			var r : Number;
    			var tf : TextFormat;
    			var f_size : uint;
    			var mt : TextLineMetrics;
    			var i1 : int;
    			var k : int;
    			var k1 : int;
    			var a : int;
    			var a1 : int;
    			var a2 : int;
    			var kx : int;
    			var ky : int;
    			var len : int;
    			var x1 : Number;
    			var y1 : Number;
    							//
    							// 描画領域の設定
    							//
    			draw.graphics.beginFill(0xFFFFFF);
    			draw.graphics.drawRect(10, 10, width-20, height-20);
    			draw.graphics.endFill();
    			x_l    = 5;
    			x_r    = draw.width - 5;
    			y_u    = 5;
    			y_d    = draw.height - 5;
    							//
    							// グラフタイトルの表示
    							//
    			r      = 0.05;   // タイトル領域の割合
    			f_size = ((y_d - y_u) < (x_r - x_l)) ? (int)((y_d - y_u) * r) : (int)((x_r - x_l) * r);
    			if (f_size < 5)
    				f_size = 5;
    			if (d_t) {
    				tf         = new TextFormat();
    				tf.size    = f_size;
    				tf.bold    = true;
    				tx[n]      = new TextField();
    				tx[n].text = title;
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - f_size;
    				draw.addChild(tx[n]);
    				y_d -= (f_size + 10);
    				n++;
    			}
    			else
    				y_d -= 5;
    							//
    							// 色や線の太さ切り替えボタンの設置
    							//
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			c_l_n      = n;
    			tx[n]      = new TextField();
    			tx[n].text = change;
    			tx[n].setTextFormat(tf);
    			mt                    = tx[n].getLineMetrics(0);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - tx[n].width - 5;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick);
    			draw.addChild(tx[n]);
    			n++;
    							//
    							// 凡例の表示
    							//
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf      = new TextFormat();
    			tf.size = f_size;
    			tf.bold = true;
    			var han : int = 0;
    			for (i1 = 0; i1 < n_p; i1++) {
    				tx[n+i1]      = new TextField();
    				tx[n+i1].text = x_title[i1] + "(" + data[i1].toFixed(1) + "%)";
    				tx[n+i1].setTextFormat(tf);
    				mt = tx[n+i1].getLineMetrics(0);
    				if (mt.width > han)
    					han = mt.width;
    			}
    			han += 15;
    			kx   = x_r - han;
    			ky   = y_u + 4 * f_size + 5;
    			k    = 0;
    			for (i1 = 0; i1 < n_p; i1++) {
    				draw.graphics.beginFill(cl[k]);
    				draw.graphics.drawRect(kx, ky-1, 10, 7);
    				draw.graphics.endFill();
    				tx[n].width  = tx[n].getLineMetrics(0).width + 5;
    				tx[n].height = tx[n].getLineMetrics(0).height + 5;
    				tx[n].x      = kx + 15;
    				tx[n].y      = ky - 0.5 * f_size;
    				draw.addChild(tx[n]);
    				n++;
    				k++;
    				if (k > 9)
    					k = 0;
    				ky += (f_size + 5);
    			}
    			x_r -= (han + 10);
    							//
    							// グラフの表示
    							//
    			if (x_r-x_l < y_d-y_u)
    				k1 = x_r - x_l;
    			else
    				k1 = y_d - y_u;
    			len = 9 * k1 / 20;
    			kx  = (x_r + x_l) / 2;
    			ky  = (y_d + y_u) / 2;
    			a1  = 90;
    			a2  = a1 + (int)(Math.round(3.60 * data[n_p-1]));
    			k--;
    			if (k < 0)
    				k = 9;
    			for (i1 = 0; i1 < n_p; i1++) {
    				x1 = kx + len * Math.cos(Math.PI * a1 / 180.0);
    				y1 = ky - len * Math.sin(Math.PI * a1 / 180.0);
    				draw.graphics.beginFill(cl[k]);
    				draw.graphics.moveTo(kx, ky);
    				draw.graphics.lineTo(x1, y1);
    				for (a = a1+1; a <= a2; a++) {
    					x1 = kx + len * Math.cos(Math.PI * a / 180.0);
    					y1 = ky - len * Math.sin(Math.PI * a / 180.0);
    					draw.graphics.lineTo(x1, y1);
    				}
    				draw.graphics.lineTo(kx, ky);
    				draw.graphics.endFill();
    				if (i1 < n_p-1) {
    					a1 = a2;
    					a2 = a1 + (int)(Math.round(3.60 * data[n_p-2-i1]));
    					k--;
    					if (k < 0)
    						k = 9;
    				}
    			}
    		}
    					// 色や線の太さの切り替え
    		private function onClick(event:MouseEvent):void
    		{
    			if (c_l) {
    				c_l = false;
    				change = "色";
    				draw.graphics.clear();
    				draw.removeChild(md);
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				graph_draw();
    			}
    			else {
    				c_l = true;
    				change = "設";
    				tx[c_l_n].text = change;
    				var n : int = (n_p > 10) ? 10 : n_p;
    				var w : int = 310;
    				var h : int = 30 + 23 * n;
    				md = new Modify_pie(this, w, h);
    				md.width  = w;
    				md.height = h;
    				md.x = 0;
    				md.y = 0;
    				draw.addChild(md);
    			}
    		}
    	}
    }
    
    /***********************************/
    /* 色及び線の太さの変更(円グラフ)*/
    /*      coded by Y.Suganuma        */
    /***********************************/
    package {
    	import flash.display.Sprite;
    	import flash.display.Shape;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.events.FocusEvent;
    
    	public class Modify_pie extends Sprite {
    		public var tx : Array = new Array();
    		private var PIE : PieGraph;
    		private var sp : Shape;
    		private var rd1 : Sprite;
    		private var rd2 : Sprite;
    		private var n : int;
    
    		public function Modify_pie (pie:PieGraph, width:int, height:int)
    		{
    			PIE = pie;
    							// 表示領域
    			graphics.beginFill(0x00FF00);
    			graphics.drawRect(0, 0, width, height);
    			graphics.endFill();
    			graphics.beginFill(0xFFFFFF);
    			graphics.drawRect(10, 10, width-20, height-20);
    			graphics.endFill();
    							// 設定エリア
    			var tf: TextFormat = new TextFormat();
    			tf.size = 20;
    			tf.bold = true;
    			n = (PIE.n_p > 10) ? 10 : PIE.n_p;
    									// 色
    			for (var i1 : int = 0; i1 < n; i1++) {
    
    				tx[i1] = new Array();
    
    				tx[i1][0] = new TextField();
    				tx[i1][0].text = "   ";
    				tx[i1][0].setTextFormat(tf);
    				tx[i1][0].x = 15;
    				tx[i1][0].y = 15 + 23 * i1;
    				tx[i1][0].width  = 30;
    				tx[i1][0].height = 20;
    				tx[i1][0].background = true;
    				tx[i1][0].backgroundColor = PIE.cl[i1];
    				addChild(tx[i1][0]);
    
    				tx[i1][1] = new TextField();
    				tx[i1][1].text  = "赤";
    				tx[i1][1].setTextFormat(tf);
    				tx[i1][1].x = 55;
    				tx[i1][1].y = 15 + 23 * i1;
    				tx[i1][1].width  = 25;
    				tx[i1][1].height = 20;
    				addChild(tx[i1][1]);
    
    				tx[i1][2] = new TextField();
    				tx[i1][2].name = "tx" + i1 + 2;
    				tx[i1][2].text  = (int)(PIE.cl[i1] / (256 * 256));
    				tx[i1][2].setTextFormat(tf);
    				tx[i1][2].type = TextFieldType.INPUT;
    				tx[i1][2].x = 85;
    				tx[i1][2].y = 14 + 23 * i1;
    				tx[i1][2].width  = 35;
    				tx[i1][2].height = 22;
    				tx[i1][2].background = true;
    				tx[i1][2].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][2]);
    				tx[i1][2].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][3] = new TextField();
    				tx[i1][3].text  = "緑";
    				tx[i1][3].setTextFormat(tf);
    				tx[i1][3].x = 130;
    				tx[i1][3].y = 15 + 23 * i1;
    				tx[i1][3].width  = 25;
    				tx[i1][3].height = 20;
    				addChild(tx[i1][3]);
    
    				tx[i1][4] = new TextField();
    				tx[i1][4].name = "tx" + i1 + 4;
    				tx[i1][4].text  = (int)((PIE.cl[i1] % (256 * 256)) / 256);
    				tx[i1][4].setTextFormat(tf);
    				tx[i1][4].type = TextFieldType.INPUT;
    				tx[i1][4].x = 160;
    				tx[i1][4].y = 14 + 23 * i1;
    				tx[i1][4].width  = 35;
    				tx[i1][4].height = 22;
    				tx[i1][4].background = true;
    				tx[i1][4].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][4]);
    				tx[i1][4].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][5] = new TextField();
    				tx[i1][5].text  = "青";
    				tx[i1][5].setTextFormat(tf);
    				tx[i1][5].x = 205;
    				tx[i1][5].y = 15 + 23 * i1;
    				tx[i1][5].width  = 25;
    				tx[i1][5].height = 20;
    				addChild(tx[i1][5]);
    
    				tx[i1][6] = new TextField();
    				tx[i1][6].name = "tx" + i1 + 6;
    				tx[i1][6].text  = (int)(PIE.cl[i1] % 256);
    				tx[i1][6].setTextFormat(tf);
    				tx[i1][6].type = TextFieldType.INPUT;
    				tx[i1][6].x = 235;
    				tx[i1][6].y = 14 + 23 * i1;
    				tx[i1][6].width  = 35;
    				tx[i1][6].height = 22;
    				tx[i1][6].background = true;
    				tx[i1][6].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][6]);
    				tx[i1][6].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    			}
    		}
    					// テキストフィールドの変更
    		private function onFocusOut(event:FocusEvent):void
    		{
    			for (var i1 : int = 0; i1 < n; i1++) {
    				var str : String = "tx" + i1;
    				if ((event.target.name).search(str) >= 0) {
    					var v : String = "0x";
    					var s : String;
    					for (var i2 : int = 2; i2 <= 6; i2+=2) {
    						if (tx[i1][i2].text.length > 0) {
    							s = ((int)(tx[i1][i2].text)).toString(16);
    							if (s.length <= 1)
    								s = "0" + s;
    							v += s;
    						}
    						else
    							v += "00";
    					}
    					tx[i1][0].backgroundColor = v;
    					PIE.cl[i1] = v;
    					break;
    				}
    			}
    		}
    	}
    }
    			
    散布図( ScatterDiagram.as )
    /****************************/
    /* 散布図の描画             */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.text.TextLineMetrics;
    
    	public class ScatterDiagram {
    
    		private var title : Array;   // グラフタイトル, x軸タイトル, y軸タイトル
    		private var n_p : int;   // データの数
    		private var x_scale : Array;   // x軸の最小値, x軸の最大値, x軸の刻み幅
    		private var y_scale : Array;   // y軸の最小値, y軸の最大値, y軸の刻み幅
    		private var place : int;   // y軸の小数点以下桁数
    		private var data : Array;   // データ(2×n_p個)
    		private var d_t : Boolean = true;   // グラフタイトル表示の有無
    		private var draw : Sprite;   // 表示画面
    		private var width : int;   // ステージの幅
    		private var height : int;   // ステージの高さ
    		private var x_l : int;   // 描画領域(横左)
    		private var x_r : int;   // 描画領域(横右)
    		private var y_u : int;   // 描画領域(縦上)
    		private var y_d : int;   // 描画領域(舘下)
    		private var place_x : int;   // 小数点以下の桁数(x軸)
    		private var place_y : int;   // 小数点以下の桁数(y軸)
    		private var tx : Array = new Array();   // TextField
    		private var n : int = 0;   // TextField の数
    					// コンストラクタ
    		public function ScatterDiagram(title1:Array, x_scale1:Array, y_scale1:Array, place_x1:int, place_y1:int, data1:Array, d_t1:Boolean, draw1:Sprite, width1:int, height1:int)
    		{
    							// データの保存
    			title   = title1;
    			x_scale = x_scale1;
    			place_x = place_x1;
    			y_scale = y_scale1;
    			place_y = place_y1;
    			n_p     = data1[0].length;
    			data    = data1;
    			d_t     = d_t1;
    			draw    = draw1;
    			width   = width1;
    			height  = height1;
    							// グラフの描画
    			graph_draw();
    		}
    					// グラフの描画
    		public function graph_draw() : void
    		{
    			var r : Number;
    			var tf : TextFormat;
    			var f_size : uint;
    			var mt : TextLineMetrics;
    			var i1 : int;
    			var i2 : int;
    			var k : int;
    			var k1 : int;
    			var k2 : int;
    			var kx : int;
    			var ky : int;
    			var kx1 : int;
    			var ky1 : int;
    			var len : int;
    			var cr : int;
    			var sp : Number;
    			var x1 : Number;
    			var y1 : Number;
    							//
    							// 描画領域の設定
    							//
    			draw.graphics.beginFill(0xFFFFFF);
    			draw.graphics.drawRect(10, 10, width-20, height-20);
    			draw.graphics.endFill();
    			x_l    = 5;
    			x_r    = draw.width - 20;
    			y_u    = 5;
    			y_d    = draw.height - 5;
    							//
    							// グラフタイトルの表示
    							//
    			r      = 0.05;   // タイトル領域の割合
    			f_size = ((y_d - y_u) < (x_r - x_l)) ? (int)((y_d - y_u) * r) : (int)((x_r - x_l) * r);
    			if (f_size < 5)
    				f_size = 5;
    			if (d_t) {
    				tf         = new TextFormat();
    				tf.size    = f_size;
    				tf.bold    = true;
    				tx[n]      = new TextField();
    				tx[n].text = title[0];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - f_size;
    				draw.addChild(tx[n]);
    				y_d -= (f_size + 10);
    				n++;
    			}
    			else
    				y_d -= 5;
    							//
    							// x軸及びy軸のタイトルの表示
    							//
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf      = new TextFormat();
    			tf.size = f_size;
    			tf.bold = true;
    			if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    				tx[n]      = new TextField();
    				tx[n].text = title[1];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - 4 * f_size / 5;
    				draw.addChild(tx[n]);
    				y_d -= (7 * f_size / 4 + 5);
    				n++;
    			}
    			else
    				y_d -= (f_size / 2 + 5);
    			if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    				tx[n]      = new TextField();
    				tx[n].text = title[2];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = x_l + 10;
    				tx[n].y      = y_u + f_size / 5;
    				draw.addChild(tx[n]);
    				y_u += (f_size + 5);
    				n++;
    			}
    							//
    							// x軸,y軸,及び,各軸の目盛り
    							//
    			draw.graphics.lineStyle(1, 0x000000);  
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf       = new TextFormat();
    			tf.size  = f_size;
    			y_u     += 10;
    									// y軸
    			y1  = y_scale[0];
    			k   = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    			len = 0;
    			for (i1 = 0; i1 < k+1; i1++) {
    				tx[n+i1]      = new TextField();
    				tx[n+i1].text = y1.toFixed(place_y);
    				tx[n+i1].setTextFormat(tf);
    				mt = tx[n+i1].getLineMetrics(0);
    				if (mt.width > len)
    					len = mt.width;
    				y1 += y_scale[2];
    			}
    			draw.graphics.moveTo(x_l+len+10, y_u);
    			draw.graphics.lineTo(x_l+len+10, y_d);
    			draw.graphics.moveTo(x_r, y_u);
    			draw.graphics.lineTo(x_r, y_d);
    			y1 = y_scale[0];
    			x1 = y_d;
    			sp = (Number)(y_d - y_u) / k;
    			for (i1 = 0; i1 < k+1; i1++) {
    				ky           = (int)(Math.round(x1));
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				k1           = tx[n].width;
    				tx[n].x      = x_l + len - k1 + 10;
    				tx[n].y      = ky - f_size / 2;
    				draw.addChild(tx[n]);
    				draw.graphics.moveTo(x_l+len+10, ky);
    				draw.graphics.lineTo(x_r, ky);
    				y1 += y_scale[2];
    				x1 -= sp;
    				n++;
    			}
    			x_l += (len + 10);
    									// x軸
    			k  = (int)((x_scale[1] - x_scale[0]) / (0.99 * x_scale[2]));
    			x1 = x_scale[0];
    			y1 = x_l;
    			sp = (Number)(x_r - x_l) / k;
    			for (i1 = 0; i1 < k+1; i1++) {
    				kx         = (int)(Math.round(y1));
    				tx[n]      = new TextField();
    				tx[n].text = x1.toFixed(place_x);
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				k1           = mt.width;
    				tx[n].x      = kx - k1 / 2;
    				tx[n].y      = y_d + f_size / 5;
    				draw.addChild(tx[n]);
    				if (i1 < k) {
    					draw.graphics.moveTo(kx, y_d);
    					draw.graphics.lineTo(kx, y_u);
    				}
    				x1 += x_scale[2];
    				y1 += sp;
    				n++;
    			}
    							//
    							// グラフの表示
    							//
    			cr = f_size / 4;
    			if (cr == 0)
    				cr = 1;
    			for (i1 = 0; i1 < n_p; i1++) {
    				kx = x_l + (int)((x_r - x_l) * (data[0][i1] - x_scale[0]) / (x_scale[1] - x_scale[0]));
    				ky = y_d - (int)((y_d - y_u) * (data[1][i1] - y_scale[0]) / (y_scale[1] - y_scale[0]));
    				draw.graphics.beginFill(0x000000);
    				draw.graphics.drawCircle(kx, ky, cr);
    				draw.graphics.endFill();
    			}
    							//
    							// 相関係数
    							//
    			var vii : Number = 0.0;
    			var vjj : Number = 0.0;
    			var vij : Number = 0.0;
    			var mi : Number = 0.0;
    			var mj : Number = 0.0;
    			for (i1 = 0; i1 < n_p; i1++) {
    				mi += data[0][i1];
    				mj += data[1][i1];
    			}
    			mi /= n_p;
    			mj /= n_p;
    			for (i1 = 0; i1 < n_p; i1++) {
    				vii += (data[0][i1] - mi) * (data[0][i1] - mi);
    				vjj += (data[1][i1] - mj) * (data[1][i1] - mj);
    				vij += (data[0][i1] - mi) * (data[1][i1] - mj);
    			}
    			vii /= (n_p - 1);
    			vjj /= (n_p - 1);
    			vij /= (n_p - 1);
    			x1   = vij / (Math.sqrt(vii) * Math.sqrt(vjj));
    			tf.bold    = true;
    			tx[n]      = new TextField();
    			tx[n].text = "相関係数: " + x1.toFixed(3);
    			tx[n].setTextFormat(tf);
    			mt           = tx[n].getLineMetrics(0);
    			tx[n].width  = mt.width + 5;
    			tx[n].height = mt.height + 5;
    			tx[n].x      = x_r - mt.width;
    			tx[n].y      = y_u - f_size - 5;
    			draw.addChild(tx[n]);
    			n++;
    		}
    	}
    }
    			
    レーダーチャート( RadarChart.as と Modify_radar.as )
    /****************************/
    /* レーダーチャートの描画   */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.text.TextLineMetrics;
    	import flash.events.MouseEvent;
    
    	public class RadarChart {
    
    		private var title : String;   // グラフタイトル
    		private var g_title : Array;   // 各グラフのタイトル(凡例)
    		private var n_p : int;   // データの数
    		private var x_title : Array;   // x軸への表示内容
    		private var y_scale : Array;   // y軸の最小値, y軸の最大値, y軸の刻み幅
    		private var data : Array;   // データ(n_g×n_p個)
    		private var d_t : Boolean = true;   // グラフタイトル表示の有無
    		private var d_g : Boolean = true;   // 凡例表示の有無
    		private var draw : Sprite;   // 表示画面
    		private var width : int;   // ステージの幅
    		private var height : int;   // ステージの高さ
    		private var x_l : int;   // 描画領域(横左)
    		private var x_r : int;   // 描画領域(横右)
    		private var y_u : int;   // 描画領域(縦上)
    		private var y_d : int;   // 描画領域(舘下)
    		private var place_y : int;   // 小数点以下の桁数
    		private var tx : Array = new Array();   // TextField
    		private var n : int = 0;   // TextField の数
    		private var m : int;   // TextField の数
    		private var change : String = "色";   // 色や線の太さの切り替えボタン
    		private var c_l : Boolean = false;   // 色設定領域が表示?( true がYes)
    		private var c_l_n : int;   // 色や線の太さの切り替えボタンの位置
    		private var md : Modify_radar;   // 色や線の太さの切り替え領域
    		public var line_w : int = 2;   // 折れ線グラフ等の線の太さ
    		public var line_m : Boolean = true;   // 折れ線グラフ等にマークを付けるか否か
    		public var cl : Array;   // グラフの色
    		public var n_g : int;   // グラフの数
    					// コンストラクタ
    		public function RadarChart(title1:String, g_title1:Array, x_title1:Array, y_scale1:Array, place_y1:int, data1:Array, d_t1:Boolean, d_g1:Boolean, draw1:Sprite, width1:int, height1:int)		{
    							// データの保存
    			title   = title1;
    			n_g     = g_title1.length;
    			g_title = g_title1;
    			n_p     = x_title1.length;
    			x_title = x_title1;
    			y_scale = y_scale1;
    			place_y = place_y1;
    			data    = data1;
    			d_t     = d_t1;
    			d_g     = d_g1;
    			draw    = draw1;
    			width   = width1;
    			height  = height1;
    							// 初期設定
    			cl = new Array(10);
    			cl[0] = 0x000000;
    			cl[1] = 0xFF00FF;
    			cl[2] = 0x0000FF;
    			cl[3] = 0x800080;
    			cl[4] = 0x00FFFF;
    			cl[5] = 0x008080;
    			cl[6] = 0x008000;
    			cl[7] = 0xC0C0C0;
    			cl[8] = 0xFF0000;
    			cl[9] = 0x800000;
    							// グラフの描画
    			graph_draw();
    		}
    					// グラフの描画
    		public function graph_draw() : void
    		{
    			var r : Number;
    			var tf : TextFormat;
    			var f_size : uint;
    			var mt : TextLineMetrics;
    			var i1 : int;
    			var i2 : int;
    			var k : int;
    			var k1 : int;
    			var kx : int;
    			var ky : int;
    			var pt : int;
    			var sp : Number;
    							//
    							// 描画領域の設定
    							//
    			draw.graphics.beginFill(0xFFFFFF);
    			draw.graphics.drawRect(10, 10, width-20, height-20);
    			draw.graphics.endFill();
    			x_l    = 5;
    			x_r    = draw.width - 5;
    			y_u    = 5;
    			y_d    = draw.height - 5;
    							//
    							// グラフタイトルの表示
    							//
    			r      = 0.05;   // タイトル領域の割合
    			f_size = ((y_d - y_u) < (x_r - x_l)) ? (int)((y_d - y_u) * r) : (int)((x_r - x_l) * r);
    			if (f_size < 5)
    				f_size = 5;
    			if (d_t) {
    				tf         = new TextFormat();
    				tf.size    = f_size;
    				tf.bold    = true;
    				tx[n]      = new TextField();
    				tx[n].text = title;
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - f_size;
    				draw.addChild(tx[n]);
    				y_d -= (f_size + 10);
    				n++;
    			}
    			else
    				y_d -= 5;
    							//
    							// 色や線の太さ切り替えボタンの設置
    							//
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			c_l_n      = n;
    			tx[n]      = new TextField();
    			tx[n].text = change;
    			tx[n].setTextFormat(tf);
    			mt                    = tx[n].getLineMetrics(0);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - tx[n].width - 5;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick);
    			draw.addChild(tx[n]);
    			n++;
    							//
    							// 凡例の表示
    							//
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			if (d_g) {
    				var han : int = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = g_title[i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > han)
    						han = mt.width;
    				}
    				han += 15;
    				r    = 0.2;   // 凡例領域の割合
    				k1   = (int)((x_r - x_l) * r);
    				if (han > k1)
    					han = k1;
    				kx = x_r - han;
    				ky = y_u + 4 * f_size + 5;
    				k  = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					draw.graphics.beginFill(cl[k]);
    					draw.graphics.drawRect(kx, ky-1, 10, 7);
    					draw.graphics.endFill();
    					tx[n].width  = tx[n].getLineMetrics(0).width + 5;
    					tx[n].height = tx[n].getLineMetrics(0).height + 5;
    					tx[n].x      = kx + 15;
    					tx[n].y      = ky - 0.5 * f_size;
    					draw.addChild(tx[n]);
    					n++;
    					k++;
    					if (k > 9)
    						k = 0;
    					ky += (f_size + 5);
    				}
    				x_r -= (han + 10);
    			}
    			else
    				x_r -= (int)(0.03 * (x_r - x_l));
    							//
    							// 軸,及び,軸の目盛り
    							//
    									// フォントサイズ
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    									// 大きさの決定
    			n_p = x_title.length;
    			var a : Number   = 0.5 * Math.PI;
    			var aa : Number  = 2.0 * Math.PI / n_p;
    			var x11 : Number = 0.0;
    			var x12 : Number = 0.0;
    			var x21 : Number = 0.0;
    			var x22 : Number = 0.0;
    			var y11 : Number = 0.0;
    			var y12 : Number = 0.0;
    			var y21 : Number = 0.0;
    			var y22 : Number = 0.0;
    			var xx : Number;
    			var yy : Number;
    			var x0 : Number;
    			var y0 : Number;
    			var kx0 : Number;
    			var ky0 : Number;
    			var kx1 : Number;
    			var ky1 : Number;
    			var kx2 : Number;
    			var ky2 : Number;
    			var cx : Number;
    			var cy : Number;
    			var cr : Number;
    			for (i1 = 0; i1 < n_p; i1++) {
    				xx            = 100 * Math.cos(a);
    				yy            = 100 * Math.sin(a);
    				tx[n+i1]      = new TextField();
    				tx[n+i1].text = x_title[i1];
    				tx[n+i1].setTextFormat(tf);
    				mt = tx[n+i1].getLineMetrics(0);
    				k1 = mt.width;
    				if (i1 == 0) {
    					x12 = 0.5 * k1;
    					x22 = x12;
    					y11 = 100.0;
    					y12 = 5.0 * f_size / 4.0;
    				}
    				else if (Math.abs(xx) < 1.0e-5) {
    					x0 = 0.5 * k1;
    					if (x0 > x12)
    						x12 = x0;
    					if (x0 > x22)
    						x22 = x0;
    					y21 = 100.0;
    					y22 = f_size + 5.0;
    				}
    				else {
    					if (yy < 0.0) {
    						y0 = -yy + 0.5 * f_size;
    						if (y0 > y21+y22) {
    							y21 = -yy;
    							y22 = 0.5 * f_size;
    						}
    					}
    					if (xx > 0.0) {
    						x0 = xx + k1 + 5.0;
    						if (x0 > x21+x22) {
    							x21 = xx;
    							x22 = k1 + 5.0;
    						}
    					}
    					else {
    						x0 = -xx + k1 + 5.0;
    						if (x0 > x11+x12) {
    							x11 = -xx;
    							x12 = k1 + 5.0;
    						}
    					}
    				}
    				a += aa;
    			}
    			x0 = x12 + x22;
    			xx = (x_r - x_l - x0 - 10) / (x11 + x21);
    			y0 = y12 + y22;
    			yy = (y_d - y_u - y0 - 10) / (y11 + y21);
    			r  = (xx < yy) ? xx : yy;
    			cr = (int)(100 * r);
    			xx = x_l + r * x11 + x12 + 5.0;
    			cx = (int)(xx + (x_r - x_l - r * x11 - x12 - r * x21 - x22 - 5) / 2);
    			yy = y_u + r * y11 + y12 + 5.0;
    			cy = (int)(yy + (y_d - y_u - r * y11 - y12 - r * y21 - y22 - 5) / 2);
    									// 軸とタイトルの描画
    			draw.graphics.lineStyle(1, 0x000000);  
    			m  = n + n_p;
    			k  = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2])) + 1;
    			xx = Number(cr) / k;
    			a  = 0.5 * Math.PI;
    			aa = 2.0 * Math.PI / n_p;
    			for (i1 = 0; i1 < n_p; i1++) {
    				kx = (int)(Math.round(cr * Math.cos(a)));
    				ky = (int)(Math.round(cr * Math.sin(a)));
    				mt = tx[n].getLineMetrics(0);
    				k1 = mt.width;
    				draw.graphics.moveTo(cx, cy);
    				draw.graphics.lineTo(cx+kx, cy-ky);
    				yy = xx;
    				for (i2 = 0; i2 < k; i2++) {
    					kx0 = cx + (int)(Math.round(yy * Math.cos(a)));
    					ky0 = cy - (int)(Math.round(yy * Math.sin(a)));
    					kx1 = kx0 + (int)(Math.round(3 * Math.cos(a+0.5*Math.PI)));
    					ky1 = ky0 - (int)(Math.round(3 * Math.sin(a+0.5*Math.PI)));
    					kx2 = kx0 + (int)(Math.round(3 * Math.cos(a-0.5*Math.PI)));
    					ky2 = ky0 - (int)(Math.round(3 * Math.sin(a-0.5*Math.PI)));
    					draw.graphics.moveTo(kx1, ky1);
    					draw.graphics.lineTo(kx2, ky2);
    					yy += xx;
    				}
    				if (i1 == 0) {
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					tx[n].x      = cx + kx - k1 / 2;
    					tx[n].y      = cy - ky - 9 * f_size / 5;
    					draw.addChild(tx[n]);
    					yy = xx;
    					sp = y_scale[0];
    					for (i2 = 0; i2 < k; i2++) {
    						kx0 = cx + (int)(Math.round(yy * Math.cos(a))) + 5;
    						ky0 = cy - (int)(Math.round(yy * Math.sin(a))) - 7 * f_size / 10;
    						tx[m]      = new TextField();
    						tx[m].text = sp.toFixed(place_y);
    						tx[m].setTextFormat(tf);
    						mt           = tx[m].getLineMetrics(0);
    						tx[m].width  = mt.width + 5;
    						tx[m].height = mt.height + 5;
    						tx[m].x      = kx0;
    						tx[m].y      = ky0;
    						draw.addChild(tx[m]);
    						yy += xx;
    						sp += y_scale[2];
    						m++;
    					}
    				}
    				else {
    					mt           = tx[n].getLineMetrics(0);
    					tx[n].width  = mt.width + 5;
    					tx[n].height = mt.height + 5;
    					if (kx == 0) {
    						tx[n].x = cx + kx - k1 / 2;
    						tx[n].y = cy - ky + 9 * f_size / 5;
    					}
    					else if (kx > 0) {
    						tx[n].x = cx + kx + 5;
    						tx[n].y = cy - ky - 7 * f_size / 10;
    					}
    					else {
    						tx[n].x = cx + kx - k1 - 10;
    						tx[n].y = cy - ky - 7 * f_size / 10;
    					}
    					draw.addChild(tx[n]);
    				}
    				a += aa;
    				n++;
    			}
    							//
    							// グラフの表示
    							//
    			pt = line_w / 2 + 2;
    
    			k1 = 0;
    			for (i1 = 0; i1 < n_g; i1++) {
    				draw.graphics.lineStyle(line_w, cl[k1]);  
    				a   = 0.5 * Math.PI;
    				aa  = 2.0 * Math.PI / n_p;
    				kx1 = 0;
    				ky1 = 0;
    				kx2 = 0;
    				ky2 = 0;
    				for (i2 = 0; i2 < n_p; i2++) {
    					yy = xx + (cr - xx) * (data[i1][i2] - y_scale[0]) / (y_scale[1] - y_scale[0]);
    					kx = cx + (int)(Math.round(yy * Math.cos(a)));
    					ky = cy - (int)(Math.round(yy * Math.sin(a)));
    					if (line_m) {
    						draw.graphics.beginFill(cl[k1]);
    						draw.graphics.drawCircle(kx, ky, pt);
    						draw.graphics.endFill();
    					}
    					if (i2 == 0) {
    						kx2 = kx;
    						ky2 = ky;
    					}
    					else {
    						draw.graphics.moveTo(kx1, ky1);
    						draw.graphics.lineTo(kx, ky);
    						if (i2 == n_p-1) {
    							draw.graphics.moveTo(kx2, ky2);
    							draw.graphics.lineTo(kx, ky);
    						}
    					}
    					kx1  = kx;
    					ky1  = ky;
    					a   += aa;
    				}
    				k1++;
    				if (k1 > 9)
    					k1 = 0;
    			}
    		}
    					// 色や線の太さの切り替え
    		private function onClick(event:MouseEvent):void
    		{
    			if (c_l) {
    				c_l = false;
    				change = "色";
    				draw.graphics.clear();
    				draw.removeChild(md);
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				graph_draw();
    			}
    			else {
    				c_l = true;
    				change = "設";
    				tx[c_l_n].text = change;
    				var n : int = (n_g > 10) ? 10 : n_g;
    				var w : int = 310;
    				var h : int = 30 + 23 * (n + 2);
    				md = new Modify_radar(this, w, h);
    				md.width  = w;
    				md.height = h;
    				md.x = 0;
    				md.y = 0;
    				draw.addChild(md);
    			}
    		}
    	}
    }
    
    /*****************************************/
    /* 色及び線の太さの変更(レーダチャート)*/
    /*      coded by Y.Suganuma              */
    /*****************************************/
    package {
    	import flash.display.Sprite;
    	import flash.display.Shape;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.events.FocusEvent;
    
    	public class Modify_radar extends Sprite {
    		public var tx : Array = new Array();
    		private var RC : RadarChart;
    		private var sp : Shape;
    		private var rd1 : Sprite;
    		private var rd2 : Sprite;
    		private var n : int;
    
    		public function Modify_radar (rc:RadarChart, width:int, height:int)
    		{
    			RC = rc;
    							// 表示領域
    			graphics.beginFill(0x00FF00);
    			graphics.drawRect(0, 0, width, height);
    			graphics.endFill();
    			graphics.beginFill(0xFFFFFF);
    			graphics.drawRect(10, 10, width-20, height-20);
    			graphics.endFill();
    							// 設定エリア
    			var tf: TextFormat = new TextFormat();
    			tf.size = 20;
    			tf.bold = true;
    			n = (RC.n_g > 10) ? 10 : RC.n_g;
    									// 色
    			for (var i1 : int = 0; i1 < n; i1++) {
    
    				tx[i1] = new Array();
    
    				tx[i1][0] = new TextField();
    				tx[i1][0].text = "   ";
    				tx[i1][0].setTextFormat(tf);
    				tx[i1][0].x = 15;
    				tx[i1][0].y = 15 + 23 * i1;
    				tx[i1][0].width  = 30;
    				tx[i1][0].height = 20;
    				tx[i1][0].background = true;
    				tx[i1][0].backgroundColor = RC.cl[i1];
    				addChild(tx[i1][0]);
    
    				tx[i1][1] = new TextField();
    				tx[i1][1].text  = "赤";
    				tx[i1][1].setTextFormat(tf);
    				tx[i1][1].x = 55;
    				tx[i1][1].y = 15 + 23 * i1;
    				tx[i1][1].width  = 25;
    				tx[i1][1].height = 20;
    				addChild(tx[i1][1]);
    
    				tx[i1][2] = new TextField();
    				tx[i1][2].name = "tx" + i1 + 2;
    				tx[i1][2].text  = (int)(RC.cl[i1] / (256 * 256));
    				tx[i1][2].setTextFormat(tf);
    				tx[i1][2].type = TextFieldType.INPUT;
    				tx[i1][2].x = 85;
    				tx[i1][2].y = 14 + 23 * i1;
    				tx[i1][2].width  = 35;
    				tx[i1][2].height = 22;
    				tx[i1][2].background = true;
    				tx[i1][2].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][2]);
    				tx[i1][2].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][3] = new TextField();
    				tx[i1][3].text  = "緑";
    				tx[i1][3].setTextFormat(tf);
    				tx[i1][3].x = 130;
    				tx[i1][3].y = 15 + 23 * i1;
    				tx[i1][3].width  = 25;
    				tx[i1][3].height = 20;
    				addChild(tx[i1][3]);
    
    				tx[i1][4] = new TextField();
    				tx[i1][4].name = "tx" + i1 + 4;
    				tx[i1][4].text  = (int)((RC.cl[i1] % (256 * 256)) / 256);
    				tx[i1][4].setTextFormat(tf);
    				tx[i1][4].type = TextFieldType.INPUT;
    				tx[i1][4].x = 160;
    				tx[i1][4].y = 14 + 23 * i1;
    				tx[i1][4].width  = 35;
    				tx[i1][4].height = 22;
    				tx[i1][4].background = true;
    				tx[i1][4].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][4]);
    				tx[i1][4].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][5] = new TextField();
    				tx[i1][5].text  = "青";
    				tx[i1][5].setTextFormat(tf);
    				tx[i1][5].x = 205;
    				tx[i1][5].y = 15 + 23 * i1;
    				tx[i1][5].width  = 25;
    				tx[i1][5].height = 20;
    				addChild(tx[i1][5]);
    
    				tx[i1][6] = new TextField();
    				tx[i1][6].name = "tx" + i1 + 6;
    				tx[i1][6].text  = (int)(RC.cl[i1] % 256);
    				tx[i1][6].setTextFormat(tf);
    				tx[i1][6].type = TextFieldType.INPUT;
    				tx[i1][6].x = 235;
    				tx[i1][6].y = 14 + 23 * i1;
    				tx[i1][6].width  = 35;
    				tx[i1][6].height = 22;
    				tx[i1][6].background = true;
    				tx[i1][6].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][6]);
    				tx[i1][6].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    			}
    									// マーク
    			tx[n] = new Array();
    			tx[n][0] = new TextField();
    			tx[n][0].text  = "マーク:";
    			tx[n][0].setTextFormat(tf);
    			tx[n][0].x = 15;
    			tx[n][0].y = 16 + 23 * n;
    			tx[n][0].width  = 80;
    			tx[n][0].height = 22;
    			addChild(tx[n][0]);
    
    			rd1 = new Sprite();
    			rd1.name = "rd1";
    			rd1.x = 95;
    			rd1.y = 16 + 23 * n;
    			rd1.graphics.beginFill(0xe1ffe1);
    			rd1.graphics.drawCircle(11, 11, 11);
    			rd1.graphics.endFill();
    			if (RC.line_m) {
    				sp = new Shape();
    				sp.graphics.beginFill(0x000000);
    				sp.graphics.drawCircle(11, 11, 5);
    				sp.graphics.endFill();
    				rd1.addChild(sp);
    			}
    			addChild(rd1);
    			rd1.addEventListener(MouseEvent.CLICK, onClick);
    
    			tx[n][1] = new TextField();
    			tx[n][1].text  = "付ける";
    			tx[n][1].setTextFormat(tf);
    			tx[n][1].x = 117;
    			tx[n][1].y = 16 + 23 * n;
    			tx[n][1].width  = 60;
    			tx[n][1].height = 22;
    			addChild(tx[n][1]);
    
    			rd2 = new Sprite();
    			rd2.name = "rd2";
    			rd2.x = 187;
    			rd2.y = 16 + 23 * n;
    			rd2.graphics.beginFill(0xe1ffe1);
    			rd2.graphics.drawCircle(11, 11, 11);
    			rd2.graphics.endFill();
    			if (!RC.line_m) {
    				sp = new Shape();
    				sp.graphics.beginFill(0x000000);
    				sp.graphics.drawCircle(11, 11, 5);
    				sp.graphics.endFill();
    				rd2.addChild(sp);
    			}
    			addChild(rd2);
    			rd2.addEventListener(MouseEvent.CLICK, onClick);
    
    			tx[n][2] = new TextField();
    			tx[n][2].text  = "付けない";
    			tx[n][2].setTextFormat(tf);
    			tx[n][2].x = 209;
    			tx[n][2].y = 16 + 23 * n;
    			tx[n][2].width  = 90;
    			tx[n][2].height = 22;
    			addChild(tx[n][2]);
    									// 線の太さ
    			tx[n+1] = new Array();
    			tx[n+1][0] = new TextField();
    			tx[n+1][0].text  = "線の太さ:";
    			tx[n+1][0].setTextFormat(tf);
    			tx[n+1][0].x = 15;
    			tx[n+1][0].y = 18 + 23 * (n + 1);
    			tx[n+1][0].width  = 100;
    			tx[n+1][0].height = 22;
    			addChild(tx[n+1][0]);
    
    			tx[n+1][1] = new TextField();
    			tx[n+1][1].name = "line";
    			tx[n+1][1].text  = RC.line_w;
    			tx[n+1][1].setTextFormat(tf);
    			tx[n+1][1].type = TextFieldType.INPUT;
    			tx[n+1][1].x = 125;
    			tx[n+1][1].y = 18 + 23 * (n + 1);
    			tx[n+1][1].width  = 30;
    			tx[n+1][1].height = 22;
    			tx[n+1][1].background = true;
    			tx[n+1][1].backgroundColor = "0xe1ffe1";
    			addChild(tx[n+1][1]);
    			tx[n+1][1].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    		}
    					// マークの選択
    		private function onClick(event:MouseEvent):void
    		{
    			if (event.target.name == "rd1") {
    				if (rd1.numChildren == 0) {
    					rd1.addChild(sp);
    					RC.line_m = true;
    				}
    			}
    			else {
    				if (rd2.numChildren == 0) {
    					rd2.addChild(sp);
    					RC.line_m = false;
    				}
    			}
    		}
    					// テキストフィールドの変更
    		private function onFocusOut(event:FocusEvent):void
    		{
    							// 線の太さ
    			if (event.target.name == "line") {
    				if (tx[n+1][1].text.length > 0)
    					RC.line_w = (int)(tx[n+1][1].text);
    			}
    							// 色
    			else {
    				for (var i1 : int = 0; i1 < n; i1++) {
    					var str : String = "tx" + i1;
    					if ((event.target.name).search(str) >= 0) {
    						var v : String = "0x";
    						var s : String;
    						for (var i2 : int = 2; i2 <= 6; i2+=2) {
    							if (tx[i1][i2].text.length > 0) {
    								s = ((int)(tx[i1][i2].text)).toString(16);
    								if (s.length <= 1)
    									s = "0" + s;
    								v += s;
    							}
    							else
    								v += "00";
    						}
    						tx[i1][0].backgroundColor = v;
    						RC.cl[i1] = v;
    						break;
    					}
    				}
    			}
    		}
    	}
    }
    			
    ボード線図( Bode.as と Modify_bode.as )
    /****************************/
    /* ボード線図の描画         */
    /*      coded by Y.Suganuma */
    /****************************/
    package {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.text.TextLineMetrics;
    	import flash.events.MouseEvent;
    
    	public class Bode {
    
    		private var title : Array;   // グラフタイトル, x軸タイトル, y軸タイトル
    		private var g_title : Array;   // 各グラフのタイトル(凡例)
    		private var n_p : int;   // データの数
    		private var x_scale : Array;   // x軸の最小値, x軸の最大値, x軸の刻み幅
    		private var y_scale : Array;   // y軸の最小値, y軸の最大値, y軸の刻み幅
    		private var place : int;   // y軸の小数点以下桁数
    		private var data_x : Array;   // データ(x軸,n_g×n_p個)
    		private var data_y : Array;   // データ(y軸,n_g×n_p個)
    		private var d_t : Boolean = true;   // グラフタイトル表示の有無
    		private var d_g : Boolean = true;   // 凡例表示の有無
    		private var draw : Sprite;   // 表示画面
    		private var width : int;   // ステージの幅
    		private var height : int;   // ステージの高さ
    		private var x_l : int;   // 描画領域(横左)
    		private var x_r : int;   // 描画領域(横右)
    		private var y_u : int;   // 描画領域(縦上)
    		private var y_d : int;   // 描画領域(舘下)
    		private var place_x : int;   // 小数点以下の桁数(x軸)
    		private var place_y : int;   // 小数点以下の桁数(y軸)
    		private var tx : Array = new Array();   // TextField
    		private var n : int = 0;   // TextField の数
    		private var change : String = "色";   // 色や線の太さの切り替えボタン
    		private var c_l : Boolean = false;   // 色設定領域が表示?( true がYes)
    		private var c_l_n : int;   // 色や線の太さの切り替えボタンの位置
    		private var md : Modify_bode;   // 色や線の太さの切り替え領域
    		public var line_w : int = 2;   // 折れ線グラフ等の線の太さ
    		public var cl : Array;   // グラフの色
    		public var n_g : int;   // グラフの数
    					// コンストラクタ
    		public function Bode(title1:Array, g_title1:Array, x_scale1:Array, place_x1:int, y_scale1:Array, place_y1:int, data1:Array, data2:Array, d_t1:Boolean, d_g1:Boolean, draw1:Sprite, width1:int, height1:int)
    		{
    							// データの保存
    			title   = title1;
    			n_g     = g_title1.length;
    			g_title = g_title1;
    			x_scale = x_scale1;
    			place_x = place_x1;
    			y_scale = y_scale1;
    			place_y = place_y1;
    			n_p     = data1[0].length;
    			data_x  = data1;
    			data_y  = data2;
    			d_t     = d_t1;
    			d_g     = d_g1;
    			draw    = draw1;
    			width   = width1;
    			height  = height1;
    							// 初期設定
    			cl = new Array(10);
    			cl[0] = 0x000000;
    			cl[1] = 0xFF00FF;
    			cl[2] = 0x0000FF;
    			cl[3] = 0x800080;
    			cl[4] = 0x00FFFF;
    			cl[5] = 0x008080;
    			cl[6] = 0x008000;
    			cl[7] = 0xC0C0C0;
    			cl[8] = 0xFF0000;
    			cl[9] = 0x800000;
    							// グラフの描画
    			graph_draw();
    		}
    					// グラフの描画
    		public function graph_draw() : void
    		{
    			var r : Number;
    			var tf : TextFormat;
    			var f_size : uint;
    			var mt : TextLineMetrics;
    			var i1 : int;
    			var i2 : int;
    			var k : int;
    			var k1 : int;
    			var kx : int;
    			var ky : int;
    			var kx1 : int;
    			var ky1 : int;
    			var k_x : int;
    			var k_y : int;
    			var len : int;
    			var cr : int;
    			var sp : Number;
    			var x1 : Number;
    			var x2 : Number;
    			var y1 : Number;
    			var y2 : Number;
    			var x_scale_org : Number = x_scale[0];
    			var xx_scale : Array = new Array(3);
    			var data_xx : Array;
    							//
    							// 描画領域の設定
    							//
    			draw.graphics.beginFill(0xFFFFFF);
    			draw.graphics.drawRect(10, 10, width-20, height-20);
    			draw.graphics.endFill();
    			x_l    = 5;
    			x_r    = draw.width - 5;
    			y_u    = 5;
    			y_d    = draw.height - 5;
    							//
    							// グラフタイトルの表示
    							//
    			r      = 0.05;   // タイトル領域の割合
    			f_size = ((y_d - y_u) < (x_r - x_l)) ? (int)((y_d - y_u) * r) : (int)((x_r - x_l) * r);
    			if (f_size < 5)
    				f_size = 5;
    			if (d_t) {
    				tf         = new TextFormat();
    				tf.size    = f_size;
    				tf.bold    = true;
    				tx[n]      = new TextField();
    				tx[n].text = title[0];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - f_size;
    				draw.addChild(tx[n]);
    				y_d -= (f_size + 10);
    				n++;
    			}
    			else
    				y_d -= 5;
    							//
    							// 色や線の太さ切り替えボタンの設置
    							//
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			c_l_n      = n;
    			tx[n]      = new TextField();
    			tx[n].text = change;
    			tx[n].setTextFormat(tf);
    			mt                    = tx[n].getLineMetrics(0);
    			tx[n].width           = mt.width + 5;
    			tx[n].height          = mt.height + 5;
    			tx[n].x               = x_r - tx[n].width - 5;
    			tx[n].y               = y_u + f_size;
    			tx[n].background      = true;
    			tx[n].backgroundColor = 0xffd700;
    			tx[n].addEventListener(MouseEvent.CLICK, onClick);
    			draw.addChild(tx[n]);
    			n++;
    							//
    							// 凡例の表示
    							//
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf         = new TextFormat();
    			tf.size    = f_size;
    			tf.bold    = true;
    			if (d_g) {
    				var han : int = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					tx[n+i1]      = new TextField();
    					tx[n+i1].text = g_title[i1];
    					tx[n+i1].setTextFormat(tf);
    					mt = tx[n+i1].getLineMetrics(0);
    					if (mt.width > han)
    						han = mt.width;
    				}
    				han += 15;
    				r    = 0.2;   // 凡例領域の割合
    				k1   = (int)((x_r - x_l) * r);
    				if (han > k1)
    					han = k1;
    				kx = x_r - han;
    				ky = y_u + 4 * f_size + 5;
    				k  = 0;
    				for (i1 = 0; i1 < n_g; i1++) {
    					draw.graphics.beginFill(cl[k]);
    					draw.graphics.drawRect(kx, ky-1, 10, 7);
    					draw.graphics.endFill();
    					tx[n].width  = tx[n].getLineMetrics(0).width + 5;
    					tx[n].height = tx[n].getLineMetrics(0).height + 5;
    					tx[n].x      = kx + 15;
    					tx[n].y      = ky - 0.5 * f_size;
    					draw.addChild(tx[n]);
    					n++;
    					k++;
    					if (k > 9)
    						k = 0;
    					ky += (f_size + 5);
    				}
    				x_r -= (han + 10);
    			}
    			else
    				x_r -= (int)(0.03 * (x_r - x_l));
    							//
    							// x軸の対数
    							//
    			x_scale_org = x_scale[0];
    			xx_scale[0] = Math.log(x_scale[0]) / Math.log(10.0);
    			xx_scale[1] = Math.log(x_scale[1]) / Math.log(10.0);
    			xx_scale[2] = 1.0;
    			data_xx     = new Array(n_g);
    			for (i1 = 0; i1 < n_g; i1++) {
    				data_xx[i1] = new Array(n_p);
    				for (i2 = 0; i2 < n_p; i2++)
    					data_xx[i1][i2] = Math.log(data_x[i1][i2]) / Math.log(10.0);
    			}
    							//
    							// x軸及びy軸のタイトルの表示
    							//
    			if (title[1].length > 0 && title[1].localeCompare("-") != 0) {
    				tx[n]      = new TextField();
    				tx[n].text = title[1];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = (x_l + x_r) / 2 - tx[n].width / 2;
    				tx[n].y      = y_d - 4 * f_size / 5;
    				draw.addChild(tx[n]);
    				y_d -= (7 * f_size / 4 + 5);
    				n++;
    			}
    			else
    				y_d -= (f_size / 2 + 5);
    			if (title[2].length > 0 && title[2].localeCompare("-") != 0) {
    				tx[n]      = new TextField();
    				tx[n].text = title[2];
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				tx[n].x      = x_l + 10;
    				tx[n].y      = y_u + f_size / 5;
    				draw.addChild(tx[n]);
    				y_u += (f_size + 5);
    				n++;
    			}
    							//
    							// x軸,y軸,及び,各軸の目盛り
    							//
    			draw.graphics.lineStyle(1, 0x000000);  
    			f_size = (int)(0.8 * f_size);
    			if (f_size < 5)
    				f_size = 5;
    			tf       = new TextFormat();
    			tf.size  = f_size;
    			y_u     += 10;
    			x_l     += f_size;
    									// y軸
    			k_y = (int)((y_scale[1] - y_scale[0]) / (0.99 * y_scale[2]));
    			y1  = y_scale[0];
    			len = 0;
    			for (i1 = 0; i1 < k_y+1; i1++) {
    				tx[n+i1]      = new TextField();
    				tx[n+i1].text = y1.toFixed(place_y);
    				tx[n+i1].setTextFormat(tf);
    				mt = tx[n+i1].getLineMetrics(0);
    				if (mt.width > len)
    					len = mt.width;
    				y1 += y_scale[2];
    			}
    			draw.graphics.moveTo(x_l+len+5, y_u);
    			draw.graphics.lineTo(x_l+len+5, y_d);
    			draw.graphics.moveTo(x_r, y_u);
    			draw.graphics.lineTo(x_r, y_d);
    			y1 = y_scale[0];
    			x1 = y_d;
    			sp = (Number)(y_d - y_u) / k_y;
    			for (i1 = 0; i1 < k_y+1; i1++) {
    				ky = (int)(Math.round(x1));
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				k1           = tx[n].width;
    				tx[n].x      = x_l + len - k1;
    				tx[n].y      = ky - 4 * f_size / 5;
    				draw.addChild(tx[n]);
    				draw.graphics.moveTo(x_l+len+5, ky);
    				draw.graphics.lineTo(x_r, ky);
    				y1 += y_scale[2];
    				x1 -= sp;
    				n++;
    			}
    			x_l += (len + 5);
    									// x軸
    			k_x = (int)((xx_scale[1] - xx_scale[0]) / (0.99 * xx_scale[2]));
    			x1  = x_scale_org;
    			y1  = x_l;
    			sp = (Number)(x_r - x_l) / k_x;
    			for (i1 = 0; i1 < k_x+1; i1++) {
    				kx         = (int)(Math.round(y1));
    				tx[n]      = new TextField();
    				tx[n].text = x1.toFixed(place_x);
    				tx[n].setTextFormat(tf);
    				mt           = tx[n].getLineMetrics(0);
    				tx[n].width  = mt.width + 5;
    				tx[n].height = mt.height + 5;
    				k1           = tx[n].width;
    				tx[n].x      = kx - k1 / 2;
    				tx[n].y      = y_d;
    				draw.addChild(tx[n]);
    				draw.graphics.moveTo(kx, y_d);
    				draw.graphics.lineTo(kx, y_u);
    				if (i1 != k_x) {
    					draw.graphics.lineStyle(1, 0x808080);  
    					for (i2 = 2; i2 <= 9; i2++) {
    						y2 = Math.log(x1 * i2) / Math.log(10.0);
    						kx = x_l + (int)(Math.round(((x_r - x_l) * (y2 - xx_scale[0]) / (xx_scale[1] - xx_scale[0]))));
    						draw.graphics.moveTo(kx, y_d);
    						draw.graphics.lineTo(kx, y_u);
    					}
    					draw.graphics.lineStyle(1, 0x000000);  
    				}
    				x1 *= 10.0;
    				y1 += sp;
    				n++;
    			}
    							//
    							// グラフの表示
    							//
    			k1 = 0;
    			for (i1 = 0; i1 < n_g; i1++) {
    				draw.graphics.lineStyle(line_w, cl[k1]);  
    				kx1 = 0;
    				ky1 = 0;
    				for (i2 = 0; i2 < n_p; i2++) {
    					kx = x_l + (int)((x_r - x_l) * (data_xx[i1][i2] - xx_scale[0]) / (xx_scale[1] - xx_scale[0]));
    					ky = y_d - (int)((y_d - y_u) * (data_y[i1][i2] - y_scale[0]) / (y_scale[1] - y_scale[0]));
    					if (i2 > 0) {
    						draw.graphics.moveTo(kx1, ky1);
    						draw.graphics.lineTo(kx, ky);
    					}
    					kx1 = kx;
    					ky1 = ky;
    				}
    				k1++;
    				if (k1 >= cl.length)
    					k1 = 0;
    			}
    		}
    					// 色や線の太さの切り替え
    		private function onClick(event:MouseEvent):void
    		{
    			if (c_l) {
    				c_l = false;
    				change = "色";
    				draw.graphics.clear();
    				draw.removeChild(md);
    				for (var i1:int = 0; i1 < n; i1++)
    					draw.removeChild(tx[i1]);
    				n = 0;
    				graph_draw();
    			}
    			else {
    				c_l = true;
    				change = "設";
    				tx[c_l_n].text = change;
    				var n : int = (n_g > 10) ? 10 : n_g;
    				var w : int = 310;
    				var h : int = 30 + 23 * (n + 1);
    				md = new Modify_bode(this, w, h);
    				md.width  = w;
    				md.height = h;
    				md.x = 0;
    				md.y = 0;
    				draw.addChild(md);
    			}
    		}
    	}
    }
    
    /*************************************/
    /* 色及び線の太さの変更(ボード線図)*/
    /*      coded by Y.Suganuma          */
    /*************************************/
    package {
    	import flash.display.Sprite;
    	import flash.display.Shape;
    	import flash.text.TextField;
    	import flash.text.TextFieldType;
    	import flash.text.TextFormat;
    	import flash.events.MouseEvent;
    	import flash.events.FocusEvent;
    
    	public class Modify_bode extends Sprite {
    		public var tx : Array = new Array();
    		private var BD : Bode;
    		private var sp : Shape;
    		private var rd1 : Sprite;
    		private var rd2 : Sprite;
    		private var n : int;
    
    		public function Modify_bode (bd:Bode, width:int, height:int)
    		{
    			BD = bd;
    							// 表示領域
    			graphics.beginFill(0x00FF00);
    			graphics.drawRect(0, 0, width, height);
    			graphics.endFill();
    			graphics.beginFill(0xFFFFFF);
    			graphics.drawRect(10, 10, width-20, height-20);
    			graphics.endFill();
    							// 設定エリア
    			var tf: TextFormat = new TextFormat();
    			tf.size = 20;
    			tf.bold = true;
    			n = (BD.n_g > 10) ? 10 : BD.n_g;
    									// 色
    			for (var i1 : int = 0; i1 < n; i1++) {
    
    				tx[i1] = new Array();
    
    				tx[i1][0] = new TextField();
    				tx[i1][0].text = "   ";
    				tx[i1][0].setTextFormat(tf);
    				tx[i1][0].x = 15;
    				tx[i1][0].y = 15 + 23 * i1;
    				tx[i1][0].width  = 30;
    				tx[i1][0].height = 20;
    				tx[i1][0].background = true;
    				tx[i1][0].backgroundColor = BD.cl[i1];
    				addChild(tx[i1][0]);
    
    				tx[i1][1] = new TextField();
    				tx[i1][1].text  = "赤";
    				tx[i1][1].setTextFormat(tf);
    				tx[i1][1].x = 55;
    				tx[i1][1].y = 15 + 23 * i1;
    				tx[i1][1].width  = 25;
    				tx[i1][1].height = 20;
    				addChild(tx[i1][1]);
    
    				tx[i1][2] = new TextField();
    				tx[i1][2].name = "tx" + i1 + 2;
    				tx[i1][2].text  = (int)(BD.cl[i1] / (256 * 256));
    				tx[i1][2].setTextFormat(tf);
    				tx[i1][2].type = TextFieldType.INPUT;
    				tx[i1][2].x = 85;
    				tx[i1][2].y = 14 + 23 * i1;
    				tx[i1][2].width  = 35;
    				tx[i1][2].height = 22;
    				tx[i1][2].background = true;
    				tx[i1][2].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][2]);
    				tx[i1][2].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][3] = new TextField();
    				tx[i1][3].text  = "緑";
    				tx[i1][3].setTextFormat(tf);
    				tx[i1][3].x = 130;
    				tx[i1][3].y = 15 + 23 * i1;
    				tx[i1][3].width  = 25;
    				tx[i1][3].height = 20;
    				addChild(tx[i1][3]);
    
    				tx[i1][4] = new TextField();
    				tx[i1][4].name = "tx" + i1 + 4;
    				tx[i1][4].text  = (int)((BD.cl[i1] % (256 * 256)) / 256);
    				tx[i1][4].setTextFormat(tf);
    				tx[i1][4].type = TextFieldType.INPUT;
    				tx[i1][4].x = 160;
    				tx[i1][4].y = 14 + 23 * i1;
    				tx[i1][4].width  = 35;
    				tx[i1][4].height = 22;
    				tx[i1][4].background = true;
    				tx[i1][4].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][4]);
    				tx[i1][4].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    
    				tx[i1][5] = new TextField();
    				tx[i1][5].text  = "青";
    				tx[i1][5].setTextFormat(tf);
    				tx[i1][5].x = 205;
    				tx[i1][5].y = 15 + 23 * i1;
    				tx[i1][5].width  = 25;
    				tx[i1][5].height = 20;
    				addChild(tx[i1][5]);
    
    				tx[i1][6] = new TextField();
    				tx[i1][6].name = "tx" + i1 + 6;
    				tx[i1][6].text  = (int)(BD.cl[i1] % 256);
    				tx[i1][6].setTextFormat(tf);
    				tx[i1][6].type = TextFieldType.INPUT;
    				tx[i1][6].x = 235;
    				tx[i1][6].y = 14 + 23 * i1;
    				tx[i1][6].width  = 35;
    				tx[i1][6].height = 22;
    				tx[i1][6].background = true;
    				tx[i1][6].backgroundColor = "0xe1ffe1";
    				addChild(tx[i1][6]);
    				tx[i1][6].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    			}
    									// 線の太さ
    			tx[n] = new Array();
    			tx[n][0] = new TextField();
    			tx[n][0].text  = "線の太さ:";
    			tx[n][0].setTextFormat(tf);
    			tx[n][0].x = 15;
    			tx[n][0].y = 18 + 23 * n;
    			tx[n][0].width  = 100;
    			tx[n][0].height = 22;
    			addChild(tx[n][0]);
    
    			tx[n][1] = new TextField();
    			tx[n][1].name = "line";
    			tx[n][1].text  = BD.line_w;
    			tx[n][1].setTextFormat(tf);
    			tx[n][1].type = TextFieldType.INPUT;
    			tx[n][1].x = 125;
    			tx[n][1].y = 18 + 23 * n;
    			tx[n][1].width  = 30;
    			tx[n][1].height = 22;
    			tx[n][1].background = true;
    			tx[n][1].backgroundColor = "0xe1ffe1";
    			addChild(tx[n][1]);
    			tx[n][1].addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
    		}
    					// テキストフィールドの変更
    		private function onFocusOut(event:FocusEvent):void
    		{
    							// 線の太さ
    			if (event.target.name == "line") {
    				if (tx[n][1].text.length > 0)
    					BD.line_w = (int)(tx[n][1].text);
    			}
    							// 色
    			else {
    				for (var i1 : int = 0; i1 < n; i1++) {
    					var str : String = "tx" + i1;
    					if ((event.target.name).search(str) >= 0) {
    						var v : String = "0x";
    						var s : String;
    						for (var i2 : int = 2; i2 <= 6; i2+=2) {
    							if (tx[i1][i2].text.length > 0) {
    								s = ((int)(tx[i1][i2].text)).toString(16);
    								if (s.length <= 1)
    									s = "0" + s;
    								v += s;
    							}
    							else
    								v += "00";
    						}
    						tx[i1][0].backgroundColor = v;
    						BD.cl[i1] = v;
    						break;
    					}
    				}
    			}
    		}
    	}
    }
    			

  2. 一般的なグラフ

      上の例では,棒グラフだけを描きましたが,Graph.as とその関連プログラムを利用すると,様々なグラフを描くことができます.この例では,表示されたページ( graph.htm )によってグラフを選択すると,指定したグラフが表示されます.グラフの右上に「横表示」(または,「縦表示」)の表示がある場合は,そこをクリックするとグラフの縦表示,横表示が切り替わります.

    graph.htm

    <!DOCTYPE HTML>
    <HTML>
    <HEAD>
    	<TITLE>グラフの表示</TITLE>
    	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
    	<LINK REL="stylesheet" TYPE="text/css" HREF="../../../master.css">
    	<SCRIPT TYPE="text/javascript">
    		function sel(k)
    		{
    			document.getElementById("kind").value = k;
    		}
    	</SCRIPT>
    </HEAD>
    <BODY CLASS="white">
    	<P STYLE="text-align: center">
    		表示するグラフを選択し,「決定」ボタンをクリックしてください
    	</P>
    	<FORM NAME="graph" ACTION="graph.php" METHOD="POST">
    		<DIV STYLE="text-align: center">
    			<TABLE STYLE="text-align: left; margin-right: auto; margin-left: auto">
    				<TR>
    					<TD><INPUT TYPE="radio" NAME="g_type" VALUE="0" onClick="sel(0)" STYLE="font-size:90%;" CHECKED>棒グラフ</TD>
    				</TR>
    				<TR>
    					<TD><INPUT TYPE="radio" NAME="g_type" VALUE="1" onClick="sel(1)" STYLE="font-size:90%;">折れ線グラフ(1)</TD>
    				<TR>
    					<TD><INPUT TYPE="radio" NAME="g_type" VALUE="2" onClick="sel(2)" STYLE="font-size:90%;">折れ線グラフ(2)</TD>
    				</TR>
    				<TR>
    					<TD><INPUT TYPE="radio" NAME="g_type" VALUE="3" onClick="sel(3)" STYLE="font-size:90%;">積み上げ棒グラフ</TD>
    				</TR>
    				<TR>
    					<TD><INPUT TYPE="radio" NAME="g_type" VALUE="4" onClick="sel(4)" STYLE="font-size:90%;">円グラフ</TD>
    				</TR>
    				<TR>
    					<TD><INPUT TYPE="radio" NAME="g_type" VALUE="5" onClick="sel(5)" STYLE="font-size:90%;">散布図</TD>
    				</TR>
    				<TR>
    					<TD><INPUT TYPE="radio" NAME="g_type" VALUE="6" onClick="sel(6)" STYLE="font-size:90%;">レーダーチャート</TD>
    				</TR>
    				<TR>
    					<TD><INPUT TYPE="radio" NAME="g_type" VALUE="7" onClick="sel(7)" STYLE="font-size:90%;">ボード線図(片対数グラフ)</TD>
    				</TR>
    			</TABLE>
    		</DIV>
    		<P STYLE="text-align: center">
    			<INPUT TYPE="submit" VALUE="決定" STYLE="font-size:90%;">
    			<INPUT ID="kind" TYPE="hidden" NAME="kind" VALUE="0">
    		</P>
    	</FORM>
    </BODY>
    </HTML>
    			

      上に示したページにおいて,項目を選択しボタンをクリックすると,下に示す graph.php という PHP のプログラムにデータが送信されます.このページでは,グラフ作成に必要なデータを作成し,それをアプレットにパラメータとして渡しています.graph.php によって生成されるページは,その下に示すように,ほとんど Flash だけから構成されています.その内容は,graph.htm で選択された項目によって PARAM 要素に記述される内容が異なります.生成されるページの例は,円グラフを選択した場合です.

    graph.php
    <!DOCTYPE HTML>
    <HTML>
    <HEAD>
    	<TITLE>グラフ</TITLE>
    	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
    	<LINK REL="stylesheet" TYPE="text/css" HREF="../../../master.css">
    </HEAD>
    <BODY CLASS="white">
    	<H1 CLASS="center">グラフ</H1>
    <?php
    	$kind = intval($_POST['kind']);
    					// 棒グラフ
    	if ($kind == 0)
    		$gp = "par=0,棒グラフの例,x軸タイトル,y軸タイトル,6,自己啓発,目的意識,国際感覚,実行力,創造力,交渉力,5,非常に重視する,やや重視する,普通,あまり考慮しない,全く考慮しない,0.0,200.0,50.0,0,114,146,40,0,0,144,130,24,0,1,10,56,160,36,15,179,100,21,0,0,101,141,46,0,1,131,104,60,1,0,1,1";
    					// 折れ線グラフ(1)
    	else if ($kind == 1)
    		$gp = "par=1,折れ線グラフの例(1),x軸タイトル,y軸タイトル,6,自己啓発,目的意識,国際感覚,実行力,創造力,交渉力,5,非常に重視する,やや重視する,普通,あまり考慮しない,全く考慮しない,0.0,200.0,50.0,0,114,146,40,0,0,144,130,24,0,1,10,56,160,36,15,179,100,21,0,0,101,141,46,0,1,131,104,60,1,0,1,1";
    					// 折れ線グラフ(2)
    	else if ($kind == 2)
    		$gp = "par=2,折れ線グラフの例(2),x軸タイトル,y軸タイトル,3,グラフ1,グラフ2,グラフ3,0.0,100.0,20.0,1,0.0,200.0,50.0,0,4,0,14,40,100,179,100,21,0,0,30,34,100,101,141,46,10,0,56,60,100,131,104,60,100,1,1";
    					// 積み上げ棒グラフ
    	else if ($kind == 3) {
    		$gp = "par=3,積み上げ棒グラフの例(全体:300人),x軸タイトル,y軸タイトル,21,自己啓発,目的意識,国際感覚,実行力,創造力,交渉力,情報収集力,プレゼンテーション能力,積極性・自主性・チャレンジ精神,柔軟性・協調性,好奇心・探求心,持続力・忍耐力,責任感,明朗さ,真面目さ,基礎学力(数学・物理等),専門知識,専門技術,日本語(文章読解・文章作成),英語,コンピュータ・情報処理,5,非常に重視する,やや重視する,普通,あまり考慮しない,全く考慮しない,0.0,100.0,20.0,0";
    		$data_y[0][0] = 114;
    		$data_y[0][1] = 146;
    		$data_y[0][2] = 40;
    		$data_y[0][3] = 0;
    		$data_y[0][4] = 0;
    		$data_y[1][0] = 144;
    		$data_y[1][1] = 130;
    		$data_y[1][2] = 24;
    		$data_y[1][3] = 0;
    		$data_y[1][4] = 1;
    		$data_y[2][0] = 10;
    		$data_y[2][1] = 56;
    		$data_y[2][2] = 160;
    		$data_y[2][3] = 36;
    		$data_y[2][4] = 15;
    		$data_y[3][0] = 179;
    		$data_y[3][1] = 100;
    		$data_y[3][2] = 21;
    		$data_y[3][3] = 0;
    		$data_y[3][4] = 0;
    		$data_y[4][0] = 101;
    		$data_y[4][1] = 141;
    		$data_y[4][2] = 46;
    		$data_y[4][3] = 0;
    		$data_y[4][4] = 1;
    		$data_y[5][0] = 131;
    		$data_y[5][1] = 104;
    		$data_y[5][2] = 60;
    		$data_y[5][3] = 1;
    		$data_y[5][4] = 0;
    		$data_y[6][0] = 55;
    		$data_y[6][1] = 122;
    		$data_y[6][2] = 107;
    		$data_y[6][3] = 5;
    		$data_y[6][4] = 1;
    		$data_y[7][0] = 43;
    		$data_y[7][1] = 95;
    		$data_y[7][2] = 132;
    		$data_y[7][3] = 13;
    		$data_y[7][4] = 3;
    		$data_y[8][0] = 215;
    		$data_y[8][1] = 75;
    		$data_y[8][2] = 11;
    		$data_y[8][3] = 0;
    		$data_y[8][4] = 0;
    		$data_y[9][0] = 115;
    		$data_y[9][1] = 142;
    		$data_y[9][2] = 41;
    		$data_y[9][3] = 0;
    		$data_y[9][4] = 0;
    		$data_y[10][0] = 87;
    		$data_y[10][1] = 139;
    		$data_y[10][2] = 61;
    		$data_y[10][3] = 2;
    		$data_y[10][4] = 1;
    		$data_y[11][0] = 116;
    		$data_y[11][1] = 141;
    		$data_y[11][2] = 39;
    		$data_y[11][3] = 0;
    		$data_y[11][4] = 1;
    		$data_y[12][0] = 172;
    		$data_y[12][1] = 107;
    		$data_y[12][2] = 23;
    		$data_y[12][3] = 0;
    		$data_y[12][4] = 1;
    		$data_y[13][0] = 106;
    		$data_y[13][1] = 122;
    		$data_y[13][2] = 67;
    		$data_y[13][3] = 2;
    		$data_y[13][4] = 1;
    		$data_y[14][0] = 115;
    		$data_y[14][1] = 107;
    		$data_y[14][2] = 68;
    		$data_y[14][3] = 3;
    		$data_y[14][4] = 1;
    		$data_y[15][0] = 43;
    		$data_y[15][1] = 116;
    		$data_y[15][2] = 121;
    		$data_y[15][3] = 12;
    		$data_y[15][4] = 3;
    		$data_y[16][0] = 44;
    		$data_y[16][1] = 104;
    		$data_y[16][2] = 124;
    		$data_y[16][3] = 13;
    		$data_y[16][4] = 7;
    		$data_y[17][0] = 41;
    		$data_y[17][1] = 99;
    		$data_y[17][2] = 125;
    		$data_y[17][3] = 16;
    		$data_y[17][4] = 8;
    		$data_y[18][0] = 32;
    		$data_y[18][1] = 98;
    		$data_y[18][2] = 150;
    		$data_y[18][3] = 6;
    		$data_y[18][4] = 3;
    		$data_y[19][0] = 9;
    		$data_y[19][1] = 48;
    		$data_y[19][2] = 158;
    		$data_y[19][3] = 50;
    		$data_y[19][4] = 17;
    		$data_y[20][0] = 46;
    		$data_y[20][1] = 106;
    		$data_y[20][2] = 128;
    		$data_y[20][3] = 13;
    		$data_y[20][4] = 1;
    		for ($i1 = 0; $i1 < 21; $i1++) {
    			$s = 0;
    			for ($i2 = 0; $i2 < 5; $i2++)
    				$s += $data_y[$i1][$i2];
    			for ($i2 = 0; $i2 < 5; $i2++) {
    				$data_y[$i1][$i2] = $data_y[$i1][$i2] / $s * 100;
    				$gp = $gp.",".$data_y[$i1][$i2];
    			}
    		}
    		$gp = $gp.",1,1";
    	}
    					// 円グラフ
    	else if ($kind == 4) {
    		$gp = "par=4,円グラフの例(全体:277人),5,非常に重視する,やや重視する,普通,あまり考慮しない,全く考慮しない";
    		$x[0] = 10;
    		$x[1] = 56;
    		$x[2] = 160;
    		$x[3] = 36;
    		$x[4] = 15;
    		$s    = 0;
    		for ($i1 = 0; $i1 < 5; $i1++)
    			$s += $x[$i1];
    		for ($i1 = 0; $i1 < 5; $i1++) {
    			$x[$i1] = $x[$i1] / $s * 100;
    			$gp = $gp.",".$x[$i1];
    		}
    		$gp = $gp.",1";
    	}
    					// 散布図
    	else if ($kind == 5)
    		$gp = "par=5,散布図の例,x軸タイトル,y軸タイトル,0.0,150.0,30.0,0,0.0,200.0,50.0,0,10,11,146,40,70,100,120,50,130,80,130,17,170,21,80,140,100,80,190,60,180,1";
    					// レーダーチャート
    	else if ($kind == 6)
    		$gp = "par=6,レーダーチャートの例,2,重要度,評価,21,自己啓発,目的意識,国際感覚,実行力,創造力,交渉力・調整力・コミュニケーション,情報収集力,プレゼンテーション能力,積極性・自主性・チャレンジ精神,柔軟性・協調性,好奇心・探求心,持続力・忍耐力,責任感,明朗さ,真面目さ,基礎学力(数学・物理等),専門知識,専門技術,日本語(文章読解・文章作成),英語,コンピュータ・情報処理,1.0,5.0,1.0,1,4.2,4.4,3.0,4.5,4.2,4.2,3.8,3.6,4.7,4.2,4.1,4.2,4.5,4.1,4.1,3.6,3.6,3.5,3.5,2.9,3.6,3.4,3.5,2.7,3.5,3.2,3.2,3.1,2.9,3.4,3.6,3.3,3.6,3.8,3.5,4.0,3.3,3.2,3.2,3.1,2.7,3.4,1,1";
    					// ボード線図(片対数グラフ)
    	else
    		$gp = "par=7,ボード線図の例,角周波数,ゲイン(dB),2,一次遅れ要素,二次遅れ要素,0.01,100.0,1.0,2,-80.0,20.0,20.0,0,101,0.01,0.0109647819614318,0.0120226443461741,0.013182567385564,0.0144543977074592,0.0158489319246111,0.0173780082874937,0.0190546071796325,0.0208929613085404,0.0229086765276777,0.0251188643150958,0.0275422870333817,0.0301995172040202,0.0331131121482591,0.0363078054770102,0.0398107170553498,0.0436515832240167,0.0478630092322639,0.0524807460249773,0.0575439937337158,0.0630957344480195,0.0691830970918938,0.0758577575029186,0.0831763771102673,0.0912010839355912,0.1,0.109647819614318,0.120226443461741,0.131825673855641,0.144543977074593,0.158489319246111,0.173780082874938,0.190546071796325,0.208929613085404,0.229086765276778,0.251188643150959,0.275422870333817,0.301995172040202,0.331131121482592,0.363078054770102,0.398107170553498,0.436515832240167,0.47863009232264,0.524807460249774,0.575439937337159,0.630957344480195,0.691830970918939,0.758577575029186,0.831763771102674,0.912010839355913,1,1.09647819614318,1.20226443461741,1.31825673855641,1.44543977074593,1.58489319246111,1.73780082874938,1.90546071796325,2.08929613085404,2.29086765276778,2.51188643150958,2.75422870333817,3.01995172040202,3.31131121482592,3.63078054770102,3.98107170553498,4.36515832240167,4.7863009232264,5.24807460249774,5.75439937337159,6.30957344480195,6.91830970918939,7.58577575029186,8.31763771102674,9.12010839355913,10,10.9647819614318,12.0226443461741,13.1825673855641,14.4543977074593,15.8489319246112,17.3780082874938,19.0546071796325,20.8929613085404,22.9086765276778,25.1188643150959,27.5422870333818,30.1995172040203,33.1131121482592,36.3078054770103,39.8107170553499,43.6515832240168,47.8630092322641,52.4807460249775,57.543993733716,63.0957344480196,69.183097091894,75.8577575029188,83.1763771102676,91.2010839355915,100,-0.00043427276862636,-0.000522105424932322,-0.000627701152241214,-0.000754651740749838,-0.000907275005683991,-0.00109076142866441,-0.00131135036701045,-0.0015765417703246,-0.00189535052688523,-0.00227861197648364,-0.00273934881496565,-0.00329321162892171,-0.00395900769500453,-0.00475933552387765,-0.00572134599940977,-0.00687765494318666,-0.00826743661415132,-0.00993773312918616,-0.0119450211581656,-0.014357084593869,-0.017255250287929,-0.0207370534016865,-0.0249194093944646,-0.0299423809918071,-0.0359736402894658,-0.0432137378264255,-0.051902300972248,-0.0623252917208117,-0.0748234565761777,-0.0898020952083107,-0.10774225511957,-0.129213420154599,-0.154887692755856,-0.185555362732532,-0.222141596415848,-0.265723755961027,-0.317548557029209,-0.379047887154574,-0.451851641314966,-0.537795410636778,-0.6389203414338,-0.757462064101649,-0.895825422443528,-1.05654200302736,-1.2422083724146,-1.45540463109294,-1.69859540490393,-1.97401850619972,-2.2835697095824,-2.62869465226149,-3.01029995663982,-3.42869465226149,-3.8835697095824,-4.37401850619973,-4.89859540490394,-5.45540463109295,-6.04220837241461,-6.65654200302738,-7.29582542244354,-7.95746206410166,-8.63892034143381,-9.33779541063679,-10.0518516413149,-10.7790478871545,-11.5175485570292,-12.265723755961,-13.0221415964158,-13.7855553627325,-14.5548876927558,-15.3292134201546,-16.1077422551196,-16.8898020952083,-17.6748234565762,-18.4623252917208,-19.2519023009722,-20.0432137378264,-20.8359736402895,-21.6299423809918,-22.4249194093944,-23.2207370534017,-24.0172552502879,-24.8143570845939,-25.6119450211582,-26.4099377331292,-27.2082674366141,-28.0068776549432,-28.8057213459994,-29.6047593355239,-30.403959007695,-31.2032932116289,-32.002739348815,-32.8022786119765,-33.6018953505269,-34.4015765417703,-35.201311350367,-36.0010907614287,-36.8009072750057,-37.6007546517408,-38.4006277011522,-39.2005221054249,-40.0004342727686,0.01,0.0109647819614318,0.0120226443461741,0.013182567385564,0.0144543977074592,0.0158489319246111,0.0173780082874937,0.0190546071796325,0.0208929613085404,0.0229086765276777,0.0251188643150958,0.0275422870333817,0.0301995172040202,0.0331131121482591,0.0363078054770102,0.0398107170553498,0.0436515832240167,0.0478630092322639,0.0524807460249773,0.0575439937337158,0.0630957344480195,0.0691830970918938,0.0758577575029186,0.0831763771102673,0.0912010839355912,0.1,0.109647819614318,0.120226443461741,0.131825673855641,0.144543977074593,0.158489319246111,0.173780082874938,0.190546071796325,0.208929613085404,0.229086765276778,0.251188643150959,0.275422870333817,0.301995172040202,0.331131121482592,0.363078054770102,0.398107170553498,0.436515832240167,0.47863009232264,0.524807460249774,0.575439937337159,0.630957344480195,0.691830970918939,0.758577575029186,0.831763771102674,0.912010839355913,1,1.09647819614318,1.20226443461741,1.31825673855641,1.44543977074593,1.58489319246111,1.73780082874938,1.90546071796325,2.08929613085404,2.29086765276778,2.51188643150958,2.75422870333817,3.01995172040202,3.31131121482592,3.63078054770102,3.98107170553498,4.36515832240167,4.7863009232264,5.24807460249774,5.75439937337159,6.30957344480195,6.91830970918939,7.58577575029186,8.31763771102674,9.12010839355913,10,10.9647819614318,12.0226443461741,13.1825673855641,14.4543977074593,15.8489319246112,17.3780082874938,19.0546071796325,20.8929613085404,22.9086765276778,25.1188643150959,27.5422870333818,30.1995172040203,33.1131121482592,36.3078054770103,39.8107170553499,43.6515832240168,47.8630092322641,52.4807460249775,57.543993733716,63.0957344480196,69.183097091894,75.8577575029188,83.1763771102676,91.2010839355915,100,0.000760038415382399,0.000913772766359686,0.00109860460812431,0.00132082497033832,0.0015879978301257,0.00190921780497035,0.00229542006615489,0.00275975307888415,0.00331802694011069,0.00398925269639393,0.00479629117620189,0.00576663367903434,0.0069333414679863,0.00833617658612594,0.0100229632730993,0.0120512274603127,0.0144901717990999,0.0174230558361977,0.0209500658109257,0.0251917767617845,0.0302933320307221,0.0364294929122781,0.043810745501032,0.0526906945590592,0.0633750278465736,0.0762324020119698,0.0917076870782207,0.11033811653403,0.132773031837264,0.159798094398276,0.192365079368509,0.231628683657635,0.278992202428454,0.336164489672405,0.405231365272613,0.488745617523805,0.589841028229403,0.712377430460434,0.861125568145392,1.0420019107726,1.26236286023883,1.53136003903385,1.86032983314904,2.26310269847673,2.7558619659877,3.35544406114777,4.07285867859558,4.8930591948081,5.71985312756973,6.26638529740493,6.02059991327959,4.66638529740486,2.51985312756961,0.0930591948079767,-2.32714132140453,-4.64455593885234,-6.84413803401239,-8.93689730152335,-10.939670166851,-12.8686399609662,-14.7376371397612,-16.5579980892274,-18.3388744318546,-20.0876225695396,-21.8101589717706,-23.5112543824762,-25.1947686347274,-26.8638355103276,-28.5210077975716,-30.1683713163424,-31.8076349206315,-33.4402019056017,-35.0672269681628,-36.689661883466,-38.3082923129218,-39.9237675979881,-41.5366249721535,-43.147309305441,-44.756189254499,-46.3635705070877,-47.9697066679693,-49.5748082232382,-51.1790499341891,-52.7825769441638,-54.3855098282009,-55.9879487725397,-57.5899770367269,-59.1916638234139,-60.7930666585321,-62.394233366321,-63.9952037088238,-65.5960107473037,-67.1966819730599,-68.7972402469212,-70.3977045799339,-71.9980907821951,-73.5984120021699,-75.1986791750297,-76.7989013953919,-78.3990862272337,-79.9992399615847,1,1";
    							// 描画
    	printf("	<div class=\"center\">\n");
    	printf("		<object type=\"application/x-shockwave-flash\" width=\"900\" height=\"600\" data=\"./draw/Graph.swf\">\n");
    	printf("			<param name=\"movie\" value=\"./draw/Graph.swf\">\n");
    	printf("			<param name=\"quality\" value=\"high\">\n");
    	printf("			<param name=\"bgcolor\" value=\"#e1ffe1\">\n");
    	printf("			<param name=\"FlashVars\" value=\"%s\">\n", $gp);
    	printf("		</object>\n");
    	printf("	</div>\n");
    ?>
    </BODY>
    </HTML>
    			
    graph.php によって生成されるページの例(円グラフの場合)
    <!DOCTYPE HTML>
    <HTML>
    <HEAD>
    	<TITLE>グラフ</TITLE>
    	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
    	<LINK REL="stylesheet" TYPE="text/css" HREF="../../../master.css">
    </HEAD>
    <BODY CLASS="white">
    	<H1 CLASS="center">グラフ</H1>
    	<div class="center">
    		<object type="application/x-shockwave-flash" width="900" height="600" data="./draw/Graph.swf">
    			<param name="movie" value="./draw/Graph.swf">
    			<param name="quality" value="high">
    			<param name="bgcolor" value="#e1ffe1">
    			<param name="FlashVars" value="par=4,円グラフの例(全体:277人),5,非常に重視する,やや重視する,普通,あまり考慮しない,全く考慮しない,3.6101083032491,20.216606498195,57.761732851986,12.996389891697,5.4151624548736,1">
    		</object>
    	</div>
    </BODY>
    </HTML>
    			

静岡理工科大学 菅沼ホーム ActionScript目次 索引