You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.6 KiB
89 lines
2.6 KiB
import chartdatas from './chartData.json';
|
|
|
|
const chartDatas = chartdatas;
|
|
|
|
export function getAllChartdatas(){
|
|
return chartDatas;
|
|
}
|
|
export function getChartData(name,childName){
|
|
return chartDatas[name][childName];
|
|
}
|
|
|
|
export function tranNumber(num){
|
|
let numStr = num.toString();
|
|
let numV = 0;
|
|
// 十万以内直接返回
|
|
if (numStr.length < 5 ) {
|
|
return numStr;
|
|
}else if(numStr.length>=5 && numStr.length<=7){
|
|
// 单位用K(千)
|
|
numV =parseInt(num/1000);
|
|
return numV+'K';
|
|
}else if(numStr.length>=8 && numStr.length<=10){
|
|
numV =parseInt(num/10000);
|
|
return numV+'W';
|
|
}else if(numStr.length>=11){
|
|
numV =parseInt(num/100000000);
|
|
return numV+'M';
|
|
}
|
|
|
|
};
|
|
|
|
// 折线 图表 统一弹窗
|
|
|
|
/**
|
|
*
|
|
*
|
|
* @export
|
|
* @param {*} name 标题
|
|
* backgrouncolor 背景色
|
|
* @param {*} data 数据
|
|
* @param {*} seriesName 系列名
|
|
* @param {*} label 数据后面的单位
|
|
*/
|
|
export function lineToolTips(name,backgrouncolor,data,seriesName,index){
|
|
// var res = `<div>
|
|
|
|
// </div>`
|
|
// var top = index==0?0:15;
|
|
var res = `<div style="font-size:12px; color:#ffffff;text-align:left;">
|
|
<span style="display:inline-block;margin-right:0px;width:8px;height:8px;border-radius:0px;background-color:${backgrouncolor};"></span>
|
|
<span style="margin-right:3px;opacity: 0.65;">${seriesName}</span>
|
|
<span style="opacity: 0.65;">${name}</span>
|
|
<span style="font-weight:400;color:#fff;margin-left:3px;">
|
|
${data}</span>
|
|
</div>`
|
|
|
|
return res;
|
|
}
|
|
|
|
/**
|
|
*
|
|
*
|
|
* @export 16进制颜色值转RGB
|
|
* @param {*} color
|
|
* @return {*}
|
|
*/
|
|
export function colorTransferToRgb(color) {
|
|
var colorObj = {r:0,g:0,b:0};
|
|
if (typeof color !== 'string' && !(color instanceof String)) return console.error("请输入16进制字符串形式的颜色值");
|
|
color = color.charAt(0) === '#' ? color.substring(1) : color;
|
|
if (color.length !== 6 && color.length !== 3) return console.error("请输入正确的颜色值")
|
|
if (color.length === 3) {
|
|
color = color.replace(/(\w)(\w)(\w)/, '$1$1$2$2$3$3')
|
|
}
|
|
var reg = /\w{2}/g;
|
|
var colors = color.match(reg);
|
|
for (var i = 0; i < colors.length; i++) {
|
|
colors[i] = parseInt(colors[i], 16).toString();
|
|
if(i==0){
|
|
colorObj.r = parseInt(colors[i]);
|
|
}else if(i==1){
|
|
colorObj.g = parseInt(colors[i]);
|
|
}else if(i==2){
|
|
colorObj.b = parseInt(colors[i]);
|
|
}
|
|
}
|
|
|
|
return colorObj;
|
|
}
|
|
|