代码之家  ›  专栏  ›  技术社区  ›  Idrees Samim

无法识别的跟踪类型“轮廓”绘图javascript

  •  0
  • Idrees Samim  · 技术社区  · 9 年前

    以下代码无效。应绘制“等高线”图:

    <!DOCTYPE html>
    <head>
      <!-- D3.js -->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
      <!-- jQuery -->  
      <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
      <!-- Plotly.js -->   
      <script src="https://d14fo0winaifog.cloudfront.net/plotly-basic.js"></script>
    </head>
    <body>
    <!-- Plotly chart will be drawn inside this DIV -->
    <div id="myDiv"></div>
      <script>
      var size = 100, x = new Array(size), y = new Array(size), z = new Array(size), i, j;
    
    for(i = 0; i < size; i++) {
        x[i] = y[i] = -2 * Math.PI + 4 * Math.PI * i / size;
        z[i] = new Array(size);
    }
    
    for(i = 0; i < size; i++) {
        for(j = 0; j < size; j++) {
            var r2 = x[i]*x[i] + y[j]*y[j];
            z[i][j] = Math.sin(x[i]) * Math.cos(y[j]) * Math.sin(r2) / Math.log(r2+1);
        }
    }
    
    var data = [ {
            z: z, 
            x: x, 
            y: y, 
            type: "contour"
        }
    ];
    
    Plotly.plot("myDiv", data);
      </script>
    </body>
    </html>
    

    控制台中出现以下警告:

    无法识别的跟踪类型“轮廓”

    该代码是plotly网站上提供的基本示例。

    谢谢你的帮助

    1 回复  |  直到 9 年前
        1
  •  1
  •   potatopeelings    9 年前

    根据文件要求 plotly-basic.js 用于基本图表。等高线图是高级图表-请参见 https://plot.ly/javascript-graphing-library/#advanced-charts