|
49 | 49 |
|
50 | 50 | function refresh(){ |
51 | 51 | let wrapper = $('#timeline-wrapper').empty().parent(); |
52 | | - let tickFormat = d3.timeFormat("%Y-%m-%d"); |
| 52 | + let tickFormat = d3.timeFormat('%Y-%m-%d'); |
53 | 53 | width = wrapper.width() - margin.left - margin.right, |
54 | 54 | height = wrapper.height() - margin.top - margin.bottom; |
55 | 55 | middle = height / 2; |
|
64 | 64 | } |
65 | 65 | }); |
66 | 66 | if(times.length < 2){ |
67 | | - times.push(new Date(2000, 1, 1)); |
68 | | - times.push(new Date()); |
| 67 | + times = [new Date(2000, 1, 1), new Date()]; |
69 | 68 | } |
70 | 69 | timeDomainStart = Math.min(...times); |
71 | 70 | timeDomainEnd = Math.max(...times); |
|
74 | 73 | .domain([timeDomainStart, timeDomainEnd]) |
75 | 74 | .rangeRound([0, width]); |
76 | 75 |
|
77 | | - svg = d3.select("#timeline-wrapper").append("svg") |
78 | | - .attr("width", width + margin.left + margin.right) |
79 | | - .attr("height", height + margin.top + margin.bottom) |
80 | | - .append("g") |
81 | | - .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); |
| 76 | + svg = d3.select('#timeline-wrapper').append('svg') |
| 77 | + .attr('width', width + margin.left + margin.right) |
| 78 | + .attr('height', height + margin.top + margin.bottom) |
| 79 | + .append('g') |
| 80 | + .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); |
82 | 81 |
|
83 | | - svg.append("g") |
84 | | - .attr("class", "axis axis--grid") |
85 | | - .attr("transform", "translate(0," + height + ")") |
| 82 | + svg.append('g') |
| 83 | + .attr('class', 'axis axis--grid') |
| 84 | + .attr('transform', 'translate(0,' + height + ')') |
86 | 85 | .call(d3.axisBottom(x) |
87 | 86 | .ticks(d3.timeYear) |
88 | 87 | .tickSize(-height) |
89 | 88 | .tickFormat(function(){ return null; }) |
90 | 89 | ); |
91 | 90 |
|
92 | | - svg.append("g") |
93 | | - .attr("class", "axis axis--x") |
94 | | - .attr("transform", "translate(0," + height + ")") |
| 91 | + svg.append('g') |
| 92 | + .attr('class', 'axis axis--x') |
| 93 | + .attr('transform', 'translate(0,' + height + ')') |
95 | 94 | .call(d3.axisBottom(x) |
96 | 95 | .tickSize(8) |
97 | 96 | .tickPadding(8) |
98 | 97 | .tickFormat(tickFormat) |
99 | 98 | ) |
100 | | - .attr("text-anchor", null) |
101 | | - .selectAll("text") |
102 | | - .attr("x", 6); |
| 99 | + .attr('text-anchor', null) |
| 100 | + .selectAll('text') |
| 101 | + .attr('x', 6); |
103 | 102 |
|
104 | | - svg.append("g") |
| 103 | + svg.append('g') |
105 | 104 | .attr('class', 'nodes'); |
106 | 105 |
|
107 | 106 | svg.select('.nodes') |
|
124 | 123 | } |
125 | 124 | }); |
126 | 125 |
|
127 | | - brushG = svg.append("g") |
128 | | - .attr("class", "brush") |
| 126 | + brushG = svg.append('g') |
| 127 | + .attr('class', 'brush') |
129 | 128 | .call(brush); |
130 | 129 | } |
131 | 130 |
|
|
0 commit comments