Javascript 切换(plotly.js-散射)y轴的可见性&;踪迹

Javascript 切换(plotly.js-散射)y轴的可见性&;踪迹,javascript,css,svg,plotly,Javascript,Css,Svg,Plotly,plotly.js新增 (我在有角度的环境中) 我想把痕迹放在多选下拉菜单中。所有y轴都相同。以便能够切换这些的可见性。建议…简单/正确的方法 我试图用css影响svg容器,但没有效果: 对于轴: var update = { 'yaxis.visible': false }; Plotly.relayout(myDiv, update) 对于跟踪: data = [ { line: {width: 5}, name: "myName1",

plotly.js新增 (我在有角度的环境中)

我想把痕迹放在多选下拉菜单中。所有y轴都相同。以便能够切换这些的可见性。建议…简单/正确的方法

我试图用css影响svg容器,但没有效果:

对于轴:

var update = {
    'yaxis.visible': false
};
Plotly.relayout(myDiv, update)
对于跟踪:

data = [
    {
        line: {width: 5},
        name: "myName1",
        type: "scatter",
        visible: "legendonly", // Plot trace but hide it to the user
        x:  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        y:  [10, 11, 2, 23, 14, 5, 16, 7, 18, 29, 10]
    },
    {
        line: {width: 5},
        name: "myName2",
        type: "scatter",
        visible: "legendonly" ,// Plot trace but hide it to the user
        x:  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        y:  [10, 1, 12, 13, 4, 25, 16, 17, 8, 19, 20]
    }
];

allTraces=document.getElementById("myDiv").data; // Get data from chart AFTER plotting it.

// Find index of trace-object with "name" property  = "text to find":
result = allTraces.findIndex(obj => { 
    return obj.name === "text to find";
}

// Make specified trace visible to user:
Plotly.restyle(document.getElementById("myDiv"), {"visible": true}, [result]);
对于axis:

var update = {
    'yaxis.visible': false
};
Plotly.relayout(myDiv, update)
对于跟踪:

data = [
    {
        line: {width: 5},
        name: "myName1",
        type: "scatter",
        visible: "legendonly", // Plot trace but hide it to the user
        x:  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        y:  [10, 11, 2, 23, 14, 5, 16, 7, 18, 29, 10]
    },
    {
        line: {width: 5},
        name: "myName2",
        type: "scatter",
        visible: "legendonly" ,// Plot trace but hide it to the user
        x:  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        y:  [10, 1, 12, 13, 4, 25, 16, 17, 8, 19, 20]
    }
];

allTraces=document.getElementById("myDiv").data; // Get data from chart AFTER plotting it.

// Find index of trace-object with "name" property  = "text to find":
result = allTraces.findIndex(obj => { 
    return obj.name === "text to find";
}

// Make specified trace visible to user:
Plotly.restyle(document.getElementById("myDiv"), {"visible": true}, [result]);

原因是我有Y轴用于每个轨迹,以便在它们重叠时能够在Y轴上移动独立轨迹以比较曲线。我想避免长列表,因此在下拉列表中。我想最简单的方法是制作一个下拉菜单,设置与正确布局对象属性相关的ng模型的值!原因是我有Y轴用于每个轨迹,以便在它们重叠时能够在Y轴上移动独立轨迹以比较曲线。我想避免长列表,因此在下拉列表中。我想最简单的方法是制作一个下拉菜单,设置与正确布局对象属性相关的ng模型的值!