[heatmap] fix start, end render extrapolation

This commit is contained in:
Prateeksha Singh 2018-04-15 14:00:43 +05:30
parent eb3041ae4f
commit 620382a431
11 changed files with 25 additions and 18 deletions

View File

@ -282,10 +282,6 @@ class SvgTip {
}
}
/**
* Returns the value of a number upto 2 decimal places.
* @param {Number} d Any number
*/
function floatTwo(d) {
return parseFloat(d.toFixed(2));
}
@ -2687,7 +2683,7 @@ class Heatmap extends BaseChart {
s.start = clone(this.data.start);
s.end = clone(this.data.end);
s.firstWeekStart = setDayToSunday(s.start);
s.firstWeekStart = clone(s.start);
s.noOfWeeks = getWeeksBetween(s.start, s.end);
s.distribution = calcDistribution(
Object.values(this.data.dataPoints), HEATMAP_DISTRIBUTION_SIZE);
@ -2866,13 +2862,19 @@ class Heatmap extends BaseChart {
}
getCol(startDate, month, empty = false) {
let s = this.state;
// startDate is the start of week
let currentDate = clone(startDate);
let col = [];
for(var i = 0; i < NO_OF_DAYS_IN_WEEK; i++, addDays(currentDate, 1)) {
let config = {};
if(empty || currentDate.getMonth() !== month) {
// Non-generic adjustment for entire heatmap, needs state
let currentDateWithinData = currentDate >= s.start && currentDate <= s.end;
if(empty || currentDate.getMonth() !== month || !currentDateWithinData) {
config.yyyyMmDd = getYyyyMmDd(currentDate);
} else {
config = this.getSubDomainConfig(currentDate);
@ -3577,7 +3579,6 @@ class AxisChart extends BaseChart {
// removeDataPoint(index = 0) {}
}
// import MultiAxisChart from './charts/MultiAxisChart';
const chartTypes = {
// multiaxis: MultiAxisChart,
percentage: PercentageChart,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -177,7 +177,7 @@ export const moonData = {
let today = new Date();
let start = clone(today);
addDays(start, 5);
addDays(start, 4);
let end = clone(start);
start.setFullYear( start.getFullYear() - 2 );
end.setFullYear( end.getFullYear() - 1 );

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -272,7 +272,7 @@ var moonData = {
var today = new Date();
var start = clone(today);
addDays(start, 5);
addDays(start, 4);
var end = clone(start);
start.setFullYear(start.getFullYear() - 2);
end.setFullYear(end.getFullYear() - 1);

File diff suppressed because one or more lines are too long

View File

@ -71,7 +71,7 @@ export default class Heatmap extends BaseChart {
s.start = clone(this.data.start);
s.end = clone(this.data.end);
s.firstWeekStart = setDayToSunday(s.start);
s.firstWeekStart = clone(s.start);
s.noOfWeeks = getWeeksBetween(s.start, s.end);
s.distribution = calcDistribution(
Object.values(this.data.dataPoints), HEATMAP_DISTRIBUTION_SIZE);
@ -250,13 +250,19 @@ export default class Heatmap extends BaseChart {
}
getCol(startDate, month, empty = false) {
let s = this.state;
// startDate is the start of week
let currentDate = clone(startDate);
let col = [];
for(var i = 0; i < NO_OF_DAYS_IN_WEEK; i++, addDays(currentDate, 1)) {
let config = {};
if(empty || currentDate.getMonth() !== month) {
// Non-generic adjustment for entire heatmap, needs state
let currentDateWithinData = currentDate >= s.start && currentDate <= s.end;
if(empty || currentDate.getMonth() !== month || !currentDateWithinData) {
config.yyyyMmDd = getYyyyMmDd(currentDate);
} else {
config = this.getSubDomainConfig(currentDate);