diff options
author | srichman333 <sarah_n_richman@brown.edu> | 2023-07-12 16:25:22 -0400 |
---|---|---|
committer | srichman333 <sarah_n_richman@brown.edu> | 2023-07-12 16:25:22 -0400 |
commit | d20a4b3791c79325c709c42f797452275f2da312 (patch) | |
tree | a339d3d414f67bbffbae0d0a1243899c8a62aaeb /src | |
parent | 217f656cd39701d87bc298717551ae78e5b9eb13 (diff) |
histogram bar width fix
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/DataVizBox/components/Histogram.tsx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/Histogram.tsx b/src/client/views/nodes/DataVizBox/components/Histogram.tsx index f9410a580..e4267aee3 100644 --- a/src/client/views/nodes/DataVizBox/components/Histogram.tsx +++ b/src/client/views/nodes/DataVizBox/components/Histogram.tsx @@ -278,17 +278,17 @@ export class Histogram extends React.Component<HistogramProps> { .domain([0, numBins]) .range([0, width]); } - + var histogram = d3.histogram() .value(function(d) {return d}) .domain([startingPoint!, endingPoint!]) - .thresholds(x.ticks(numBins)) + .thresholds(x.ticks(numBins-1)) var bins = histogram(data) - var eachRectWidth = width/(bins.length+1) + var eachRectWidth = width/(bins.length) var graphStartingPoint = bins[0].x1! - (bins[1].x1! - bins[1].x0!) bins[0].x0 = graphStartingPoint; x = x.domain([graphStartingPoint, endingPoint]) - .range([0, width - eachRectWidth]) + .range([0, Number.isInteger(this.rangeVals.xMin!)? (width-eachRectWidth) : width ]) var xAxis; if (!this.numericalData) { // if the data is strings rather than numbers @@ -345,7 +345,6 @@ export class Histogram extends React.Component<HistogramProps> { .data(bins) .enter() .append("rect") - .attr("x", 1) .attr("transform", function(d) { return "translate(" + x(d.x0!) + "," + y(d.length) + ")"; }) .attr("width", eachRectWidth) .attr("height", function(d) { return height - y(d.length); }) |