I add two buttons in echarts dashboard. they appears in edit mode (and work) but not in view mode. why? what I am missing?
view mode:
edit mode:
I add two buttons in echarts dashboard. they appears in edit mode (and work) but not in view mode. why? what I am missing?
view mode:
edit mode:
How are you adding them, I am not seeing the code for them
const incrementa = () => {
let mianyo = replaceVariables(“${anyo}”);
alert(mianyo);
mianyo++;
let anyohoy = new Date().getFullYear();
if (anyohoy >= mianyo) locationService.partial({ “var-anyo”: mianyo }, true);
};
const decrementa = () => {
let mianyo = replaceVariables(“${anyo}”);
alert(mianyo);
mianyo–;
if (2020 <= mianyo) locationService.partial({ “var-anyo”: mianyo }, true);
alert(mianyo);
};
let dom = echartsInstance.getDom();
console.log(‘dom:’, dom);
let nodeList = dom.childNodes;
console.log(‘nodeList:’, nodeList);
if (nodeList.length < 2) {
const btnms = document.createElement(“button”);
const textms = document.createTextNode(“+”);
btnms.appendChild(textms);
const btnmn = document.createElement(“button”);
const textmn = document.createTextNode(“-”);
btnmn.appendChild(textmn);
btnms.addEventListener(“click”, incrementa);
btnmn.addEventListener(“click”, decrementa);
const div = document.createElement(“div”);
div.appendChild(btnms);
div.appendChild(btnmn);
dom.insertBefore(div, dom.firstChild);
}
yosiasz
I guess is nodeList.length is less than 2 in edit mode but in view mode is 2. (¿?)
I changed
“if (nodeList.length < 2) {”
to
“if (nodeList.length <= 2) {”
and buttons are shown.
Thank you.
Documentation example must be fixed. BR.rené1
You could contribute to fixing it. since you are using it for free?
uff I need to learn Github. I have it never used.
This is your oppprtunity. Very very easy.