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 faeb3e8d
authored
Jun 30, 2022
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
折线图
1 parent
9fe4756f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
40 deletions
src/components/LineChart.vue
src/components/LineChart.vue
View file @
faeb3e8
...
...
@@ -8,7 +8,9 @@
</div>
<div
class=
"rank-block"
>
<div
class=
"rank-line"
v-for=
"(item, index) in rankList"
:key=
"index"
>
<marquee
class=
"line-item"
:direction=
"directionTimer"
:delay=
"delayTimer"
:text=
"item.label"
></marquee>
<div
class=
"line-item"
>
<marquee
:direction=
"directionTimer"
:delay=
"delayTimer"
:text=
"item.label"
></marquee>
</div>
<p
class=
"line-item txt-orange"
>
{{
item
.
value
}}
</p>
</div>
</div>
...
...
@@ -67,9 +69,9 @@ export default {
rankList
:
[],
echartsLine
:
''
,
moveAttr
:
{
speed
:
900
,
//
speed: 900,
seriesIndex
:
0
,
dataIndex
:
-
1
dataIndex
:
0
},
timer
:
null
}
...
...
@@ -81,12 +83,12 @@ export default {
mounted
()
{
this
.
lineDom
=
document
.
getElementById
(
this
.
domId
)
this
.
echartsLine
=
echarts
.
init
(
this
.
lineDom
)
this
[
this
.
domId
]
=
echarts
.
init
(
this
.
lineDom
)
},
methods
:
{
resetRankList
()
{
this
.
rankList
=
new
Array
(
5
).
fill
({
label
:
'-
'
,
value
:
'
-'
})
this
.
rankList
=
new
Array
(
5
).
fill
({
label
:
'-
-'
,
value
:
'-
-'
})
},
tooltipFormatter
(
obj
)
{
var
currentItem
=
this
.
dataList
[
obj
[
0
].
dataIndex
]
...
...
@@ -100,41 +102,44 @@ export default {
return
txt
},
autoMove
()
{
clearInterval
(
this
.
timer
)
this
.
timer
=
setInterval
(()
=>
{
this
.
moveAttr
.
dataIndex
=
this
.
moveAttr
.
dataIndex
+
1
if
(
this
.
moveAttr
.
dataIndex
===
this
.
dataList
.
length
)
{
this
.
moveAttr
.
dataIndex
=
0
}
//
autoMove() {
//
clearInterval(this.timer)
//
this.timer = setInterval(() => {
//
this.moveAttr.dataIndex = this.moveAttr.dataIndex + 1
//
if (this.moveAttr.dataIndex === this.dataList.length) {
//
this.moveAttr.dataIndex = 0
//
}
this
.
chartAction
()
this
.
autoMove
()
this
.
getRankList
(
this
.
moveAttr
.
dataIndex
,
this
.
rankFlag
+
'List'
)
},
this
.
moveAttr
.
speed
)
},
//
this.chartAction()
//
this.autoMove()
//
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
//
}, this.moveAttr.speed)
//
},
chartBindEvent
()
{
// resize
window
.
addEventListener
(
'resize'
,
()
=>
{
this
.
echartsLine
.
resize
()
this
[
this
.
domId
]
.
resize
()
})
// 鼠标划入
this
.
lineDom
.
addEventListener
(
'mouseover'
,
()
=>
{
clearInterval
(
this
.
timer
)
this
.
chartAction
(
'downplay
'
)
this
[
this
.
domId
].
on
(
'mouseover'
,
data
=>
{
this
.
moveAttr
.
seriesIndex
=
data
.
dataIndex
this
.
getRankList
(
this
.
moveAttr
.
seriesIndex
,
this
.
rankFlag
+
'List
'
)
})
// 鼠标划出
this
.
lineDom
.
addEventListener
(
'mouseout'
,
()
=>
{
this
.
moveAttr
.
dataIndex
=
-
1
this
.
autoMove
()
this
[
this
.
domId
].
on
(
'mouseout'
,
()
=>
{
console
.
log
(
'0000000000'
)
setTimeout
(()
=>
{
this
.
chartAction
()
},
1000
)
})
},
chartAction
(
type
)
{
this
.
echartsLine
.
dispatchAction
({
console
.
log
(
this
.
moveAttr
,
'???/cwq'
)
this
[
this
.
domId
].
dispatchAction
({
type
:
type
||
'showTip'
,
seriesIndex
:
this
.
moveAttr
.
seriesIndex
,
dataIndex
:
this
.
moveAttr
.
dataIndex
...
...
@@ -150,26 +155,16 @@ export default {
this
.
lineOptions
.
series
[
0
].
data
=
this
.
dataList
.
map
(
item
=>
item
.
num
)
this
.
echartsLine
.
setOption
(
this
.
lineOptions
)
this
[
this
.
domId
]
.
setOption
(
this
.
lineOptions
)
// // 鼠标划入
// this.echartsLine.on('click', data => {
// clearInterval(this.timer)
// this.chartAction('downplay')
// })
// // 鼠标划出
// this.echartsLine.on('mouseout', () => {
// this.moveAttr.dataIndex = -1
// this.autoMove()
// })
// console.log(this.echartsLine)
this
.
chartBindEvent
()
// 默认展示tooltip
this
.
chartAction
()
this
.
getRankList
(
0
)
this
.
autoMove
()
//
this.autoMove()
},
handleRankChange
(
value
)
{
...
...
@@ -232,6 +227,7 @@ p {
border-left
:
1px
solid
rgba
(
96
,
98
,
102
,
0.4
);
.line-item
{
height
:
1.8vh
;
width
:
100%
;
font-size
:
10px
;
padding-bottom
:
0.6vh
;
}
...
...
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