更改 Plotly .js 中的标记形状

dsa*_*ick 2 javascript plotly

我在更改plotly.js 库中的标记形状方面寻求一些帮助。

我想要做的是将每组的第一个标记和最后一个标记更改为垂直线,将中间的标记更改为菱形。

我已经从plotly中跟踪了这个参考链接,但似乎无法让它工作。

这是我正在使用的 JS。

var subject = ["Title 1","Title 1","Title 1","Title 2","Title 2","Title 2"];
var score = [40,50,60,20,40,60];
var data = [{
    type: 'scatter',
    x: score,
    y: subject,
    mode: 'line',      
    transforms: [{
        type: 'groupby',
        groups: subject,
    }],  
    hoverinfo: 'text',
    text: ['Lower Index : 40','Est : 50','Higher Index : 60','Lower Index : 20','Est : 40','Higher Index : 60'],
    marker: {
        size: 12,
        shape: ['line-ew',"diamond-open","line-ew","line-ew","diamond-open","line-ew"]
    },
}];
var layout = {
    xaxis: {
        type: '-',
        title: "x Title",
        range:[0,100]
    },
    yaxis: {
        title: "Y title",
    },
    title: "Main Title",
    showlegend: false,
    legend: {"orientation": "h"}
    };
Plotly.plot('myGraph', data,layout)
Run Code Online (Sandbox Code Playgroud)

以及同例的码笔

https://codepen.io/dsadnick/pen/xYEXXw

dsa*_*ick 5

逐行查看后我发现了问题,

marker: {
    size: 12,
    shape: ['line-ew',"diamond-open","line-ew","line-ew","diamond-open","line-ew"]
},
Run Code Online (Sandbox Code Playgroud)

应该是

marker: {
    size: 12,
    symbol: ['line-ew',"diamond-open","line-ew","line-ew","diamond-open","line-ew"]
},
Run Code Online (Sandbox Code Playgroud)