save js2
function generateData() { var data = []; for (var i = 0; i <= 20; i++) { for (var j = 0; j <= 20; j++) { for (var k = 0; k <= 20; k++) { data.push([i, j, k, Math.random(10)*5+16 ]); } } } return data; } var data = generateData(); myChart.setOption( (option = { visualMap: { show: false, min: 2, max: 20, inRange: { color: [ '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026' ] } }, xAxis3D: { type: 'value' }, yAxis3D: { type: 'value' }, zAxis3D: { type: 'value', max: 20, min: 0 }, grid3D: { axisLine: { lineStyle: { color: '#fff' } }, axisPointer: { lineStyle: { color: '#fff' } }, viewControl: { // autoRotate: true }, light: { main: { shadow: true, quality: 'ultra', intensity: 2.5 } } }, series: [ { type: 'bar3D', data: data, shading: 'lambert', label: { formatter: function (param) { return param.value[2].toFixed(1); } } } ] }) );