[fix] width and dataByIndex update problem

This commit is contained in:
Prateeksha Singh 2018-04-20 11:03:12 +05:30
parent ee53223020
commit 1ba567dc24
12 changed files with 36 additions and 18 deletions

View File

@ -298,6 +298,10 @@ 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));
}
@ -1458,8 +1462,9 @@ class BaseChart {
bindTooltip() {}
draw(onlyWidthChange=false, init=false) {
this.calc(onlyWidthChange);
this.updateWidth();
this.calc(onlyWidthChange);
this.makeChartArea();
this.setupComponents();
@ -2718,12 +2723,13 @@ class Heatmap extends BaseChart {
let d = this.data;
let spacing = this.discreteDomains ? NO_OF_YEAR_MONTHS : 0;
this.independentWidth = (getWeeksBetween(d.start, d.end)
+ spacing) * COL_WIDTH + m.margins.right + m.margins.left;
+ spacing) * COL_WIDTH + getExtraWidth(m);
}
updateWidth() {
let spacing = this.discreteDomains ? NO_OF_YEAR_MONTHS : 0;
this.baseWidth = (this.state.noOfWeeks + spacing) * COL_WIDTH
let noOfWeeks = this.state.noOfWeeks ? this.state.noOfWeeks : 52;
this.baseWidth = (noOfWeeks + spacing) * COL_WIDTH
+ getExtraWidth(this.measures);
}
@ -3139,8 +3145,9 @@ class AxisChart extends BaseChart {
calc(onlyWidthChange = false) {
this.calcXPositions();
if(onlyWidthChange) return;
this.calcYAxisParameters(this.getAllYValues(), this.type === 'line');
if(!onlyWidthChange) {
this.calcYAxisParameters(this.getAllYValues(), this.type === 'line');
}
this.makeDataByIndex();
}
@ -3666,6 +3673,7 @@ class AxisChart extends BaseChart {
// removeDataPoint(index = 0) {}
}
// import MultiAxisChart from './charts/MultiAxisChart';
const chartTypes = {
bar: AxisChart,
line: AxisChart,

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,12 @@ var HEATMAP_COLORS_YELLOW = ['#ebedf0', '#fdf436', '#ffc700', '#ff9100', '#06001
// Universal constants
/**
* Returns the value of a number upto 2 decimal places.
* @param {Number} d Any number
*/
/**
* Returns whether or not two given arrays are equal.
* @param {Array} arr1 First array
@ -114,7 +120,6 @@ var MONTH_NAMES_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
// https://stackoverflow.com/a/11252167/6495043
function clone(date) {
@ -155,6 +160,8 @@ function addDays(date, numberOfDays) {
date.setDate(date.getDate() + numberOfDays);
}
// Composite Chart
// ================================================================================
var reportCountList = [152, 222, 199, 287, 534, 709, 1179, 1256, 1632, 1856, 1850];
var lineCompositeData = {

File diff suppressed because one or more lines are too long

View File

@ -55,8 +55,9 @@ export default class AxisChart extends BaseChart {
calc(onlyWidthChange = false) {
this.calcXPositions();
if(onlyWidthChange) return;
this.calcYAxisParameters(this.getAllYValues(), this.type === 'line');
if(!onlyWidthChange) {
this.calcYAxisParameters(this.getAllYValues(), this.type === 'line');
}
this.makeDataByIndex();
}

View File

@ -127,8 +127,9 @@ export default class BaseChart {
bindTooltip() {}
draw(onlyWidthChange=false, init=false) {
this.calc(onlyWidthChange);
this.updateWidth();
this.calc(onlyWidthChange);
this.makeChartArea();
this.setupComponents();

View File

@ -39,12 +39,13 @@ export default class Heatmap extends BaseChart {
let d = this.data;
let spacing = this.discreteDomains ? NO_OF_YEAR_MONTHS : 0;
this.independentWidth = (getWeeksBetween(d.start, d.end)
+ spacing) * COL_WIDTH + m.margins.right + m.margins.left;
+ spacing) * COL_WIDTH + getExtraWidth(m);
}
updateWidth() {
let spacing = this.discreteDomains ? NO_OF_YEAR_MONTHS : 0;
this.baseWidth = (this.state.noOfWeeks + spacing) * COL_WIDTH
let noOfWeeks = this.state.noOfWeeks ? this.state.noOfWeeks : 52;
this.baseWidth = (noOfWeeks + spacing) * COL_WIDTH
+ getExtraWidth(this.measures);
}