Question

I was trying to draw the raphaeljs piechart. I used the same example as shown on "http://g.raphaeljs.com/piechart2.html". It renders me the text but the pie charts goes missing.Can someone please help?

please find the code below.

<!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>
Was it helpful?

Solution

Do you have any styling on

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

In any case, try playing with the first two values in

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

They determine positioning. Sounds like in your case, you want to make those smaller.

OTHER TIPS

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;       
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top