-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd8bdb8
commit b4e84db
Showing
10 changed files
with
188 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,42 @@ | ||
export default (config, xScale) => selection => { | ||
export default (config, xScale) => { | ||
const { | ||
d3, | ||
margin, | ||
bound: { format: dateFormat }, | ||
label: { width: labelWidth }, | ||
line: { height: lineHeight }, | ||
} = config; | ||
|
||
const bounds = selection.selectAll('.bound').data(d => d); | ||
const numberRows = selection.data()[0].length; | ||
return function(viewport) { | ||
console.log(viewport.data()); | ||
const numberRows = viewport.data()[0].length; | ||
|
||
bounds.exit().remove(); | ||
viewport.selectAll('.bound').remove(); | ||
|
||
bounds | ||
.enter() | ||
.filter((_, i) => !i) | ||
.append('g') | ||
.classed('bound', true) | ||
.classed('start', true) | ||
.attr( | ||
'transform', | ||
`translate(${labelWidth}, ${lineHeight * numberRows + margin.top})` | ||
) | ||
.append('text') | ||
.text(dateFormat(xScale.domain()[0])); | ||
viewport | ||
.append('g') | ||
.classed('bound', true) | ||
.classed('start', true) | ||
.attr( | ||
'transform', | ||
`translate(${labelWidth}, ${lineHeight * numberRows + | ||
margin.top})` | ||
) | ||
.append('text') | ||
.text(dateFormat(xScale.domain()[0])); | ||
|
||
bounds | ||
.enter() | ||
.filter((_, i) => !i) | ||
.append('g') | ||
.classed('bound', true) | ||
.classed('end', true) | ||
.attr( | ||
'transform', | ||
`translate(${labelWidth}, ${lineHeight * numberRows + margin.top})` | ||
) | ||
.append('text') | ||
.attr('x', xScale.range()[1] - margin.right) | ||
.attr('text-anchor', 'end') | ||
.text(dateFormat(xScale.domain()[1])); | ||
|
||
bounds.selectAll('.bound.start text').text(dateFormat(xScale.domain()[0])); | ||
bounds.selectAll('.bound.end text').text(dateFormat(xScale.domain()[1])); | ||
viewport | ||
.append('g') | ||
.classed('bound', true) | ||
.classed('end', true) | ||
.attr( | ||
'transform', | ||
`translate(${labelWidth}, ${lineHeight * numberRows + | ||
margin.top})` | ||
) | ||
.append('text') | ||
.attr('x', xScale.range()[1] - margin.right) | ||
.attr('text-anchor', 'end') | ||
.text(dateFormat(xScale.domain()[1])); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import drop from '../drop'; | ||
|
||
export const dropsAreaFactory = (config, xScale) => { | ||
const { | ||
d3, | ||
label: { width: labelWidth }, | ||
line: { height: lineHeight }, | ||
metaballs, | ||
} = config; | ||
|
||
return function(selection) { | ||
console.log(selection); | ||
// const line = d3.select(this); | ||
// line.select('.drops').remove(); | ||
|
||
// const drops = line | ||
// .append('g') | ||
// .classed('drops', true) | ||
// .attr( | ||
// 'transform', | ||
// () => `translate(${labelWidth}, ${lineHeight / 2})` | ||
// ) | ||
// .call(drop(config, xScale)); | ||
|
||
// if (metaballs) { | ||
// drops.style('filter', 'url(#metaballs)'); | ||
// } | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export const labelFactory = config => { | ||
const { | ||
d3, | ||
label: { width: labelWidth, padding: labelPadding, text: labelText }, | ||
line: { height: lineHeight }, | ||
} = config; | ||
|
||
return function() { | ||
const line = d3.select(this); | ||
line.select('.label').remove(); | ||
|
||
line | ||
.append('text') | ||
.classed('label', true) | ||
.attr('x', labelWidth - labelPadding) | ||
.attr('y', lineHeight / 2) | ||
.attr('dy', '0.25em') | ||
.attr('text-anchor', 'end') | ||
.text(labelText); | ||
}; | ||
}; |
Oops, something went wrong.