js使用heatmap熱力圖的一些操作
阿新 • • 發佈:2019-02-17
/*********蒙版的新增***********/
$("body").append("<div></div>");
var dm_wh = $(document).width();
var dm_hg = $(document).height();
var div_last = $("body").children().last();
div_last.css({"position":"absolute","top":"0","left":"0","backgroundcolor":"#000","width":dm_wh,"height":dm_hg,"opacity":"0.65"});
/*********************************************************************************************************************************/
var xx = h337.create({"element":document.getElementById("heatmapArea"), "radius":23,"opacity": 40, "visible":true});
var m = $("a");
var m_radius = 23; //半徑的大小
var m_x = 0; //x座標軸
var m_y = 0; //y座標軸
var m_count = 0;
for(var i=0;i<m.length;i++)
{
var m_html = m.eq(i).html();
//按鈕形式連結 按鈕和圖片
if(m_html.indexOf("button")>0 || m.eq(i).role == "button" || m_html.indexOf("img")>0)
{
var m_img;
if(m_html.indexOf("img")>0)
m_img = m.eq(i).find("img");
else
m_img = m.eq(i).children();
m_x = m_img.offset().left;
m_y = m_img.offset().top;
var m_count_y = m_img.height()/m_radius;
var m_count_x = m_img.width()/m_radius;
//需要幾排的高度
if(m_count_y >= 1)
{
for(var j=0;j<m_count_y;j++)
{
for(var h=0;h<m_count_x;h++)
{
xx.store.addDataPoint(m_x, m_y,10);
m_x += m_radius;
}
m_y += m_radius;
m_x = m_img.offset().left;
}
}
else
{
for(var h=0;h<m_count_x;h++)
{
xx.store.addDataPoint(m_x, m_y,10);
m_x += m_radius;
}
}
}
//普通文字形式連線
else
{
m_count = m.eq(i).width() / m_radius;
var zf_p_l = m.eq(i).css("padding-left");
var zf_p_t = m.eq(i).css("padding-top") ;
m_x = m.eq(i).offset().left +m_radius/2;
m_y = m.eq(i).offset().top +m_radius/3;
if(zf_p_l)
{
zf_p_l = zf_p_l.substring(0,zf_p_l.length-2);
zf_p_l = zf_p_l*1;
m_x += zf_p_l;
}
if(zf_p_t)
{
zf_p_t = zf_p_t.substring(0,zf_p_t.length-2);
zf_p_t = zf_p_t*1;
m_y += zf_p_t;
}
for(var j =0;j<m_count;j++)
{
xx.store.addDataPoint(m_x, m_y,50);
m_x += m_radius;
}
}
}
$("body").append("<div></div>");
var dm_wh = $(document).width();
var dm_hg = $(document).height();
var div_last = $("body").children().last();
div_last.css({"position":"absolute","top":"0","left":"0","backgroundcolor":"#000","width":dm_wh,"height":dm_hg,"opacity":"0.65"});
/*********************************************************************************************************************************/
var xx = h337.create({"element":document.getElementById("heatmapArea"), "radius":23,"opacity": 40, "visible":true});
var m = $("a");
var m_radius = 23; //半徑的大小
var m_x = 0; //x座標軸
var m_y = 0; //y座標軸
var m_count = 0;
for(var i=0;i<m.length;i++)
{
var m_html = m.eq(i).html();
//按鈕形式連結 按鈕和圖片
if(m_html.indexOf("button")>0 || m.eq(i).role == "button" || m_html.indexOf("img")>0)
{
var m_img;
if(m_html.indexOf("img")>0)
m_img = m.eq(i).find("img");
else
m_img = m.eq(i).children();
m_x = m_img.offset().left;
m_y = m_img.offset().top;
var m_count_y = m_img.height()/m_radius;
var m_count_x = m_img.width()/m_radius;
//需要幾排的高度
if(m_count_y >= 1)
{
for(var j=0;j<m_count_y;j++)
{
for(var h=0;h<m_count_x;h++)
{
xx.store.addDataPoint(m_x, m_y,10);
m_x += m_radius;
}
m_y += m_radius;
m_x = m_img.offset().left;
}
}
else
{
for(var h=0;h<m_count_x;h++)
{
xx.store.addDataPoint(m_x, m_y,10);
m_x += m_radius;
}
}
}
//普通文字形式連線
else
{
m_count = m.eq(i).width() / m_radius;
var zf_p_l = m.eq(i).css("padding-left");
var zf_p_t = m.eq(i).css("padding-top") ;
m_x = m.eq(i).offset().left +m_radius/2;
m_y = m.eq(i).offset().top +m_radius/3;
if(zf_p_l)
{
zf_p_l = zf_p_l.substring(0,zf_p_l.length-2);
zf_p_l = zf_p_l*1;
m_x += zf_p_l;
}
if(zf_p_t)
{
zf_p_t = zf_p_t.substring(0,zf_p_t.length-2);
zf_p_t = zf_p_t*1;
m_y += zf_p_t;
}
for(var j =0;j<m_count;j++)
{
xx.store.addDataPoint(m_x, m_y,50);
m_x += m_radius;
}
}
}