Get rid of var
This commit is contained in:
parent
f16143de7c
commit
20b43d8ad1
|
@ -1,11 +1,11 @@
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { logger } from '../../logger'
|
import { logger } from '../../logger'
|
||||||
|
|
||||||
var dateFormat = ''
|
let dateFormat = ''
|
||||||
var title = ''
|
let title = ''
|
||||||
var sections = []
|
let sections = []
|
||||||
var tasks = []
|
let tasks = []
|
||||||
var currentSection = ''
|
let currentSection = ''
|
||||||
|
|
||||||
export const clear = function () {
|
export const clear = function () {
|
||||||
sections = []
|
sections = []
|
||||||
|
@ -39,9 +39,9 @@ export const addSection = function (txt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTasks = function () {
|
export const getTasks = function () {
|
||||||
var allItemsPricessed = compileTasks()
|
let allItemsPricessed = compileTasks()
|
||||||
var maxDepth = 10
|
const maxDepth = 10
|
||||||
var iterationCount = 0
|
let iterationCount = 0
|
||||||
while (!allItemsPricessed && (iterationCount < maxDepth)) {
|
while (!allItemsPricessed && (iterationCount < maxDepth)) {
|
||||||
allItemsPricessed = compileTasks()
|
allItemsPricessed = compileTasks()
|
||||||
iterationCount++
|
iterationCount++
|
||||||
|
@ -52,18 +52,18 @@ export const getTasks = function () {
|
||||||
return tasks
|
return tasks
|
||||||
}
|
}
|
||||||
|
|
||||||
var getStartDate = function (prevTime, dateFormat, str) {
|
const getStartDate = function (prevTime, dateFormat, str) {
|
||||||
str = str.trim()
|
str = str.trim()
|
||||||
|
|
||||||
// Test for after
|
// Test for after
|
||||||
var re = /^after\s+([\d\w-]+)/
|
const re = /^after\s+([\d\w-]+)/
|
||||||
var afterStatement = re.exec(str.trim())
|
const afterStatement = re.exec(str.trim())
|
||||||
|
|
||||||
if (afterStatement !== null) {
|
if (afterStatement !== null) {
|
||||||
var task = findTaskById(afterStatement[1])
|
const task = findTaskById(afterStatement[1])
|
||||||
|
|
||||||
if (typeof task === 'undefined') {
|
if (typeof task === 'undefined') {
|
||||||
var dt = new Date()
|
const dt = new Date()
|
||||||
dt.setHours(0, 0, 0, 0)
|
dt.setHours(0, 0, 0, 0)
|
||||||
return dt
|
return dt
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ var getStartDate = function (prevTime, dateFormat, str) {
|
||||||
return new Date()
|
return new Date()
|
||||||
}
|
}
|
||||||
|
|
||||||
var getEndDate = function (prevTime, dateFormat, str) {
|
const getEndDate = function (prevTime, dateFormat, str) {
|
||||||
str = str.trim()
|
str = str.trim()
|
||||||
|
|
||||||
// Check for actual date
|
// Check for actual date
|
||||||
|
@ -90,10 +90,10 @@ var getEndDate = function (prevTime, dateFormat, str) {
|
||||||
return moment(str, dateFormat.trim()).toDate()
|
return moment(str, dateFormat.trim()).toDate()
|
||||||
}
|
}
|
||||||
|
|
||||||
var d = moment(prevTime)
|
const d = moment(prevTime)
|
||||||
// Check for length
|
// Check for length
|
||||||
var re = /^([\d]+)([wdhms])/
|
const re = /^([\d]+)([wdhms])/
|
||||||
var durationStatement = re.exec(str.trim())
|
const durationStatement = re.exec(str.trim())
|
||||||
|
|
||||||
if (durationStatement !== null) {
|
if (durationStatement !== null) {
|
||||||
switch (durationStatement[2]) {
|
switch (durationStatement[2]) {
|
||||||
|
@ -119,8 +119,8 @@ var getEndDate = function (prevTime, dateFormat, str) {
|
||||||
return d.toDate()
|
return d.toDate()
|
||||||
}
|
}
|
||||||
|
|
||||||
var taskCnt = 0
|
let taskCnt = 0
|
||||||
var parseId = function (idStr) {
|
const parseId = function (idStr) {
|
||||||
if (typeof idStr === 'undefined') {
|
if (typeof idStr === 'undefined') {
|
||||||
taskCnt = taskCnt + 1
|
taskCnt = taskCnt + 1
|
||||||
return 'task' + taskCnt
|
return 'task' + taskCnt
|
||||||
|
@ -138,8 +138,8 @@ var parseId = function (idStr) {
|
||||||
// endDate
|
// endDate
|
||||||
// length
|
// length
|
||||||
|
|
||||||
var compileData = function (prevTask, dataStr) {
|
const compileData = function (prevTask, dataStr) {
|
||||||
var ds
|
let ds
|
||||||
|
|
||||||
if (dataStr.substr(0, 1) === ':') {
|
if (dataStr.substr(0, 1) === ':') {
|
||||||
ds = dataStr.substr(1, dataStr.length)
|
ds = dataStr.substr(1, dataStr.length)
|
||||||
|
@ -147,13 +147,13 @@ var compileData = function (prevTask, dataStr) {
|
||||||
ds = dataStr
|
ds = dataStr
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = ds.split(',')
|
const data = ds.split(',')
|
||||||
|
|
||||||
var task = {}
|
const task = {}
|
||||||
var df = getDateFormat()
|
const df = getDateFormat()
|
||||||
|
|
||||||
// Get tags like active, done cand crit
|
// Get tags like active, done cand crit
|
||||||
var matchFound = true
|
let matchFound = true
|
||||||
while (matchFound) {
|
while (matchFound) {
|
||||||
matchFound = false
|
matchFound = false
|
||||||
if (data[0].match(/^\s*active\s*$/)) {
|
if (data[0].match(/^\s*active\s*$/)) {
|
||||||
|
@ -172,8 +172,7 @@ var compileData = function (prevTask, dataStr) {
|
||||||
matchFound = true
|
matchFound = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var i
|
for (let i = 0; i < data.length; i++) {
|
||||||
for (i = 0; i < data.length; i++) {
|
|
||||||
data[i] = data[i].trim()
|
data[i] = data[i].trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,21 +198,20 @@ var compileData = function (prevTask, dataStr) {
|
||||||
return task
|
return task
|
||||||
}
|
}
|
||||||
|
|
||||||
var parseData = function (prevTaskId, dataStr) {
|
const parseData = function (prevTaskId, dataStr) {
|
||||||
var ds
|
let ds
|
||||||
|
|
||||||
if (dataStr.substr(0, 1) === ':') {
|
if (dataStr.substr(0, 1) === ':') {
|
||||||
ds = dataStr.substr(1, dataStr.length)
|
ds = dataStr.substr(1, dataStr.length)
|
||||||
} else {
|
} else {
|
||||||
ds = dataStr
|
ds = dataStr
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = ds.split(',')
|
const data = ds.split(',')
|
||||||
|
|
||||||
var task = {}
|
const task = {}
|
||||||
|
|
||||||
// Get tags like active, done cand crit
|
// Get tags like active, done cand crit
|
||||||
var matchFound = true
|
let matchFound = true
|
||||||
while (matchFound) {
|
while (matchFound) {
|
||||||
matchFound = false
|
matchFound = false
|
||||||
if (data[0].match(/^\s*active\s*$/)) {
|
if (data[0].match(/^\s*active\s*$/)) {
|
||||||
|
@ -232,8 +230,7 @@ var parseData = function (prevTaskId, dataStr) {
|
||||||
matchFound = true
|
matchFound = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var i
|
for (let i = 0; i < data.length; i++) {
|
||||||
for (i = 0; i < data.length; i++) {
|
|
||||||
data[i] = data[i].trim()
|
data[i] = data[i].trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,19 +256,19 @@ var parseData = function (prevTaskId, dataStr) {
|
||||||
return task
|
return task
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastTask
|
let lastTask
|
||||||
var lastTaskID
|
let lastTaskID
|
||||||
var rawTasks = []
|
let rawTasks = []
|
||||||
var taskDb = {}
|
const taskDb = {}
|
||||||
export const addTask = function (descr, data) {
|
export const addTask = function (descr, data) {
|
||||||
var rawTask = {
|
const rawTask = {
|
||||||
section: currentSection,
|
section: currentSection,
|
||||||
type: currentSection,
|
type: currentSection,
|
||||||
processed: false,
|
processed: false,
|
||||||
raw: { data: data },
|
raw: { data: data },
|
||||||
task: descr
|
task: descr
|
||||||
}
|
}
|
||||||
var taskInfo = parseData(lastTaskID, data)
|
const taskInfo = parseData(lastTaskID, data)
|
||||||
rawTask.raw.startTime = taskInfo.startTime
|
rawTask.raw.startTime = taskInfo.startTime
|
||||||
rawTask.raw.endTime = taskInfo.endTime
|
rawTask.raw.endTime = taskInfo.endTime
|
||||||
rawTask.id = taskInfo.id
|
rawTask.id = taskInfo.id
|
||||||
|
@ -280,7 +277,7 @@ export const addTask = function (descr, data) {
|
||||||
rawTask.done = taskInfo.done
|
rawTask.done = taskInfo.done
|
||||||
rawTask.crit = taskInfo.crit
|
rawTask.crit = taskInfo.crit
|
||||||
|
|
||||||
var pos = rawTasks.push(rawTask)
|
const pos = rawTasks.push(rawTask)
|
||||||
|
|
||||||
lastTaskID = rawTask.id
|
lastTaskID = rawTask.id
|
||||||
// Store cross ref
|
// Store cross ref
|
||||||
|
@ -288,18 +285,18 @@ export const addTask = function (descr, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const findTaskById = function (id) {
|
export const findTaskById = function (id) {
|
||||||
var pos = taskDb[id]
|
const pos = taskDb[id]
|
||||||
return rawTasks[pos]
|
return rawTasks[pos]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addTaskOrg = function (descr, data) {
|
export const addTaskOrg = function (descr, data) {
|
||||||
var newTask = {
|
const newTask = {
|
||||||
section: currentSection,
|
section: currentSection,
|
||||||
type: currentSection,
|
type: currentSection,
|
||||||
description: descr,
|
description: descr,
|
||||||
task: descr
|
task: descr
|
||||||
}
|
}
|
||||||
var taskInfo = compileData(lastTask, data)
|
const taskInfo = compileData(lastTask, data)
|
||||||
newTask.startTime = taskInfo.startTime
|
newTask.startTime = taskInfo.startTime
|
||||||
newTask.endTime = taskInfo.endTime
|
newTask.endTime = taskInfo.endTime
|
||||||
newTask.id = taskInfo.id
|
newTask.id = taskInfo.id
|
||||||
|
@ -310,15 +307,15 @@ export const addTaskOrg = function (descr, data) {
|
||||||
tasks.push(newTask)
|
tasks.push(newTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
var compileTasks = function () {
|
const compileTasks = function () {
|
||||||
var df = getDateFormat()
|
const df = getDateFormat()
|
||||||
|
|
||||||
var compileTask = function (pos) {
|
const compileTask = function (pos) {
|
||||||
var task = rawTasks[pos]
|
const task = rawTasks[pos]
|
||||||
var startTime = ''
|
let startTime = ''
|
||||||
switch (rawTasks[pos].raw.startTime.type) {
|
switch (rawTasks[pos].raw.startTime.type) {
|
||||||
case 'prevTaskEnd':
|
case 'prevTaskEnd':
|
||||||
var prevTask = findTaskById(task.prevTaskId)
|
const prevTask = findTaskById(task.prevTaskId)
|
||||||
task.startTime = prevTask.endTime
|
task.startTime = prevTask.endTime
|
||||||
break
|
break
|
||||||
case 'getStartDate':
|
case 'getStartDate':
|
||||||
|
@ -339,9 +336,8 @@ var compileTasks = function () {
|
||||||
return rawTasks[pos].processed
|
return rawTasks[pos].processed
|
||||||
}
|
}
|
||||||
|
|
||||||
var i
|
let allProcessed = true
|
||||||
var allProcessed = true
|
for (let i = 0; i < rawTasks.length; i++) {
|
||||||
for (i = 0; i < rawTasks.length; i++) {
|
|
||||||
compileTask(i)
|
compileTask(i)
|
||||||
|
|
||||||
allProcessed = allProcessed && rawTasks[i].processed
|
allProcessed = allProcessed && rawTasks[i].processed
|
||||||
|
|
|
@ -7,8 +7,8 @@ import d3 from '../../d3'
|
||||||
|
|
||||||
parser.yy = ganttDb
|
parser.yy = ganttDb
|
||||||
|
|
||||||
var daysInChart
|
let daysInChart
|
||||||
var conf = {
|
const conf = {
|
||||||
titleTopMargin: 25,
|
titleTopMargin: 25,
|
||||||
barHeight: 20,
|
barHeight: 20,
|
||||||
barGap: 4,
|
barGap: 4,
|
||||||
|
@ -20,18 +20,18 @@ var conf = {
|
||||||
fontFamily: '"Open-Sans", "sans-serif"'
|
fontFamily: '"Open-Sans", "sans-serif"'
|
||||||
}
|
}
|
||||||
export const setConf = function (cnf) {
|
export const setConf = function (cnf) {
|
||||||
var keys = Object.keys(cnf)
|
const keys = Object.keys(cnf)
|
||||||
|
|
||||||
keys.forEach(function (key) {
|
keys.forEach(function (key) {
|
||||||
conf[key] = cnf[key]
|
conf[key] = cnf[key]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
var w
|
let w
|
||||||
export const draw = function (text, id) {
|
export const draw = function (text, id) {
|
||||||
parser.yy.clear()
|
parser.yy.clear()
|
||||||
parser.parse(text)
|
parser.parse(text)
|
||||||
|
|
||||||
var elem = document.getElementById(id)
|
const elem = document.getElementById(id)
|
||||||
w = elem.parentElement.offsetWidth
|
w = elem.parentElement.offsetWidth
|
||||||
|
|
||||||
if (typeof w === 'undefined') {
|
if (typeof w === 'undefined') {
|
||||||
|
@ -42,25 +42,25 @@ export const draw = function (text, id) {
|
||||||
w = conf.useWidth
|
w = conf.useWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
var taskArray = parser.yy.getTasks()
|
const taskArray = parser.yy.getTasks()
|
||||||
|
|
||||||
// Set height based on number of tasks
|
// Set height based on number of tasks
|
||||||
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding
|
const h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding
|
||||||
|
|
||||||
elem.setAttribute('height', '100%')
|
elem.setAttribute('height', '100%')
|
||||||
// Set viewBox
|
// Set viewBox
|
||||||
elem.setAttribute('viewBox', '0 0 ' + w + ' ' + h)
|
elem.setAttribute('viewBox', '0 0 ' + w + ' ' + h)
|
||||||
var svg = d3.select('#' + id)
|
const svg = d3.select('#' + id)
|
||||||
|
|
||||||
var startDate = d3.min(taskArray, function (d) {
|
const startDate = d3.min(taskArray, function (d) {
|
||||||
return d.startTime
|
return d.startTime
|
||||||
})
|
})
|
||||||
var endDate = d3.max(taskArray, function (d) {
|
const endDate = d3.max(taskArray, function (d) {
|
||||||
return d.endTime
|
return d.endTime
|
||||||
})
|
})
|
||||||
|
|
||||||
// Set timescale
|
// Set timescale
|
||||||
var timeScale = d3.time.scale()
|
const timeScale = d3.time.scale()
|
||||||
.domain([d3.min(taskArray, function (d) {
|
.domain([d3.min(taskArray, function (d) {
|
||||||
return d.startTime
|
return d.startTime
|
||||||
}),
|
}),
|
||||||
|
@ -69,15 +69,15 @@ export const draw = function (text, id) {
|
||||||
})])
|
})])
|
||||||
.rangeRound([0, w - conf.leftPadding - conf.rightPadding])
|
.rangeRound([0, w - conf.leftPadding - conf.rightPadding])
|
||||||
|
|
||||||
var categories = []
|
let categories = []
|
||||||
|
|
||||||
daysInChart = moment.duration(endDate - startDate).asDays()
|
daysInChart = moment.duration(endDate - startDate).asDays()
|
||||||
|
|
||||||
for (var i = 0; i < taskArray.length; i++) {
|
for (let i = 0; i < taskArray.length; i++) {
|
||||||
categories.push(taskArray[i].type)
|
categories.push(taskArray[i].type)
|
||||||
}
|
}
|
||||||
|
|
||||||
var catsUnfiltered = categories // for vert labels
|
const catsUnfiltered = categories // for vert labels
|
||||||
|
|
||||||
categories = checkUnique(categories)
|
categories = checkUnique(categories)
|
||||||
|
|
||||||
|
@ -93,12 +93,12 @@ export const draw = function (text, id) {
|
||||||
.attr('class', 'titleText')
|
.attr('class', 'titleText')
|
||||||
|
|
||||||
function makeGant (tasks, pageWidth, pageHeight) {
|
function makeGant (tasks, pageWidth, pageHeight) {
|
||||||
var barHeight = conf.barHeight
|
const barHeight = conf.barHeight
|
||||||
var gap = barHeight + conf.barGap
|
const gap = barHeight + conf.barGap
|
||||||
var topPadding = conf.topPadding
|
const topPadding = conf.topPadding
|
||||||
var leftPadding = conf.leftPadding
|
const leftPadding = conf.leftPadding
|
||||||
|
|
||||||
var colorScale = d3.scale.linear()
|
const colorScale = d3.scale.linear()
|
||||||
.domain([0, categories.length])
|
.domain([0, categories.length])
|
||||||
.range(['#00B9FA', '#F95002'])
|
.range(['#00B9FA', '#F95002'])
|
||||||
.interpolate(d3.interpolateHcl)
|
.interpolate(d3.interpolateHcl)
|
||||||
|
@ -124,7 +124,7 @@ export const draw = function (text, id) {
|
||||||
})
|
})
|
||||||
.attr('height', theGap)
|
.attr('height', theGap)
|
||||||
.attr('class', function (d) {
|
.attr('class', function (d) {
|
||||||
for (var i = 0; i < categories.length; i++) {
|
for (let i = 0; i < categories.length; i++) {
|
||||||
if (d.type === categories[i]) {
|
if (d.type === categories[i]) {
|
||||||
return 'section section' + (i % conf.numberSectionStyles)
|
return 'section section' + (i % conf.numberSectionStyles)
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ export const draw = function (text, id) {
|
||||||
return 'section section0'
|
return 'section section0'
|
||||||
})
|
})
|
||||||
|
|
||||||
var rectangles = svg.append('g')
|
const rectangles = svg.append('g')
|
||||||
.selectAll('rect')
|
.selectAll('rect')
|
||||||
.data(theArray)
|
.data(theArray)
|
||||||
.enter()
|
.enter()
|
||||||
|
@ -151,10 +151,10 @@ export const draw = function (text, id) {
|
||||||
})
|
})
|
||||||
.attr('height', theBarHeight)
|
.attr('height', theBarHeight)
|
||||||
.attr('class', function (d) {
|
.attr('class', function (d) {
|
||||||
var res = 'task '
|
const res = 'task '
|
||||||
|
|
||||||
var secNum = 0
|
let secNum = 0
|
||||||
for (var i = 0; i < categories.length; i++) {
|
for (let i = 0; i < categories.length; i++) {
|
||||||
if (d.type === categories[i]) {
|
if (d.type === categories[i]) {
|
||||||
secNum = (i % conf.numberSectionStyles)
|
secNum = (i % conf.numberSectionStyles)
|
||||||
}
|
}
|
||||||
|
@ -189,9 +189,9 @@ export const draw = function (text, id) {
|
||||||
})
|
})
|
||||||
.attr('font-size', conf.fontSize)
|
.attr('font-size', conf.fontSize)
|
||||||
.attr('x', function (d) {
|
.attr('x', function (d) {
|
||||||
var startX = timeScale(d.startTime)
|
const startX = timeScale(d.startTime)
|
||||||
var endX = timeScale(d.endTime)
|
const endX = timeScale(d.endTime)
|
||||||
var textWidth = this.getBBox().width
|
const textWidth = this.getBBox().width
|
||||||
|
|
||||||
// Check id text width > width of rectangle
|
// Check id text width > width of rectangle
|
||||||
if (textWidth > (endX - startX)) {
|
if (textWidth > (endX - startX)) {
|
||||||
|
@ -209,17 +209,17 @@ export const draw = function (text, id) {
|
||||||
})
|
})
|
||||||
.attr('text-height', theBarHeight)
|
.attr('text-height', theBarHeight)
|
||||||
.attr('class', function (d) {
|
.attr('class', function (d) {
|
||||||
var startX = timeScale(d.startTime)
|
const startX = timeScale(d.startTime)
|
||||||
var endX = timeScale(d.endTime)
|
const endX = timeScale(d.endTime)
|
||||||
var textWidth = this.getBBox().width
|
const textWidth = this.getBBox().width
|
||||||
var secNum = 0
|
let secNum = 0
|
||||||
for (var i = 0; i < categories.length; i++) {
|
for (let i = 0; i < categories.length; i++) {
|
||||||
if (d.type === categories[i]) {
|
if (d.type === categories[i]) {
|
||||||
secNum = (i % conf.numberSectionStyles)
|
secNum = (i % conf.numberSectionStyles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var taskType = ''
|
let taskType = ''
|
||||||
if (d.active) {
|
if (d.active) {
|
||||||
if (d.crit) {
|
if (d.crit) {
|
||||||
taskType = 'activeCritText' + secNum
|
taskType = 'activeCritText' + secNum
|
||||||
|
@ -254,7 +254,7 @@ export const draw = function (text, id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeGrid (theSidePad, theTopPad, w, h) {
|
function makeGrid (theSidePad, theTopPad, w, h) {
|
||||||
var pre = [
|
const pre = [
|
||||||
['.%L', function (d) {
|
['.%L', function (d) {
|
||||||
return d.getMilliseconds()
|
return d.getMilliseconds()
|
||||||
}],
|
}],
|
||||||
|
@ -265,12 +265,12 @@ export const draw = function (text, id) {
|
||||||
['h1 %I:%M', function (d) {
|
['h1 %I:%M', function (d) {
|
||||||
return d.getMinutes()
|
return d.getMinutes()
|
||||||
}]]
|
}]]
|
||||||
var post = [
|
const post = [
|
||||||
['%Y', function () {
|
['%Y', function () {
|
||||||
return true
|
return true
|
||||||
}]]
|
}]]
|
||||||
|
|
||||||
var mid = [
|
let mid = [
|
||||||
// Within a day
|
// Within a day
|
||||||
['%I:%M', function (d) {
|
['%I:%M', function (d) {
|
||||||
return d.getHours()
|
return d.getHours()
|
||||||
|
@ -288,11 +288,11 @@ export const draw = function (text, id) {
|
||||||
return d.getMonth()
|
return d.getMonth()
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
var formatter
|
let formatter
|
||||||
if (typeof conf.axisFormatter !== 'undefined') {
|
if (typeof conf.axisFormatter !== 'undefined') {
|
||||||
mid = []
|
mid = []
|
||||||
conf.axisFormatter.forEach(function (item) {
|
conf.axisFormatter.forEach(function (item) {
|
||||||
var n = []
|
const n = []
|
||||||
n[0] = item[0]
|
n[0] = item[0]
|
||||||
n[1] = item[1]
|
n[1] = item[1]
|
||||||
mid.push(n)
|
mid.push(n)
|
||||||
|
@ -300,7 +300,7 @@ export const draw = function (text, id) {
|
||||||
}
|
}
|
||||||
formatter = pre.concat(mid).concat(post)
|
formatter = pre.concat(mid).concat(post)
|
||||||
|
|
||||||
var xAxis = d3.svg.axis()
|
let xAxis = d3.svg.axis()
|
||||||
.scale(timeScale)
|
.scale(timeScale)
|
||||||
.orient('bottom')
|
.orient('bottom')
|
||||||
.tickSize(-h + theTopPad + conf.gridLineStartPadding, 0, 0)
|
.tickSize(-h + theTopPad + conf.gridLineStartPadding, 0, 0)
|
||||||
|
@ -323,10 +323,10 @@ export const draw = function (text, id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function vertLabels (theGap, theTopPad) {
|
function vertLabels (theGap, theTopPad) {
|
||||||
var numOccurances = []
|
const numOccurances = []
|
||||||
var prevGap = 0
|
let prevGap = 0
|
||||||
|
|
||||||
for (var i = 0; i < categories.length; i++) {
|
for (let i = 0; i < categories.length; i++) {
|
||||||
numOccurances[i] = [categories[i], getCount(categories[i], catsUnfiltered)]
|
numOccurances[i] = [categories[i], getCount(categories[i], catsUnfiltered)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ export const draw = function (text, id) {
|
||||||
.attr('x', 10)
|
.attr('x', 10)
|
||||||
.attr('y', function (d, i) {
|
.attr('y', function (d, i) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
for (var j = 0; j < i; j++) {
|
for (let j = 0; j < i; j++) {
|
||||||
prevGap += numOccurances[i - 1][1]
|
prevGap += numOccurances[i - 1][1]
|
||||||
return d[1] * theGap / 2 + prevGap * theGap + theTopPad
|
return d[1] * theGap / 2 + prevGap * theGap + theTopPad
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ export const draw = function (text, id) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.attr('class', function (d) {
|
.attr('class', function (d) {
|
||||||
for (var i = 0; i < categories.length; i++) {
|
for (let i = 0; i < categories.length; i++) {
|
||||||
if (d[0] === categories[i]) {
|
if (d[0] === categories[i]) {
|
||||||
return 'sectionTitle sectionTitle' + (i % conf.numberSectionStyles)
|
return 'sectionTitle sectionTitle' + (i % conf.numberSectionStyles)
|
||||||
}
|
}
|
||||||
|
@ -360,10 +360,10 @@ export const draw = function (text, id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawToday (theSidePad, theTopPad, w, h) {
|
function drawToday (theSidePad, theTopPad, w, h) {
|
||||||
var todayG = svg.append('g')
|
const todayG = svg.append('g')
|
||||||
.attr('class', 'today')
|
.attr('class', 'today')
|
||||||
|
|
||||||
var today = new Date()
|
const today = new Date()
|
||||||
|
|
||||||
todayG.append('line')
|
todayG.append('line')
|
||||||
.attr('x1', timeScale(today) + theSidePad)
|
.attr('x1', timeScale(today) + theSidePad)
|
||||||
|
@ -375,9 +375,9 @@ export const draw = function (text, id) {
|
||||||
|
|
||||||
// from this stackexchange question: http://stackoverflow.com/questions/1890203/unique-for-arrays-in-javascript
|
// from this stackexchange question: http://stackoverflow.com/questions/1890203/unique-for-arrays-in-javascript
|
||||||
function checkUnique (arr) {
|
function checkUnique (arr) {
|
||||||
var hash = {}
|
const hash = {}
|
||||||
var result = []
|
const result = []
|
||||||
for (var i = 0, l = arr.length; i < l; ++i) {
|
for (let i = 0, l = arr.length; i < l; ++i) {
|
||||||
if (!hash.hasOwnProperty(arr[i])) { // it works with objects! in FF, at least
|
if (!hash.hasOwnProperty(arr[i])) { // it works with objects! in FF, at least
|
||||||
hash[arr[i]] = true
|
hash[arr[i]] = true
|
||||||
result.push(arr[i])
|
result.push(arr[i])
|
||||||
|
@ -388,8 +388,8 @@ export const draw = function (text, id) {
|
||||||
|
|
||||||
// from this stackexchange question: http://stackoverflow.com/questions/14227981/count-how-many-strings-in-an-array-have-duplicates-in-the-same-array
|
// from this stackexchange question: http://stackoverflow.com/questions/14227981/count-how-many-strings-in-an-array-have-duplicates-in-the-same-array
|
||||||
function getCounts (arr) {
|
function getCounts (arr) {
|
||||||
var i = arr.length // var to loop over
|
let i = arr.length // const to loop over
|
||||||
var obj = {} // obj to store results
|
const obj = {} // obj to store results
|
||||||
while (i) {
|
while (i) {
|
||||||
obj[arr[--i]] = (obj[arr[i]] || 0) + 1 // count occurrences
|
obj[arr[--i]] = (obj[arr[i]] || 0) + 1 // count occurrences
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue