亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法通過設置標記類型來擴展跡線

無法通過設置標記類型來擴展跡線

慕的地6264312 2023-10-14 18:25:29
通過下面的代碼,我嘗試創建一個簡單的氣泡圖。我創建了一個跟蹤以便稍后擴展它:    var t9 = {        x: [100821],        y: [11],        name: 'Some text',        text: ['Some text'],        mode: ['markers'],        marker: [{          size: [1531*10],          sizeref: 2,          sizemode: 'area'        }]      };    var data = [t9];var layout = {  title: 'Chart',  showlegend: true,  xaxis: {    title: 'Some text'  },  yaxis: {    title: 'Some text'  }};var config = {responsive: true}Plotly.newPlot('plot', data, layout, config);        Plotly.extendTraces(          'plot',         {          x: [[5491]],          y: [[5]],          text: [['Some text']],          mode: [['markers']],          marker: [[{            size: 123*100,            sizeref: 2,            sizemode: 'area'          }]]        }, [0]);                Plotly.extendTraces(          'plot',         {          x: [[60022]],          y: [[11]],          text: [['Some text']],          mode: [['markers']],          marker: [[{            size: 982*100,            sizeref: 2,            sizemode: 'area'          }]]        }, [0]);<head>  <!-- Plotly.js -->  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head><html>  <body>    <div id="plot"></div>  </body></html>結果是這樣的:正如您所看到的,標記不會占用該屬性mode: ['markers']和所有屬性markers:。知道如何獲得像本頁這樣的結果嗎? https://plotly.com/javascript/bubble-charts/
查看完整描述

1 回答

?
慕俠2389804

TA貢獻1719條經驗 獲得超6個贊

如果您使用extendTraces并想要更新屬性,例如標記大小,您需要以字符串形式提供屬性,例如,marker.size并且值必須是數組,就像新的 x 和 y 值一樣。


Plotly.extendTraces(

  'plot', 

  {

    x: [[5491]],

    y: [[5]],

    'marker.size':[[40*100]]

  }, [0]);

您的初始數據和屬性應該是一個簡單的數組或對象,而不是數組/對象的數組。

https://img1.sycdn.imooc.com/652a6d5a00017f2d11560447.jpg

 var t9 = {

  x: [100821],

  y: [11],

  name: 'Some text',

  text: 'Some text',

  mode: 'markers',

  marker: {

    size: [15*100],

    sizeref: 1,

    sizemode: 'area'

  }

};


var data = [t9];


var layout = {

  title: 'Chart',

  showlegend: true,

  xaxis: {

    title: 'Some text'

  },

  yaxis: {

    title: 'Some text',

    range: [-12, 30]

  }

};


var config = {responsive: true}


Plotly.newPlot('plot', data, layout, config);



Plotly.extendTraces(

  'plot', 

  {

    x: [[5491]],

    y: [[5]],

    'marker.size':[[40*100]]

  }, [0]);


Plotly.extendTraces(

  'plot', 

  {

    x: [[60022]],

    y: [[11]],

   'marker.size':[[200*100]] 

  }, [0]);

<head>

  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>

</head>


<div id='plot'>


</div>


查看完整回答
反對 回復 2023-10-14
  • 1 回答
  • 0 關注
  • 120 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號