Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"targz": "^1.0.1",
"tmp": "^0.2.1",
"ts-node": "^10.9.2",
"typescript": "^5.5.3",
"typescript": "^5.8.3",
"utility-types": "^3.10.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions .buildkite/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1116,10 +1116,10 @@ ts-node@^10.9.2:
v8-compile-cache-lib "^3.0.1"
yn "3.1.1"

typescript@^5.5.3:
version "5.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa"
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==
typescript@^5.8.3:
version "5.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e"
integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==

universal-github-app-jwt@^1.0.1:
version "1.1.0"
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@docusaurus/module-type-aliases": "^3.2.1",
"@docusaurus/tsconfig": "^3.2.1",
"@docusaurus/types": "^3.2.1",
"typescript": "~5.5.3"
"typescript": "~5.8.3"
},
"browserslist": {
"production": [
Expand Down
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"playwright-merge-html-reports": "^0.2.3",
"slugify": "^1.6.5",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
"typescript": "^5.8.3"
}
}
8 changes: 4 additions & 4 deletions e2e/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ tslib@^2.0.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==

typescript@^5.5.3:
version "5.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa"
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==
typescript@^5.8.3:
version "5.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e"
integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==

undici-types@~5.26.4:
version "5.26.5"
Expand Down
2 changes: 1 addition & 1 deletion github_bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"smee-client": "^1.2.3",
"ts-jest": "^29.2.6",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
"typescript": "^5.8.3"
},
"engines": {
"node": ">= 10.13.0"
Expand Down
8 changes: 4 additions & 4 deletions github_bot/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3496,10 +3496,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@^5.5.3:
version "5.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa"
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==
typescript@^5.8.3:
version "5.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e"
integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==

uglify-js@^3.1.4:
version "3.15.5"
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"@emotion/react": "^11.10.5",
"@emotion/css": "^11.10.5",
"@mdx-js/loader": "^1.6.6",
"@microsoft/api-documenter": "^7.25.4",
"@microsoft/api-extractor": "^7.47.0",
"@microsoft/api-documenter": "^7.26.27",
"@microsoft/api-extractor": "^7.52.8",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/exec": "^6.0.3",
Expand Down Expand Up @@ -104,8 +104,8 @@
"@types/seedrandom": "^2.4.28",
"@types/url-parse": "^1.4.3",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@typescript-eslint/eslint-plugin": "^8.34.0",
"@typescript-eslint/parser": "^8.34.0",
"babel-loader": "^8.3.0",
"autoprefixer": "^9.0.0",
"backport": "^5.6.6",
Expand Down Expand Up @@ -164,7 +164,7 @@
"ts-prune": "^0.10.3",
"typedoc": "^0.25.4",
"typedoc-plugin-markdown": "^4.0.0-next.36",
"typescript": "^5.5.3",
"typescript": "^5.8.3",
"webpack": "^4.46.0",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import { createCustomCachedSelector } from '../../../../state/create_selector';
export const getChartTypeDescriptionSelector = createCustomCachedSelector(
[getPartitionSpec],
(partitionSpec): string => {
return `${partitionSpec?.layout} chart` ?? 'Partition chart';
return partitionSpec?.layout ? `${partitionSpec?.layout} chart` : 'Partition chart';
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { clamp } from '../../utils/math';
import type { TimeslipConfig } from '../config';
import type { DataState } from '../data_fetch';

const TIMESLIP_MAX_TIME_GRID_COUNT = 100 || MAX_TIME_GRID_COUNT; // use either
const TIMESLIP_MAX_TIME_GRID_COUNT = 100; // MAX_TIME_GRID_COUNT; // use either

interface LoHi {
lo: Interval | null;
Expand Down
5 changes: 3 additions & 2 deletions packages/charts/src/chart_types/xy_chart/domains/x_domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ export function convertXScaleTypes(
const scaleTypes = new Set(specs.map((s) => getXScaleTypeFromSpec(s.xScaleType)));
const niceDomains = specs.map((s) => getXNiceFromSpec(s.xNice));
const timeZone = getZoneFromSpecs(specs);
const firstScaleType = scaleTypes.values().next().value
const type =
scaleTypes.size === 1
? scaleTypes.values().next().value // pick the only scaleType present
scaleTypes.size === 1 && firstScaleType
? firstScaleType
: scaleTypes.has(ScaleType.Ordinal)
? ScaleType.Ordinal
: ScaleType.Linear; // if Ordinal is not present, coerce to Linear, whether it's present or not
Expand Down
9 changes: 6 additions & 3 deletions packages/charts/src/chart_types/xy_chart/domains/y_domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { groupBy } from '../utils/group_data_series';
import type { DataSeries } from '../utils/series';
import type { BasicSeriesSpec, SeriesScales, YDomainRange } from '../utils/specs';
import { DomainPaddingUnit, SeriesType, StackMode } from '../utils/specs';
import { ScaleContinuousType } from '../../../scales';

/** @internal */
export type YBasicSeriesSpec = Pick<
Expand Down Expand Up @@ -179,9 +180,11 @@ export function isStackedSpec(spec: YBasicSeriesSpec) {
}

/** @internal */
export function coerceYScaleTypes(series: Pick<SeriesScales, 'yScaleType' | 'yNice'>[]) {
export function coerceYScaleTypes(series: Pick<SeriesScales, 'yScaleType' | 'yNice'>[]): {type: ScaleContinuousType, nice: boolean} {
const scaleTypes = new Set(series.map((s) => getYScaleTypeFromSpec(s.yScaleType)));
const niceDomains = series.map((s) => getYNiceFromSpec(s.yNice));
const type = scaleTypes.size === 1 ? scaleTypes.values().next().value : ScaleType.Linear;
return { type, nice: !niceDomains.includes(false) };
const nice = !niceDomains.includes(false)
const firstScaleType = scaleTypes.values().next().value;
const type = scaleTypes.size === 1 && firstScaleType ? firstScaleType : ScaleType.Linear;
return { type, nice };
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,33 @@ jest.spyOn(common, 'getColorFromVariant');
jest.spyOn(commonColors, 'colorToRgba');

const COLOR = 'aquamarine';

describe('Area styles', () => {
let ctx: CanvasRenderingContext2D;
let imgCanvas: HTMLCanvasElement;

// Mock CanvasRenderingContext2D and HTMLCanvasElement for Jest environment
beforeAll(() => {
// @ts-ignore
global.HTMLCanvasElement = class { getContext() { return {}; } };
// @ts-ignore
global.CanvasRenderingContext2D = class {};
});

describe('#buildAreaStyles', () => {
let result: Fill;
let baseColor = COLOR;
let themeAreaStyle = MockStyles.area();
let geometryStateStyle = MockStyles.geometryState();

function setDefaults() {
baseColor = COLOR;
themeAreaStyle = MockStyles.area();
geometryStateStyle = MockStyles.geometryState();
}

beforeEach(() => {
imgCanvas = document.createElement('canvas');
ctx = imgCanvas.getContext('2d') as CanvasRenderingContext2D;
result = buildAreaStyles(ctx, imgCanvas, baseColor, themeAreaStyle, geometryStateStyle);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ describe('Bar styles', () => {
let ctx: CanvasRenderingContext2D;
let imgCanvas: HTMLCanvasElement;

// Mock CanvasRenderingContext2D and HTMLCanvasElement for Jest environment
beforeAll(() => {
// @ts-ignore
global.HTMLCanvasElement = class { getContext() { return {}; } };
// @ts-ignore
global.CanvasRenderingContext2D = class {};
});

describe('#buildBarStyles', () => {
let result: { fill: Fill; stroke: Stroke };
let baseColor = COLOR;
Expand All @@ -45,6 +53,8 @@ describe('Bar styles', () => {
}

beforeEach(() => {
imgCanvas = document.createElement('canvas');
ctx = imgCanvas.getContext('2d') as CanvasRenderingContext2D;
result = buildBarStyle(ctx, imgCanvas, baseColor, themeRectStyle, themeRectBorderStyle, geometryStateStyle, rect);
});

Expand Down Expand Up @@ -159,6 +169,8 @@ describe('Bar styles', () => {
setDefaults();
themeRectStyle = MockStyles.rect({ texture });
(getTextureStyles as jest.Mock).mockReturnValue(mockTexture);
imgCanvas = document.createElement('canvas');
ctx = imgCanvas.getContext('2d') as CanvasRenderingContext2D;
});

it('should return correct texture', () => {
Expand Down
17 changes: 3 additions & 14 deletions packages/charts/src/chart_types/xy_chart/utils/axis_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import { computeXScale } from './scales';
import type { AxisSpec, DomainRange, TickFormatter } from './specs';
import { DEFAULT_GLOBAL_ID } from './specs';
import type { SmallMultipleScales } from '../../../common/panel_utils';
import { MockGlobalSpec /*, MockSeriesSpec*/ } from '../../../mocks/specs/specs';
// import { MockStore } from '../../../mocks/store/store';
import { MockGlobalSpec } from '../../../mocks/specs/specs';
import { MockXDomain, MockYDomain } from '../../../mocks/xy/domains';
import { ScaleType } from '../../../scales/constants';
import { getSmallMultiplesScale } from '../../../state/utils/get_small_multiples_scale';
Expand All @@ -34,15 +33,7 @@ import type { OrdinalDomain } from '../../../utils/domain';
import type { GroupId } from '../../../utils/ids';
import { LIGHT_THEME } from '../../../utils/themes/light_theme';
import type { AxisStyle, TextOffset } from '../../../utils/themes/theme';
/*
import { computeAxesGeometriesSelector } from '../state/selectors/compute_axes_geometries';
import {
AxesTicksDimensions,
computeAxisTicksDimensionsSelector,
} from '../state/selectors/compute_axis_ticks_dimensions';
*/
// import { getAxesStylesSelector } from '../state/selectors/get_axis_styles';
// import { getGridLinesSelector } from '../state/selectors/get_grid_lines';

import { mergeYCustomDomainsByGroupId } from '../state/selectors/merge_y_custom_domains';
import { generateTicks } from '../state/selectors/visible_ticks';

Expand All @@ -51,8 +42,6 @@ const alignmentsDefault = { horizontal: HorizontalAlignment.Near, vertical: Vert
const layer = 0;
const detailedLayer = 0;

// const NO_ROTATION = 0;

const getCustomStyle = (rotation = 0, padding = 10): AxisStyle =>
mergePartial(LIGHT_THEME.axes, {
tickLine: {
Expand Down Expand Up @@ -926,7 +915,7 @@ describe('Axis computational utils', () => {

const expectedTopAxisPosition = {
dimensions: {
height: 48 || axis1Dims.maxLabelBboxHeight + axisTitleHeight + tickSize + tickPadding,
height: 48,// axis1Dims.maxLabelBboxHeight + axisTitleHeight + tickSize + tickPadding,
width: 100,
left: 0,
top: cumTopSum + LIGHT_THEME.chartMargins.top,
Expand Down
5 changes: 4 additions & 1 deletion packages/charts/src/common/data_structures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export class LRUCache<K, V> {

set(key: K, val: V) {
if (this.cache.has(key)) this.cache.delete(key);
else if (this.cache.size === this.max) this.cache.delete(this.first());
else if (this.cache.size === this.max) {
const first = this.first();
if(first) this.cache.delete(first)
};
this.cache.set(key, val);
}

Expand Down
7 changes: 3 additions & 4 deletions packages/charts/src/utils/time_zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const getValidatedTimeZone = (specifiedTimeZone?: string): string =>
/** @internal */
export const getZoneFromSpecs = (specs: { timeZone?: string }[]): string => {
const allValidTimezones = new Set<string>(specs.map((s) => s.timeZone ?? '').filter(isValidTimeZone));
return allValidTimezones.size === 1
? allValidTimezones.values().next().value
: Intl.DateTimeFormat().resolvedOptions().timeZone;
};
const firstTimeZone = allValidTimezones.values().next().value;
return allValidTimezones.size === 1 && firstTimeZone ? firstTimeZone : Intl.DateTimeFormat().resolvedOptions().timeZone;
};
2 changes: 1 addition & 1 deletion storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
"storybook-addon-toggles": "^0.0.3",
"terser-webpack-plugin": "^4.2.3",
"ts-loader": "8.4.0",
"typescript": "^5.5.3"
"typescript": "^5.8.3"
}
}
Loading