Skip to content

Commit

Permalink
fixed request handling in histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
bergos committed Feb 23, 2017
1 parent d98f883 commit 66f15a7
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions lib/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,34 +65,33 @@ Histogram.prototype.render = function () {
this.request = cancelableFetch(this.client.selectQuery(query))

this.request.then(function (res) {
res.json().then(function (histData) {
var data = histData.results.bindings[0].bucket ? histData.results.bindings : []

var scale = d3.scalePow()
.exponent(0.5)
.domain([0, d3.max(data, function (d) { return parseInt(d.histo.value) })])
.range([0, that.height])

/* var colorScale = d3.scalePow()
.exponent(0.5)
.domain([0, d3.max(data, function(d) {return parseInt(d.histo.value)})])
.range(["darkblue","steelblue"])
return res.json()
}).then(function (histData) {
var data = histData.results.bindings[0].bucket ? histData.results.bindings : []

var scale = d3.scalePow()
.exponent(0.5)
.domain([0, d3.max(data, function (d) { return parseInt(d.histo.value) })])
.range([0, that.height])

/* var colorScale = d3.scalePow()
.exponent(0.5)
.domain([0, d3.max(data, function(d) {return parseInt(d.histo.value)})])
.range(["darkblue","steelblue"])
*/

that.histogram.selectAll('.bar')
.data(data)
.enter().append('rect')
.attr('class', 'bar')
.attr('x', function (d) { return d.bucket.value })
.attr('width', '1px')
// .attr("fill", function(d) { return colorScale(d.histo.value) })
.attr('y', function (d) { return that.height - scale(d.histo.value) })
.attr('height', function (d) { return scale(d.histo.value) })
.append('title')
.text(function (d) { return that.tooltip(d.histo.value, new Date(d.bucket_start.value), new Date(d.bucket_end.value)) })
})

this.request = null
that.histogram.selectAll('.bar')
.data(data)
.enter().append('rect')
.attr('class', 'bar')
.attr('x', function (d) { return d.bucket.value })
.attr('width', '1px')
// .attr("fill", function(d) { return colorScale(d.histo.value) })
.attr('y', function (d) { return that.height - scale(d.histo.value) })
.attr('height', function (d) { return scale(d.histo.value) })
.append('title')
.text(function (d) { return that.tooltip(d.histo.value, new Date(d.bucket_start.value), new Date(d.bucket_end.value)) })

that.request = null
}).catch(function (err) {
if (err.message === 'user cancelation') {
// canceled fetch
Expand Down

0 comments on commit 66f15a7

Please sign in to comment.