2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 01:14:03 +00:00

fix: y limit bug, console logs

This commit is contained in:
18alantom 2022-01-28 01:02:30 +05:30 committed by Alan
parent 2544687ab3
commit 55fc6d8b66
3 changed files with 9 additions and 4 deletions

View File

@ -31,6 +31,10 @@ export function euclideanDistance(
export function getYMax(points: Array<Array<number>>): number { export function getYMax(points: Array<Array<number>>): number {
const maxVal = Math.max(...points.flat()); const maxVal = Math.max(...points.flat());
if (maxVal === 0) {
return 0;
}
const sign = maxVal >= 0 ? 1 : -1; const sign = maxVal >= 0 ? 1 : -1;
const texp = 10 ** Math.floor(Math.log10(Math.abs(maxVal))); const texp = 10 ** Math.floor(Math.log10(Math.abs(maxVal)));
if (sign === 1) { if (sign === 1) {
@ -41,6 +45,10 @@ export function getYMax(points: Array<Array<number>>): number {
export function getYMin(points: Array<Array<number>>): number { export function getYMin(points: Array<Array<number>>): number {
const minVal = Math.min(...points.flat()); const minVal = Math.min(...points.flat());
if (minVal === 0) {
return minVal;
}
const sign = minVal >= 0 ? 1 : -1; const sign = minVal >= 0 ? 1 : -1;
const texp = 10 ** Math.floor(Math.log10(Math.abs(minVal))); const texp = 10 ** Math.floor(Math.log10(Math.abs(minVal)));
if (sign === 1) { if (sign === 1) {

View File

@ -43,7 +43,7 @@ export default {
this.$refs.tooltip.setAttribute('data-show', ''); this.$refs.tooltip.setAttribute('data-show', '');
this.virtualElement = { this.virtualElement = {
getBoundingClientRect: generateGetBoundingClientRect(), getBoundingClientRect: generateGetBoundingClientRect(-1000,-1000),
}; };
this.popper = createPopper(this.virtualElement, this.$refs.tooltip, { this.popper = createPopper(this.virtualElement, this.$refs.tooltip, {
placement: this.placement, placement: this.placement,

View File

@ -57,9 +57,6 @@ export default {
computed: { computed: {
chartData() { chartData() {
const points = [this.periodList.map((p) => this.data[p])]; const points = [this.periodList.map((p) => this.data[p])];
console.log(this.period);
console.log(this.data, this.periodList);
console.log(points);
const colors = [{ positive: '#2490EF', negative: '#B7BFC6' }]; const colors = [{ positive: '#2490EF', negative: '#B7BFC6' }];
const format = (value) => frappe.format(value ?? 0, 'Currency'); const format = (value) => frappe.format(value ?? 0, 'Currency');
const yMax = getYMax(points); const yMax = getYMax(points);