mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 23:09:49 +02:00
chore!: change addSection
header into D3Section
This commit is contained in:
@@ -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}`);
|
||||
|
@@ -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 });
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user