2009-11-05 175 views
-1

我試圖繪製raphaeljs餅圖。我使用了與「http://g.raphaeljs.com/piechart2.html」上顯示的相同的示例。它呈現給我的文字,但餅圖失蹤。可以有人請幫忙嗎?繪製gRaphaeljs餅圖

請找到下面的代碼。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd"> 
<html lang="en"> 
    <head> 
     <title>g·Raphaël Dynamic Pie Chart Demo</title> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
     <meta name="author" content="Dmitry Baranovskiy"> 
     <meta name="description" content="Charting JavaScript Library"> 
     <link rel="stylesheet" href="demo.css" type="text/css" media="screen" charset="utf-8"> 
     <link rel="stylesheet" href="demo-print.css" type="text/css" media="print" charset="utf-8"> 
     <script src="raphael.js" type="text/javascript" charset="utf-8"></script> 
     <script src="g.raphael.js" type="text/javascript" charset="utf-8"></script> 
     <script src="g.pie.js" type="text/javascript" charset="utf-8"></script> 
     <script type="text/javascript" charset="utf-8"> 
      window.onload = function() { 
       var r = Raphael("holder"); 
       r.g.txtattr.font = "12px 'Fontin Sans', Fontin-Sans, sans-serif"; 

       r.g.text(320, 100, "Interactive Pie Chart Demo").attr({"font-size": 20}); 

       var pie = r.g.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2, 10], {legend: ["%%.%% – Enterprise Users", "IE Users"], legendpos: "west", href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]}); 
       pie.hover(function() { 
        this.sector.stop(); 
        this.sector.scale(1.1, 1.1, this.cx, this.cy); 
        if (this.label) { 
         this.label[0].stop(); 
         this.label[0].scale(1.5); 
         this.label[1].attr({"font-weight": 800}); 
        } 
       }, function() { 
        this.sector.animate({scale: [1, 1, this.cx, this.cy]}, 500, "bounce"); 
        if (this.label) { 
         this.label[0].animate({scale: 1}, 500, "bounce"); 
         this.label[1].attr({"font-weight": 400}); 
        } 
       }); 

      }; 
     </script> 
    </head> 
    <body class="raphael" id="g.raphael.dmitry.baranovskiy.com"> 
     <div id="holder"></div> 
     <p> 
      Pie chart with legend, hyperlinks on two first sectors and hover effect. 
     </p> 
     <p> 
      Demo of <a href="http://g.raphaeljs.com/">g·Raphaël</a> JavaScript library. 
     </p> 
    </body> 
</html> 

回答

0

你對

<div id="holder"></div> 

任何造型在任何情況下,嘗試在

