<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    系列1、2中介紹過(guò)的內(nèi)容在這里不會(huì)贅述。
    原理同面1、2基本一樣。

    ?

    ?1 <! DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    ?2 < html? xmlns ="http://www.w3.org/1999/xhtml" >
    ?3 < head >
    ?4 < meta? http-equiv ="Content-Type" ?content ="text/html;?charset=utf-8" ? />
    ?5 < title > TEST </ title >
    ?6 < script? type ="text/javascript" ?src ="wz_jsgraphics.js" ></ script >
    ?7 < script? type ="text/javascript" ?src ="line.js" ></ script >
    ?8 </ head >
    ?9 < body >
    10 < p > 1.線圖 </ p >
    11 < div? id ="LineDiv" ?style ="position:relative;height:200px;width:300px;" ></ div >
    12 < script? language ="javascript" >
    13 ???? var ?y = ? new ?Array?();
    14 ?????y[ 0 ]? = ? 16000 ;
    15 ?????y[ 1 ]? = ? 1000 ;
    16 ?????y[ 2 ]? = ? 20000 ;
    17 ?????????y[ 3 ]? = ? 100 ;
    18 ?????y[ 4 ]? = ? - 500 ;
    19 ?????y[ 5 ]? = ? 9000 ;
    20 ???? var ?x? = ? new ?Array?();
    21 ????x[ 0 ]? = ? " a " ;
    22 ????x[ 1 ]? = ? " b " ;
    23 ????x[ 2 ]? = ? " c " ;
    24 ?????x[ 3 ]? = ? " aa " ;
    25 ?????x[ 4 ]? = ? " bb " ;
    26 ?????x[ 5 ]? = ? " dd " ;
    27 ???? var ?myline? = ? new ?Line( " LineDiv " );
    28 ????myline.drawXYLine(y,x);
    29 ???? // myline.clearLine();
    30
    </ script > ????????
    31 </ body >
    32 </ html >

    效果圖:
    line.PNG

    ??1 /* ************更多技術(shù)文章請(qǐng)?jiān)L問(wèn):http://www.tkk7.com/JAVA-HE****************
    ??2 ?*
    ??3 ?*????文件名:line.js?V?1.01
    ??4 ?*????
    ??5 ?*????作??者:何昌敏
    ??6 ?*
    ??7 ?*????時(shí)??間:2007-7
    ??8 ?*
    ??9 ?*????描??述:繪制坐標(biāo)曲線圖
    ?10 ?*
    ?11 ?*????備??注:
    ?12 ?*????????????????1.實(shí)現(xiàn)了根據(jù)所提供數(shù)據(jù),自動(dòng)標(biāo)刻y軸坐標(biāo)。
    ?13 ?*????????????????2.實(shí)現(xiàn)了圖像清除。
    ?14 ?*????????????????3.調(diào)整startx?starty能實(shí)現(xiàn)整體位置調(diào)整。
    ?15 ?*
    ?16 ?*????感??謝:Walter?Zorn提供了API?——wz_jsgraphics.js?v.?3.01。
    ?17 ?*????????????????
    ?18 *************更多技術(shù)文章請(qǐng)?jiān)L問(wèn):http://www.tkk7.com/JAVA-HE*************** */

    ?19
    ?20 function ?Line(obj)
    ?21 {
    ?22 ???? this .jg? = ? new ?jsGraphics(obj);?
    ?23 ???? var ?colors? = ? new ?Array();
    ?24 ????colors[ 0 ]? = ? " #0066FF " ;
    ?25 ????colors[ 1 ]? = ? " #FF6633 " ;
    ?26 ????colors[ 2 ]? = ? " #9900FF " ;
    ?27 ????colors[ 3 ]? = ? " #FF0066 " ;
    ?28 ????colors[ 4 ]? = ? " #066600 " ;
    ?29 ????colors[ 5 ]? = ? " #006633 " ;
    ?30 ????colors[ 6 ]? = ? " #33FFFF " ;
    ?31 ????colors[ 7 ]? = ? " #000000 " ;
    ?32 ????colors[ 8 ]? = ? " #FFFF00 " ;
    ?33 ????colors[ 9 ]? = ? " #000033 " ;
    ?34 ????colors[ 10 ]? = ? " #CCFFFF " ;
    ?35 ????colors[ 11 ]? = ? " #666666 " ;
    ?36 ???? this .start_x? = ? 40 ;???????? // 應(yīng)大于等于y_str_width
    ?37 ???? this .y_str_width = 40 ;???? // 坐標(biāo)系的左邊距
    ?38 ???? this .x_str_tom? = 10 ;???????? // x軸文字?距離坐標(biāo)系底部距離。
    ?39 ???? this .start_y? = ? 20 ;???????? // >=this.ArrowLength*2?箭頭的高度
    ?40 ???? this .width = 200 ;
    ?41 ???? this .height = 120 ;
    ?42 ???? this .y_line_num? = ? 5 ;
    ?43 ????
    ?44 ???? this .IsDrawArrow? = ? true ;
    ?45 ???? this .ArrowLength? = 6 ;
    ?46 ????
    ?47 ???? this .drawXYLine? = ? function ?(_y,_x)
    ?48 ???? {
    ?49 ???????? var ?y_length? = ?_y.length;
    ?50 ???????? var ?x_length? = ?_x.length;
    ?51 ???????? if (y_length != x_length)
    ?52 ???????? {
    ?53 ????????????alert( " X?and?Y?length?of?inconsistencies,?errors?parameters. " );
    ?54 ???????????? return ;
    ?55 ????????}

    ?56 ???????? var ?y_line_distance? = ?Math.round( this .height / this .y_line_num);
    ?57 ???????? var ?x_line_distance? = ?Math.round( this .width / x_length);
    ?58 ????????
    ?59 ???????? this .jg.drawLine( this .start_x, this .start_y + this .height, this .start_x + this .width, this .start_y + this .height); // x
    ?60 ???????? this .jg.drawLine( this .start_x, this .start_y + this .height, this .start_x, this .start_y); // y
    ?61 ???????? this .jg.setStroke(Stroke.DOTTED);????
    ?62 ???????? var ?_y_copy? = ?_y.concat();
    ?63 ???????? var ?temp? = ?_y;
    ?64 ????????temp.sort( function ?AscSort(x,?y)?
    ?65 ???????? {
    ?66 ?????????? return ?x? == ?y? ? ? 0 ?:?(x? > ?y? ? ? 1 ?:? - 1 );
    ?67 ????????}

    ?68 ????????);
    ?69 ???????? var ?y_max2y_min? = ?temp[x_length - 1 ] - temp[ 0 ];
    ?70 ???????? var ?y_min? = temp[ 0 ];
    ?71 ???????? var ?y_value_distance? = ?y_max2y_min / this .y_line_num;
    ?72 ???????? for ( var ?i = 0 ;i < this .y_line_num;i ++ )
    ?73 ???????? {
    ?74 ???????????? var ?y_item? = ? this .start_y + this .height - (i + 1 ) * y_line_distance;
    ?75 ???????????? this .jg.drawLine( this .start_x,y_item, this .start_x + this .width,y_item);
    ?76 ???????????? var ?y_v? = ?Math.round(y_value_distance * (i + 1 ) + y_min);
    ?77 ???????????? this .jg.drawString(y_v, this .start_x - this .y_str_width,y_item);
    ?78 ????????}

    ?79 ???????? for (i = 0 ;i < x_length;i ++ )
    ?80 ???????? {
    ?81 ???????????? this .jg.setStroke( - 1 );
    ?82 ???????????? this .jg.setColor( " #000000 " );
    ?83 ???????????? var ?x_item_end? = ? this .start_x + x_line_distance * (i + 1 );
    ?84 ???????????? this .jg.drawLine(x_item_end, this .start_y + this .height,x_item_end, this .start_y);
    ?85 ???????????? this .jg.drawString(_x[i],x_item_end, this .start_y + this .height + 10 );
    ?86 ????????}

    ?87 ???????? for (i = y_length;i > 1 ;i -- )
    ?88 ???????? {
    ?89 ????????????
    ?90 ????????????
    ?91 ???????????? this .jg.setStroke( 2 );
    ?92 ???????????? this .jg.setColor( " #FF0000 " );
    ?93 ????????????
    ?94 ???????????? var ?x_temp_1? = ? this .start_x + x_line_distance * (i);
    ?95 ???????????? var ?x_temp_2? = ? this .start_x + x_line_distance * (i - 1 );
    ?96 ???????????? // alert(_y_copy[i-1]);
    ?97 ???????????? // alert(y_min);
    ?98 ???????????? // alert(y_max2y_min);
    ?99 ???????????? var ?y_temp_1? = ?Math.round( this .height - this .height * (_y_copy[i - 1 ] - y_min) / y_max2y_min + this .start_y);
    100 ???????????? var ?y_temp_2? = ?Math.round( this .height - this .height * (_y_copy[i - 2 ] - y_min) / y_max2y_min + this .start_y);
    101 ???????????? this .jg.drawLine(x_temp_1,y_temp_1,x_temp_2,y_temp_2);????????????
    102 ????????}

    103 ???????? if ( this .IsDrawArrow)
    104 ???????? {
    105 ???????????? this .jg.setStroke( 1 );????
    106 ???????????? this .jg.setColor( " #000000 " );
    107 ???????????? this .jg.drawLine( this .start_x - this .ArrowLength, this .start_y, this .start_x, this .start_y - 2 * this .ArrowLength);
    108 ???????????? this .jg.drawLine( this .start_x + this .ArrowLength, this .start_y, this .start_x, this .start_y - 2 * this .ArrowLength);
    109 ???????????? this .jg.drawLine( this .start_x, this .start_y, this .start_x, this .start_y - 2 * this .ArrowLength);
    110 ???????????? this .jg.drawLine( this .start_x + this .width, this .start_y + this .height - this .ArrowLength, this .start_x + this .width + 2 * this .ArrowLength, this .start_y + this .height);
    111 ???????????? this .jg.drawLine( this .start_x + this .width, this .start_y + this .height + this .ArrowLength, this .start_x + this .width + 2 * this .ArrowLength, this .start_y + this .height);
    112 ???????????? this .jg.drawLine( this .start_x + this .width, this .start_y + this .height, this .start_x + this .width + 2 * this .ArrowLength, this .start_y + this .height);
    113 ????????}

    114 ???????? this .jg.paint();
    115 ????}
    ;
    116 ??? this .clearLine? = ? function ?()
    117 ??? {
    118 ??????????? this .jg.clear();????????
    119 ???}
    ;
    120 }


    總結(jié)遇到過(guò)的一些問(wèn)題,一數(shù)組排序
    總結(jié)如下:
    http://www.tkk7.com/JAVA-HE/archive/2007/07/01/127304.html

    二數(shù)組排序后怎么取原來(lái)沒有排序的數(shù)組
    eg:

    ?1 < html >
    ?2 < body >
    ?3 ? < script? type ="text/javascript" >
    ?4 ?? function ?AscSort(x,?y)? {
    ?5 ?? return ?x? == ?y? ? ? 0 ?:?(x? > ?y? ? ? 1 ?:? - 1 );
    ?6 }

    ?7 ? var ?y? = ? new ?Array( 36000 , 200 , 500 , 10100 );
    ?8 ? var ?te? = ?y;
    ?9 ?te.sort(AscSort);
    10 ?alert(te);
    11 ?alert(y);
    12
    </ script >
    13 </ body >
    14 </ html >

    ?

    如上程序,我對(duì)數(shù)組te排序了。但是我又要用到?jīng)]有排序的數(shù)組y,但是程序的結(jié)果是y也排序了。有什么方法嗎?
    問(wèn)題解決:利用concat方法,實(shí)現(xiàn)了數(shù)組的拷貝。

    后記:這種方式的確實(shí)現(xiàn)了將數(shù)據(jù)庫(kù)中動(dòng)態(tài)數(shù)據(jù)以圖表形式顯示在頁(yè)面上。程序以javascript實(shí)現(xiàn),利用ajax將實(shí)現(xiàn)更好的用戶體驗(yàn)。這樣做減輕了服務(wù)端的壓力。不過(guò),這種方式的確定是客戶端變得龐大。而且其實(shí)現(xiàn)原理很恐怖,基本是div實(shí)現(xiàn)點(diǎn)陣字原理(一點(diǎn)點(diǎn)畫上去的)來(lái)搞的。效率就顯得不夠快。不過(guò)我在項(xiàng)目用這中方式也做完一個(gè)項(xiàng)目了。呵呵,和原來(lái)用jfreechart比較,感覺jfreechart (當(dāng)然完全可以利用cewolf來(lái)簡(jiǎn)化操作)不爽的地方是他總是先生成圖。然后利用src來(lái)顯示的。其實(shí)效率也不怎么高。不過(guò)服務(wù)器好的話,客戶端就輕松。無(wú)非就是胖客戶端和胖服務(wù)器的比較,立場(chǎng)都不同了。

    程序內(nèi)部注釋較少,代碼很少。

    posted on 2007-07-01 04:31 -274°C 閱讀(9907) 評(píng)論(11)  編輯  收藏


    FeedBack:
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖
    2007-08-10 11:51 | 柱柱
    怎么才能動(dòng)態(tài)實(shí)現(xiàn)啊?  回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖[未登錄]
    2007-08-10 13:20 | -274°C
    @柱柱

    動(dòng)態(tài)的話,從數(shù)據(jù)庫(kù)取一次再繪制就動(dòng)態(tài)了。結(jié)合當(dāng)前的AJAX 也許你能做出更多漂亮的效果。  回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖
    2007-08-29 16:22 | 柱柱
    老板說(shuō)這個(gè)功能太簡(jiǎn)單了,能不能實(shí)現(xiàn)打印?
    或者你知道什么好點(diǎn)的,功能比較強(qiáng)點(diǎn)的?  回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖[未登錄]
    2007-08-29 20:56 | -274°C
    @柱柱
    js寫的是不能答應(yīng),因?yàn)樗麑?shí)現(xiàn)原理是用div模擬了點(diǎn)陣,無(wú)非就是div加了背景顏色……你打印肯定什么都沒有。

    你看看我總結(jié)的這篇文章
    http://www.tkk7.com/JAVA-HE/archive/2007/05/08/115813.html
    里面有不少報(bào)表,非js方面的也有。如果你不用jsp,或者你只考慮兼容IE,里面有個(gè)非常炫的能用。VML吧?  回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖
    2007-11-02 11:19 | JiMi
    要實(shí)現(xiàn)在兩條曲線呢,如何實(shí)現(xiàn)  回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖[未登錄]
    2007-11-03 15:30 | Aaron
    呵呵,不若用jfreechart實(shí)在啊。  回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖
    2007-11-03 17:01 | -274
    @JiMi
    這里我只是寫了個(gè)demo,根據(jù)這個(gè)畫線方法,再畫線。也很容易了。
    @Aaron
    jfreechart 是服務(wù)端任務(wù)。而javascript是客戶端的來(lái)完成。
      回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖
    2007-11-03 17:03 | -274
    @柱柱

    其實(shí)方法很多,你如果用服務(wù)端技術(shù),那么可以用java生成bufferedimage,那么答應(yīng)圖片就行。當(dāng)然php也一樣的道理。

    而作為胖客戶端的話,可以根據(jù)判斷選擇svg、或者VML。那樣生成的報(bào)表也是可以答應(yīng)的。  回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖
    2007-12-10 16:02 | tianhua876543
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖[未登錄]
    2010-04-02 10:00 | aa
    將div換成span 就可以了啊  回復(fù)  更多評(píng)論
      
    # re: javascript 在客戶端繪制圖表系列三——xy坐標(biāo)曲線圖
    2012-03-15 16:45 | HU Ruifemg
    為什么我運(yùn)行不了啊  回復(fù)  更多評(píng)論
      

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

    常用鏈接

    留言簿(21)

    隨筆分類(265)

    隨筆檔案(242)

    相冊(cè)

    JAVA網(wǎng)站

    關(guān)注的Blog

    搜索

    •  

    積分與排名

    • 積分 - 914507
    • 排名 - 40

    最新評(píng)論

    主站蜘蛛池模板: 国产成人无码免费看视频软件| 天天摸夜夜摸成人免费视频| 成人毛片免费视频| 久久亚洲AV无码西西人体| 亚洲毛片免费视频| 一级看片免费视频囗交| 亚洲免费中文字幕| 国产精品亚洲综合一区| 亚洲一区在线免费观看| 久久嫩草影院免费看夜色| 女性无套免费网站在线看| 久久久久久久尹人综合网亚洲| 亚洲精品无码成人片久久不卡| 国产色爽免费无码视频| 日韩免费高清视频| 久久综合亚洲色一区二区三区 | 边摸边吃奶边做爽免费视频网站| 日本视频免费高清一本18| 国产精品色午夜免费视频| 亚洲第一成年人网站| 国产免费一级高清淫曰本片| 成人激情免费视频| 亚洲精品熟女国产| 丝袜足液精子免费视频| 国产一级淫片a免费播放口之| 亚洲成在人线电影天堂色| 97在线视频免费公开视频| 国产大片91精品免费观看男同| 综合自拍亚洲综合图不卡区| sihu国产精品永久免费| 在线观看无码的免费网站| 亚洲酒色1314狠狠做| 男女一边摸一边做爽的免费视频| 免费黄色app网站| 亚洲精彩视频在线观看| 91福利免费网站在线观看| 免费一级毛片不卡不收费| 亚洲综合无码一区二区痴汉| 99精品视频在线视频免费观看| 精品国产人成亚洲区| 色天使色婷婷在线影院亚洲|