From c26e366674bc690f0cf70d5976c7a1ef3379e24e Mon Sep 17 00:00:00 2001 From: Irina Kuzmina Date: Thu, 12 Dec 2024 17:48:24 +0300 Subject: [PATCH] Minor improvements to the pie chart (font color/margins, etc.) --- .../modes/charts/plugins/datalens/d3/index.ts | 11 ++++++--- .../plugins/datalens/preparers/pie/d3.ts | 23 ++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/server/modes/charts/plugins/datalens/d3/index.ts b/src/server/modes/charts/plugins/datalens/d3/index.ts index bbad64433a..bc1bf40cc5 100644 --- a/src/server/modes/charts/plugins/datalens/d3/index.ts +++ b/src/server/modes/charts/plugins/datalens/d3/index.ts @@ -33,7 +33,12 @@ export function buildD3Config(args: BuildD3ConfigArgs) { const chartWidgetData: Partial = { title: getChartTitle(extraSettings), tooltip: {enabled: extraSettings?.tooltip !== 'hide'}, - legend: {enabled: isLegendEnabled}, + legend: { + enabled: isLegendEnabled, + itemStyle: { + fontSize: '13px', + }, + }, xAxis: { type: getAxisType({ field: xItem, @@ -90,10 +95,10 @@ export function buildD3Config(args: BuildD3ConfigArgs) { }, chart: { margin: { - top: 10, + top: 15, left: 10, right: 10, - bottom: 15, + bottom: 20, }, }, }; diff --git a/src/server/modes/charts/plugins/datalens/preparers/pie/d3.ts b/src/server/modes/charts/plugins/datalens/preparers/pie/d3.ts index 3aabf0fe1e..690f04181a 100644 --- a/src/server/modes/charts/plugins/datalens/preparers/pie/d3.ts +++ b/src/server/modes/charts/plugins/datalens/preparers/pie/d3.ts @@ -3,7 +3,11 @@ import type {PieSeries, PieSeriesData} from '@gravity-ui/chartkit'; import type {SeriesExportSettings} from '../../../../../../../shared'; import {WizardVisualizationId, formatNumber, getFormatOptions} from '../../../../../../../shared'; import {getFakeTitleOrTitle} from '../../../../../../../shared/modules/fields'; -import {isMarkdownField, isMarkupField} from '../../../../../../../shared/types/index'; +import { + isMarkdownField, + isMarkupField, + isNumberField, +} from '../../../../../../../shared/types/index'; import {getExportColumnSettings} from '../../utils/export-helpers'; import type {PiePoint, PrepareFunctionArgs} from '../types'; @@ -42,11 +46,28 @@ export function prepareD3Pie(args: PrepareFunctionArgs) { dataLabels: { enabled: isLabelsEnabled, html: isMarkdownLabel || isMarkupLabel, + style: { + fontWeight: '500', + fontSize: '12px', + fontColor: 'var(--g-color-text-complementary)', + }, + }, + legend: { + symbol: { + width: 10, + }, }, data: graph.data?.map((item) => { + let dataLabel: PiePoint['label'] = item.label; + if (label && isNumberField(label)) { + dataLabel = getFormattedValue(String(dataLabel), label); + } + return { ...item, + name: item.formattedName ?? item.name, + label: dataLabel, value: item.y, color: String(item.color), formattedValue: getFormattedValue(String(item.y), {