提交 88433498 authored 作者: 王鹏飞's avatar 王鹏飞

update

上级 fb5bd4e4
module.exports = { module.exports = {
isHttps: false, isHttps: false,
domain: 'localhost', domain: 'localhost',
url: 'http://172.16.3.11:8011/', url: 'http://data-view.ezijing.com/',
webpack: { webpack: {
externals: { externals: {
CKEDITOR: 'window.CKEDITOR', CKEDITOR: 'window.CKEDITOR',
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<script> <script>
import * as api from '@/api/index' import * as api from '@/api/index'
export default { export default {
name: 'MonthIncomeTrend', name: 'WeekIncome',
data() { data() {
return { return {
loading: false, loading: false,
...@@ -13,29 +13,52 @@ export default { ...@@ -13,29 +13,52 @@ export default {
} }
}, },
computed: { computed: {
colors() {
return this.$store.state.colors
},
dataset() { dataset() {
const dimensions = [] const legend = []
const source = {} const axis = []
const series = [] const series = []
this.response.forEach(item => { this.response.forEach(item => {
if (!dimensions.includes(item.week)) { // 类目
dimensions.push(item.week) if (!legend.includes(item.project_name)) {
legend.push(item.project_name)
}
// X 轴
if (!axis.includes(item.week)) {
axis.push(item.week)
} }
console.log(item.week)
if (!source[item.project_name]) {
source[item.project_name] = []
const temp = { type: 'bar', name: item.project_name, stack: 'total', barWidth: 20 } const currentData = { name: item.project_name, value: item.pay_money }
// 去除颜色,显示边框
if (['当前周预测', 'T+1', 'T+2'].includes(item.week)) { if (['当前周预测', 'T+1', 'T+2'].includes(item.week)) {
console.log(temp) const borderColor = this.colors[item.project_name] || '#000'
temp.itemStyle = { color: 'transparent', borderWidth: 1, borderColor: '#000' } currentData.itemStyle = { color: 'transparent', borderWidth: 1, borderType: 'dashed', borderColor }
} }
series.push(temp) const serisItem = { type: 'bar', name: item.project_name, stack: 'total', barWidth: 20, data: [] }
const found = series.find(data => data.name === item.project_name)
if (found) {
found.data.push(currentData)
} else {
serisItem.data.push(currentData)
series.push(serisItem)
} }
source[item.project_name].push(item.pay_money)
}) })
source.product = dimensions // 统计
return { dimensions, source, series } const total = axis.map(week => {
return this.response.reduce((item, result) => {
if (item.week === week) {
result += item.pay_money
}
return result
}, 0)
})
// 统计
series.push({ type: 'bar', name: 'total', stack: 'total', barWidth: 20, data: total })
return { legend, axis, series }
}, },
option() { option() {
return { return {
...@@ -47,18 +70,20 @@ export default { ...@@ -47,18 +70,20 @@ export default {
itemWidth: 13, itemWidth: 13,
itemHeight: 13, itemHeight: 13,
icon: 'rect', icon: 'rect',
textStyle: { color: '#fff', fontSize: 16 } textStyle: { color: '#fff', fontSize: 16 },
data: this.dataset.legend
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
splitLine: { show: false }, splitLine: { show: false },
axisLabel: { color: '#0A7199', formatter: value => value / 10000 } axisLabel: { color: '#0A7199', width: 40, interval: 0, formatter: value => value / 10000 }
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
axisTick: { show: false }, axisTick: { show: false },
axisLine: { show: false }, axisLine: { show: false },
axisLabel: { color: '#0A7199' } axisLabel: { color: '#0A7199', rotate: 45 },
data: this.dataset.axis
}, },
series: this.dataset.series series: this.dataset.series
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论