import h337 from 'heatmapjs';
/**
 * @function getDpi
 * @description 获取Dpi
 * @return dpi
 */
export const getDpi = () => {
    const tmpNode = document.createElement('DIV');
    tmpNode.style.cssText =
        'width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden';
    document.body.appendChild(tmpNode);
    const dpi = tmpNode.offsetWidth;
    tmpNode.parentNode.removeChild(tmpNode);
    return dpi;
};
/**
 * @function guid
 * @description 获取唯一ID
 * @return uid
 */
export const guid = () => {
    function S4() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    }
    return (S4() +
        S4() +
        '-' +
        S4() +
        '-' +
        S4() +
        '-' +
        S4() +
        '-' +
        S4() +
        S4() +
        S4());
};
/**
 * @function
 * @description 创建热力图
 * @return
 */
export const createHeatMap = (value) => {
    const heatmapInstance = h337.create({
        container: document.querySelector('.heatmap'),
        radius: value
    });
    const points = [];
    let max = 0;
    const width = 840;
    const height = 400;
    let len = 200;
    while (len--) {
        const val = Math.floor(Math.random() * 100);
        max = Math.max(max, val);
        const point = {
            x: Math.floor(Math.random() * width),
            y: Math.floor(Math.random() * height),
            value: val
        };
        points.push(point);
    }
    const data = {
        max: max,
        data: points
    };
    heatmapInstance.setData(data);
    return heatmapInstance;
};
