Skip to content

Commit

Permalink
Merge pull request #82 from two-n/master
Browse files Browse the repository at this point in the history
debugging 10
  • Loading branch information
efrymire authored Aug 31, 2018
2 parents 8878673 + 380c370 commit d0b5e54
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions read_and_reply.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,35 @@ const parse = (text) => {
const makeViz = (data) => {
console.log('vizing... ')

const xScale = scaleLinear()
.domain([data[0][0], data[data.length-1][0]])
.range([0, 10])
const xTicks = xScale.ticks( data.length/2 ).map(d => d.toString().slice(2,4))

const makeVizRow = (values, init='') => {
if(values.length === 0){
return init
} else {
return makeVizRow(values.slice(1), init+'\u3000'.repeat(Math.max(0, xScale(values[0][0]) - init.length))+'\uff0a')
if (data) {
const xScale = scaleLinear()
.domain([data[0][0], data[data.length-1][0]])
.range([0, 10])
const xTicks = xScale.ticks( data.length/2 ).map(d => d.toString().slice(2,4))

const makeVizRow = (values, init='') => {
if(values.length === 0){
return init
} else {
return makeVizRow(values.slice(1), init+'\u3000'.repeat(Math.max(0, xScale(values[0][0]) - init.length))+'\uff0a')
}
}
}

const yScale = scaleLinear().domain([max(data, d => d[1]), 0])
const yTicks = yScale.ticks( data.length/2 )
const yStep = yTicks[0] - yTicks[1]
const yScale = scaleLinear().domain([max(data, d => d[1]), 0])
const yTicks = yScale.ticks( data.length/2 )
const yStep = yTicks[0] - yTicks[1]

const xStep = Math.round(xScale.range()[1] / xTicks.length) - 2
let viz = yTicks.map(e => {
let filtered = data.filter(d => d[1] >= +e && d[1] < +e + yStep)
return `${format('.2s')(e)}| ${makeVizRow(filtered)}`
}).join('\n')
viz += '\n' + '\u3000'.repeat(2) + xScale.domain()[0].toString().slice(2,4) + '\uffe3'.repeat(xScale.range()[1]) + xScale.domain()[1].toString().slice(2,4)
const xStep = Math.round(xScale.range()[1] / xTicks.length) - 2
let viz = yTicks.map(e => {
let filtered = data.filter(d => d[1] >= +e && d[1] < +e + yStep)
return `${format('.2s')(e)}| ${makeVizRow(filtered)}`
}).join('\n')
viz += '\n' + '\u3000'.repeat(2) + xScale.domain()[0].toString().slice(2,4) + '\uffe3'.repeat(xScale.range()[1]) + xScale.domain()[1].toString().slice(2,4)

return viz
return viz
} else {
return
}
}

module.exports.read_and_reply = read_and_reply = (tweetEvent) => {
Expand Down

0 comments on commit d0b5e54

Please sign in to comment.