import echarts from 'echarts'
/**
* @description 生成echarts 渐变色
*/
export const generateLineGraphic = (startColor, endColor) => {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: startColor },
{ offset: 1, color: endColor }
])
}
/**
* 生成分析图hover dom
*/
export const generateDiagramsHoveDom = (options) => {
return `
${options[0].value}
`
}
/**
* @description 获取地图的hover item元素
* @param {*} title
* @param {*} value
* @returns
*/
export const getMapDataItem = (title, value = 0) => {
return `
${title}
${value}
`
}
/**
* @description
*/
export const generateMapHoveDom = (options) => {
let currentData = options.data
if (currentData && typeof currentData.value === 'string') {
currentData = JSON.parse(currentData.value)
} else {
currentData = [{}, {}, {}, {}]
}
return `
${options.name}
${getMapDataItem(currentData[0].dataType || '', currentData[0].dataNumber || 0)}
${getMapDataItem(currentData[1].dataType || '', currentData[1].dataNumber) || 0}
${getMapDataItem(currentData[2].dataType || '', currentData[2].dataNumber) || 0}
${getMapDataItem(currentData[3].dataType || '', currentData[3].dataNumber) || 0}
`
}
/**
* @description 生成默认的统计数据
*/
export const getDefaultBarData = () => {
const res = {}
for (let i = 1; i <= 12; i++) {
res[i] = 0
}
return res
}