~bcsaller/juju-gui/charmFind

« back to all changes in this revision

Viewing changes to lib/yui/tests/charts/tests/pie.html

  • Committer: kapil.foss at gmail
  • Date: 2012-07-13 18:45:59 UTC
  • Revision ID: kapil.foss@gmail.com-20120713184559-2xl7be17egsrz0c9
reshape

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
 
<html>
3
 
    <head>
4
 
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
 
        <style>
6
 
            /*Supplemental: CSS for the YUI distribution*/
7
 
            #custom-doc { width: 95%; min-width: 950px; }
8
 
            #pagetitle {background-image: url(../../assets/bg_hd.gif);}
9
 
            #mychart {
10
 
                padding:10px 10px 10px 10px;
11
 
            }
12
 
        </style>
13
 
        <link rel="stylesheet" type="text/css" href="../../../build/cssfonts/fonts-min.css">
14
 
    </head>             
15
 
<body class="yui3-skin-sam">
16
 
<h3>Unit Tests</h3>
17
 
<div id="mychart"></div>
18
 
<script type="text/javascript" src="../../../build/yui/yui.js"></script>
19
 
<script>            
20
 
YUI({
21
 
    allowRollup: false,
22
 
    filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min'
23
 
}).use('charts', 'test', 'console', function (Y) 
24
 
25
 
    Y.namespace("example.test");
26
 
 
27
 
    var suite = new Y.Test.Suite("Y.Charts.Pie"),
28
 
    
29
 
    //test to ensure that pie charts are drawn from center
30
 
    //pie charts need to have the same width/height
31
 
    PieCenterTest = new Y.Test.Case({
32
 
        name: "PieChartCenterTest",
33
 
        setUp: function() {
34
 
            var myDataValues = [ 
35
 
                {day:"Monday", taxes:2000}, 
36
 
                {day:"Tuesday", taxes:50}, 
37
 
                {day:"Wednesday", taxes:4000}, 
38
 
                {day:"Thursday", taxes:200}, 
39
 
                {day:"Friday", taxes:2000}
40
 
            ];
41
 
            var mychart = new Y.Chart({type: "pie", width:400, height:400, dataProvider:myDataValues});
42
 
            mychart.render("#mychart");
43
 
            this.chart = mychart;
44
 
        },
45
 
 
46
 
        tearDown: function() {
47
 
            this.chart.destroy();
48
 
        },
49
 
 
50
 
        testWidthAndHeightEqual: function()
51
 
        {
52
 
            var graphic = this.chart.get("graph").get("graphic"),
53
 
                shapes = graphic.get("shapes"),
54
 
                i,
55
 
                shape;
56
 
            for(i in shapes)
57
 
            {
58
 
                if(shapes.hasOwnProperty(i))
59
 
                {
60
 
                    shape = shapes[i];
61
 
                    Y.assert(shape.get("width") === shape.get("height"));
62
 
                }
63
 
            }
64
 
        },
65
 
 
66
 
        testWidthGreaterThanHeight: function()
67
 
        {
68
 
            var graphic = this.chart.get("graph").get("graphic"),
69
 
                shapes,
70
 
                i,
71
 
                shape;
72
 
            this.chart.set("width", 500);
73
 
            shapes = graphic.get("shapes");
74
 
            for(i in shapes)
75
 
            {
76
 
                if(shapes.hasOwnProperty(i))
77
 
                {
78
 
                    shape = shapes[i];
79
 
                    Y.assert(shape.get("width") === shape.get("height"));
80
 
                }
81
 
            }
82
 
        },
83
 
 
84
 
        testHeightGreaterThanWidth: function()
85
 
        {
86
 
            var graphic = this.chart.get("graph").get("graphic"),
87
 
                shapes,
88
 
                i,
89
 
                shape;
90
 
            this.chart.set("height", 600);
91
 
            shapes = graphic.get("shapes");
92
 
            for(i in shapes)
93
 
            {
94
 
                if(shapes.hasOwnProperty(i))
95
 
                {
96
 
                    shape = shapes[i];
97
 
                    Y.assert(shape.get("width") === shape.get("height"));
98
 
                }
99
 
            }
100
 
        }
101
 
    });
102
 
 
103
 
    suite.add(PieCenterTest);
104
 
 
105
 
    //create the console
106
 
    var r = new Y.Console({
107
 
        newestOnTop : false,
108
 
        style: 'block' // to anchor in the example content
109
 
    });
110
 
    
111
 
    r.render('#testLogger');
112
 
 
113
 
    //run the tests
114
 
    Y.Test.Runner.setName("Y.Charts.Pie");
115
 
    Y.Test.Runner.add(suite);
116
 
    Y.Test.Runner.run();
117
 
});
118
 
</script>
119
 
</body>
120
 
</html>