2025-08-12 09:13:50 +08:00

1321 lines
36 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* uCharts®
* 高性能跨平台图表库支持H5、APP、小程序微信/支付宝/百度/头条/QQ/360、Vue、Taro等支持canvas的框架平台
* Copyright (c) 2021 QIUN®秋云 https://www.ucharts.cn All rights reserved.
* Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
* 复制使用请保留本段注释,感谢支持开源!
*
* uCharts®官方网站
* https://www.uCharts.cn
*
* 开源地址:
* https://gitee.com/uCharts/uCharts
*
* uni-app插件市场地址
* http://ext.dcloud.net.cn/plugin?id=271
*
*/
// 主题颜色配置如每个图表类型需要不同主题请在对应图表类型上更改color属性
const color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
// 四舍五入的保留两位小数的 金额化数字方法
const fmoney = (s, n) => {
/*
* 参数说明:
* s要格式化的数字
* n保留几位小数
* */
n = n > 0 && n <= 20 ? n : 2;
var fuhao = ''; //如果数字小于零则值为-
if (s < 0) {
s = Math.abs(s);
fuhao = '-'
}
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
var l = s.split(".")[0].split("").reverse(),
r = s.split(".")[1];
let t = "";
for (let i = 0; i < l.length; i++) {
t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
}
if (n === 0) {
return s
} else {
return fuhao + [...t].reverse().join("") + "." + r;
}
}
// 四舍五入不保留小数的 金额化数字方法
const noDecimal = (s) => {
let fuhao = ''; //如果数字小于零则值为-
if (s < 0) {
s = Math.abs(s);
fuhao = '-'
}
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")) + ""
let l = s.split(".")[0].split("").reverse(),
r = s.split(".")[1];
let t = ''
for (let i = 0; i < l.length; i++) {
t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
}
return fuhao + [...t].reverse().join("")
}
// 不四舍五入 保留两位小数的金额化方法
const getMoney = (money) => {
if (!money || isNaN(money)) return "0.00";
let num = parseFloat(money + '') + '';
num = parseInt(money * 100 + '') / 100 + ''
let reg = /(-?\d+)(\d{3})/;
while (reg.test(num)) {
num = num.replace(reg, "$1,$2");
}
let idx = num.indexOf('.')
if (idx === -1) {
num = num + '.00'
}
if (idx > 0) {
let num_per = num.substring(0, idx) + '.'
let num_next = num.substring(idx + 1).padEnd(2, '0')
num = num_per + num_next
}
return num;
}
// 不四舍五入 不保留两位小数的金额化方法
const getMoneyNoDecimal = (money) => {
if (!money || isNaN(money)) return "0";
let num = parseFloat(money + '') + '';
num = parseInt(money * 100 + '') / 100 + ''
let reg = /(-?\d+)(\d{3})/;
while (reg.test(num)) {
num = num.replace(reg, "$1,$2");
}
let idx = num.indexOf('.')
if (idx === -1) {
num = num
}
if (idx > 0) {
let num_per = num.substring(0, idx)
let num_next = num.substring(idx + 1).padEnd(2, '0')
num = num_per
}
return num;
}
// 2023年的农历日历
let chineseCalendar2023 = [
'腊月十六',
'腊月十七',
'腊月十八',
'腊月十九',
'腊月二十',
'腊月廿一',
'腊月廿二',
'北小年',
'南小年',
'腊月廿五',
'腊月廿六',
'腊月廿七',
'腊月廿八',
'腊月廿九',
'除夕',
'春节',
'正月初二',
'正月初三',
'正月初四',
'正月初五',
'正月初六',
'正月初七',
'正月初八',
'正月初九',
'正月初十',
'正月十一',
'正月十二',
'正月十三',
'正月十四',
'正月十五',
'正月十六',
'正月十七',
'正月十八',
'正月十九',
'正月二十',
'正月廿一',
'正月廿二',
'正月廿三',
'正月廿四',
'正月廿五',
]
// 2024年的农历日历
let chineseCalendar2024 = [
'腊月十六',
'腊月十七',
'腊月十八',
'腊月十九',
'腊月二十',
'腊月廿一',
'腊月廿二',
'北小年',
'南小年',
'腊月廿五',
'腊月廿六',
'腊月廿七',
'腊月廿八',
'腊月廿九',
'除夕',
'春节',
'正月初二',
'正月初三',
'正月初四',
'正月初五',
'正月初六',
'正月初七',
'正月初八',
'正月初九',
'正月初十',
'正月十一',
'正月十二',
'正月十三',
'正月十四',
'正月十五',
'正月十六',
'正月十七',
'正月十八',
'正月十九',
'正月二十',
'正月廿一',
'正月廿二',
'正月廿三',
'正月廿四',
'正月廿五',
]
// 2025年农历日历
let chineseCalendar2025 = [
'腊月十五',
'腊月十六',
'腊月十七',
'腊月十八',
'腊月十九',
'腊月二十',
'腊月廿一',
'腊月廿二',
'北小年',
'南小年',
'腊月廿五',
'腊月廿六',
'腊月廿七',
'腊月廿八',
'除夕',
'春节',
'正月初二',
'正月初三',
'正月初四',
'正月初五',
'正月初六',
'正月初七',
'正月初八',
'正月初九',
'正月初十',
'正月十一',
'正月十二',
'正月十三',
'正月十四',
'正月十五',
'正月十六',
'正月十七',
'正月十八',
'正月十九',
'正月二十',
'正月廿一',
'正月廿二',
'正月廿三',
'正月廿四',
'正月廿五',
]
// 2023年节假日安排表
let festivalObj2023 = {
"2023-01-01": "元旦",
"2023-04-05": "清明节",
"2023-05-01": "劳动节‌",
"2023-06-22": "端午节‌",
"2023-09-29": "中秋节",
"2023-10-01": "国庆节",
}
// 2024年节假日安排表
let festivalObj2024 = {
"2024-01-01": "元旦",
"2024-04-04": "清明节",
"2024-05-01": "劳动节‌",
"2024-06-10": "端午节‌",
"2024-09-17": "中秋节",
"2024-10-01": "国庆节",
}
// 2025年节假日安排表
let festivalObj2025 = {
"2025-01-01": "元旦",
"2025-04-04": "清明节",
"2025-05-01": "劳动节‌",
"2025-05-31": "端午节‌",
"2025-10-06": "中秋节",
"2025-10-01": "国庆节",
}
const handleRedText = (value) => {
return <text > {
{
value
}
} < /text>
}
//事件转换函数主要用作格式化x轴为时间轴根据需求自行修改
const formatDateTime = (timeStamp, returnType) => {
var date = new Date();
date.setTime(timeStamp * 1000);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
if (returnType == 'full') {
return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
}
if (returnType == 'y-m-d') {
return y + '-' + m + '-' + d;
}
if (returnType == 'h:m') {
return h + ':' + minute;
}
if (returnType == 'h:m:s') {
return h + ':' + minute + ':' + second;
}
return [y, m, d, h, minute, second];
}
const cfu = {
//demotype为自定义图表类型一般不需要自定义图表类型只需要改根节点上对应的类型即可
"type": ["pie", "ring", "rose", "word", "funnel", "map", "arcbar", "line", "column", "mount", "bar", "area", "radar", "gauge", "candle", "mix", "tline", "tarea", "scatter", "bubble", "demotype"],
"range": ["饼状图", "圆环图", "玫瑰图", "词云图", "漏斗图", "地图", "圆弧进度条", "折线图", "柱状图", "山峰图", "条状图", "区域图", "雷达图", "仪表盘", "K线图", "混合图", "时间轴折线", "时间轴区域", "散点图", "气泡图", "自定义类型"],
//增加自定义图表类型如果需要categories请在这里加入您的图表类型例如最后的"demotype"
//自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴矢量x轴类图表没有categories不需要加入categories
"categories": ["line", "column", "mount", "bar", "area", "radar", "gauge", "candle", "mix", "demotype"],
//instance为实例变量承载属性不要删除
"instance": {},
//option为opts及eopts承载属性不要删除
"option": {},
//下面是自定义format配置因除H5端外的其他端无法通过props传递函数只能通过此属性对应下标的方式来替换
"formatter": {
"yAxisDemo1": function (val, index, opts) {
return val + '元'
},
"yAxisDemo2": function (val, index, opts) {
return val.toFixed(2)
},
"xAxisDemo1": function (val, index, opts) {
return val + '年';
},
"xAxisDemo2": function (val, index, opts) {
return formatDateTime(val, 'h:m')
},
"seriesDemo1": function (val, index, series, opts) {
return val + '元'
},
"tooltipDemo1": function (item, category, index, opts) {
if (index == 0) {
return '随便用' + item.data + '年'
} else {
return '其他我没改' + item.data + '天'
}
},
"pieDemo": function (val, index, series, opts) {
if (index !== undefined) {
return series[index].name + '' + series[index].data + '元'
}
},
"entryCarNumber2": function (item, category, index, opts) {
console.log('item', item)
console.log('category', category)
console.log('index', index)
console.log('opts', opts)
let type = opts.series[0].selectFestival
console.log('type', type)
if (type === 0) {
// return item.name
let data = opts.series.filter(subItem => subItem.name === item.name)[0].real[index]
let day = opts.series.filter(subItem => subItem.name === item.name)[0].howDayNumber
console.log('data', data)
console.log('day', day)
if (item.name === '23年') {
if (index < day) {
return item.name + "" + getMoney(data / 10000, 2) + '万元'
} else {
let indexList = "6,8,14,15,20,22,24,25,29,30"
let dateList = opts.series.filter(subItem => subItem.name === item.name)[0].tradDate
let realDate
if (index === 6 || index === 8 || index === 14 || index === 15 || index === 20 || index === 22 || index === 24 || index === 25 || index === 29 || index === 30) {
realDate = dateList[index]
}
return item.name + "" + getMoney(data / 10000, 2) + '万元' + `${realDate?realDate:''}`
}
} else {
let indexList = "6,8,14,15,20,22,24,25,29,30"
// let indexList = "8,9,15,16,21,23,25,26,30,31"
let dateList = opts.series.filter(subItem => subItem.name === item.name)[0].tradDate
console.log('dateList', dateList)
let realDate
if (index === 6 || index === 8 || index === 14 || index === 15 || index === 20 || index === 22 || index === 24 || index === 25 || index === 29 || index === 30) {
realDate = dateList[index]
}
let curData = opts.series.filter(subItem => subItem.name === '24年')[0].real[index]
let compareData = opts.series.filter(subItem => subItem.name === '23年')[0].real[index]
let add = Number(((curData / compareData) - 1) * 100).toFixed(2)
if (index < day) {
return `${item.name}${getMoney(data / 10000,2)}万元${add>0?'+':add<0?'':''}${add?add+'%':''}${realDate?realDate:''}`
} else {
return ' '
}
}
} else if (type === 1) {
let data = opts.series.filter(subItem => subItem.name === item.name)[0].real[index]
let day = opts.series.filter(subItem => subItem.name === item.name)[0].howDayNumber
let festivalType = opts.series[0].selectFestival
console.log('festivalType', festivalType)
console.log('data', data)
console.log('day', day)
let curData = opts.series.filter(subItem => subItem.name === '24年')[0].real[index]
let compareData = opts.series.filter(subItem => subItem.name === '23年')[0].real[index]
// 显示具体的日期
let realDate = opts.series.filter(subItem => subItem.name === '23年')[0].realDateList[index]
// 显示具体的日期
let curDate = opts.series.filter(subItem => subItem.name === '24年')[0].realDateList[index]
let add = Number(((curData / compareData) - 1) * 100).toFixed(2)
if (item.name === '24年') {
if (data) {
return `${festivalType===2?curDate:item.name}${data?getMoney(data / 10000,2):''}万元${add>0?'+':add<0?'':''}${add?add+'%':''}${festivalType===1 && index===1?'(清明节)':''}`
} else {
return `${curDate}`
}
} else {
return `${festivalType===2?realDate:item.name}${data?getMoney(data / 10000,2):''}万元${festivalType===1 && index===1?'(清明节)':''}`
}
} else if (type === 2) {
let data = opts.series.filter(subItem => subItem.name === item.name)[0].real[index]
let day = opts.series.filter(subItem => subItem.name === item.name)[0].howDayNumber
let festivalType = opts.series[0].selectFestival
console.log('festivalType', festivalType)
console.log('data', data)
console.log('day', day)
let curData = opts.series.filter(subItem => subItem.name === '24年')[0].real[index]
let compareData = opts.series.filter(subItem => subItem.name === '23年')[0].real[index]
// 显示具体的日期
let realDate = opts.series.filter(subItem => subItem.name === '23年')[0].realDateList[index]
// 显示具体的日期
let curDate = opts.series.filter(subItem => subItem.name === '24年')[0].realDateList[index]
let add = Number(((curData / compareData) - 1) * 100).toFixed(2)
if (item.name === '24年') {
if (data) {
return `${curDate}${data?getMoney(data / 10000,2):''}万元${add>0?'+':add<0?'':''}${add?add+'%':''}${festivalType===1 && index===1?'(劳动节)':''}`
} else {
return `${curDate}`
}
} else {
return `${realDate}${data?getMoney(data / 10000,2):''}万元${festivalType===1 && index===1?'(劳动节)':''}`
}
} else if (type === 3) {
let data = opts.series.filter(subItem => subItem.name === item.name)[0].real[index]
let day = opts.series.filter(subItem => subItem.name === item.name)[0].howDayNumber
let festivalType = opts.series[0].selectFestival
console.log('festivalType', festivalType)
console.log('data', data)
console.log('day', day)
let curData = opts.series.filter(subItem => subItem.name === '24年')[0].real[index]
let compareData = opts.series.filter(subItem => subItem.name === '23年')[0].real[index]
// 显示具体的日期
let realDate = opts.series.filter(subItem => subItem.name === '23年')[0].realDateList[index]
// 显示具体的日期
let curDate = opts.series.filter(subItem => subItem.name === '24年')[0].realDateList[index]
let add = Number(((curData / compareData) - 1) * 100).toFixed(2)
if (item.name === '24年') {
if (data) {
return `${curDate}${data?getMoney(data / 10000,2):''}万元${add>0?'+':add<0?'':''}${add?add+'%':''}${index===3?'(端午节)':''}`
} else {
return `${curDate}`
}
} else {
return `${realDate}${data?getMoney(data / 10000,2):''}万元${index===1?'(端午节)':''}`
}
} else {
let festivalType = opts.series[0].selectFestival
let curData = opts.series.filter(subItem => subItem.name === '24年')[0].real[index]
let compareData = opts.series.filter(subItem => subItem.name === '23年')[0].real[index]
// 显示具体的日期
let realDate = opts.series.filter(subItem => subItem.name === '23年')[0].realDateList[index]
// 显示具体的日期
let curDate = opts.series.filter(subItem => subItem.name === '24年')[0].realDateList[index]
let add = Number(((curData / compareData) - 1) * 100).toFixed(2)
console.log('curDate', curDate)
let data = opts.series.filter(subItem => subItem.name === item.name)[0].real[index]
if (item.name === '24年') {
if (data) {
return `${curDate}${data?getMoney(data / 10000,2):''}万元${add>0?'+':add<0?'':''}${add?add+'%':''}${
festivalType===1 && index===1?'(清明节)':
festivalType===2 && index===2?'(劳动节)':
festivalType===3 && index===3?'(端午节)':
festivalType===5 && index===3?'(中秋节)':
festivalType===6 && index===1?'(国庆节)':
''}`
} else {
return `${curDate}`
}
} else {
return `${realDate}${data?getMoney(data / 10000,2):''}万元${
festivalType===1 && index===1?'(清明节)':
festivalType===2 && index===3?'(劳动节)':
festivalType===3 && index===1?'(端午节)':
festivalType===5 && index===1?'(中秋节)':
festivalType===6 && index===3?'(国庆节)':
''}`
}
}
},
"entryCarNumber": function (item, category, index, opts) {
console.log('item', item);
console.log('category', category);
console.log('index', index);
console.log('opts', opts);
// 先拿到节日类型
let festival = opts.selectFestival
// 需要添加在显示文字的节日文字
let otherFestivalTest = ''
// 从opts里面 拿到这一行的详细数据
let detail = opts.series.filter(subItem => subItem.name === item.name)[0]
console.log('detail.realDateList[index]', detail.realDateList[index]);
if (festival === 2) {
// 春节
let resObj = [];
if (item.name === 2023) {
resObj = chineseCalendar2023
} else if (item.name === 2024) {
resObj = chineseCalendar2024
} else if (item.name === 2025) {
resObj = chineseCalendar2025
}
otherFestivalTest = resObj[index]
} else if (festival === 1 || festival === 3 || festival === 4 || festival === 5 || festival === 7 || festival === 8) {
// 非春节和暑期
let resObj = {}
if (item.name === 2023) {
resObj = festivalObj2023
} else if (item.name === 2024) {
resObj = festivalObj2024
} else if (item.name === 2025) {
resObj = festivalObj2025
}
if (detail.realDateList[index]) {
if (resObj[detail.realDateList[index]]) {
otherFestivalTest = resObj[detail.realDateList[index]]
}
}
}
// 日期格式老的太长了修改一下显示
const date = new Date(detail.realDateList[index])
let y = date.getFullYear()
y = y.toString().slice(2, 4)
let m = date.getMonth() + 1
if (m < 10) {
m = '0' + m
}
let d = date.getDate()
if (d < 10) {
d = '0' + d
}
let dateText = `${y}.${m}.${d}`
let add = ''
if (detail.linearIndex > 0) {
// 上一年
let lastYearObj = opts.series[detail.linearIndex - 1]
console.log('lastYearObj', lastYearObj);
// 当前年
let currentYearObj = opts.series[detail.linearIndex]
add = (((currentYearObj.real[index] - lastYearObj.real[index]) / lastYearObj.real[index]) * 100).toFixed(2) + '%'
}
return `${dateText}${otherFestivalTest?`(${otherFestivalTest})`:'' } ${detail.data[index].toFixed(2)}万元${add?detail.data[index]>0?''+add:'':''}`
// return item.name
// let data = opts.series.filter(subItem=> subItem.name === item.name)[0].real[index]
// let day = opts.series.filter(subItem=> subItem.name === item.name)[0].howDayNumber
// let festivalType = opts.series[0].selectFestival
// console.log('festivalType',festivalType)
// console.log('data',data)
// console.log('day',day)
// let curData = opts.series.filter(subItem=> subItem.name === '24年')[0].real[index]
// let compareData = opts.series.filter(subItem=> subItem.name === '23年')[0].real[index]
// // 显示具体的日期
// let realDate = opts.series.filter(subItem=> subItem.name === '23年')[0].realDateList[index]
// // 显示具体的日期
// let curDate = opts.series.filter(subItem=> subItem.name === '24年')[0].realDateList[index]
// let add = Number(((curData/compareData)-1)*100).toFixed(2)
// if(item.name==='24年'){
// if(data){
// return `${curDate}${data?getMoney(data / 10000,2):''}万元${add>0?'+':add<0?'':''}${add?add+'%':''}${
// festivalType===1 && index===1?'(清明节)':
// festivalType===2 && index===2?'(劳动节)':
// festivalType===3 && index===3?'(端午节)':
// festivalType===5 && index===3?'(中秋节)':
// festivalType===6 && index===1?'(国庆节)':
// ''}`
// }else{
// return `${curDate}`
// }
// }else{
// return `${realDate}${data?getMoney(data / 10000,2):''}万元${
// festivalType===1 && index===1?'(清明节)':
// festivalType===2 && index===3?'(劳动节)':
// festivalType===3 && index===1?'(端午节)':
// festivalType===5 && index===1?'(中秋节)':
// festivalType===6 && index===3?'(国庆节)':
// ''}`
// }
// if (item.name==='24年'){
// if (data){
// return `${festivalType===2 || festivalType===3?curDate:item.name}${data?getMoney(data / 10000,2):''}万元${add>0?'+':add<0?'':''}${add?add+'%':''}${festivalType===1 && index===1?'(清明节)':festivalType===3 && index===3?'(端午节)':''}`
// }else{
// return `${curDate}`
// }
// }else{
// return `${festivalType===2 || festivalType===3?realDate:item.name}${data?getMoney(data / 10000,2):''}万元${festivalType===1 && index===1?'(清明节)':festivalType===3 && index===1?'(端午节)':''}`
// }
},
entryCarNumberXFormat: function (value, index, opts) {
return value
},
monthTotal: function (item, category, index, opts) {
let text = ''
let type = item.name.slice(5, 10)
let time = opts.series[0].info[index].year
if (type === '车流量') {
if (`${time}年车流量` === item.name) {
let showTime = opts.series[0].info[index].year.toString().slice(2, 5)
text = `${showTime}年入区 ${opts.series[0].info[index].allCarCount?fmoney(opts.series[0].info[index].allCarCount):''}`
} else {
let showTime = opts.series[1].info[index].year.toString().slice(2, 5)
text = `${showTime}年入区 ${opts.series[1].info[index].allCarCount?fmoney(opts.series[1].info[index].allCarCount):''}`
}
return text
} else {
if (`${time}年交易额` === item.name) {
let showTime = opts.series[2].year.toString().slice(2, 5)
console.log('showTime', showTime)
text = `${showTime}年金额 ${opts.series[2].info[index].money?fmoney(opts.series[2].info[index].money):''} 元, 单车消费 ${opts.series[0].info[index].allCarCount?((opts.series[0].info[index].money) / opts.series[0].info[index].allCarCount).toFixed(2):''}`
} else {
let showTime = opts.series[3].year.toString().slice(2, 5)
text = `${showTime}年金额 ${opts.series[3].info[index].money?fmoney(opts.series[3].info[index].money):''} 元, 单车消费 ${opts.series[1].info[index].allCarCount?((opts.series[1].info[index].money) / opts.series[1].info[index].allCarCount).toFixed(2):''}`
}
return text
}
},
homePlace: function (item, category, index, opts) {
console.log('item', item)
console.log('opts', opts)
if (item.name.split(' ')[0] === '其他') {
let str = ''
opts.homeData.forEach(item => {
if (item.name.split(' ')[0] !== '其他') {
if (str === '') {
str = item.name.split(' ')[0]
} else {
str += `,${item.name.split(' ')[0]}`
}
}
})
}
return item.name + ":" + item.data + '辆';
},
carTypeTime: function (item, category, index, opts) {
if (this.num === 0) {
this.num++
return '日均车辆' + ":" + opts.series[0].valueList[index] + '辆,占比' + item.data + '%';
} else {
this.num = 0
return '平均停留' + ":" + item.data + '分钟';
}
},
timeAnalysis: function (item, category, index, opts) {
return item.name + ":" + item.data + '分钟'
},
businessType: function (item, category, index, opts) {
return item.name;
},
"moneyCompare": function (item, category, index, opts) {
const date = new Date()
let m = date.getMonth()
console.log('item', item)
console.log('category', category)
console.log('index', index)
console.log('opts', opts)
if (index > m) {
if (opts.otherType === 0) {
if (item.name === '工作日平均') {
return item.name + "" + item.data + '万元'
} else if (item.name === '周末平均') {
return item.name + "" + item.data + '万元'
} else {
return item.name + "" + item.data + '万元'
}
} else if (opts.otherType === 1) {
if (item.name === '工作日平均') {
return item.name + "" + noDecimal(item.data) + '笔'
} else if (item.name === '周末平均') {
return item.name + "" + noDecimal(item.data) + '笔'
} else {
return item.name + "" + noDecimal(item.data) + '笔'
}
} else if (opts.otherType === 2) {
if (item.name === '工作日平均') {
return item.name + "" + item.data + '元'
} else if (item.name === '周末平均') {
return item.name + "" + item.data + '元'
} else {
return item.name + "" + item.data + '元'
}
}
} else {
if (opts.otherType === 0) {
if (item.name === '工作日平均') {
return item.name + "" + item.data + '万元,' + '较上月:' + opts.series[0].qoqAdd[index] + '%'
} else if (item.name === '周末平均') {
return item.name + "" + item.data + '万元,' + '较工作日:' + opts.series[1].qoqAdd[index] + '%'
} else {
// 判断有节假日就显示括号 没有就不显示
if (opts.series[2].holiday[index][1]) {
return item.name + "" + item.data + '万元' + '(' + opts.series[2].holiday[index][1] + ')'
} else {
return item.name + "" + item.data + '万元'
}
}
} else if (opts.otherType === 1) {
if (item.name === '工作日平均') {
return item.name + "" + noDecimal(item.data) + '笔,' + '较上月:' + opts.series[0].qoqAdd[index] + '%'
} else if (item.name === '周末平均') {
return item.name + "" + noDecimal(item.data) + '笔,' + '较工作日:' + opts.series[1].qoqAdd[index] + '%'
} else {
if (opts.series[2].holiday[index][1]) {
return item.name + "" + noDecimal(item.data) + '笔' + '(' + opts.series[2].holiday[index][1] + ')'
} else {
return item.name + "" + noDecimal(item.data) + '笔'
}
}
} else if (opts.otherType === 2) {
if (item.name === '工作日平均') {
return item.name + "" + item.data + '元,' + '较上月:' + opts.series[0].qoqAdd[index] + '%'
} else if (item.name === '周末平均') {
return item.name + "" + item.data + '元,' + '较工作日:' + opts.series[1].qoqAdd[index] + '%'
} else {
if (opts.series[2].holiday[index][1]) {
return item.name + "" + item.data + '元' + '(' + opts.series[2].holiday[index][1] + ')'
} else {
return item.name + "" + item.data + '元'
}
}
}
}
},
consumptionCompare: function (item, category, index, opts) {
if (item.name === '客单数') {
return item.name + ':' + item.data + '笔'
} else {
return item.name + ':' + item.data + '辆,交易概率: ' + ((opts.series[0].data[index] / opts.series[1].data[index]) * 100).toFixed(2) + '%'
}
},
consumptionCompareFormat: function (val) {
if (val === '0:00' || val === '4:00' || val === '8:00' || val === '12:00' || val === '16:00' || val === '20:00' || val === '23:00') {
if (val === '23:00') {
return '24:00'
} else {
return val
}
} else {
return ''
}
},
timePeriodAnalysisFormat: function (val) {
if (val === 0 || val === 4 || val === 8 || val === 12 || val === 16 || val === 20 || val === 23) {
if (val === 23) {
return '24:00'
} else {
return `${val}:00`
}
} else {
return ''
}
},
timePeriodAnalysis: function (item, category, index, opts) {
return item.name + ':' + item.data + '%,' + '数量:' + opts.series[0].number[index] + '笔,金额:' + opts.series[0].money[index] + '元'
},
levelTop: function (item, category, index, opts) {
return item.name + ' ' + item.data + '%';
},
businessFormat: function (item, category, index, opts) {
return item.name + ',' + opts.series[index].text
},
fillingDegree: function (item, category, index, opts) {
return item.name;
},
yearRevenue: function (item, category, index, opts) {
let data = opts.series.filter(subItem => subItem.name === item.name)[0].real[index]
console.log('data', data)
if (data) {
return item.name + "" + getMoneyNoDecimal(data) + '辆';
} else {
return item.name + "" + 0 + '辆';
}
}
},
//这里演示了自定义您的图表类型的option可以随意命名之后在组件上 type="demotype" 后组件会调用这个花括号里的option如果组件上还存在opts参数会将demotype与opts中option合并后渲染图表。
"demotype": {
//我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
"type": "line",
"color": color,
"padding": [15, 10, 0, 15],
"xAxis": {
"disableGrid": true,
},
"yAxis": {
"gridType": "dash",
"dashLength": 2,
},
"legend": {},
"extra": {
"line": {
"type": "curve",
"width": 2
},
}
},
//下面是自定义配置,请添加项目所需的通用配置
"pie": {
"type": "pie",
"color": color,
"padding": [5, 5, 5, 5],
"extra": {
"pie": {
"activeOpacity": 0.5,
"activeRadius": 10,
"offsetAngle": 0,
"labelWidth": 15,
"border": true,
"borderWidth": 3,
"borderColor": "#FFFFFF"
},
}
},
"ring": {
"type": "ring",
"color": color,
"padding": [5, 5, 5, 5],
"rotate": false,
"dataLabel": true,
"legend": {
"show": true,
"position": "right",
"lineHeight": 25,
},
"title": {
"name": "收益率",
"fontSize": 15,
"color": "#666666"
},
"subtitle": {
"name": "70%",
"fontSize": 25,
"color": "#7cb5ec"
},
"extra": {
"ring": {
"ringWidth": 30,
"activeOpacity": 0.5,
"activeRadius": 10,
"offsetAngle": 0,
"labelWidth": 15,
"border": true,
"borderWidth": 3,
"borderColor": "#FFFFFF"
},
},
},
"rose": {
"type": "rose",
"color": color,
"padding": [5, 5, 5, 5],
"legend": {
"show": true,
"position": "left",
"lineHeight": 25,
},
"extra": {
"rose": {
"type": "area",
"minRadius": 50,
"activeOpacity": 0.5,
"activeRadius": 10,
"offsetAngle": 0,
"labelWidth": 15,
"border": false,
"borderWidth": 2,
"borderColor": "#FFFFFF"
},
}
},
"word": {
"type": "word",
"color": color,
"extra": {
"word": {
"type": "normal",
"autoColors": false
}
}
},
"funnel": {
"type": "funnel",
"color": color,
"padding": [15, 15, 0, 15],
"extra": {
"funnel": {
"activeOpacity": 0.3,
"activeWidth": 10,
"border": true,
"borderWidth": 2,
"borderColor": "#FFFFFF",
"fillOpacity": 1,
"labelAlign": "right"
},
}
},
"map": {
"type": "map",
"color": color,
"padding": [0, 0, 0, 0],
"dataLabel": true,
"extra": {
"map": {
"border": true,
"borderWidth": 1,
"borderColor": "#666666",
"fillOpacity": 0.6,
"activeBorderColor": "#F04864",
"activeFillColor": "#FACC14",
"activeFillOpacity": 1
},
}
},
"arcbar": {
"type": "arcbar",
"color": color,
"title": {
"name": "百分比",
"fontSize": 25,
"color": "#00FF00"
},
"subtitle": {
"name": "默认标题",
"fontSize": 15,
"color": "#666666"
},
"extra": {
"arcbar": {
"type": "default",
"width": 12,
"backgroundColor": "#E9E9E9",
"startAngle": 0.75,
"endAngle": 0.25,
"gap": 2
}
}
},
"line": {
"type": "line",
"color": color,
"padding": [15, 10, 0, 15],
"xAxis": {
"disableGrid": true,
},
"yAxis": {
"gridType": "dash",
"dashLength": 2,
},
"legend": {},
"extra": {
"line": {
"type": "straight",
"width": 2,
"activeType": "hollow"
},
}
},
"tline": {
"type": "line",
"color": color,
"padding": [15, 10, 0, 15],
"xAxis": {
"disableGrid": false,
"boundaryGap": "justify",
},
"yAxis": {
"gridType": "dash",
"dashLength": 2,
"data": [{
"min": 0,
"max": 80
}]
},
"legend": {},
"extra": {
"line": {
"type": "curve",
"width": 2,
"activeType": "hollow"
},
}
},
"tarea": {
"type": "area",
"color": color,
"padding": [15, 10, 0, 15],
"xAxis": {
"disableGrid": true,
"boundaryGap": "justify",
},
"yAxis": {
"gridType": "dash",
"dashLength": 2,
"data": [{
"min": 0,
"max": 80
}]
},
"legend": {},
"extra": {
"area": {
"type": "curve",
"opacity": 0.2,
"addLine": true,
"width": 2,
"gradient": true,
"activeType": "hollow"
},
}
},
"column": {
"type": "column",
"color": color,
"padding": [15, 15, 0, 5],
"xAxis": {
"disableGrid": true,
},
"yAxis": {
"data": [{
"min": 0
}]
},
"legend": {},
"extra": {
"column": {
"type": "group",
"width": 30,
"activeBgColor": "#000000",
"activeBgOpacity": 0.08
},
}
},
"mount": {
"type": "mount",
"color": color,
"padding": [15, 15, 0, 5],
"xAxis": {
"disableGrid": true,
},
"yAxis": {
"data": [{
"min": 0
}]
},
"legend": {},
"extra": {
"mount": {
"type": "mount",
"widthRatio": 1.5,
},
}
},
"bar": {
"type": "bar",
"color": color,
"padding": [15, 30, 0, 5],
"xAxis": {
"boundaryGap": "justify",
"disableGrid": false,
"min": 0,
"axisLine": false
},
"yAxis": {},
"legend": {},
"extra": {
"bar": {
"type": "group",
"width": 30,
"meterBorde": 1,
"meterFillColor": "#FFFFFF",
"activeBgColor": "#000000",
"activeBgOpacity": 0.08
},
}
},
"area": {
"type": "area",
"color": color,
"padding": [15, 15, 0, 15],
"xAxis": {
"disableGrid": true,
},
"yAxis": {
"gridType": "dash",
"dashLength": 2,
},
"legend": {},
"extra": {
"area": {
"type": "straight",
"opacity": 0.2,
"addLine": true,
"width": 2,
"gradient": false,
"activeType": "hollow"
},
}
},
"radar": {
"type": "radar",
"color": color,
"padding": [5, 5, 5, 5],
"dataLabel": false,
"legend": {
"show": true,
"position": "right",
"lineHeight": 25,
},
"extra": {
"radar": {
"gridType": "radar",
"gridColor": "#CCCCCC",
"gridCount": 3,
"opacity": 0.2,
"max": 200,
"labelShow": true
},
}
},
"gauge": {
"type": "gauge",
"color": color,
"title": {
"name": "66Km/H",
"fontSize": 25,
"color": "#2fc25b",
"offsetY": 50
},
"subtitle": {
"name": "实时速度",
"fontSize": 15,
"color": "#1890ff",
"offsetY": -50
},
"extra": {
"gauge": {
"type": "default",
"width": 30,
"labelColor": "#666666",
"startAngle": 0.75,
"endAngle": 0.25,
"startNumber": 0,
"endNumber": 100,
"labelFormat": "",
"splitLine": {
"fixRadius": 0,
"splitNumber": 10,
"width": 30,
"color": "#FFFFFF",
"childNumber": 5,
"childWidth": 12
},
"pointer": {
"width": 24,
"color": "auto"
}
}
}
},
"candle": {
"type": "candle",
"color": color,
"padding": [15, 15, 0, 15],
"enableScroll": true,
"enableMarkLine": true,
"dataLabel": false,
"xAxis": {
"labelCount": 4,
"itemCount": 40,
"disableGrid": true,
"gridColor": "#CCCCCC",
"gridType": "solid",
"dashLength": 4,
"scrollShow": true,
"scrollAlign": "left",
"scrollColor": "#A6A6A6",
"scrollBackgroundColor": "#EFEBEF"
},
"yAxis": {},
"legend": {},
"extra": {
"candle": {
"color": {
"upLine": "#f04864",
"upFill": "#f04864",
"downLine": "#2fc25b",
"downFill": "#2fc25b"
},
"average": {
"show": true,
"name": ["MA5", "MA10", "MA30"],
"day": [5, 10, 20],
"color": ["#1890ff", "#2fc25b", "#facc14"]
}
},
"markLine": {
"type": "dash",
"dashLength": 5,
"data": [{
"value": 2150,
"lineColor": "#f04864",
"showLabel": true
},
{
"value": 2350,
"lineColor": "#f04864",
"showLabel": true
}
]
}
}
},
"mix": {
"type": "mix",
"color": color,
"padding": [15, 15, 0, 15],
"xAxis": {
"disableGrid": true,
},
"yAxis": {
"disabled": false,
"disableGrid": false,
"splitNumber": 5,
"gridType": "dash",
"dashLength": 4,
"gridColor": "#CCCCCC",
"padding": 10,
"showTitle": true,
"data": []
},
"legend": {},
"extra": {
"mix": {
"column": {
"width": 20
}
},
}
},
"scatter": {
"type": "scatter",
"color": color,
"padding": [15, 15, 0, 15],
"dataLabel": false,
"xAxis": {
"disableGrid": false,
"gridType": "dash",
"splitNumber": 5,
"boundaryGap": "justify",
"min": 0
},
"yAxis": {
"disableGrid": false,
"gridType": "dash",
},
"legend": {},
"extra": {
"scatter": {},
}
},
"bubble": {
"type": "bubble",
"color": color,
"padding": [15, 15, 0, 15],
"xAxis": {
"disableGrid": false,
"gridType": "dash",
"splitNumber": 5,
"boundaryGap": "justify",
"min": 0,
"max": 250
},
"yAxis": {
"disableGrid": false,
"gridType": "dash",
"data": [{
"min": 0,
"max": 150
}]
},
"legend": {},
"extra": {
"bubble": {
"border": 2,
"opacity": 0.5,
},
}
}
}
export default cfu;