//构建数据 let creatives=['创意A创意A创意A创意A','创意B创意B创意B创意B创意B','创意C','创意D','创意E','创意F']; let targets=['定向一定向一定向一定向一定向一定向一','定向二','定向三','定向四','定向五','定向六','定向七','定向八','定向九','定向十','定向十一']; let resources=['PC购物链路','淘好物活动','首页猜你喜欢','购中猜你喜欢','购后猜你喜欢']; let data= []; computeData(); //为空的色块填充f5f5f6试试看 var options = { coord : { type : "cube", xAxis : { field : "target", label:{ rotation:20, maxLength:6 }, // dataSection:targets }, yAxis :{ field : "creative", label:{ //textAlign:"right", //rotation:20, //maxLength:4 }, // dataSection:creatives }, zAxis:{ field : "resource", label:{ //rotation:20, //maxLength:6 }, //dataSection:resources }, controls:{ alpha: 5, //绕X轴旋转 beta: 5, //绕Y轴旋转 gamma: 0 //绕Z轴旋转 } }, graphs : [ { type : "heatmap", field:'score', face:'front', //绘制在box的那个面上 colorScheme: "#0A2A91", area:{ highColor:'#9254de' } }, { type : "heatmap", field:'score', face:'top', colorScheme: "#910044", area:{ highColor:'#5278f8' } }, { type : "heatmap", field:'score', face:'right', colorScheme: "#33007A", area:{ highColor:'#E05A99' } } ], tips:{ content(e){ let str='
' str+='
质量分:
'+e.data.score+'
'; str+='
创意:
'+e.data.creative+'
'; str+='
定向:
'+e.data.target+'
'; str+='
资源包:
'+e.data.resource+'
'; str+="
" return str; } }, // legend:{ // mode:'radio', // data:[{ // color:'#385ACC', // name:'创意-定向', // face:'front', // enabled:true // },{ // color:'#CC377C', // name:'创意-资源包', // face:'right', // enabled:false // },{ // color:'#FA7836', // name:'资源包-定向', // face:'top', // enabled:false // }] // } }; window.heatmap = Chartx3d.create("canvasTest" , data , options) function rotationCube(val){ if(val==1){ // heatmap.getCoord().fire({type:'toFront'}); heatmap.getCoord().rotationTo('front'); } if(val==2){ //heatmap.getCoord().fire({type:'toRight'}); heatmap.getCoord().rotationTo('right'); } if(val==3){ //heatmap.getCoord().fire({type:'toTop'}); heatmap.getCoord().rotationTo('top'); } } heatmap.getCoord().on('planeclick',(e)=>{ alert(JSON.stringify(e.data.rowData)); }) function computeData(){ data= []; let cs = creatives.concat([]); cs.length = Math.floor(Math.random()*creatives.length+1); let ts = targets.concat([]); ts.length = Math.floor(Math.random()*targets.length+1); let rs = resources.concat([]); rs.length = Math.floor(Math.random()*resources.length+1); //(创意和定向) cs.forEach(creative=>{ ts.forEach(target=>{ data.push({ creative, target, resource:'', score:Math.floor(Math.random()*10) }) }) }); //(创意和资源包) cs.forEach(creative=>{ rs.forEach(resource=>{ data.push({ creative, target:'', resource, score:Math.floor(Math.random()*10) }) }) }); //(资源包和定向) rs.forEach(resource=>{ ts.forEach(target=>{ data.push({ creative:'', target, resource, score:Math.floor(Math.random()*10) }) }) }); } function resetData(){ computeData(); heatmap.resetData(data); }
魔方-热力图(bar chart)
联系人:@不决
创意-定向
创意-资源包
资源包-定向
更新数据