javascript - Mxgraph 如何以编程方式在形状内添加文本元素?
问题描述
我想在任何形状内添加一个文本元素。我可以使用以下代码以编程方式添加占位符,但无法移动仅能够更改样式的文本。我想标签应该移动到任何位置。
var applyBtn = mxUtils.button(mxResources.get('apply'), function()
{
try
{
ui.hideDialog.apply(ui, arguments);
// Clones and updates the value
value = value.cloneNode(true);
var removeLabel = false;
for (var i = 0; i < names.length; i++)
{
if (texts[i] == null)
{
value.removeAttribute(names[i]);
}
else
{
value.setAttribute(names[i], texts[i].value);
//console.log(names[i]+"==="+texts[i].value);
removeLabel = removeLabel || (names[i] == 'placeholder' &&
value.getAttribute('placeholders') == '1');
}
}
// Removes label if placeholder is assigned
if (removeLabel)
{
value.removeAttribute('label');
}
// set booth id here
value.setAttribute('label',value.getAttribute('booth_number'));
graph.getModel().setValue(cell, value);
}
catch (e)
{
mxUtils.alert(e);
}
});
输出
需要
提前致谢!
解决方案
推荐阅读
- metal - 调试金属着色器时,Xcode 是否支持 iPhone 中的着色器调试器?
- html - CSS Hover 仅适用于按钮的下半部分
- mysql - 未定义 Qt 库“mysql”
- python - NumPy cumsum 舍入问题
- python - 根据条件转换特定列值并使用该转换值更新另一行
- javascript - Aframe 在组件中的函数之间传递变量
- web-services - Web 服务在 SOAP 中显示 localhost 而不是 IP
- excel - 如何通过包含数百个文本文件的文件夹运行宏
- node.js - 如何使用 mocha、node 和 selenium 集成测试 react-select 多选下拉菜单?
- elasticsearch - 需要帮助使用 logstash 将 csv JSON 字段解析为字符串