javascript - Change Marker Shapes in Plotly .js - Stack Overflow

Im looking for a little assistance in changing the marker shapes in the plotly.js libary.What I am look

Im looking for a little assistance in changing the marker shapes in the plotly.js libary.

What I am looking to do is change the first Marker and last marker for each group to a vertical line, and the middle one to a diamond.

I have followed this reference link from plotly but can not seem to get it to work.

Here is my JS that im using.

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)

And a code pen of the same example

Im looking for a little assistance in changing the marker shapes in the plotly.js libary.

What I am looking to do is change the first Marker and last marker for each group to a vertical line, and the middle one to a diamond.

I have followed this reference link from plotly but can not seem to get it to work.

Here is my JS that im using.

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)

And a code pen of the same example

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

Share Improve this question asked Feb 6, 2018 at 19:49 dsadnickdsadnick 6241 gold badge7 silver badges25 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

After going line by line i figured out the problem,

marker: {
    size: 12,
    shape: ['line-ew',"diamond-open","line-ew","line-ew","diamond-open","line-ew"]
},

Should of been

marker: {
    size: 12,
    symbol: ['line-ew',"diamond-open","line-ew","line-ew","diamond-open","line-ew"]
},

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744756358a4591905.html

相关推荐

  • javascript - Change Marker Shapes in Plotly .js - Stack Overflow

    Im looking for a little assistance in changing the marker shapes in the plotly.js libary.What I am look

    9小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信