Add log for createLinearGradient

This commit is contained in:
jaredvu 2023-11-26 17:00:06 -08:00
parent 19a377a9e5
commit fad4284ed5
No known key found for this signature in database
GPG Key ID: B9FE2F3F0A5D523C
2 changed files with 27 additions and 10 deletions

View File

@ -10,6 +10,7 @@ import { getAppTheme } from '@/state/configsSelectors';
import { ROW_HEIGHT, ROW_PADDING_RIGHT, type RowData } from '@/views/Orderbook/OrderbookRow';
import { MustBigNumber } from '@/lib/numbers';
import { log } from '@/lib/telemetry';
export const useDrawOrderbookHistograms = ({
data,
@ -107,15 +108,29 @@ export const useDrawOrderbookHistograms = ({
const barWidth = value ? (value / histogramRange) * histogramBarWidth : 0;
const { gradient, bar } = getXYValues({ barWidth, canvasWidth, gradientMultiplier });
const linearGradient = ctx.createLinearGradient(
gradient.x1,
ROW_HEIGHT / 2,
gradient.x2,
ROW_HEIGHT / 2
);
linearGradient.addColorStop(0, histogramAccentColor);
linearGradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
ctx.fillStyle = linearGradient;
let linearGradient;
try {
linearGradient = ctx.createLinearGradient(
gradient.x1,
ROW_HEIGHT / 2,
gradient.x2,
ROW_HEIGHT / 2
);
linearGradient.addColorStop(0, histogramAccentColor);
linearGradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
ctx.fillStyle = linearGradient;
} catch (err) {
log('Orderbook/createLinearGradient', err, {
x1: gradient.x1,
y1: ROW_HEIGHT / 2,
x2: gradient.x2,
y2: ROW_HEIGHT / 2,
});
ctx.fillStyle = 'rgba(0, 0, 0, 0)';
}
ctx.beginPath();

View File

@ -74,7 +74,9 @@ export const Orderbook = ({
if (asksSlice.length < numRows) {
const emptyRows = new Array(numRows - asksSlice.length).fill(getEmptyRow('ask'));
asksSlice.push(...emptyRows);
} else if (bidsSlice.length < numRows) {
}
if (bidsSlice.length < numRows) {
const emptyRows = new Array(numRows - bidsSlice.length).fill(getEmptyRow('bid'));
bidsSlice.unshift(...emptyRows);
}