mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-29 05:06:43 +02:00
Added rendering and documentation for treemap - linting
This commit is contained in:
@@ -58,8 +58,6 @@ const addClass = (id: string, _style: string) => {
|
|||||||
if (style) {
|
if (style) {
|
||||||
style.forEach((s) => {
|
style.forEach((s) => {
|
||||||
if (isLabelStyle(s)) {
|
if (isLabelStyle(s)) {
|
||||||
console.debug('isLabelStyle', s);
|
|
||||||
// const newStyle = s.replace('fill', 'bgFill'); // .replace('color', 'fill');
|
|
||||||
if (styleClass?.textStyles) {
|
if (styleClass?.textStyles) {
|
||||||
styleClass.textStyles.push(s);
|
styleClass.textStyles.push(s);
|
||||||
} else {
|
} else {
|
||||||
@@ -74,12 +72,6 @@ const addClass = (id: string, _style: string) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// classes.forEach((value) => {
|
|
||||||
// if (value.cssClasses.includes(id)) {
|
|
||||||
// value.styles.push(...style.flatMap((s) => s.split(',')));
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
classes.set(id, styleClass);
|
classes.set(id, styleClass);
|
||||||
};
|
};
|
||||||
const getClasses = (): Map<string, DiagramStyleClassDef> => {
|
const getClasses = (): Map<string, DiagramStyleClassDef> => {
|
||||||
|
@@ -7,7 +7,6 @@ import type {
|
|||||||
const id = 'treemap';
|
const id = 'treemap';
|
||||||
|
|
||||||
const detector: DiagramDetector = (txt) => {
|
const detector: DiagramDetector = (txt) => {
|
||||||
console.log('treemap detector', txt);
|
|
||||||
return /^\s*treemap/.test(txt);
|
return /^\s*treemap/.test(txt);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ const populate = (ast: any) => {
|
|||||||
|
|
||||||
// Extract classes and styles from the treemap
|
// Extract classes and styles from the treemap
|
||||||
for (const row of ast.TreemapRows || []) {
|
for (const row of ast.TreemapRows || []) {
|
||||||
const item = row.item;
|
|
||||||
|
|
||||||
if (row.$type === 'ClassDefStatement') {
|
if (row.$type === 'ClassDefStatement') {
|
||||||
db.addClass(row.className, row.styleText);
|
db.addClass(row.className, row.styleText);
|
||||||
}
|
}
|
||||||
@@ -43,7 +41,7 @@ const populate = (ast: any) => {
|
|||||||
classSelector: item.classSelector,
|
classSelector: item.classSelector,
|
||||||
cssCompiledStyles: item.classSelector ? db.getStylesForClass(item.classSelector) : undefined,
|
cssCompiledStyles: item.classSelector ? db.getStylesForClass(item.classSelector) : undefined,
|
||||||
};
|
};
|
||||||
console.debug('itemData', item.$type);
|
|
||||||
items.push(itemData);
|
items.push(itemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,11 +59,6 @@ const populate = (ast: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
addNodesRecursively(hierarchyNodes, 0);
|
addNodesRecursively(hierarchyNodes, 0);
|
||||||
|
|
||||||
console.debug('ast.ClassDefStatement', ast);
|
|
||||||
// Extract data from each classdefintion in the treemap
|
|
||||||
|
|
||||||
log.debug('Processed items:', items);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -104,8 +104,6 @@ describe('Treemap Parser', () => {
|
|||||||
it('should parse a classDef statement', () => {
|
it('should parse a classDef statement', () => {
|
||||||
const result = parse('treemap\nclassDef myClass fill:red;');
|
const result = parse('treemap\nclassDef myClass fill:red;');
|
||||||
|
|
||||||
console.debug(result.value);
|
|
||||||
|
|
||||||
// We know there are parser errors with styleText as the Langium grammar can't handle it perfectly
|
// We know there are parser errors with styleText as the Langium grammar can't handle it perfectly
|
||||||
// Check that we at least got the right type and className
|
// Check that we at least got the right type and className
|
||||||
expect(result.value.TreemapRows).toHaveLength(1);
|
expect(result.value.TreemapRows).toHaveLength(1);
|
||||||
|
Reference in New Issue
Block a user