更改表面图vis.js的颜色?

时间:2018-07-02 05:46:21

标签: javascript html vis.js

我目前正在尝试使用vis.js来绘制3d图形,但是经过多次尝试,我仍然找不到改变表面类型颜色的正确方法。我用下面的代码。还有其他更好的库吗?或任何其他直接方式使用三个js并实现相同的显示。

var options = {
  width: '100%',
  height: '100%',
  style: 'surface',
  showPerspective: true,
  showGrid: true,
  showShadow: false,
  keepAspectRatio: true,
  verticalRatio: 0.5,
  /*
   * style : { surfaceColor : "#ff9900" },
   */
  cameraPosition: {
    horizontal: 0.9,
    vertical: 0.4,
    distance: 2.8
  }
};

while (lx <= lengthX) {
  while (lz < lengthZ) {
    var r = this[type](lx, lz);
    data.add({
      id: counter++,
      x: r[0],
      z: r[1],
      y: r[2],
      style: 1
    });
    lz += asZ;
    lz = this.precisionRound(lz, 2);
  }
  lz = 0;
  lx += asX;
  lx = this.precisionRound(lx, 2);
}

1 个答案:

答案 0 :(得分:-1)

我使用以下选项:

var options = {
layout: {
    randomSeed: undefined,
    improvedLayout:true,
    hierarchical: {
      enabled:false,
      levelSeparation: 150,
      nodeSpacing: 100,
      treeSpacing: 20,
      blockShifting: true,
      edgeMinimization: true,
      parentCentralization: true,
      direction: 'UD',        // UD, DU, LR, RL
      sortMethod: 'hubsize'   // hubsize, directed
    }
  },
physics: {
        fit: true,
        stabilization: {
            enabled: false
        },
    },
edges:{
    color: 'black',
    length: 100,
    font: '16px tahoma #ff0000',
    scaling:{
      label: false,
    },
    shadow: true,
    smooth: true,
  },
nodes: {},
interaction: {
        multiselect: false,
        navigationButtons: true,
        selectable: true,
        selectConnectedEdges: true,
        tooltipDelay: 100,
        zoomView: true
    }
  };