latest v of ss.js

This commit is contained in:
jlord 2013-08-03 22:24:50 -07:00
parent 9beda801cf
commit 1ca16208e5
1 changed files with 47 additions and 154 deletions

View File

@ -8,7 +8,6 @@ function exportFunctions(exports) {
function initiateTableFilter(data, filterDiv, tableDiv) {
$('.clear').on("click", function() {
console.log(this)
$(this.id + ".noMatches").css("visibility", "hidden")
$(this.id + filterDiv).val("")
makeTable(data, tableDiv)
@ -23,9 +22,8 @@ function searchTable(data, searchTerm, tableDiv) {
var filteredList = []
data.forEach(function(object) {
var stringObject = JSON.stringify(object).toLowerCase()
if (stringObject.match(searchTerm)) filteredList.push(object)
if (stringObject.match(searchTerm.toLowerCase())) filteredList.push(object)
})
// if ($('#tableFilter').val("")) makeTable(data, tableDiv)
if (filteredList.length === 0) {
console.log("no matchie")
$(".noMatches").css("visibility", "inherit")
@ -60,8 +58,6 @@ function resolveDataTitle(string) {
function sendToSort(event) {
var tableDiv = "#" + $(event.target).closest("div").attr("id")
console.log("came from this table",tableDiv)
// var dataset = $(tableDiv).attr('dataset')
// console.log("made with this data", dataset, typeof dataset)
var sorted = $(event.target).attr("data-sorted")
if (sorted) {
if (sorted === "descending") sorted = "ascending"
@ -89,7 +85,6 @@ function makeTable(data, targetDiv) {
// // // // // // // // // // // // // // // // // // // // // // // // // //
function getKeywordCount(data, keyword) {
console.log(data, keyword)
var group = []
data.forEach(function (d) {
for(var key in d) {
@ -102,7 +97,6 @@ function getKeywordCount(data, keyword) {
}
function getKeyword(data, keyword) {
console.log(data, keyword)
var group = []
data.forEach(function (d) {
for(var key in d) {
@ -169,14 +163,8 @@ function getMin(data, column){
function getMatches(data, filter, category) {
var matches = []
data.forEach(function (element) {
if (category === 'rowNumber') {
var projectType = element[category].toString()
if (projectType === filter) matches.push(element)
}
else {
var projectType = element[category].toLowerCase()
if (projectType === filter.toLowerCase()) matches.push(element)
}
})
return matches
}
@ -255,7 +243,6 @@ function makeColorArrayOfObject(data, colors) {
})
}
function makeArrayOfObject(data) {
var keys = Object.keys(data)
return keys.map(function(key){
@ -457,24 +444,6 @@ function d3BarChart(data, options) {
if (options.xaxis) return options.xaxis
return
})
d3.select("input").on("change", change)
function change() {
// Copy-on-write since in betweens are evaluated after a delay.
var y0 = y.domain(data.sort(this.checked
? function(a, b) { return b.units - a.units }
: function(a, b) { return d3.ascending(a.label, b.label) })
.map(function(d) { return d.label }))
.copy()
var transition = svg.transition().duration(750),
delay = function(d, i) { return i * 50 }
transition.selectAll(".bar")
.delay(delay)
.attr("transform", function(d) { return "translate(0," + y(d.label) + ")" })
}
}
// Pie Chart
@ -557,54 +526,13 @@ function mouseOut(d) {
.style("fill", function(d) { return d.data.hexcolor})
.attr("fill", function(d) { return d.data.hexcolor})
// g.append("text")
// .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")" })
// .attr("dy", ".35em")
// .attr("dx", ".35em")
// .attr("class", "pieTip")
// .style("text-anchor", "middle")
// .text(function(d) { return d.data.units })
// var labelr = radius + 8 // radius for label anchor
// g.append("text")
// .attr("transform", function(d) {
// var c = arc.centroid(d),
// x = c[0],
// y = c[1],
// // pythagorean theorem for hypotenuse
// h = Math.sqrt(x*x + y*y)
// return "translate(" + (x/h * labelr) + ',' +
// (y/h * labelr) + ")"
// })
// .attr("dy", ".35em")
// .attr("fill", "#333")
// .attr("class", "pieTip")
// .attr("text-anchor", function(d) {
// // are we past the center?
// return (d.endAngle + d.startAngle)/2 > Math.PI ?
// "end" : "start"
// })
// .text(function(d) { return d.data.units })
// svg.selectAll("rect")
// .data(data)
// .enter().append("g")
// .append("rect")
// .attr("width", 100)
// .attr("height", 26)
// .attr("fill", function(d) { return d.hexcolor })
// .attr("x", 0)
// .attr("y", "-140px") // Controls padding to place text above bars
svg.selectAll("g.labels")
.data(data)
.enter().append("g") // Append legend elements
.append("text")
.attr("text-anchor", "start")
.attr("x", width / 2.5)
.attr("y", function(d, i) { return data.length + i*(data.length * 2)})
.attr("y", function(d, i) { return (height / 2) - i*(data.length * 20)})
.attr("dx", 0)
.attr("dy", "-140px") // Controls padding to place text above bars
.text(function(d) { return d.label + ", " + d.units})
@ -613,42 +541,7 @@ svg.selectAll("g.labels")
.attr("class", function(d, i) { return "labels-" + "index-" + i + " aLabel "})
.on('mouseover', mouseOver)
.on("mouseout", mouseOut)
d3.select("input").on("change", change)
function change() {
console.log("checked/unchecked")
// Copy-on-write since in betweens are evaluated after a delay.
// pie.sort(function(a, b) { return b.units - a.units })
path = path.data(pie(data).sort(function(a, b) { return b.units - a.units; })); // update the data
path.attr("d", arc)
// path.transition().duration(750).attrTween("d", arcTween)
// var pie = d3.layout.pie()
// .sort(null)
// .value(function(d) { return d.units })
// function change() {
// clearTimeout(timeout);
// path = path.data(pie(dataset[this.value])); // update the data
// path.attr("d", arc); // redraw the arcs
// }
function arcTween(a) {
var i = d3.interpolate(this._current, a);
this._current = i(0);
return function(t) {
return arc(i(t));
};
}
var transition = svg.transition().duration(750),
delay = function(d, i) { return i * 50 }
transition.selectAll(".path")
.delay(delay)
}
}
// Line Chart