优化节点标签代码

This commit is contained in:
wanglin2 2023-09-23 10:51:30 +08:00
parent 9528631ed1
commit 5052c0427a
5 changed files with 2 additions and 33 deletions

View File

@ -1,27 +1,3 @@
// 标签颜色列表
export const tagColorList = [
{
color: 'rgb(77, 65, 0)',
background: 'rgb(255, 244, 179)'
},
{
color: 'rgb(0, 50, 77)',
background: 'rgb(179, 229, 255)'
},
{
color: 'rgb(77, 0, 73)',
background: 'rgb(255, 179, 251)'
},
{
color: 'rgb(57, 77, 0)',
background: 'rgb(236, 255, 179)'
},
{
color: 'rgb(0, 77, 47)',
background: 'rgb(179, 255, 226)'
}
]
// 主题列表
export const themeList = [
{

View File

@ -204,7 +204,5 @@ export const defaultOpt = {
},
// 自定义标签的颜色
// {pass: 'green, unpass: 'red'}
tagsColorMap: {
pass: 'green'
}
tagsColorMap: {}
}

View File

@ -1,4 +1,3 @@
import { tagColorList } from '../../../constants/constant'
import {
checkIsNodeStyleDataKey,
generateColorByContent

View File

@ -253,17 +253,14 @@ function createTagNode() {
tagData.slice(0, this.mindMap.opt.maxTag).forEach((item, index) => {
let tag = new G()
// 标签文本
let text = new Text().text(item).x(8).cy(10)
let text = new Text().text(item).x(8).cy(8)
this.style.tagText(text, index)
let { width } = text.bbox()
// 标签矩形
let rect = new Rect().size(width + 16, 20)
// 先从自定义的颜色中获取颜色,没有的话就按照内容生成
const tagsColorList = this.mindMap.opt.tagsColorMap || {}
const color = tagsColorList[text.node.textContent]
this.style.tagRect(rect, text, color)
tag.add(rect).add(text)
nodes.push({

View File

@ -798,7 +798,6 @@ export const getNodeIndex = node => {
: 0
}
// 根据内容生成颜色
export const generateColorByContent = str => {
let hash = 0