Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
gh
/
data-view
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 8dba2d4f
authored
Jul 05, 2022
by
王志慧
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit
1 parent
7a2b6a49
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
36 deletions
src/components/LineChart.vue
src/components/lineOptions.js
src/components/LineChart.vue
View file @
8dba2d4
...
...
@@ -17,7 +17,6 @@
</div>
</div>
</
template
>
<
script
>
import
datas
from
'@/utils/data'
import
*
as
echarts
from
'echarts'
...
...
@@ -63,7 +62,6 @@ export default {
}
}
},
data
()
{
return
{
directionTimer
:
datas
.
DefaultData
.
directionTimer
,
...
...
@@ -80,17 +78,14 @@ export default {
timer
:
null
}
},
created
()
{
this
.
lineOptions
=
getLineOptions
({
tooltipFormatter
:
this
.
tooltipFormatter
})
},
mounted
()
{
this
.
lineDom
=
document
.
getElementById
(
this
.
domId
)
this
[
this
.
domId
]
=
echarts
.
init
(
this
.
lineDom
)
this
.
chartBindEvent
()
},
methods
:
{
resetRankList
()
{
this
.
rankList
=
new
Array
(
5
).
fill
({
label
:
'- -'
,
value
:
'- -'
})
...
...
@@ -107,19 +102,16 @@ export default {
})
return
txt
},
chartBindEvent
()
{
// resize
window
.
addEventListener
(
'resize'
,
()
=>
{
this
[
this
.
domId
].
resize
()
})
// 鼠标划入
this
[
this
.
domId
].
on
(
'mouseover'
,
data
=>
{
this
.
moveAttr
.
dataIndex
=
data
.
dataIndex
this
.
getRankList
(
this
.
moveAttr
.
dataIndex
,
this
.
rankFlag
+
'List'
)
})
// 绑定点击事件
this
[
this
.
domId
].
getZr
().
on
(
'mouseover'
,
params
=>
{
const
pointInPixel
=
[
params
.
offsetX
,
params
.
offsetY
]
...
...
@@ -130,13 +122,11 @@ export default {
this
.
getRankList
(
this
.
moveAttr
.
dataIndex
,
this
.
rankFlag
+
'List'
)
}
})
// 移除图表
// this[this.domId].on('globalout', () => {
// this.chartAction()
// })
},
// chartAction(type) {
// this[this.domId].dispatchAction({
// type: type || 'showTip',
...
...
@@ -144,28 +134,21 @@ export default {
// dataIndex: +this.moveAttr.dataIndex
// })
// },
getRankList
(
idx
,
attrName
=
'topList'
)
{
this
.
dataList
[
idx
][
attrName
].
length
?
this
.
$set
(
this
,
'rankList'
,
this
.
dataList
[
idx
][
attrName
])
:
this
.
resetRankList
()
},
drawLine
()
{
this
.
lineOptions
.
xAxis
.
data
=
[]
this
.
dataList
.
map
(
e
=>
{
let
month
=
new
Date
(
e
.
statDate
).
getMonth
()
this
.
lineOptions
.
xAxis
.
data
.
push
(
this
.
queryType
==
0
?
`
${
month
==
0
?
'1月'
:
`
${
Number
(
month
)
+
1
}
月`
}
`
:
e
.
statDate
.
split
(
'-'
).
slice
(
1
).
join
(
'-'
))
})
this
.
lineOptions
.
series
[
0
].
data
=
this
.
dataList
.
map
(
item
=>
item
.
num
)
this
[
this
.
domId
].
setOption
(
this
.
lineOptions
)
// 默认展示tooltip
// this.chartAction()
this
.
getRankList
(
0
)
},
handleRankChange
(
value
)
{
this
.
rankFlag
=
value
this
.
getRankList
(
this
.
moveAttr
.
dataIndex
,
this
.
rankFlag
+
'List'
)
...
...
@@ -173,7 +156,6 @@ export default {
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
p
{
margin
:
0
0
;
...
...
@@ -241,18 +223,4 @@ p {
}
}
}
::v-deep
.line-chart
{
width
:
100%
;
height
:
100%
;
div
{
&:nth-child(1)
{
width
:
100%
!important
;
height
:
100%
!important
;
canvas
{
width
:
100%
!important
;
height
:
100%
!important
;
}
}
}
}
</
style
>
\ No newline at end of file
src/components/lineOptions.js
View file @
8dba2d4
...
...
@@ -4,7 +4,7 @@ function getLineOptions(obj) {
tooltip
:
{
trigger
:
'axis'
,
borderWidth
:
0
,
show
:
fals
e
,
show
:
tru
e
,
backgroundColor
:
'rgba(68,68,68,0.80)'
,
textStyle
:
{
color
:
'#FFFFFF'
,
...
...
@@ -34,7 +34,7 @@ function getLineOptions(obj) {
color
:
'#606266'
}
},
splitNumber
:
3
splitNumber
:
4
},
series
:
[
{
...
...
@@ -43,7 +43,6 @@ function getLineOptions(obj) {
itemStyle
:
{
color
:
'#F5AA01'
},
// 平滑曲线
smooth
:
true
,
showSymbol
:
false
,
...
...
@@ -73,5 +72,4 @@ function getLineOptions(obj) {
}
return
lineOptions
}
export
default
getLineOptions
\ No newline at end of file
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