diff --git a/packages/osd-charts/src/chart_types/xy_chart/rendering/rendering.areas.test.ts b/packages/osd-charts/src/chart_types/xy_chart/rendering/rendering.areas.test.ts index ec2736ea9c79..109bce79ae09 100644 --- a/packages/osd-charts/src/chart_types/xy_chart/rendering/rendering.areas.test.ts +++ b/packages/osd-charts/src/chart_types/xy_chart/rendering/rendering.areas.test.ts @@ -1001,7 +1001,7 @@ describe('Rendering points - areas', () => { expect(renderedArea.areaGeometry.seriesIdentifier.specId).toEqual(SPEC_ID); expect(renderedArea.areaGeometry.transform).toEqual({ x: 0, y: 0 }); }); - test('Can render points points', () => { + test('Can render points', () => { const { areaGeometry: { points }, indexedGeometries, diff --git a/packages/osd-charts/src/chart_types/xy_chart/utils/__snapshots__/series.test.ts.snap b/packages/osd-charts/src/chart_types/xy_chart/utils/__snapshots__/series.test.ts.snap index 2c6ab09efde2..6484ea9d0cc6 100644 --- a/packages/osd-charts/src/chart_types/xy_chart/utils/__snapshots__/series.test.ts.snap +++ b/packages/osd-charts/src/chart_types/xy_chart/utils/__snapshots__/series.test.ts.snap @@ -11,7 +11,7 @@ Array [ }, "x": 0, "y0": null, - "y1": undefined, + "y1": null, }, ], "key": "spec{spec1}yAccessor{y1}splitAccessors{y-1}", @@ -34,7 +34,7 @@ Array [ }, "x": 1, "y0": null, - "y1": undefined, + "y1": null, }, ], "key": "spec{spec1}yAccessor{y1}splitAccessors{y-2}", @@ -57,7 +57,7 @@ Array [ }, "x": 2, "y0": null, - "y1": undefined, + "y1": null, }, ], "key": "spec{spec1}yAccessor{y1}splitAccessors{y-10}", @@ -80,7 +80,7 @@ Array [ }, "x": 3, "y0": null, - "y1": undefined, + "y1": null, }, ], "key": "spec{spec1}yAccessor{y1}splitAccessors{y-6}", diff --git a/packages/osd-charts/src/chart_types/xy_chart/utils/series.test.ts b/packages/osd-charts/src/chart_types/xy_chart/utils/series.test.ts index 8ad65d0cdbd5..e49b4246201f 100644 --- a/packages/osd-charts/src/chart_types/xy_chart/utils/series.test.ts +++ b/packages/osd-charts/src/chart_types/xy_chart/utils/series.test.ts @@ -9,6 +9,7 @@ import { RawDataSeries, splitSeries, SeriesIdentifier, + cleanDatum, } from './series'; import { BasicSeriesSpec, LineSeriesSpec, SpecTypes, SeriesTypes } from './specs'; import { formatStackedDataSeriesValues } from './stacked_series_utils'; @@ -560,4 +561,24 @@ describe('Series', () => { expect(getSortedDataSeriesColorsValuesMap(seriesCollection)).toEqual(undefinedSortedColorValues); }); + test('clean datum shall parse string as number for y values', () => { + let datum = cleanDatum([0, 1, 2], 0, 1, 2); + expect(datum.y1).toBe(1); + expect(datum.y0).toBe(2); + datum = cleanDatum([0, '1', 2], 0, 1, 2); + expect(datum.y1).toBe(1); + expect(datum.y0).toBe(2); + + datum = cleanDatum([0, '1', '2'], 0, 1, 2); + expect(datum.y1).toBe(1); + expect(datum.y0).toBe(2); + + datum = cleanDatum([0, 1, '2'], 0, 1, 2); + expect(datum.y1).toBe(1); + expect(datum.y0).toBe(2); + + datum = cleanDatum([0, 'invalid', 'invalid'], 0, 1, 2); + expect(datum.y1).toBe(null); + expect(datum.y0).toBe(null); + }); }); diff --git a/packages/osd-charts/src/chart_types/xy_chart/utils/series.ts b/packages/osd-charts/src/chart_types/xy_chart/utils/series.ts index b4e562d5d01e..dc7895aece2c 100644 --- a/packages/osd-charts/src/chart_types/xy_chart/utils/series.ts +++ b/packages/osd-charts/src/chart_types/xy_chart/utils/series.ts @@ -206,16 +206,29 @@ function getSplitAccessors(datum: Datum, accessors: Accessor[] = []): Map,