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 24b85236
authored
Jun 24, 2022
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
折线图
1 parent
7cf5c116
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
23 deletions
src/components/LineChart.vue
src/components/lineOptions.js
src/views/afterSales/file.vue
src/components/LineChart.vue
View file @
24b8523
...
...
@@ -17,10 +17,6 @@ export default {
name
:
'LineChart'
,
props
:
{
// height: {
// type: String,
// default: '19.8vh'
// },
apiName
:
{
type
:
String
,
default
:
''
...
...
@@ -46,15 +42,18 @@ export default {
dataIndex
:
-
1
},
timer
:
null
// chartHeight: this.height
}
},
created
()
{
this
.
lineOptions
=
getLineOptions
({
axisLabelColor
:
this
.
axisLabelColo
r
})
this
.
lineOptions
=
getLineOptions
({
tooltipFormatter
:
this
.
tooltipFormatte
r
})
},
mounted
()
{
this
.
lineDom
=
document
.
getElementById
(
'line-chart'
)
this
.
echartsLine
=
echarts
.
init
(
this
.
lineDom
)
this
.
chartBindEvent
()
this
.
drawLine
()
},
...
...
@@ -63,26 +62,43 @@ export default {
this
.
lineOptions
.
xAxis
.
data
=
this
.
xAxisLabel
.
monthList
},
tooltipFormatter
(
obj
)
{
var
currentItem
=
this
.
dataList
[
obj
[
0
].
dataIndex
]
return
`数量:
${
currentItem
}
<br>环比:
${
currentItem
}
<br>同比:
${
currentItem
}
`
},
autoMove
()
{
clear
Timeout
(
this
.
timer
)
this
.
timer
=
set
Timeout
(()
=>
{
clear
Interval
(
this
.
timer
)
this
.
timer
=
set
Interval
(()
=>
{
this
.
moveAttr
.
dataIndex
=
this
.
moveAttr
.
dataIndex
+
1
if
(
this
.
moveAttr
.
dataIndex
===
this
.
dataList
.
length
)
{
this
.
moveAttr
.
dataIndex
=
0
}
this
.
move
Action
()
this
.
chart
Action
()
this
.
autoMove
()
},
this
.
moveAttr
.
speed
)
},
chartBindEvent
()
{
this
.
echartsLine
.
on
(
'click'
,
()
=>
{
// clearTimeout(this.timer)
console
.
log
(
'???????'
)
// resize
window
.
addEventListener
(
'resize'
,
()
=>
{
this
.
echartsLine
.
resize
()
})
// 鼠标划入
this
.
lineDom
.
addEventListener
(
'mouseover'
,
()
=>
{
clearInterval
(
this
.
timer
)
this
.
chartAction
(
'downplay'
)
})
// 鼠标划出
this
.
lineDom
.
addEventListener
(
'mouseout'
,
()
=>
{
this
.
moveAttr
.
dataIndex
=
-
1
this
.
autoMove
()
})
},
move
Action
(
type
)
{
chart
Action
(
type
)
{
this
.
echartsLine
.
dispatchAction
({
type
:
type
||
'showTip'
,
seriesIndex
:
this
.
moveAttr
.
seriesIndex
,
...
...
@@ -91,22 +107,18 @@ export default {
},
drawLine
()
{
// var lineDom = document.getElementById('line-chart')
// this.echartsLine = echarts.init(lineDom)
this
.
echartsLine
=
echarts
.
init
(
document
.
getElementById
(
'line-chart'
))
this
.
dealxAxisLabel
()
this
.
lineOptions
.
series
[
0
].
data
=
this
.
dataList
this
.
echartsLine
.
setOption
(
this
.
lineOptions
)
console
.
log
(
this
.
echartsLine
)
this
.
chartBindEvent
()
// this.autoMove()
this
.
autoMove
()
},
handleRankChange
(
value
)
{
this
.
rankFlag
=
value
this
.
$emit
(
'handleRankChange'
,
value
)
}
}
}
...
...
src/components/lineOptions.js
View file @
24b8523
function
getLineOptions
(
obj
)
{
// const { axisLabelColo
r } = obj
const
{
tooltipFormatte
r
}
=
obj
console
.
log
(
obj
)
var
lineOptions
=
{
tooltip
:
{
trigger
:
'axis'
,
formatter
:
''
borderWidth
:
0
,
backgroundColor
:
'rgba(68,68,68,0.80)'
,
textStyle
:
{
color
:
'#FFFFFF'
,
fontSize
:
'8px'
},
extraCssText
:
'width: 60px;'
,
formatter
:
tooltipFormatter
||
''
},
grid
:
{
left
:
'3%'
,
...
...
@@ -17,7 +24,6 @@ function getLineOptions(obj) {
type
:
'category'
,
axisLabel
:
{
color
:
'#606266'
,
// color: axisLabelColor ? (value, index) => axisLabelColor(value, index) : '#606266',
fontSize
:
'0.8em'
},
data
:
[]
...
...
src/views/afterSales/file.vue
View file @
24b8523
...
...
@@ -8,7 +8,7 @@
<
template
>
<div>
<div
class=
"title"
>
售后档案客户
</div>
<LineChart
:height=
"height
"
></LineChart>
<LineChart
@
handleRankChange=
"handleRankChange
"
></LineChart>
</div>
</
template
>
...
...
@@ -20,6 +20,12 @@ export default {
type
:
String
,
default
:
'19.8vh'
}
},
mounted
()
{
},
methods
:
{
handleRankChange
(
value
)
{
console
.
log
(
value
)
}
}
}
</
script
>
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