File tree Expand file tree Collapse file tree 4 files changed +30
-16
lines changed Expand file tree Collapse file tree 4 files changed +30
-16
lines changed Original file line number Diff line number Diff line change 51
51
"ampersand-view" : " ^7.0.1" ,
52
52
"ampersand-view-switcher" : " ^2.0.0" ,
53
53
"bootstrap" : " https://github.com/twbs/bootstrap/archive/v3.3.2.tar.gz" ,
54
+ "d3" : " ^3.5.5" ,
55
+ "d3-tip" : " ^0.6.7" ,
54
56
"debug" : " ^2.0.0" ,
55
57
"domready" : " ^1.0.7" ,
56
58
"event-stream" : " ^3.3.0" ,
57
59
"flatnest" : " ^0.2.2" ,
58
60
"font-awesome" : " https://github.com/FortAwesome/Font-Awesome/archive/v4.3.0.tar.gz" ,
59
61
"jade" : " ^1.9.2" ,
60
62
"jquery" : " ^2.1.1" ,
63
+ "lodash" : " ^3.8.0" ,
61
64
"moment" : " ^2.8.2" ,
65
+ "mongodb-schema" : " git://github.com/mongodb-js/mongodb-schema.git#ampersand" ,
62
66
"numeral" : " ^1.5.3" ,
63
67
"octicons" : " https://github.com/github/octicons/archive/v2.2.0.tar.gz" ,
64
68
"phantomjs-polyfill" : " 0.0.1" ,
65
69
"qs" : " ^2.2.4" ,
66
- "underscore" : " ^1.6.0" ,
67
- "mongodb-schema" : " git://github.com/mongodb-js/mongodb-schema.git#ampersand" ,
68
- "d3" : " ^3.5.5" ,
69
- "d3-tip" : " ^0.6.7" ,
70
- "lodash" : " ^3.8.0"
70
+ "underscore" : " ^1.6.0"
71
71
},
72
72
"devDependencies" : {
73
73
"browserify" : " ^9.0.3" ,
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ var MinichartView = require('../minicharts');
4
4
var FieldCollection = require ( 'mongodb-schema' ) . FieldCollection ;
5
5
var ViewSwitcher = require ( 'ampersand-view-switcher' ) ;
6
6
var _ = require ( 'lodash' ) ;
7
- var debug = require ( 'debug' ) ( 'scout-ui:field-list' ) ;
8
7
9
8
var BasicFieldView = View . extend ( {
10
9
bindings : {
@@ -38,10 +37,10 @@ var BasicFieldView = View.extend({
38
37
initialize : function ( ) {
39
38
var that = this ;
40
39
// the debounce cuts down computation time by a factor of 5-10 here
41
- this . model . on ( 'change ' , _ . debounce ( function ( model ) {
40
+ this . model . types . on ( 'sync ' , _ . debounce ( function ( ) {
42
41
// for now pick first type, @todo: make the type bars clickable and toggle chart
43
- that . switchView ( model . types . at ( 0 ) ) ;
44
- } , 100 ) ) ;
42
+ that . switchView ( that . model . types . at ( 0 ) ) ;
43
+ } , 300 ) ) ;
45
44
} ,
46
45
render : function ( ) {
47
46
this . renderWithTemplate ( this ) ;
Original file line number Diff line number Diff line change 1
1
var AmpersandView = require ( 'ampersand-view' ) ;
2
2
var $ = require ( 'jquery' ) ;
3
3
var format = require ( 'util' ) . format ;
4
+ var _ = require ( 'underscore' ) ;
5
+ var numeral = require ( 'numeral' ) ;
4
6
5
7
require ( 'bootstrap/js/tooltip' ) ;
6
8
@@ -21,18 +23,27 @@ module.exports = AmpersandView.extend({
21
23
{
22
24
hook : 'bar' ,
23
25
type : function ( el ) {
24
- var percent = Math . min ( this . model . probability * 100 , 100 ) ;
25
26
$ ( el ) . css ( {
26
- width : percent + '%'
27
+ width : Math . floor ( this . model . probability * 100 ) + '%'
27
28
} ) ;
28
- if ( percent ) {
29
- $ ( el ) . tooltip ( {
30
- title : format ( '%s (%d%)' , this . model . getId ( ) , percent )
31
- } ) ;
32
- }
33
29
}
34
30
}
35
31
]
36
32
} ,
33
+ derived : {
34
+ percent : {
35
+ deps : [ 'model.probability' ] ,
36
+ fn : function ( ) {
37
+ return this . model . probability ;
38
+ }
39
+ }
40
+ } ,
41
+ initialize : function ( ) {
42
+ this . listenTo ( this . model , 'change:probability' , _ . debounce ( function ( ) {
43
+ $ ( this . el ) . tooltip ( {
44
+ title : format ( '%s (%s)' , this . model . getId ( ) , numeral ( this . model . probability ) . format ( '%' ) )
45
+ } ) ;
46
+ } . bind ( this ) , 300 ) ) ;
47
+ } ,
37
48
template : require ( './type-list-item.jade' )
38
49
} ) ;
Original file line number Diff line number Diff line change 102
102
display : inline-block ;
103
103
}
104
104
105
+ & .schema-field-basic {
106
+ min-height : 141px ;
107
+ }
108
+
105
109
& .schema-field-object , & .schema-field-array {
106
110
.schema-field-name {
107
111
cursor : pointer ;
You can’t perform that action at this time.
0 commit comments