1
<html>
2
  <head>
3
    <title>Cars</title>
4
    <link type="text/css" href="../ex.css" rel="stylesheet"/>
5
    <script type="text/javascript" src="../../protovis-r3.3.js"></script>
6
    <script type="text/javascript" src="cars.js"></script>
7
    <style type="text/css">
8
9
#fig {
10
  width: 880px;
11
  height: 460px;
12
}
13
14
#title {
15
  position: absolute;
16
  top: 70px;
17
  left: 200px;
18
  padding: 10px;
19
  background: white;
20
}
21
22
large {
23
  font-size: medium;
24
}
25
26
    </style>
27
  </head>
28
  <body><div id="center"><div id="fig">
29
    <script type="text/javascript+protovis">
30
31
/* The dimensions to visualize, in order. */
32
var dims = [
33
  "cylinders",
34
  "displacement",
35
  "weight",
36
  "horsepower",
37
  "acceleration",
38
  "mpg",
39
  "year",
40
  "origin"
41
];
42
43
/* Sizing and scales. */
44
var w = 840,
45
    h = 420,
46
    color = pv.Colors.category10(),
47
    x = pv.Scale.ordinal(dims).splitFlush(0, w),
48
    y = pv.dict(dims, function(t) pv.Scale.linear()
49
            .domain(cars.filter(function(d) !isNaN(d[t])), function(d) d[t])
50
            .range(0, h));
51
52
/* The root panel. */
53
var vis = new pv.Panel()
54
    .width(w)
55
    .height(h)
56
    .margin(20)
57
    .bottom(40);
58
59
/* Rule and labels per dimension. */
60
var rule = vis.add(pv.Rule)
61
    .data(dims)
62
    .left(x)
63
    .strokeStyle(color.by(pv.index))
64
    .lineWidth(2);
65
66
rule.anchor("top").add(pv.Label)
67
    .text(function(t) y[t].domain()[0]);
68
69
rule.anchor("bottom").add(pv.Label)
70
    .text(function(t) y[t].domain()[1]);
71
72
rule.anchor("bottom").add(pv.Label)
73
    .textStyle(function() color(this.index).darker())
74
    .textMargin(14);
75
76
/* Parallel coordinates. */
77
vis.add(pv.Panel)
78
    .data(cars)
79
  .add(pv.Line)
80
    .data(dims)
81
    .left(function(t, d) x(t))
82
    .bottom(function(t, d) y[t](d[t]))
83
    .strokeStyle("rgba(0, 0, 0, .2)")
84
    .lineWidth(1);
85
86
vis.render();
87
88
    </script>
89
  </div></div></body>
90
</html>