mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 07:49:43 +02:00
chore!: change addSection
header into D3Section
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
import { parseDirective as _parseDirective } from '../../directiveUtils.js';
|
import { parseDirective as _parseDirective } from '../../directiveUtils.js';
|
||||||
import { getConfig as commonGetConfig } from '../../config.js';
|
|
||||||
import { sanitizeText } from '../common/common.js';
|
|
||||||
import {
|
import {
|
||||||
setAccTitle,
|
setAccTitle,
|
||||||
getAccTitle,
|
getAccTitle,
|
||||||
@@ -12,7 +10,7 @@ import {
|
|||||||
clear as commonClear,
|
clear as commonClear,
|
||||||
} from '../../commonDb.js';
|
} from '../../commonDb.js';
|
||||||
import type { ParseDirectiveDefinition } from '../../diagram-api/types.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 { RequiredDeep } from 'type-fest';
|
||||||
import type { PieDiagramConfig } from '../../config.type.js';
|
import type { PieDiagramConfig } from '../../config.type.js';
|
||||||
import DEFAULT_CONFIG from '../../defaultConfig.js';
|
import DEFAULT_CONFIG from '../../defaultConfig.js';
|
||||||
@@ -41,8 +39,7 @@ const clear = (): void => {
|
|||||||
commonClear();
|
commonClear();
|
||||||
};
|
};
|
||||||
|
|
||||||
const addSection = (label: string, value: number): void => {
|
const addSection = ({ label, value }: D3Section): void => {
|
||||||
label = sanitizeText(label, commonGetConfig());
|
|
||||||
if (sections[label] === undefined) {
|
if (sections[label] === undefined) {
|
||||||
sections[label] = value;
|
sections[label] = value;
|
||||||
log.debug(`added new section: ${label}, with value: ${value}`);
|
log.debug(`added new section: ${label}, with value: ${value}`);
|
||||||
|
@@ -12,7 +12,8 @@ function populateDb(ast: Pie, db: PieDB) {
|
|||||||
populateCommonDb(ast, db);
|
populateCommonDb(ast, db);
|
||||||
db.setShowData(ast.showData);
|
db.setShowData(ast.showData);
|
||||||
ast.sections.map((section: PieSection) => {
|
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;
|
getAccDescription: () => string;
|
||||||
|
|
||||||
// diagram db
|
// diagram db
|
||||||
addSection: (label: string, value: number) => void;
|
addSection: ({ label, value }: D3Section) => void;
|
||||||
getSections: () => Sections;
|
getSections: () => Sections;
|
||||||
setShowData: (toggle: boolean) => void;
|
setShowData: (toggle: boolean) => void;
|
||||||
getShowData: () => boolean;
|
getShowData: () => boolean;
|
||||||
|
Reference in New Issue
Block a user