如何在plotly.js中建立数千个3d立方体的模型

时间:2019-03-25 09:59:38

标签: javascript plotly

如何绘制5000个3D立方体?当我尝试执行此操作时,浏览器将显示一个空白页。当我有1000个多维数据集时,一切正常。我尝试如下构建:创建3D多维数据集(例如3dmesh)并将其移动到特定坐标。

我的代码:

    function drawPlot(allData) {
        console.log(allData);
        var data=[];
        var xMas = [];
        var yMas = [];
        var zMas = [];
        for (var i = 1; i <= allData.length - 1; i++) {
            xMas.push(parseInt(allData[i]['X']))
            yMas.push(parseInt(allData[i]['Y']))
            zMas.push(parseInt(allData[i]['Z']))
        }
            data.push(
            {
                mode: 'markers',
                marker: {
                    //color:'rgb(' + (255 - zPlus * 7) + ',0,' + (50 + zPlus * 7) + ')',
                    size: 10,
                    symbol: 'square',
                    line: {
                    color: 'rgb(204, 204, 204)',
                    width: 1},
                    opacity: 1},
                type: 'scatter3d',
                x: xMas,
                y: yMas,
                z: zMas,
                showscale: true
            });

        var axis_template = {
            showgrid: true,
            zeroline: true,
            nticks: 1000,
            showline: true
        };

        var layout = {
            title:'Test model',
            scene: {
                xaxis: {
                    autotick: false,
                    ticks: 'outside',
                    //tick0: 0,
                    dtick: 1
                },
                yaxis: {
                    autotick: false,
                    ticks: 'outside',
                    //tick0: 0,
                    dtick: 1
                },
                zaxis: {
                    autotick: false,
                    ticks: 'outside',
                    //tick0: 0,
                    dtick: 1
                }
            }
        };

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

    makePlot();

! [1]:https://i.stack.imgur.com/JRPxc.png

0 个答案:

没有答案