var pie = r.g.piechart(320, 240, ... 

與前兩個值打他們確定的定位。聽起來就像你的情況,你想讓這些更小。

0
package com.book.dao; 
import java.util.ArrayList; import java.sql.*; 
import com.book.model.Book; import com.book.util.DBUtility; 

public class BookDAO { 
    public ArrayList<Book> selectBooks() { 
     Connection conn = null;    
     Statement stat = null;   
     ResultSet rs = null;    
     ArrayList<Book> bookList = new ArrayList<Book>();   

     try { 
      conn = OracleDAOFactory.createConnection(); 
      stat = conn.createStatement(); 
      String query = "select * from books order by isbn"; 
      rs = stat.executeQuery(query); 
      while (rs.next()) { 
       Book b = new Book(); 
       b.setIsbn(rs.getInt(1)); 
       b.setTitle(rs.getString(2)); 
       b.setAuthor(rs.getString(3)); 
       b.setPrice(rs.getFloat(4)); 
       b.setQty(rs.getInt(5)); 

       bookList.add(b); 
       }   
     } catch (SQLException e) { 
      e.printStackTrace();    
     } catch (Exception e) { 
      e.getMessage();    
     } finally { 
      DBUtility.close(conn); 
      DBUtility.close(stat); 
      DBUtility.close(rs);    
     }   

     System.out.println(bookList);   
     return bookList;   
    } 

    public void insertBook(Book book) {   // TODO Auto-generated method 
     stub System.out.println("connecting....");   
     Connection conn = null;    
     Statement stat = null; 
     ResultSet rs = null; 

     try { 
      conn = OracleDAOFactory.createConnection(); 
      stat = conn.createStatement(); 
      String query="insert into books values("+book.getIsbn()+",'"+book.getTitle()+"','"+book.getAuthor()+"',"+book.getPrice()+","+book.getQty()+")"; 
      rs=stat.executeQuery(query); 
      System.out.println("The query::" + query);   
     } 
     catch (SQLException e) { 
      e.printStackTrace();    
      } 
     catch (Exception e) { 
      e.getMessage();    
     } 
     finally { 
      DBUtility.close(conn); 
      DBUtility.close(stat); 
      DBUtility.close(rs);    
     }  
    } 

    public ArrayList<Book> findBook(Book book) { 
     Connection conn = null;   
     Statement stat = null;  
     ResultSet rs = null;   
     ArrayList<Book> bookList = new ArrayList<Book>();  

     try {   
      conn = OracleDAOFactory.createConnection(); 
      stat = conn.createStatement(); 

      String query = "select isbn,title,author,price,qty from books where isbn="+book.getIsbn()+"";   
      rs = stat.executeQuery(query); 

      if (rs.next()) { 
       Book b = new Book(); 
       b.setIsbn(rs.getInt(1)); 
       b.setTitle(rs.getString(2)); 
       b.setAuthor(rs.getString(3)); 
       b.setPrice(rs.getFloat(4)); 
       b.setQty(rs.getInt(5));       
       bookList.add(b);    
      }  
     } 
     catch (SQLException e) {    
      e.printStackTrace();   
     } 
     catch (Exception e) {   
      e.getMessage(); 
     } 
     finally {   
      DBUtility.close(conn);   
      DBUtility.close(stat); 
      DBUtility.close(rs);   
     }  

     System.out.println(bookList);  
     return bookList;  
    } 

    public void updateBook(Book b) { 
     System.out.println("connecting....");  
     Connection conn = null; 
     Statement stat = null; 
     ResultSet rs = null; 

     try { 
      conn = OracleDAOFactory.createConnection(); 
      stat = conn.createStatement(); 
      String query="update books set title='"+b.getTitle()+"',author='"+b.getAuthor()+"',price="+b.getPrice()+",qty="+b.getQty()+" where isbn="+b.getIsbn()+""; 
      rs=stat.executeQuery(query); 
      System.out.println("The query::" + query);  
     } 
     catch (SQLException e) {    
      e.printStackTrace();   
     } 
     catch (Exception e) { 
      e.getMessage();   
     } 
     finally {   
      DBUtility.close(conn);   
      DBUtility.close(stat);   
      DBUtility.close(rs);   
     } 
    } 

    public void deleteBook(Book b) { 
     System.out.println("connecting....");  Connection conn = null; 
     Statement stat = null; 
     ResultSet rs = null; 

     try { 
      conn = OracleDAOFactory.createConnection(); 
      stat = conn.createStatement(); 
      String query="delete from books where isbn="+b.getIsbn()+""; 
      rs=stat.executeQuery(query); 
      System.out.println("The query::" + query);  
     } 
     catch (SQLException e) {    
      e.printStackTrace();   
     } 
     catch (Exception e) { 
      e.getMessage();   
     } 
     finally {   
      DBUtility.close(conn);   
      DBUtility.close(stat);   
      DBUtility.close(rs);   
     } 
    } 

    public int checkBook(Book b) {  
     Connection conn = null; 
     Statement stat = null;  
     ResultSet rs = null;   
     int check = 0; 

     try {   
      conn = OracleDAOFactory.createConnection();    
      stat = conn.createStatement(); 
      String query = "select isbn,title,author,price,qty from books where isbn="+b.getIsbn()+"";   
      rs = stat.executeQuery(query);   

      if (rs.next()) {    
       check=1;     
      }  
     } 
     catch (SQLException e) { 
      e.printStackTrace();   
     } 
     catch (Exception e) {   
      e.getMessage(); 
     } 
     finally {   
      DBUtility.close(conn);   
      DBUtility.close(stat); 
      DBUtility.close(rs);   
     }   

     return check;  
    } 
}