Skip to content

Commit

Permalink
extended date ranges to fix occasional bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kornysietsma committed Oct 25, 2020
1 parent 040908d commit 363051d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.4.3] - 2020-10-25

### Changed

- Fixed date scale, so it starts and ends one day earlier/later - otherwise sometimes had problems if commits happened on the very last day in the range.

## [0.4.2] - 2020-10-13

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polyglot-code-explorer",
"version": "0.4.2",
"version": "0.4.3",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.1",
Expand Down
3 changes: 2 additions & 1 deletion src/State.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function initialiseGlobalState(initialDataRef) {
const twoYearsAgo = moment.unix(latestCommit).subtract(2, "year").unix();

const earliest = twoYearsAgo < earliestCommit ? earliestCommit : twoYearsAgo;
const latest = moment.unix(latestCommit).add(1, "day").unix(); // otherwise files committed today get confused
const couplingAvailable = coupling !== undefined;

const defaults = {
Expand Down Expand Up @@ -149,7 +150,7 @@ function initialiseGlobalState(initialDataRef) {
},
dateRange: {
earliest,
latest: latestCommit,
latest,
},
selectedNode: null,
},
Expand Down
12 changes: 11 additions & 1 deletion src/Viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ const draw = (d3Container, files, metadata, state, dispatch) => {
);
};

function addDays(date, days) {
const result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}

function drawTimescale(d3TimescaleContainer, timescaleData, state, dispatch) {
const { config } = state;
const {
Expand Down Expand Up @@ -353,9 +359,13 @@ function drawTimescale(d3TimescaleContainer, timescaleData, state, dispatch) {

const yMax = d3.max(timescaleData, valueFn);

const dateRange = d3.extent(timescaleData, (d) => d.day);
dateRange[0] = addDays(dateRange[0], -1);
dateRange[1] = addDays(dateRange[1], 1);

const xScale = d3
.scaleUtc()
.domain(d3.extent(timescaleData, (d) => d.day))
.domain(dateRange)
.range([margin.left, width - margin.right, width]);
const yScale = d3
.scaleLinear()
Expand Down

0 comments on commit 363051d

Please sign in to comment.