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