Skip to content

Commit

Permalink
fix: remove errors in console
Browse files Browse the repository at this point in the history
  • Loading branch information
QuCMGisaia committed Jul 30, 2024
1 parent c85408a commit de2c47c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/histograms/brushes/brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ export abstract class Brush {
});
}



protected abstract drawHandles(): void;

protected checkSelectionNotNaN(selection: BrushSelection): boolean {
return selection.every(v => {

Check failure on line 69 in src/histograms/brushes/brush.ts

View workflow job for this annotation

GitHub Actions / Lint, Build, Test & Documentation

This expression is not callable.
if (typeof v === 'number') {
return !isNaN(v);
} else {
return v.every(s => !isNaN(s));
}
});
}
}
2 changes: 1 addition & 1 deletion src/histograms/brushes/rectangle-brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class RectangleBrush extends Brush {

public translateBrushHandles(selection: BrushSelection) {
const xTranslation = this.handleHeight - (this.dimensions.height - this.handleHeight) / 2;
if (selection !== null) {
if (selection !== null && this.checkSelectionNotNaN(selection)) {
this.handles.attr('display', null).attr('transform', (d, i) =>
'translate(' + [selection[i], -xTranslation] + ')');
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/histograms/brushes/slider-brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class SliderBrush extends Brush {
}

public translateBrushHandles(selection: BrushSelection) {
if (selection !== null) {
if (selection !== null && this.checkSelectionNotNaN(selection)) {
this.handles.attr('display', null).attr('transform', (d, i) =>
'translate(' + [selection[i], 0] + ')');
this.lineContext.selection()
Expand Down
6 changes: 3 additions & 3 deletions src/histograms/charts/AbstractChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@ export abstract class AbstractChart extends AbstractHistogram {
.tickFormat(d => !this.histogramParams.shortYLabels ? tickNumberFormat(d, this.histogramParams.numberFormatChar) : format('~s')(d));
}

protected drawYAxis(chartAxes: ChartAxes, chartIdsToSide?: Map<string, string>, chartId?: string): void {
protected drawYAxis(chartAxes: ChartAxes, chartIdsToSide?: Map<string, 'left' | 'right'>, chartId?: string): void {
// yTicksAxis and yLabelsAxis are translated of 1px to the left so that they are not hidden by the histogram
let translate = 'translate(-1, 0)';
let side;
let side: 'left' | 'right';
if (!!chartId && !!chartIdsToSide) {
side = chartIdsToSide.get(chartId);
}
Expand All @@ -484,7 +484,7 @@ export abstract class AbstractChart extends AbstractHistogram {
if (side === 'right') {
translate = 'translate('.concat((this.chartDimensions.width + 1).toString()).concat(', 0)');
}
let axisColor;
let axisColor: string;
if (!!chartId && !!this.histogramParams.colorGenerator) {
axisColor = this.histogramParams.colorGenerator.getColor(chartId);
}
Expand Down
2 changes: 1 addition & 1 deletion src/histograms/charts/ChartCurve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ChartCurve extends AbstractChart {
if (chartIdToData.size === 0) {
chartIdToData.set('default', data);
}
const chartIdsToSides = new Map();
const chartIdsToSides = new Map<string, 'left' | 'right'>();
let i = 0;
const dataArray: Array<Array<HistogramData>> = [];
chartIdToData.forEach((values, id) => {
Expand Down

0 comments on commit de2c47c

Please sign in to comment.