Skip to content

Commit

Permalink
Merge pull request #83 from sebastienbarbier/develop
Browse files Browse the repository at this point in the history
Release 1.1.2
  • Loading branch information
sebastienbarbier authored Dec 19, 2022
2 parents 6452290 + 7ea5322 commit 81a6e49
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
See for sample https://raw.githubusercontent.com/favoloso/conventional-changelog-emoji/master/CHANGELOG.md
-->

## [1.1.2] - 2022-12-19
### 🐛 Bug Fixes
- CalendarGraph crash on start (#82)

## [1.1.1] - 2022-12-16
### 🐛 Bug Fixes
- Sync is broken on update event (#78)
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": "seven23",
"version": "1.0.1",
"version": "1.1.2",
"description": "seven23",
"scripts": {
"start": "webpack-dev-server --config webpack-dev-server.config.js",
Expand Down
41 changes: 22 additions & 19 deletions src/app/components/charts/CalendarGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,26 @@ export default function CalendarGraph({ values, isLoading, color, quantile=0.90,
}, [color, theme.palette.primary.main]);

const draw = (_svg) => {

// Somehow call calendar
_svg.selectAll("g").remove();
if (array || animateLoading) {
let weeksCounter = 0;
if (array && array.length) {
weeksCounter = Math.min(moment.duration(moment(array[array.length - 1].date).diff(moment(array[0].date))).as('weeks'), 52);
try {
// Somehow call calendar
_svg.selectAll("g").remove();
if (array || animateLoading) {
let weeksCounter = 0;
if (array && array.length) {
weeksCounter = Math.min(moment.duration(moment(array[array.length - 1].date).diff(moment(array[0].date))).as('weeks'), 52);
}
Calendar(_svg, array, {
x: value => value.date,
y: value => value.amount,
width: +_svg._groups[0][0].parentNode.clientWidth,
cellSize: Math.min(52 * 10 / weeksCounter, 10), // if 52 then 10.
colors: d3.interpolateRgb.gamma(2.2)(d3.color(`${primaryColor}`), d3.color(`${primaryColor}20`))
});
}

Calendar(_svg, array, {
x: value => value.date,
y: value => value.amount,
width: +_svg._groups[0][0].parentNode.clientWidth,
cellSize: Math.min(52 * 10 / weeksCounter, 10), // if 52 then 10.
colors: d3.interpolateRgb.gamma(2.2)(d3.color(`${primaryColor}`), d3.color(`${primaryColor}20`))
});
} catch (error) {
// Handle exception on crash after #82
console.error(error);
}
};

Expand Down Expand Up @@ -148,15 +152,15 @@ export default function CalendarGraph({ values, isLoading, color, quantile=0.90,
}

if (animateLoading && data.length === 0) {
let i = moment().endOf('month').toDate().getTime();
const until = moment().subtract(monthPerLine-1, 'months').startOf('month').add(1, 'day').toDate().getTime();
while (i > until) {
i = i - (1000*60*60*24);
let i = moment().utc().endOf('month').toDate().getTime();
const until = moment().utc().subtract(monthPerLine-1, 'months').startOf('month').toDate().getTime();
while (i >= until) {
// Generate zero amount for each days of the first row
data.push({
date: new Date(i),
amount: 0,
});
i = i - (1000*60*60*24);
}
data.reverse();
}
Expand Down Expand Up @@ -230,7 +234,6 @@ export default function CalendarGraph({ values, isLoading, color, quantile=0.90,
list.push(i);
}
})

years.push([X[list[0]].getFullYear(), list]);
}
}
Expand Down

0 comments on commit 81a6e49

Please sign in to comment.