Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzmadom committed Dec 28, 2024
1 parent a76a985 commit 22cb035
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
ChartKitWidgetData,
} from '@gravity-ui/chartkit/build/types/widget-data';

import type {SeriesExportSettings, ServerField} from '../../../../../../../shared';
import type {SeriesExportSettings, ServerField, WrappedMarkdown} from '../../../../../../../shared';
import {
AxisMode,
LabelsPositions,
Expand All @@ -29,7 +29,7 @@ type OldBarXDataItem = {
} | null;

type ExtendedBaXrSeriesData = Omit<BarXSeriesData, 'x'> & {
x?: BarXSeriesData['x'] | WrappedHTML;
x?: BarXSeriesData['x'] | WrappedHTML | WrappedMarkdown;
};

type ExtendedBarXSeries = Omit<BarXSeries, 'data'> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
ServerPlaceholder,
WizardVisualizationId,
WrappedHTML,
WrappedMarkdown,
} from '../../../../../../../shared';
import {
AxisMode,
Expand Down Expand Up @@ -514,7 +515,9 @@ export function prepareBarX(args: PrepareFunctionArgs) {

return {
graphs,
categories: categories.map<string | WrappedHTML>(categoriesFormatter),
categories: categories.map<string | WrappedHTML | WrappedMarkdown>(
categoriesFormatter,
),
};
} else {
return {graphs};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
ServerPlaceholder,
WizardVisualizationId,
WrappedHTML,
WrappedMarkdown,
} from '../../../../../../../shared';
import {
AxisMode,
Expand Down Expand Up @@ -466,7 +467,9 @@ export function prepareBarYData({
if (isXCategoryAxis) {
return {
graphs,
categories: categories.map<string | WrappedHTML>(categoriesFormatter),
categories: categories.map<string | WrappedHTML | WrappedMarkdown>(
categoriesFormatter,
),
};
} else {
return {graphs};
Expand Down Expand Up @@ -523,7 +526,12 @@ export function prepareBarYData({
if (xIsDate && xAxisMode !== AxisMode.Discrete) {
return {graphs, categories_ms: categories};
} else {
return {graphs, categories: categories.map<string | WrappedHTML>(categoriesFormatter)};
return {
graphs,
categories: categories.map<string | WrappedHTML | WrappedMarkdown>(
categoriesFormatter,
),
};
}
}
}
9 changes: 7 additions & 2 deletions src/server/modes/charts/plugins/datalens/preparers/line/d3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import type {
LineSeriesData,
} from '@gravity-ui/chartkit/build/types/widget-data';

import type {SeriesExportSettings, ServerField, WrappedHTML} from '../../../../../../../shared';
import type {
SeriesExportSettings,
ServerField,
WrappedHTML,
WrappedMarkdown,
} from '../../../../../../../shared';
import {AxisMode, PlaceholderId, getXAxisMode} from '../../../../../../../shared';
import {getFormattedLabel} from '../../d3/utils/dataLabels';
import {getConfigWithActualFieldTypes} from '../../utils/config-helpers';
Expand All @@ -15,7 +20,7 @@ import type {PrepareFunctionArgs} from '../types';
import {prepareLineData} from './prepare-line-data';

type ExtendedLineSeriesData = Omit<LineSeriesData, 'x'> & {
x?: LineSeriesData['x'] | WrappedHTML;
x?: LineSeriesData['x'] | WrappedHTML | WrappedMarkdown;
};

type ExtendedLineSeries = Omit<LineSeries, 'data'> & {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import _isEmpty from 'lodash/isEmpty';
import isNil from 'lodash/isNil';

import type {HighchartsSeriesCustomObject, WrappedHTML} from '../../../../../../../shared';
import type {
HighchartsSeriesCustomObject,
WrappedHTML,
WrappedMarkdown,
} from '../../../../../../../shared';
import {
AxisMode,
AxisNullsMode,
Expand Down Expand Up @@ -562,7 +566,9 @@ export function prepareLineData(args: PrepareFunctionArgs) {
if (isXCategoryAxis) {
return {
graphs,
categories: categories.map<string | WrappedHTML>(categoriesFormatter),
categories: categories.map<string | WrappedHTML | WrappedMarkdown>(
categoriesFormatter,
),
};
} else {
return {graphs};
Expand Down Expand Up @@ -621,6 +627,9 @@ export function prepareLineData(args: PrepareFunctionArgs) {
return {graphs, categories_ms: categories};
}

return {graphs, categories: categories.map<string | WrappedHTML>(categoriesFormatter)};
return {
graphs,
categories: categories.map<string | WrappedHTML | WrappedMarkdown>(categoriesFormatter),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ export function getSeriesTitleFormatter(args: {fields: (ServerField | undefined)
const {fields} = args;

if (fields.some(isHtmlField)) {
return (value: string) => wrapHtml(String(value));
return (value?: string) => wrapHtml(String(value ?? ''));
}

return (value: string) => value;
return (value?: string) => value ?? '';
}

export {
Expand Down

0 comments on commit 22cb035

Please sign in to comment.