-
Notifications
You must be signed in to change notification settings - Fork 30
/
Selection.scala
executable file
·145 lines (126 loc) · 5.62 KB
/
Selection.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright 2007-2010 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.liftweb {
package flot_demo {
package web {
package snippet {
import scala.xml.NodeSeq
import net.liftweb.common._
import net.liftweb.util._
import Helpers._
import net.liftweb.http.js.JsCmds._
import net.liftmodules.widgets.flot._
/*
*
*/
class Selection {
def render (xhtml: NodeSeq) = {
/*
*/
def graph () = {
val us = new FlotSerie () {
override val color = Full (Right(0))
override val label = Full ("United States")
override val data = (1990.0, 18.9) :: (1991.0, 18.7) :: (1992.0, 18.4) ::
(1993.0, 19.3) :: (1994.0, 19.5) :: (1995.0, 19.3) ::
(1996.0, 19.4) :: (1997.0, 20.2) :: (1998.0, 19.8) ::
(1999.0, 19.9) :: (2000.0, 20.4) :: (2001.0, 20.1) ::
(2002.0, 20.0) :: (2003.0, 19.8) :: (2004.0, 20.4) :: Nil
}
val russia = new FlotSerie () {
override val color = Full (Right(1))
override val label = Full ("Russia")
override val data = (1992.0, 13.4) :: (1993.0, 12.2) :: (1994.0, 10.6) ::
(1995.0, 10.2) :: (1996.0, 10.1) :: (1997.0, 9.7) ::
(1998.0, 9.5) :: (1999.0, 9.7) :: (2000.0, 9.9) ::
(2001.0, 9.9) :: (2002.0, 9.9) :: (2003.0, 10.3) ::
(2004.0, 10.5) :: Nil
}
val uk = new FlotSerie () {
override val color = Full (Right(2))
override val label = Full ("United Kingdom")
override val data = (1990.0, 10.0) :: (1991.0, 11.3) :: (1992.0, 9.9) ::
(1993.0, 9.6) :: (1994.0, 9.5) :: (1995.0, 9.5) ::
(1996.0, 9.9) :: (1997.0, 9.3) :: (1998.0, 9.2) ::
(1999.0, 9.2) :: (2000.0, 9.5) :: (2001.0, 9.6) ::
(2002.0, 9.3) :: (2003.0, 9.4) :: (2004.0, 9.79) :: Nil
}
val de = new FlotSerie () {
override val color = Full (Right(3))
override val label = Full ("Germany")
override val data = (1990.0, 12.4) :: (1991.0, 11.2) :: (1992.0, 10.8) ::
(1993.0, 10.5) :: (1994.0, 10.4) :: (1995.0, 10.2) ::
(1996.0, 10.5) :: (1997.0, 10.2) :: (1998.0, 10.1) ::
(1999.0, 9.6) :: (2000.0, 9.7) :: (2001.0, 10.0) ::
(2002.0, 9.7) :: (2003.0, 9.8) :: (2004.0, 9.79) :: Nil
}
val dk = new FlotSerie () {
override val color = Full (Right(4))
override val label = Full ("Denmark")
override val data = (1990.0, 9.7) :: (1991.0, 12.1) :: (1992.0, 10.3) ::
(1993.0, 11.3) :: (1994.0, 11.7) :: (1995.0, 10.6) ::
(1996.0, 12.8) :: (1997.0, 10.8) :: (1998.0, 10.3) ::
(1999.0, 9.4) :: (2000.0, 8.7) :: (2001.0, 9.0) ::
(2002.0, 8.9) :: (2003.0, 10.1) :: (2004.0, 9.80) :: Nil
}
val sw = new FlotSerie () {
override val color = Full (Right(5))
override val label = Full ("Sweden")
override val data = (1990.0, 5.8) :: (1991.0, 6.0) :: (1992.0, 5.9) ::
(1993.0, 5.5) :: (1994.0, 5.7) :: (1995.0, 5.3) ::
(1996.0, 6.1) :: (1997.0, 5.4) :: (1998.0, 5.4) ::
(1999.0, 5.1) :: (2000.0, 5.2) :: (2001.0, 5.4) ::
(2002.0, 6.2) :: (2003.0, 5.9) :: (2004.0, 5.89) :: Nil
}
val nw = new FlotSerie () {
override val color = Full (Right(6))
override val label = Full ("Norway")
override val data = (1990.0, 8.3) :: (1991.0, 8.3) :: (1992.0, 7.8) ::
(1993.0, 8.3) :: (1994.0, 8.4) :: (1995.0, 5.9) ::
(1996.0, 6.4) :: (1997.0, 6.7) :: (1998.0, 6.9) ::
(1999.0, 7.6) :: (2000.0, 7.4) :: (2001.0, 8.1) ::
(2002.0, 12.5) :: (2003.0, 9.9) :: (2004.0, 19.0) :: Nil
}
val options = new FlotOptions () {
override val lines = Full(new FlotLinesOptions () {
override val show = Full (true)
})
override val points = Full(new FlotPointsOptions () {
override val show = Full (true)
})
override val xaxis = Full (new FlotAxisOptions () {
override val tickDecimals = Full (0.0)
})
override val yaxis = Full (new FlotAxisOptions () {
override val min = Full (0.0)
})
override val legend = Full (new FlotLegendOptions () {
override val noColumns = Full (4)
override val container = Full ("ph_legend")
})
override val modeSelection = Full ("x")
}
Flot.render ( "ph_graph", us :: russia :: uk :: de ::
dk :: sw :: nw :: Nil, options, Flot.script(xhtml))
}
//
bind ("flot", xhtml, "graph" -> graph)
}
}
}
}
}
}