chore!: change addSection header into D3Section

This commit is contained in:
Reda Al Sulais
2023-08-20 22:39:32 +03:00
parent 341db13279
commit d0c36c0de3
3 changed files with 5 additions and 7 deletions

View File

@@ -1,7 +1,5 @@
import { log } from '../../logger.js';
import { parseDirective as _parseDirective } from '../../directiveUtils.js';
import { getConfig as commonGetConfig } from '../../config.js';
import { sanitizeText } from '../common/common.js';
import {
setAccTitle,
getAccTitle,
@@ -12,7 +10,7 @@ import {
clear as commonClear,
} from '../../commonDb.js';
import type { ParseDirectiveDefinition } from '../../diagram-api/types.js';
import type { PieFields, PieDB, Sections } from './pieTypes.js';
import type { PieFields, PieDB, Sections, D3Section } from './pieTypes.js';
import type { RequiredDeep } from 'type-fest';
import type { PieDiagramConfig } from '../../config.type.js';
import DEFAULT_CONFIG from '../../defaultConfig.js';
@@ -41,8 +39,7 @@ const clear = (): void => {
commonClear();
};
const addSection = (label: string, value: number): void => {
label = sanitizeText(label, commonGetConfig());
const addSection = ({ label, value }: D3Section): void => {
if (sections[label] === undefined) {
sections[label] = value;
log.debug(`added new section: ${label}, with value: ${value}`);

View File

@@ -12,7 +12,8 @@ function populateDb(ast: Pie, db: PieDB) {
populateCommonDb(ast, db);
db.setShowData(ast.showData);
ast.sections.map((section: PieSection) => {
db.addSection(section.label, section.value);
const { label, value } = section;
db.addSection({ label, value });
});
}

View File

@@ -56,7 +56,7 @@ export interface PieDB extends DiagramDB {
getAccDescription: () => string;
// diagram db
addSection: (label: string, value: number) => void;
addSection: ({ label, value }: D3Section) => void;
getSections: () => Sections;
setShowData: (toggle: boolean) => void;
getShowData: () => boolean;