60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
import { fillArray } from '../utils/helpers';
|
|
|
|
const MIN_BAR_PERCENT_HEIGHT = 0.01;
|
|
|
|
export function getBarHeightAndYAttr(yTop, zeroLine, totalHeight) {
|
|
let height, y;
|
|
if (yTop <= zeroLine) {
|
|
height = zeroLine - yTop;
|
|
y = yTop;
|
|
|
|
// In case of invisible bars
|
|
if(height === 0) {
|
|
height = totalHeight * MIN_BAR_PERCENT_HEIGHT;
|
|
y -= height;
|
|
}
|
|
} else {
|
|
height = yTop - zeroLine;
|
|
y = zeroLine;
|
|
|
|
// In case of invisible bars
|
|
if(height === 0) {
|
|
height = totalHeight * MIN_BAR_PERCENT_HEIGHT;
|
|
}
|
|
}
|
|
|
|
return [height, y];
|
|
}
|
|
|
|
export function equilizeNoOfElements(array1, array2,
|
|
extra_count=array2.length - array1.length) {
|
|
|
|
if(extra_count > 0) {
|
|
array1 = fillArray(array1, extra_count);
|
|
} else {
|
|
array2 = fillArray(array2, extra_count);
|
|
}
|
|
return [array1, array2];
|
|
}
|
|
|
|
// let char_width = 8;
|
|
// let allowed_space = avgUnitWidth * 1.5;
|
|
// let allowed_letters = allowed_space / 8;
|
|
|
|
// return values.map((value, i) => {
|
|
// let space_taken = getStringWidth(value, char_width) + 2;
|
|
// if(space_taken > allowed_space) {
|
|
// if(is_series) {
|
|
// // Skip some axis lines if X axis is a series
|
|
// let skips = 1;
|
|
// while((space_taken/skips)*2 > allowed_space) {
|
|
// skips++;
|
|
// }
|
|
// if(i % skips !== 0) {
|
|
// return;
|
|
// }
|
|
// } else {
|
|
// value = value.slice(0, allowed_letters-3) + " ...";
|
|
// }
|
|
// }
|