隨筆-57  評論-202  文章-17  trackbacks-0
                以前一直是用JFreeChart畫統計圖的,不過JFreeChart畫出來的圖形不夠精細,看起來有些模糊,今天在網上看到另外一個工具ChartDirector,這是一個商業版本的工具,不過也可以免費使用,只是在畫出來的圖形下面都有一條它的廣告條。
                下面是它的一個柱狀圖的例子:

          threedbar.JPG
                范例程序:

          <%@page import="ChartDirector.*" %>
          <%
          //The data for the bar chart
          double[] data = {85156179.5211123};

          //The labels for the bar chart
          String[] labels = {"Mon""Tue""Wed""Thu""Fri"};

          //Create a XYChart object of size 300 x 280 pixels
          XYChart c = new XYChart(300280);

          //Set the plotarea at (45, 30) and of size 200 x 200 pixels
          c.setPlotArea(4530200200);

          //Add a title to the chart
          c.addTitle("Weekly Server Load");

          //Add a title to the y axis
          c.yAxis().setTitle("MBytes");

          //Add a title to the x axis
          c.xAxis().setTitle("Work Week 25");

          //Add a bar chart layer with green (0x00ff00) bars using the given data
          c.addBarLayer(data, 0xff00).set3D();

          //Set the labels on the x axis.
          c.xAxis().setLabels(labels);

          //output the chart
          String chart1URL = c.makeSession(request, "chart1");

          //include tool tip for the chart
          String imageMap1 = c.getHTMLImageMap("""""title='{xLabel}: {value} MBytes'")
              ;
          %>
          <html>
          <body topmargin="5" leftmargin="5" rightmargin="0">
          <div style="font-size:18pt; font-family:verdana; font-weight:bold">
              3D Bar Chart
          </div>
          <hr color="#000080">
          <a href="viewsource.jsp?file=<%=request.getServletPath()%>">
              
          <font size="2" face="Verdana">View Chart Source Code</font>
          </a>
          </div>
          <br>
          <img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
              usemap
          ="#map1" border="0">
          <map name="map1"><%=imageMap1%></map>
          </body>
          </html>


                如果要在柱的頂部顯示數值,可以調用Layer的setDataLabelFormat方法設置,范例:layer.setDataLabelFormat("{value}");

                其它的例子可以參考它的文檔的說明。ChartDirector的網址:http://www.advsofteng.com

          posted on 2005-06-14 17:46 小米 閱讀(5256) 評論(5)  編輯  收藏 所屬分類: Java

          評論:
          # re: 用ChartDirector在JSP中畫統計圖 2005-06-14 19:41 | Mstar軟件研發小組
          這東西的確非常不錯,又好用,功能也很強。可惜就是不是免費的  回復  更多評論
            
          # re: 用ChartDirector在JSP中畫統計圖 2005-06-15 09:41 | 小米
          看他們公司的地址,應該是香港的公司。ChartDirector支持大部分的編程語言,所以是不錯的一個工具。不過,確實是不便宜,按照國內的價格來說。  回復  更多評論
            
          # re: 用ChartDirector在JSP中畫統計圖 2005-06-15 11:43 | Mstar軟件研發小組
          我在網上搞到過破解的,在一些自己弄得小玩意中用過它。  回復  更多評論
            
          # re: 用ChartDirector在JSP中畫統計圖 2005-06-15 12:34 | 小米
          呵呵,看看這里,也許有幫助:http://www.javayou.com/showlog.jspe?log_id=414,自己用倒是沒有問題,但是要用在商業項目上估計就不行了。不知道還有沒有其它開源的工具呢。  回復  更多評論
            
          # re: 用ChartDirector在JSP中畫統計圖[未登錄] 2008-12-27 14:20 | 冷面閻羅
          生成的jsp圖片,我想點某一個柱,跳轉到另一個頁面怎么實現?  回復  更多評論
            
          小米,生活在深圳,專注于Java,主要從事數據庫和網頁編程。現在在學習著Hibernate和Spring。喜歡游戲、音樂和臺球。聯系方式:georgehill@21cn.com
          <2005年6月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          常用鏈接

          留言簿(27)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          我的朋友們

          我的鏈接

          搜索

          •  

          積分與排名

          • 積分 - 234202
          • 排名 - 247

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 江油市| 清镇市| 新乡县| 新巴尔虎右旗| 新泰市| 孝昌县| 杭锦后旗| 咸阳市| 化州市| 康保县| 竹溪县| 洪洞县| 荣成市| 徐州市| 昌平区| 彭泽县| 宜阳县| 延津县| 平湖市| 赣榆县| 扎赉特旗| 固原市| 涞水县| 密山市| 曲沃县| 漾濞| 渭南市| 桂阳县| 田林县| 九江县| 隆尧县| 重庆市| 保靖县| 大同县| 南丹县| 吉木萨尔县| 潼南县| 晴隆县| 喀喇沁旗| 松阳县| 北流市|