@@ -12,6 +12,9 @@ var lineLayerMaker = require('./lines');
12
12
var Lib = require ( '../../lib' ) ;
13
13
var d3 = require ( 'd3' ) ;
14
14
15
+ var overdrag = 40 ;
16
+ var legendWidth = 80 ;
17
+
15
18
function keyFun ( d ) { return d . key ; }
16
19
17
20
function repeat ( d ) { return [ d ] ; }
@@ -67,6 +70,55 @@ function domainToUnitScale(values) {
67
70
return d3 . scale . linear ( ) . domain ( extent ) ;
68
71
}
69
72
73
+ function model ( layout , d ) {
74
+
75
+ var data = d . dimensions ;
76
+
77
+ var canvasPixelRatio = d . lines . pixelratio ;
78
+ var lines = Lib . extendDeep ( d . lines , {
79
+ color : d . line . color . map ( domainToUnitScale ( d . line . color ) ) ,
80
+ canvasOverdrag : overdrag * canvasPixelRatio
81
+ } ) ;
82
+
83
+ var layoutWidth = layout . width * ( d . domain . x [ 1 ] - d . domain . x [ 0 ] ) ;
84
+ var layoutHeight = layout . height * ( d . domain . y [ 1 ] - d . domain . y [ 0 ] ) ;
85
+
86
+ var padding = d . padding || 80 ;
87
+ var translateX = ( d . domain . x [ 0 ] || 0 ) * layout . width ;
88
+ var translateY = ( d . domain . y [ 0 ] || 0 ) * layout . height ;
89
+ var width = layoutWidth - 2 * padding - legendWidth ; // leavig room for the colorbar
90
+ var height = layoutHeight - 2 * padding ;
91
+
92
+ var canvasWidth = width * canvasPixelRatio + 2 * lines . canvasOverdrag ;
93
+ var canvasHeight = height * canvasPixelRatio ;
94
+
95
+ var resizeHeight = d . filterbar . handleheight ;
96
+ var brushVisibleWidth = d . filterbar . width ;
97
+ var brushCaptureWidth = d . filterbar . capturewidth || Math . min ( 32 , brushVisibleWidth + 16 ) ;
98
+
99
+ return [
100
+ {
101
+ key : Math . random ( ) ,
102
+ dimensions : data ,
103
+ tickDistance : d . tickdistance ,
104
+ unitToColor : d . unitToColor ,
105
+ lines : lines ,
106
+ translateX : translateX ,
107
+ translateY : translateY ,
108
+ padding : padding ,
109
+ canvasWidth : canvasWidth ,
110
+ canvasHeight : canvasHeight ,
111
+ width : width ,
112
+ height : height ,
113
+ brushVisibleWidth : brushVisibleWidth ,
114
+ brushCaptureWidth : brushCaptureWidth ,
115
+ resizeHeight : resizeHeight ,
116
+ canvasPixelRatio : canvasPixelRatio ,
117
+ filterBar : d . filterbar
118
+ }
119
+ ] ;
120
+ }
121
+
70
122
function viewModel ( model ) {
71
123
72
124
var lines = model . lines ;
@@ -128,58 +180,6 @@ function styleExtentTexts(selection) {
128
180
129
181
module . exports = function ( root , styledData , layout , callbacks ) {
130
182
131
- var overdrag = 40 ;
132
- var legendWidth = 80 ;
133
-
134
- function model ( d ) {
135
-
136
- var data = d . dimensions ;
137
-
138
- var canvasPixelRatio = d . lines . pixelratio ;
139
- var lines = Lib . extendDeep ( d . lines , {
140
- color : d . line . color . map ( domainToUnitScale ( d . line . color ) ) ,
141
- canvasOverdrag : overdrag * canvasPixelRatio
142
- } ) ;
143
-
144
- var layoutWidth = layout . width * ( d . domain . x [ 1 ] - d . domain . x [ 0 ] ) ;
145
- var layoutHeight = layout . height * ( d . domain . y [ 1 ] - d . domain . y [ 0 ] ) ;
146
-
147
- var padding = d . padding || 80 ;
148
- var translateX = ( d . domain . x [ 0 ] || 0 ) * layout . width ;
149
- var translateY = ( d . domain . y [ 0 ] || 0 ) * layout . height ;
150
- var width = layoutWidth - 2 * padding - legendWidth ; // leavig room for the colorbar
151
- var height = layoutHeight - 2 * padding ;
152
-
153
- var canvasWidth = width * canvasPixelRatio + 2 * lines . canvasOverdrag ;
154
- var canvasHeight = height * canvasPixelRatio ;
155
-
156
- var resizeHeight = d . filterbar . handleheight ;
157
- var brushVisibleWidth = d . filterbar . width ;
158
- var brushCaptureWidth = d . filterbar . capturewidth || Math . min ( 32 , brushVisibleWidth + 16 ) ;
159
-
160
- return [
161
- {
162
- key : Math . random ( ) ,
163
- dimensions : data ,
164
- tickDistance : d . tickdistance ,
165
- unitToColor : d . unitToColor ,
166
- lines : lines ,
167
- translateX : translateX ,
168
- translateY : translateY ,
169
- padding : padding ,
170
- canvasWidth : canvasWidth ,
171
- canvasHeight : canvasHeight ,
172
- width : width ,
173
- height : height ,
174
- brushVisibleWidth : brushVisibleWidth ,
175
- brushCaptureWidth : brushCaptureWidth ,
176
- resizeHeight : resizeHeight ,
177
- canvasPixelRatio : canvasPixelRatio ,
178
- filterBar : d . filterbar
179
- }
180
- ] ;
181
- }
182
-
183
183
function enterSvgDefs ( root ) {
184
184
var defs = root . selectAll ( 'defs' )
185
185
. data ( repeat , keyFun ) ;
@@ -215,7 +215,7 @@ module.exports = function(root, styledData, layout, callbacks) {
215
215
}
216
216
217
217
var parcoordsModel = d3 . select ( root ) . selectAll ( '.parcoordsModel' )
218
- . data ( model ( styledData ) , keyFun ) ;
218
+ . data ( model ( layout , styledData ) , keyFun ) ;
219
219
220
220
parcoordsModel . enter ( )
221
221
. append ( 'div' )
0 commit comments