-
Notifications
You must be signed in to change notification settings - Fork 49
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
Showing
6 changed files
with
115 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
.axis path, | ||
.axis line { | ||
.slideraxis { | ||
font: 0px sans-serif; | ||
-webkit-user-select: none; | ||
-moz-user-select: none; | ||
user-select: none; | ||
} | ||
.slideraxis .sliderdomain { | ||
display:none; | ||
fill: none; | ||
stroke: #000; | ||
shape-rendering: crispEdges; | ||
} | ||
.bar { | ||
fill:#c9c9c9; | ||
} | ||
.x.axis path { | ||
display: none; | ||
.slideraxis .sliderhalo { | ||
fill:none; | ||
stroke:#000; | ||
stroke-width:1px; | ||
} | ||
.chrt_ts { | ||
font-size:11px; | ||
.slider .sliderhandle { | ||
fill: #fff; | ||
stroke: #666; | ||
stroke-width: 1px; | ||
pointer-events: none; | ||
} |
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,95 +1,76 @@ | ||
// Slider for data tables | ||
function mkSlider(callerID,low,high) { | ||
|
||
/* Copyright (C) 2013 Paul Halliday <[email protected]> */ | ||
return; | ||
var margin = {top: 3, right: 15, bottom: 3, left: 5}, | ||
width = 100, | ||
height = 10; | ||
|
||
function math(stamp) { | ||
p = stamp.split(":"); | ||
c = p[0] * 60 + p[1]; | ||
return c; | ||
} | ||
|
||
function chartInterval(data) { | ||
|
||
ct = data.split(","); | ||
|
||
var hours = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; | ||
if (high > 1000) high = 1000; | ||
|
||
$.each(ct, function(a,b) { | ||
parts = b.split(":"); | ||
switch (parts[0]) { | ||
case '00': hours[0] = hours[0] + 1; break; | ||
case '01': hours[1] = hours[1] + 1; break; | ||
case '02': hours[2] = hours[2] + 1; break; | ||
case '03': hours[3] = hours[3] + 1; break; | ||
case '04': hours[4] = hours[4] + 1; break; | ||
case '05': hours[5] = hours[5] + 1; break; | ||
case '06': hours[6] = hours[6] + 1; break; | ||
case '07': hours[7] = hours[7] + 1; break; | ||
case '08': hours[8] = hours[8] + 1; break; | ||
case '09': hours[9] = hours[9] + 1; break; | ||
case '10': hours[10] = hours[10] + 1; break; | ||
case '11': hours[11] = hours[11] + 1; break; | ||
case '12': hours[12] = hours[12] + 1; break; | ||
case '13': hours[13] = hours[13] + 1; break; | ||
case '14': hours[14] = hours[14] + 1; break; | ||
case '15': hours[15] = hours[15] + 1; break; | ||
case '16': hours[16] = hours[16] + 1; break; | ||
case '17': hours[17] = hours[17] + 1; break; | ||
case '18': hours[18] = hours[18] + 1; break; | ||
case '19': hours[19] = hours[19] + 1; break; | ||
case '20': hours[20] = hours[20] + 1; break; | ||
case '21': hours[21] = hours[21] + 1; break; | ||
case '22': hours[22] = hours[22] + 1; break; | ||
case '23': hours[23] = hours[23] + 1; break; | ||
} | ||
}); | ||
|
||
var margin = {top: 20, right: 20, bottom: 30, left: 40}, | ||
width = 960 - margin.left - margin.right, | ||
height = 150 - margin.top - margin.bottom; | ||
var x = d3.scale.linear() | ||
.domain([1, high]) | ||
.range([1, width]) | ||
.clamp(true); | ||
|
||
var formatPercent = d3.format(".0%"); | ||
var brush = d3.svg.brush() | ||
.x(x) | ||
.extent([0, 0]) | ||
.on("brush", brushed); | ||
|
||
var x = d3.scale.ordinal() | ||
.rangeRoundBands([0, width], .1); | ||
d3.select("#" + callerID) | ||
.text(""); | ||
|
||
var y = d3.scale.linear() | ||
.range([height, 0]); | ||
|
||
var xAxis = d3.svg.axis() | ||
.scale(x) | ||
.orient("bottom"); | ||
|
||
var yAxis = d3.svg.axis() | ||
.scale(y) | ||
.orient("left") | ||
.tickFormat(formatPercent); | ||
|
||
var svg = d3.select(".chrt_ts").append("svg") | ||
var svg = d3.select("#" + callerID).append("svg") | ||
.attr("width", width + margin.left + margin.right) | ||
.attr("height", height + margin.top + margin.bottom) | ||
.append("g") | ||
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | ||
|
||
svg.append("g") | ||
.attr("class", "x axis") | ||
.attr("transform", "translate(0," + height + ")") | ||
.call(xAxis); | ||
|
||
svg.append("g") | ||
.attr("class", "y axis") | ||
.call(yAxis) | ||
.append("text") | ||
.attr("transform", "rotate(-90)") | ||
.attr("y", 6) | ||
.attr("dy", ".71em") | ||
.style("text-anchor", "end") | ||
.text("Frequency"); | ||
.attr("class", "x slideraxis") | ||
.attr("transform", "translate(0," + height / 2 + ")") | ||
.call(d3.svg.axis() | ||
.scale(x) | ||
.orient("bottom") | ||
.tickFormat(function(d) { return d; }) | ||
.tickSize(0) | ||
.tickPadding(7)) | ||
.select(".domain") | ||
.select(function() { return this.parentNode.appendChild(this.cloneNode(true)); }) | ||
.attr("class", "sliderhalo"); | ||
|
||
var slider = svg.append("g") | ||
.attr("class", "slider") | ||
.call(brush); | ||
|
||
slider.selectAll(".extent,.resize") | ||
.remove(); | ||
|
||
slider.select(".background") | ||
.attr("height", height); | ||
|
||
var handle = slider.append("circle") | ||
.attr("class", "sliderhandle") | ||
.attr("transform", "translate(0," + height / 2 + ")") | ||
.attr("r", 5); | ||
|
||
// Position the brush at our current selection | ||
slider | ||
.call(brush.event) | ||
.transition() | ||
.duration(0) | ||
.call(brush.extent([low, low])) | ||
.call(brush.event); | ||
|
||
function brushed() { | ||
var value = brush.extent()[0]; | ||
if (d3.event.sourceEvent) { | ||
value = x.invert(d3.mouse(this)[0]); | ||
brush.extent([value, value]); | ||
} | ||
|
||
svg.selectAll(".bar") | ||
.data(hours) | ||
.enter().append("rect") | ||
.attr("class", "bar") | ||
.attr("width", x.rangeBand()) | ||
}); | ||
handle.attr("cx", x(value)); | ||
d3.select("#" + callerID + "_lbl").html(value.toFixed(0)); | ||
} | ||
} | ||
|
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