(initChart)
| 14 | } |
| 15 | |
| 16 | function startOrdinal(initChart) { |
| 17 | d3.json('../examples/fruits.json').then(function(counts) { |
| 18 | var ndx = crossfilter(counts), |
| 19 | fruitDimension = ndx.dimension(function(d) {return d.name;}), |
| 20 | sumGroup = fruitDimension.group().reduceSum(function(d) {return d.cnt;}), |
| 21 | sumGroupFiltered = remove_empty_bins(sumGroup), |
| 22 | fruit2 = ndx.dimension(function(d) {return d.name;}); |
| 23 | |
| 24 | var chart = initChart(fruitDimension, sumGroupFiltered); |
| 25 | chart.render(); |
| 26 | |
| 27 | var ordinary_ordering = chart.ordering(); |
| 28 | var reset = function() { |
| 29 | chart.ordering(ordinary_ordering); |
| 30 | fruit2.filter(null); |
| 31 | }; |
| 32 | window.button1 = transitionTest.oscillate(function() { |
| 33 | fruit2.filter(ordinal_filter(['grapefruit', 'lime', 'orange', 'pomegranate'])); |
| 34 | }, reset); |
| 35 | window.button2 = transitionTest.oscillate(function() { |
| 36 | fruit2.filter(ordinal_filter(['apple', 'banana', 'grape', 'grapefruit'])); |
| 37 | }, reset); |
| 38 | window.button3 = transitionTest.oscillate(function() { |
| 39 | fruit2.filter(ordinal_filter(['apple', 'banana', 'orange', 'pomegranate'])); |
| 40 | }, reset); |
| 41 | window.button4 = transitionTest.oscillate(function() { |
| 42 | // reverse alphabetic sort |
| 43 | // we don't have complete control over the ordering, because dc.js uses |
| 44 | // crossfilter.quicksort.by: https://github.com/dc-js/dc.js/issues/1161 |
| 45 | // so append a low character ('`' is before 'a') and then subtract each |
| 46 | // character from 'z' and add 'a' |
| 47 | chart.ordering(function(kv) { |
| 48 | var chars = kv.key.split(''); |
| 49 | chars.push('`'); |
| 50 | return chars.map(function(s) { |
| 51 | return String.fromCharCode(122+97-s.charCodeAt(0)); |
| 52 | }).join(''); |
| 53 | }); |
| 54 | }, reset); |
| 55 | window.button5 = transitionTest.oscillate(function() { |
| 56 | chart.ordering(function(kv) { return kv.key.split('').reverse().join(''); }); |
| 57 | }, reset); |
| 58 | }); |
| 59 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…