优化节点标签代码
This commit is contained in:
parent
9528631ed1
commit
5052c0427a
@ -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 = [
|
export const themeList = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -204,7 +204,5 @@ export const defaultOpt = {
|
|||||||
},
|
},
|
||||||
// 自定义标签的颜色
|
// 自定义标签的颜色
|
||||||
// {pass: 'green, unpass: 'red'}
|
// {pass: 'green, unpass: 'red'}
|
||||||
tagsColorMap: {
|
tagsColorMap: {}
|
||||||
pass: 'green'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { tagColorList } from '../../../constants/constant'
|
|
||||||
import {
|
import {
|
||||||
checkIsNodeStyleDataKey,
|
checkIsNodeStyleDataKey,
|
||||||
generateColorByContent
|
generateColorByContent
|
||||||
|
|||||||
@ -253,17 +253,14 @@ function createTagNode() {
|
|||||||
tagData.slice(0, this.mindMap.opt.maxTag).forEach((item, index) => {
|
tagData.slice(0, this.mindMap.opt.maxTag).forEach((item, index) => {
|
||||||
let tag = new G()
|
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)
|
this.style.tagText(text, index)
|
||||||
let { width } = text.bbox()
|
let { width } = text.bbox()
|
||||||
// 标签矩形
|
// 标签矩形
|
||||||
let rect = new Rect().size(width + 16, 20)
|
let rect = new Rect().size(width + 16, 20)
|
||||||
// 先从自定义的颜色中获取颜色,没有的话就按照内容生成
|
// 先从自定义的颜色中获取颜色,没有的话就按照内容生成
|
||||||
|
|
||||||
const tagsColorList = this.mindMap.opt.tagsColorMap || {}
|
const tagsColorList = this.mindMap.opt.tagsColorMap || {}
|
||||||
|
|
||||||
const color = tagsColorList[text.node.textContent]
|
const color = tagsColorList[text.node.textContent]
|
||||||
|
|
||||||
this.style.tagRect(rect, text, color)
|
this.style.tagRect(rect, text, color)
|
||||||
tag.add(rect).add(text)
|
tag.add(rect).add(text)
|
||||||
nodes.push({
|
nodes.push({
|
||||||
|
|||||||
@ -798,7 +798,6 @@ export const getNodeIndex = node => {
|
|||||||
: 0
|
: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 根据内容生成颜色
|
// 根据内容生成颜色
|
||||||
export const generateColorByContent = str => {
|
export const generateColorByContent = str => {
|
||||||
let hash = 0
|
let hash = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user