 
						只需要引入heatmap.min.js文件
| 1 | <scriptsrc="js/heatmap.min.js"></script> | 
html加入热力图所需要的图片
| 1 | <divclass="heatmap"style="width:538px; height:503px; background:url(images/t.png) no-repeat;">热力图</div> | 
js
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // 创建一个heatmap实例对象// “h337” 是heatmap.js全局对象的名称.可以使用它来创建热点图实例// 这里直接指定热点图渲染的div了.heatmap支持自定义的样式方案,网页外包接活具体可看官网apivarheatmapInstance = h337.create({    container: document.querySelector('.heatmap'),});//构建一些随机数据点,网页切图价格这里替换成你的业务数据varpoints = [];varmax = 100;varwidth = 538;varheight = 503;varlen = 5;while(len--) {    varval = Math.floor(Math.random() * 1000);    max = Math.max(max, val);    varpoint = {        //演示随机数据        x: Math.floor(Math.random() * width),        y: Math.floor(Math.random() * height),        value: val    };    points.push(point);}vardata = {    max: max,    data: points};//因为data是一组数据,web切图报价所以直接setDataheatmapInstance.setData(data); //数据绑定还可以使用 | 
特别申明:
			本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
			本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
			如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com