<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!DOCTYPE html><html lang='en' class=''>
<head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/pissang/pen/RZWVzx?limit=all&page=76&q=app" />
<style class="cp-pen-styles">#main {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
#image-upload {
width: 300px;
height: 100px;
line-height: 100px;
text-align: center;
cursor: pointer;
background: rgba(255, 255, 255, 0.2);
border-radius: 4px;
border: 2px dashed #999;
position: absolute;
right: 10px;
bottom: 10px;
z-index: 10;
color: #fff;
}</style></head><body>
<html>
<head>
<meta charset="utf-8">
<title>Bar3D Isometric - ECHARTS-GL</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes"> <!-- Fullscreen Landscape on iOS -->
</head>
<body>
<div id="main"></div>
<div id="image-upload">Drop files here or click to upload</div>
</body>
</html>
<script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/echarts/3.6.2/echarts.min.js'></script><script src='https://rawgit.com/ecomfe/echarts-gl/master/dist/echarts-gl.min.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.5/dat.gui.min.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script><script src='https://cdn.rawgit.com/ecomfe/echarts-doc/gh-pages/slides/webgl/asset/texture/canyon.hdr.js'></script>
<script >var chart = echarts.init(document.getElementById("main"));
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
var imgData;
chart.setOption({
tooltip: {},
backgroundColor: "#000",
xAxis3D: {
type: "value"
},
yAxis3D: {
type: "value"
},
zAxis3D: {
type: "value",
min: 0,
max: 100
},
grid3D: {
show: false,
viewControl: {
projection: "orthographic",
alpha: 45,
beta: -45,
rotateSensitivity: [1, 0],
damping: 0.9,
panSensitivity: 0,
orthographicSize: 120
},
postEffect: {
enable: true,
bloom: {
intensity: 0.2
},
screenSpaceAmbientOcclusion: {
enable: true,
intensity: 1.5,
radius: 5,
quality: "high"
},
screenSpaceReflection: {
enable: true
}
// depthOfField: {
// enable: true,
// blurRadius: 4,
// fstop: 10
// }
},
boxDepth: 100,
boxHeight: 20,
environment: "none",
light: {
main: {
shadow: true,
intensity: 2
},
ambientCubemap: {
texture: canyonUrl,
exposure: 2,
diffuseIntensity: 0.2
}
}
}
});
function updateData(data, width, height) {
console.time("update");
var dataItem = [];
var dataProvider = {
getItem: function(i) {
var r = data[i * 4];
var g = data[i * 4 + 1];
var b = data[i * 4 + 2];
var lum = 0.2125 * r + 0.7154 * g + 0.0721 * b;
lum = (lum - 125) * config.scale + 50;
dataItem[0] = i % width;
dataItem[1] = height - Math.floor(i / width);
dataItem[2] = lum;
return dataItem;
},
count: function() {
return data.length / 4;
}
};
chart.setOption({
grid3D: {
boxWidth: 100 / height * width
},
series: [
{
animation: false,
type: "bar3D",
shading: "realistic",
realisticMaterial: {
roughness: config.roughness,
metalness: config.metalness
},
barSize: 0.5,
silent: true,
itemStyle: {
color: config.sameColor ? config.color : function(params) {
var i = params.dataIndex;
var r = data[i * 4] / 255;
var g = data[i * 4 + 1] / 255;
var b = data[i * 4 + 2] / 255;
var lum = 0.2125 * r + 0.7154 * g + 0.0721 * b;
// r *= lum * 2;
// g *= lum * 2;
// b *= lum * 2;
return [r, g, b, 1];
}
},
data: dataProvider
}
]
});
console.timeEnd("update");
setTimeout(function () {
chart.getZr().refresh()
}, 100);
}
function loadImage(img) {
var height = (canvas.height = Math.min(256, img.height));
var aspect = img.width / img.height;
var width = (canvas.width = Math.round(height * aspect));
ctx.drawImage(img, 0, 0, width, height);
imgData = ctx.getImageData(0, 0, width, height);
updateData(imgData.data, width, height);
}
// Configurations
var config = {
scale: 0.25,
roughness: 1,
metalness: 0,
projection: "orthographic",
depthOfField: false,
lockY: true,
move: false,
sameColor: false,
color: '#777',
lightIntensity: 2,
lightColor: '#fff',
lightRotate: 30,
lightPitch: 40,
AO: 1.5,
showEnvironment: false,
environment: 'canyon'
};
var gui = new dat.GUI();
function updateDataWhenChange() {
if (imgData) {
updateData(imgData.data, imgData.width, imgData.height);
}
}
gui.add(config, "scale", -1, 1).onFinishChange(updateDataWhenChange);
gui.add(config, 'sameColor').onChange(updateDataWhenChange);
gui.addColor(config, 'color').onChange(updateDataWhenChange);
["roughness", "metalness"].forEach(function(propName) {
gui.add(config, propName, 0, 1).step(0.01).onFinishChange(function() {
chart.setOption({
series: [
{
realisticMaterial: {
roughness: config.roughness,
metalness: config.metalness
}
}
]
});
});
});
function updateControlAndLight() {
chart.setOption({
grid3D: {
environment: config.showEnvironment ? 'auto' : '#000',
viewControl: {
panSensitivity: config.move ? 1 : 0,
rotateSensitivity: config.lockY ? [1, 0] : 1
},
light: {
main: {
intensity: config.lightIntensity,
color: config.lightColor,
alpha: config.lightPitch,
beta: config.lightRotate
},
ambientCubemap: {
texture: config.environment === 'canyon' ? canyonUrl : pisaUrl
}
},
postEffect: {
screenSpaceAmbientOcclusion: {
intensity: config.AO
}
}
}
});
}
gui.add(config, 'lightIntensity', 0, 10).onChange(updateControlAndLight);
gui.add(config, 'lightRotate', -180, 180).onChange(updateControlAndLight);
gui.add(config, 'lightPitch', 10, 90).onChange(updateControlAndLight);
gui.add(config, 'AO', 0, 2).onChange(updateControlAndLight);
// gui.addColor(config, 'lightColor').onChange(updateControlAndLight);
// FIXME Not work
// gui.add(config, 'showEnvironment').onChange(updateControlAndLight);
// gui.add(config, 'environment', ['canyon', 'pisa']).onChange(updateControlAndLight);
gui.add(config, 'move').onChange(updateControlAndLight);
gui.add(config, 'lockY').onChange(updateControlAndLight);
gui.add(config, 'projection', ['orthographic', 'perspective']).onChange(function () {
chart.setOption({
grid3D: {
viewControl: {
projection: config.projection
}
}
});
// FIXME
setTimeout(function () {
chart.setOption({});
setTimeout(function () {
var grid3DModel = chart.getModel().getComponent('grid3D');
var opt = grid3DModel.option.viewControl
chart.getViewOfComponentModel(grid3DModel)._control._needsUpdate = true;
});
}, 100);
});
// Handle file uploads.
function readFile(file) {
if (!file || !file.type.match(/image/)) {
return;
}
var fileReader = new FileReader();
fileReader.onload = function(e) {
img = new Image();
img.onload = function() {
loadImage(img);
};
img.src = e.target.result;
};
fileReader.readAsDataURL(file);
}
$("#image-upload").on("dragover", function(e) {
e.stopPropagation();
e.preventDefault();
});
$("#image-upload")[0].addEventListener("drop", function(e) {
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files;
return readFile(files[0]);
});
$("#image-upload").on("click", function() {
var $file = $('<input type="file" />');
$file.on("change", function(e) {
readFile(e.target.files[0]);
});
$file.click();
});
window.onresize = chart.resize;
// Default
var img = new Image();
img.onload = function() {
loadImage(img);
};
img.src =
"data:image/png;charset=utf-8;base64,iVBORw0K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