feat: experimental! allow overrriding yAxisLabels
This commit is contained in:
parent
3a16d6c30c
commit
f333096012
@ -147,7 +147,7 @@ export default class AxisChart extends BaseChart {
|
|||||||
|
|
||||||
// if we have an object we have multiple yAxisParameters.
|
// if we have an object we have multiple yAxisParameters.
|
||||||
if (dataValues instanceof Array) {
|
if (dataValues instanceof Array) {
|
||||||
yPts = calcChartIntervals(dataValues, withMinimum);
|
yPts = calcChartIntervals(dataValues, withMinimum, this.config.overrideCeiling, this.config.overrideFloor);
|
||||||
scaleMultiplier = this.height / getValueRange(yPts);
|
scaleMultiplier = this.height / getValueRange(yPts);
|
||||||
intervalHeight = getIntervalSize(yPts) * scaleMultiplier;
|
intervalHeight = getIntervalSize(yPts) * scaleMultiplier;
|
||||||
zeroLine = this.height - getZeroIndex(yPts) * intervalHeight;
|
zeroLine = this.height - getZeroIndex(yPts) * intervalHeight;
|
||||||
@ -170,7 +170,7 @@ export default class AxisChart extends BaseChart {
|
|||||||
yAxisAlignment = yAxisConfigObject.position
|
yAxisAlignment = yAxisConfigObject.position
|
||||||
? yAxisConfigObject.position
|
? yAxisConfigObject.position
|
||||||
: "left";
|
: "left";
|
||||||
yPts = calcChartIntervals(dataValue, withMinimum);
|
yPts = calcChartIntervals(dataValue, withMinimum, this.config.overrideCeiling, this.config.overrideFloor);
|
||||||
scaleMultiplier = this.height / getValueRange(yPts);
|
scaleMultiplier = this.height / getValueRange(yPts);
|
||||||
intervalHeight = getIntervalSize(yPts) * scaleMultiplier;
|
intervalHeight = getIntervalSize(yPts) * scaleMultiplier;
|
||||||
zeroLine = this.height - getZeroIndex(yPts) * intervalHeight;
|
zeroLine = this.height - getZeroIndex(yPts) * intervalHeight;
|
||||||
|
|||||||
@ -56,6 +56,8 @@ export default class BaseChart {
|
|||||||
: 1,
|
: 1,
|
||||||
isNavigable: options.isNavigable || 0,
|
isNavigable: options.isNavigable || 0,
|
||||||
animate: 0,
|
animate: 0,
|
||||||
|
overrideCeiling: options.overrideCeiling || false,
|
||||||
|
overrideFloor: options.overrideFloor || false,
|
||||||
truncateLegends:
|
truncateLegends:
|
||||||
typeof options.truncateLegends !== "undefined"
|
typeof options.truncateLegends !== "undefined"
|
||||||
? options.truncateLegends
|
? options.truncateLegends
|
||||||
|
|||||||
@ -81,7 +81,7 @@ function getChartIntervals(maxValue, minValue = 0) {
|
|||||||
return intervals;
|
return intervals;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calcChartIntervals(values, withMinimum = false) {
|
export function calcChartIntervals(values, withMinimum = true, overrideCeiling=false, overrideFloor=false) {
|
||||||
//*** Where the magic happens ***
|
//*** Where the magic happens ***
|
||||||
|
|
||||||
// Calculates best-fit y intervals from given values
|
// Calculates best-fit y intervals from given values
|
||||||
@ -90,6 +90,14 @@ export function calcChartIntervals(values, withMinimum = false) {
|
|||||||
let maxValue = Math.max(...values);
|
let maxValue = Math.max(...values);
|
||||||
let minValue = Math.min(...values);
|
let minValue = Math.min(...values);
|
||||||
|
|
||||||
|
if (overrideCeiling) {
|
||||||
|
maxValue = overrideCeiling
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overrideFloor) {
|
||||||
|
minValue = overrideFloor
|
||||||
|
}
|
||||||
|
|
||||||
// Exponent to be used for pretty print
|
// Exponent to be used for pretty print
|
||||||
let exponent = 0,
|
let exponent = 0,
|
||||||
intervals = []; // eslint-disable-line no-unused-vars
|
intervals = []; // eslint-disable-line no-unused-vars
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user