Fixes edges
This commit is contained in:
parent
de62bb828f
commit
a480995139
|
@ -3,6 +3,14 @@ const d3 = require('d3');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
require('./styles.css');
|
require('./styles.css');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param arr
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
function exists(arr) {
|
||||||
|
return arr.find(num => _.isFinite(num));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo: To rename as "DistPlotD3".
|
* @todo: To rename as "DistPlotD3".
|
||||||
*/
|
*/
|
||||||
|
@ -178,15 +186,27 @@ export class CdfChartD3 {
|
||||||
*/
|
*/
|
||||||
getCommonThings() {
|
getCommonThings() {
|
||||||
// Boundaries.
|
// Boundaries.
|
||||||
const xMin = this.attrs.minX
|
const xMin = exists([
|
||||||
|| d3.min(this.attrs.data.continuous.xs)
|
this.attrs.minX,
|
||||||
|| d3.min(this.attrs.data.discrete.xs);
|
d3.min(this.attrs.data.continuous.xs),
|
||||||
const xMax = this.attrs.maxX
|
d3.min(this.attrs.data.discrete.xs),
|
||||||
|| d3.max(this.attrs.data.continuous.xs)
|
]);
|
||||||
|| d3.max(this.attrs.data.discrete.xs);
|
const xMax = exists([
|
||||||
|
this.attrs.maxX,
|
||||||
|
d3.max(this.attrs.data.continuous.xs),
|
||||||
|
d3.max(this.attrs.data.discrete.xs),
|
||||||
|
]);
|
||||||
|
|
||||||
const yMin = d3.min(this.attrs.data.continuous.ys);
|
const yMin = exists([
|
||||||
const yMax = d3.max(this.attrs.data.continuous.ys);
|
this.attrs.minY,
|
||||||
|
d3.min(this.attrs.data.continuous.ys),
|
||||||
|
d3.min(this.attrs.data.discrete.ys),
|
||||||
|
]);
|
||||||
|
const yMax = exists([
|
||||||
|
this.attrs.maxY,
|
||||||
|
d3.max(this.attrs.data.continuous.ys),
|
||||||
|
d3.max(this.attrs.data.discrete.ys),
|
||||||
|
]);
|
||||||
|
|
||||||
// Errors.
|
// Errors.
|
||||||
if (!_.isFinite(xMin)) throw new Error('xMin is undefined');
|
if (!_.isFinite(xMin)) throw new Error('xMin is undefined');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user