Commit 489435db by 胡悦

格式化数字

1 parent 2b5441dd
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: huyue * @Author: huyue
* @Date: 2023-07-07 14:01:42 * @Date: 2023-07-07 14:01:42
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2023-07-11 14:28:35 * @LastEditTime: 2023-07-17 16:00:27
--> -->
<template> <template>
<div> <div>
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
import * as echarts from 'echarts' import * as echarts from 'echarts'
import BarOptions from './BarOptions' import BarOptions from './BarOptions'
import utils from '../utils/util'
export default { export default {
name: 'BarChart', name: 'BarChart',
props: { props: {
...@@ -75,7 +76,7 @@ export default { ...@@ -75,7 +76,7 @@ export default {
var _html = '' var _html = ''
var _txt = '' var _txt = ''
this.tooltipFormatterObj.forEach(item => { this.tooltipFormatterObj.forEach(item => {
_txt += `<div style="display:flex;"><div style="color: #c9c9c9">${item.label}:</div><div style="color: #fff;">${_currentItem[item.attrName]}${item.addSymbol || ''}</div></div>` _txt += `<div style="display:flex;"><div style="color: #c9c9c9">${item.label}:</div><div style="color: #fff;">${utils.numAddSymbol(_currentItem[item.attrName])}${item.addSymbol || ''}</div></div>`
}) })
_html += `<div style="backdrop-filter: blur(4px);background-color: #051526;border: 2px solid;border-image: linear-gradient(90deg, #074989, #30DCFF, #074989) 1;padding: 10px;"> _html += `<div style="backdrop-filter: blur(4px);background-color: #051526;border: 2px solid;border-image: linear-gradient(90deg, #074989, #30DCFF, #074989) 1;padding: 10px;">
${_txt} ${_txt}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2022-10-25 10:12:26 * @Date: 2022-10-25 10:12:26
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2023-07-11 14:29:12 * @LastEditTime: 2023-07-17 15:58:43
* @FilePath: \dj-data-view\src\components\ViewTitle.vue * @FilePath: \dj-data-view\src\components\ViewTitle.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
</template> </template>
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
import utils from '../utils/util'
import * as echarts from 'echarts' import * as echarts from 'echarts'
import getBarLineOptions from './BarLineOptions' import getBarLineOptions from './BarLineOptions'
export default { export default {
...@@ -76,7 +77,7 @@ export default { ...@@ -76,7 +77,7 @@ export default {
var _html = '' var _html = ''
var _txt = '' var _txt = ''
this.tooltipFormatterObj.forEach(item => { this.tooltipFormatterObj.forEach(item => {
_txt += `<div style="display:flex;"><div style="color: #c9c9c9">${item.label}:</div><div style="color: #fff;">${_currentItem[item.attrName]}${item.addSymbol || ''}</div></div>` _txt += `<div style="display:flex;"><div style="color: #c9c9c9">${item.label}:</div><div style="color: #fff;">${utils.numAddSymbol(_currentItem[item.attrName])}${item.addSymbol || ''}</div></div>`
}) })
_html += `<div style="backdrop-filter: blur(4px);background-color: #051526;border: 2px solid;border-image: linear-gradient(90deg, #074989, #30DCFF, #074989) 1;padding: 10px;"> _html += `<div style="backdrop-filter: blur(4px);background-color: #051526;border: 2px solid;border-image: linear-gradient(90deg, #074989, #30DCFF, #074989) 1;padding: 10px;">
${_txt} ${_txt}
......
import * as echarts from 'echarts' import * as echarts from 'echarts'
import utils from '../utils/util'
function getBarLineOptions(obj) { function getBarLineOptions(obj) {
const { tooltipFormatter } = obj const { tooltipFormatter } = obj
var barLineOption = { var barLineOption = {
...@@ -6,25 +7,8 @@ function getBarLineOptions(obj) { ...@@ -6,25 +7,8 @@ function getBarLineOptions(obj) {
trigger: 'axis', trigger: 'axis',
borderWidth: 0, borderWidth: 0,
padding: 0, padding: 0,
// borderColor: function(p) {
// return new echarts.graphic.LinearGradient(
// 0, 0, 0, 1, [{ // 代表渐变色从正上方开始
// offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
// color: '#074989'
// }, // 柱图渐变色
// {
// offset: 1, // 指100%处的颜色
// color: '#30DCFF'
// }]
// )
// },
backgroundColor: '#051526', backgroundColor: '#051526',
// textStyle: {
// color: '#c9c9c9',
// fontSize: '1.5px'
// },
formatter: tooltipFormatter || '' formatter: tooltipFormatter || ''
// confine: true
}, },
xAxis: { xAxis: {
data: [] data: []
...@@ -68,7 +52,10 @@ function getBarLineOptions(obj) { ...@@ -68,7 +52,10 @@ function getBarLineOptions(obj) {
label: { label: {
show: true, show: true,
position: 'top', position: 'top',
color: '#fff' color: '#fff',
formatter: (params) => {
return utils.numAddSymbol(params.value)
}
}, },
itemStyle: { itemStyle: {
barBorderRadius: [2, 2, 0, 0], // 柱体圆角 barBorderRadius: [2, 2, 0, 0], // 柱体圆角
...@@ -100,7 +87,10 @@ function getBarLineOptions(obj) { ...@@ -100,7 +87,10 @@ function getBarLineOptions(obj) {
label: { label: {
show: true, show: true,
position: 'top', position: 'top',
color: '#fff' color: '#fff',
formatter: (params) => {
return utils.numAddSymbol(params.value)
}
}, },
data: [], data: [],
itemStyle: { itemStyle: {
......
...@@ -112,13 +112,19 @@ export default { ...@@ -112,13 +112,19 @@ export default {
padding: 0 1.39vw; padding: 0 1.39vw;
cursor: pointer; cursor: pointer;
&:hover { &:hover {
color: #FFFFFF; color: #5894FF;
background-image: -webkit-linear-gradient(left, #24D8FF, #7787FF);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
} }
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
&.active { &.active {
color: #FFFFFF; color: #5894FF;
background-image: -webkit-linear-gradient(left, #24D8FF, #7787FF);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
} }
} }
} }
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
<div class="statistics-item" v-for="(item, index) in list" :key="index" :style="{'width': 100 / list.length + '%'}"> <div class="statistics-item" v-for="(item, index) in list" :key="index" :style="{'width': 100 / list.length + '%'}">
<div class="statistics-top"> <div class="statistics-top">
<div class="statistics-name">{{item.name}}</div> <div class="statistics-name">{{item.name}}</div>
<div class="statistics-price">¥<span class="statistics-price-number">{{item.value}}</span></div> <div class="statistics-price">¥<span class="statistics-price-number">{{numAddSymbol(item.value)}}</span></div>
<div v-if="item.rate" class="statistics-top-rate">占比<span>{{item.rate}}</span></div> <div v-if="item.rate" class="statistics-top-rate">占比<span>{{item.rate}}</span></div>
</div> </div>
<div class="statistics-bottom"> <div class="statistics-bottom">
<template v-if="item.bottomType == 'money'"> <template v-if="item.bottomType == 'money'">
<span> {{item.bottomLabel}}</span> <span> {{item.bottomLabel}}</span>
<span>¥{{item.bottomValue}}</span> <span>¥{{numAddSymbol(item.bottomValue)}}</span>
</template> </template>
<template v-else-if="item.bottomType == 'slot'"> <template v-else-if="item.bottomType == 'slot'">
<slot name="bottom"></slot> <slot name="bottom"></slot>
</template> </template>
<template v-else> <template v-else>
<span>{{item.bottomLabel}}</span> <span>{{item.bottomLabel}}</span>
<span>{{item.bottomValue}}</span> <span>{{numAddSymbol(item.bottomValue)}}</span>
</template> </template>
</div> </div>
</div> </div>
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
* @Author: huyue * @Author: huyue
* @Date: 2023-07-04 13:56:33 * @Date: 2023-07-04 13:56:33
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2023-07-17 10:37:36 * @LastEditTime: 2023-07-17 15:50:17
--> -->
<template> <template>
<div class="view-content"> <div class="view-content">
<ViewDate :dataList="yearList" :businessTime="businessTime"></ViewDate> <ViewDate :defaultYear="defaultYear" :dataList="yearList" :businessTime="businessTime"></ViewDate>
<div class="content"> <div class="content">
<ContentLeft></ContentLeft> <ContentLeft></ContentLeft>
<ContentRight></ContentRight> <ContentRight></ContentRight>
...@@ -30,7 +30,8 @@ export default { ...@@ -30,7 +30,8 @@ export default {
data() { data() {
return { return {
businessTime: '', businessTime: '',
yearList: [] yearList: [],
defaultYear: ''
} }
}, },
created() { created() {
...@@ -43,6 +44,8 @@ export default { ...@@ -43,6 +44,8 @@ export default {
async getYears() { async getYears() {
const _data = await this.api.solar.getYears({}) const _data = await this.api.solar.getYears({})
this.yearList = _data.data.dataList[0].year.reverse().map(item => item + '') this.yearList = _data.data.dataList[0].year.reverse().map(item => item + '')
this.defaultYear = this.yearList[0]
console.log(this.defaultYear)
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!