Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
glsk-data-view-pd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ea46d7e7
authored
Aug 03, 2023
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交
1 parent
c87524d7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
15 deletions
src/views/crowdfunding/components/ActivityTrends.vue
src/views/crowdfunding/components/BarChart.vue
src/views/crowdfunding/components/BarOptions.js
src/views/crowdfunding/components/ActivityTrends.vue
View file @
ea46d7e
<!--
* @Description:
* @Author: huyue
* @Date: 2023-08-03 15:31:53
* @LastEditors: huyue
* @LastEditTime: 2023-08-03 16:43:18
-->
<!-- 近一年活动场次趋势图 -->
<!-- 近一年活动场次趋势图 -->
<
template
>
<
template
>
<div
class=
"activity-box"
>
<div
class=
"activity-box"
>
<box-title
title=
"近一年活动场次趋势图"
></box-title>
<box-title
title=
"近一年活动场次趋势图"
></box-title>
<BarChart
ref=
"activityTrendChartRef"
class=
"bar-chart"
isMultiple
:barWidth=
"24"
domId=
"activityTrendChart"
height=
"26.22vh"
:dataList
.
sync=
"dataList"
:colorList=
"colorList"
:tooltipFormatterObj=
"tooltips.amountTooltip"
></BarChart>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
BarChart
from
'./BarChart.vue'
export
default
{
export
default
{
name
:
'ActivityTrends'
,
name
:
'ActivityTrends'
,
components
:
{
BarChart
},
data
()
{
data
()
{
return
{}
return
{
dataList
:
[
{
month
:
'1月'
,
amount
:
100
},
{
month
:
'2月'
,
amount
:
1000
},
{
month
:
'3月'
,
amount
:
1000
},
{
month
:
'4月'
,
amount
:
650
},
{
month
:
'5月'
,
amount
:
800
},
{
month
:
'6月'
,
amount
:
800
},
{
month
:
'7月'
,
amount
:
800
},
{
month
:
'8月'
,
amount
:
800
},
{
month
:
'9月'
,
amount
:
800
},
{
month
:
'10月'
,
amount
:
800
},
{
month
:
'11月'
,
amount
:
800
},
{
month
:
'12月'
,
amount
:
800
}
],
tooltips
:
{
amountTooltip
:
{
label
:
'总产值'
,
attrName
:
'amount'
}
},
colorList
:
[
[
'#2AD191'
,
'#00A89E'
,
'#061422'
],
[
'#22D8FF'
,
'#223FA9'
,
'#061422'
]
]
}
},
},
mounted
()
{},
mounted
()
{
this
.
$refs
.
activityTrendChartRef
.
drawBar
()
},
methods
:
{}
methods
:
{}
}
}
...
@@ -24,5 +98,8 @@ export default {
...
@@ -24,5 +98,8 @@ export default {
width
:
36.94vw
;
width
:
36.94vw
;
height
:
34vh
;
height
:
34vh
;
box-shadow
:
inset
0
0
20px
0
#3d57ff69
;
box-shadow
:
inset
0
0
20px
0
#3d57ff69
;
.bar-chart
{
padding-left
:
1.39vw
;
}
}
}
</
style
>
</
style
>
src/views/crowdfunding/components/BarChart.vue
View file @
ea46d7e
...
@@ -3,11 +3,11 @@
...
@@ -3,11 +3,11 @@
* @Author: huyue
* @Author: huyue
* @Date: 2023-07-07 14:01:42
* @Date: 2023-07-07 14:01:42
* @LastEditors: huyue
* @LastEditors: huyue
* @LastEditTime: 2023-08-03 1
4:58:05
* @LastEditTime: 2023-08-03 1
6:43:09
-->
-->
<
template
>
<
template
>
<div>
<div>
<div
:id=
"domId"
style=
"width: 100%;
height: 15vh
"
></div>
<div
:id=
"domId"
style=
"width: 100%;
"
:style=
"
{ height }
">
</div>
</div>
</div>
</
template
>
</
template
>
<
script
type=
"text/ecmascript-6"
>
<
script
type=
"text/ecmascript-6"
>
...
@@ -36,6 +36,15 @@ export default {
...
@@ -36,6 +36,15 @@ export default {
},
},
colorList
:
{
colorList
:
{
type
:
Array
type
:
Array
},
height
:
{
type
:
String
,
default
:
'15vh'
},
barWidth
:
String
,
isMultiple
:
{
type
:
Boolean
,
default
:
false
}
}
},
},
data
()
{
data
()
{
...
@@ -44,7 +53,7 @@ export default {
...
@@ -44,7 +53,7 @@ export default {
}
}
},
},
created
()
{
created
()
{
this
.
barOptions
=
BarOptions
({
tooltipFormatter
:
this
.
tooltipFormatter
},
this
.
colorList
)
this
.
barOptions
=
BarOptions
({
tooltipFormatter
:
this
.
tooltipFormatter
},
this
.
colorList
,
this
.
isMultiple
,
this
.
barWidth
)
},
},
mounted
()
{
mounted
()
{
this
.
barDom
=
document
.
getElementById
(
this
.
domId
)
this
.
barDom
=
document
.
getElementById
(
this
.
domId
)
...
@@ -63,9 +72,9 @@ export default {
...
@@ -63,9 +72,9 @@ export default {
return
_html
return
_html
},
},
drawBar
()
{
drawBar
()
{
console
.
log
(
this
.
dataList
)
console
.
log
(
this
.
dataList
,
this
.
tooltipFormatterObj
)
this
.
barOptions
.
xAxis
.
data
=
[
'1月'
,
'2月'
,
'3月'
,
'4月'
,
'5月'
]
this
.
barOptions
.
xAxis
.
data
=
this
.
dataList
.
map
(
item
=>
item
.
month
)
this
.
barOptions
.
series
[
0
].
data
=
this
.
dataList
.
map
(
item
=>
item
.
amount
)
this
.
barOptions
.
series
[
0
].
data
=
this
.
dataList
.
map
(
item
=>
item
[
this
.
tooltipFormatterObj
.
attrName
]
)
this
[
this
.
domId
].
setOption
(
this
.
barOptions
)
this
[
this
.
domId
].
setOption
(
this
.
barOptions
)
},
},
chartBindEvent
()
{
chartBindEvent
()
{
...
...
src/views/crowdfunding/components/BarOptions.js
View file @
ea46d7e
...
@@ -3,10 +3,12 @@
...
@@ -3,10 +3,12 @@
* @Author: huyue
* @Author: huyue
* @Date: 2023-07-07 14:04:52
* @Date: 2023-07-07 14:04:52
* @LastEditors: huyue
* @LastEditors: huyue
* @LastEditTime: 2023-08-03 1
5:12:53
* @LastEditTime: 2023-08-03 1
6:42:12
*/
*/
import
*
as
echarts
from
'echarts'
import
*
as
echarts
from
'echarts'
function
getBarOptions
(
obj
,
colorList
)
{
function
getBarOptions
(
obj
,
colorList
,
isMultiple
,
barwidth
)
{
const
barWidth
=
barwidth
||
'14'
const
multiple
=
isMultiple
||
false
const
{
tooltipFormatter
}
=
obj
const
{
tooltipFormatter
}
=
obj
var
barLineOption
=
{
var
barLineOption
=
{
tooltip
:
{
tooltip
:
{
...
@@ -19,7 +21,7 @@ function getBarOptions(obj, colorList) {
...
@@ -19,7 +21,7 @@ function getBarOptions(obj, colorList) {
xAxis
:
{
xAxis
:
{
data
:
[]
data
:
[]
},
},
barWidth
:
'14'
,
barWidth
:
barWidth
,
yAxis
:
{
yAxis
:
{
name
:
''
,
name
:
''
,
type
:
'value'
,
type
:
'value'
,
...
@@ -49,18 +51,22 @@ function getBarOptions(obj, colorList) {
...
@@ -49,18 +51,22 @@ function getBarOptions(obj, colorList) {
itemStyle
:
{
itemStyle
:
{
barBorderRadius
:
[
2
,
2
,
0
,
0
],
// 柱体圆角
barBorderRadius
:
[
2
,
2
,
0
,
0
],
// 柱体圆角
color
:
function
(
params
)
{
color
:
function
(
params
)
{
var
colorItem
=
[]
if
(
multiple
)
{
colorItem
=
params
.
dataIndex
%
2
===
0
?
colorList
[
0
]
:
colorList
[
1
]
}
return
new
echarts
.
graphic
.
LinearGradient
(
return
new
echarts
.
graphic
.
LinearGradient
(
0
,
0
,
0
,
1
,
[{
// 代表渐变色从正上方开始
0
,
0
,
0
,
1
,
[{
// 代表渐变色从正上方开始
offset
:
0
,
// offset范围是0~1,用于表示位置,0是指0%处的颜色
offset
:
0
,
// offset范围是0~1,用于表示位置,0是指0%处的颜色
color
:
colorList
[
0
]
color
:
multiple
?
colorItem
[
0
]
:
colorList
[
0
]
},
// 柱图渐变色
},
// 柱图渐变色
{
{
offset
:
0.5
,
// 指100%处的颜色
offset
:
0.5
,
// 指100%处的颜色
color
:
colorList
[
1
]
color
:
multiple
?
colorItem
[
1
]
:
colorList
[
1
]
},
},
{
{
offset
:
1
,
// 指100%处的颜色
offset
:
1
,
// 指100%处的颜色
color
:
colorList
[
2
]
color
:
multiple
?
colorItem
[
2
]
:
colorList
[
2
]
}]
}]
)
)
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment