Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ec-report-refactor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lihuizhen
ec-report-refactor
Commits
b7d9ea83
Commit
b7d9ea83
authored
May 11, 2022
by
leon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: line and bar add label show limit
parent
cd6c81c9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
217 additions
and
50 deletions
+217
-50
HorizontalBar.vue
components/HorizontalBar/HorizontalBar.vue
+55
-14
LineMixBar.vue
components/LineMixBar/LineMixBar.vue
+52
-9
NormalBar.vue
components/NormalBar/NormalBar.vue
+51
-9
NormalLine.vue
components/NormalLine/NormalLine.vue
+59
-18
No files found.
components/HorizontalBar/HorizontalBar.vue
View file @
b7d9ea83
...
@@ -17,12 +17,16 @@
...
@@ -17,12 +17,16 @@
ec
:
{
ec
:
{
lazyLoad
:
true
,
lazyLoad
:
true
,
option
:
{}
option
:
{}
}
},
labelShow
:
false
// 记录当前设置的label.show的值
}
}
},
},
components
:
{
components
:
{
uniEcCanvas
uniEcCanvas
},
},
created
()
{
this
.
labelShow
=
this
.
elementInfo
.
option
.
dataset
.
show
},
mounted
()
{
mounted
()
{
this
.
$refs
[
'horizontalBarCanvas'
].
init
(
this
.
inited
)
this
.
$refs
[
'horizontalBarCanvas'
].
init
(
this
.
inited
)
},
},
...
@@ -78,21 +82,38 @@
...
@@ -78,21 +82,38 @@
})
})
chart
.
on
(
'datazoom'
,
event
=>
{
chart
.
on
(
'datazoom'
,
event
=>
{
that
.
echartsDataZoom
(
event
)
that
.
echartsDataZoom
(
event
)
that
.
dealLabelShowStatus
(
event
)
})
})
return
chart
return
chart
},
},
initChart
()
{
initChart
()
{
const
{
categories
,
series
,
preview
,
images
}
=
this
.
elementData
.
dataList
// 等待子组件完全挂载完成---chart初始化完成
this
.
$set
(
this
.
ec
.
option
,
'yAxis.data'
,
categories
)
this
.
$nextTick
().
then
(()
=>
{
this
.
$set
(
this
.
ec
.
option
,
'series'
,
this
.
dealSeriesData
(
series
))
const
{
categories
,
series
,
preview
,
images
}
=
this
.
elementData
.
dataList
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
if
(
this
.
labelShow
)
{
if
(
chart
)
{
// 处理初始状态时,数值显示的数量是否超过了配置的最大值
// 重新setOption,使得设置的formatter生效
let
count
=
categories
.
length
chart
.
setOption
(
this
.
ec
.
option
)
if
(
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
)
{
}
count
=
count
*
(
this
.
elementInfo
.
dataZoom
.
end
-
this
.
elementInfo
.
dataZoom
.
start
)
/
100
if
(
preview
)
{
}
this
.
cacheImages
(
images
)
if
(
count
>
this
.
elementInfo
.
option
.
dataset
.
maxCount
)
{
}
this
.
elementInfo
.
option
.
dataset
.
show
=
false
}
}
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
if
(
chart
)
{
const
option
=
chart
.
getOption
()
option
.
series
=
dealSeries
// 重新setOption,使得设置的formatter生效
chart
.
setOption
(
option
)
}
if
(
preview
)
{
this
.
cacheImages
(
images
)
}
})
},
},
/**
/**
* 处理数据
* 处理数据
...
@@ -141,8 +162,28 @@
...
@@ -141,8 +162,28 @@
})
})
}
}
})
})
}
},
/**
* 处理图表的数值是否显示
* 超过10个时隐藏点的数值
* event: 包含dataZoom的start和end
*/
dealLabelShowStatus
(
event
)
{
// 当前图表初始设置了labelShow=true时,才判断超过10个隐藏
if
(
this
.
labelShow
)
{
const
count
=
this
.
elementData
.
dataList
.
categories
.
length
*
(
event
.
end
-
event
.
start
)
/
100
const
option
=
chart
.
getOption
()
// TODO:切换全屏后返回,chart实例不存在了
if
(
!
option
)
{
return
}
const
series
=
option
.
series
series
.
map
(
item
=>
{
item
.
label
.
show
=
count
<=
this
.
elementInfo
.
option
.
dataset
.
maxCount
})
chart
.
setOption
(
option
)
}
}
}
}
}
}
</
script
>
</
script
>
...
...
components/LineMixBar/LineMixBar.vue
View file @
b7d9ea83
...
@@ -23,7 +23,8 @@
...
@@ -23,7 +23,8 @@
ec
:
{
ec
:
{
lazyLoad
:
true
,
lazyLoad
:
true
,
option
:
{}
option
:
{}
}
},
labelShow
:
false
// 记录当前设置的label.show的值
}
}
},
},
components
:
{
components
:
{
...
@@ -32,6 +33,9 @@
...
@@ -32,6 +33,9 @@
mounted
()
{
mounted
()
{
this
.
$refs
[
'lineMixBarCanvas'
].
init
(
this
.
inited
)
this
.
$refs
[
'lineMixBarCanvas'
].
init
(
this
.
inited
)
},
},
created
()
{
this
.
labelShow
=
this
.
elementInfo
.
option
.
dataset
.
show
},
methods
:
{
methods
:
{
inited
(
canvas
,
width
,
height
,
canvasDpr
)
{
inited
(
canvas
,
width
,
height
,
canvasDpr
)
{
chart
=
this
.
$echarts
.
init
(
canvas
,
null
,
{
chart
=
this
.
$echarts
.
init
(
canvas
,
null
,
{
...
@@ -86,18 +90,35 @@
...
@@ -86,18 +90,35 @@
})
})
chart
.
on
(
'datazoom'
,
event
=>
{
chart
.
on
(
'datazoom'
,
event
=>
{
that
.
echartsDataZoom
(
event
)
that
.
echartsDataZoom
(
event
)
that
.
dealLabelShowStatus
(
event
)
})
})
return
chart
return
chart
},
},
initChart
()
{
initChart
()
{
const
{
categories
,
series
}
=
this
.
elementData
.
dataList
// 等待子组件完全挂载完成---chart初始化完成
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$nextTick
().
then
(()
=>
{
this
.
$set
(
this
.
ec
.
option
,
'series'
,
this
.
dealSeriesData
(
series
))
const
{
categories
,
series
}
=
this
.
elementData
.
dataList
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
if
(
this
.
labelShow
)
{
if
(
chart
)
{
// 处理初始状态时,数值显示的数量是否超过了配置的最大值
// 重新setOption,使得设置的formatter生效
let
count
=
categories
.
length
chart
.
setOption
(
this
.
ec
.
option
)
if
(
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
)
{
}
count
=
count
*
(
this
.
elementInfo
.
dataZoom
.
end
-
this
.
elementInfo
.
dataZoom
.
start
)
/
100
}
if
(
count
>
this
.
elementInfo
.
option
.
dataset
.
maxCount
)
{
this
.
elementInfo
.
option
.
dataset
.
show
=
false
}
}
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
if
(
chart
)
{
const
option
=
chart
.
getOption
()
option
.
series
=
dealSeries
// 重新setOption,使得设置的formatter生效
chart
.
setOption
(
option
)
}
})
},
},
/**
/**
* 处理数据
* 处理数据
...
@@ -132,7 +153,29 @@
...
@@ -132,7 +153,29 @@
}
}
})
})
return
newData
return
newData
},
/**
* 处理图表的数值是否显示
* 超过10个时隐藏点的数值
* event: 包含dataZoom的start和end
*/
dealLabelShowStatus
(
event
)
{
// 当前图表初始设置了labelShow=true时,才判断超过10个隐藏
if
(
this
.
labelShow
)
{
const
count
=
this
.
elementData
.
dataList
.
categories
.
length
*
(
event
.
end
-
event
.
start
)
/
100
const
option
=
chart
.
getOption
()
// TODO:切换全屏后返回,chart实例不存在了
if
(
!
option
)
{
return
}
const
series
=
option
.
series
series
.
map
(
item
=>
{
item
.
label
.
show
=
count
<=
this
.
elementInfo
.
option
.
dataset
.
maxCount
})
chart
.
setOption
(
option
)
}
}
}
}
}
}
}
</
script
>
</
script
>
...
...
components/NormalBar/NormalBar.vue
View file @
b7d9ea83
...
@@ -18,12 +18,16 @@
...
@@ -18,12 +18,16 @@
ec
:
{
ec
:
{
lazyLoad
:
true
,
lazyLoad
:
true
,
option
:
{}
option
:
{}
}
},
labelShow
:
false
// 记录当前设置的label.show的值
}
}
},
},
components
:
{
components
:
{
uniEcCanvas
uniEcCanvas
},
},
created
()
{
this
.
labelShow
=
this
.
elementInfo
.
option
.
dataset
.
show
},
mounted
()
{
mounted
()
{
this
.
$refs
[
'normalbarCanvas'
].
init
(
this
.
inited
)
this
.
$refs
[
'normalbarCanvas'
].
init
(
this
.
inited
)
},
},
...
@@ -72,18 +76,35 @@
...
@@ -72,18 +76,35 @@
})
})
chart
.
on
(
'datazoom'
,
event
=>
{
chart
.
on
(
'datazoom'
,
event
=>
{
that
.
echartsDataZoom
(
event
)
that
.
echartsDataZoom
(
event
)
that
.
dealLabelShowStatus
(
event
)
})
})
return
chart
return
chart
},
},
initChart
()
{
initChart
()
{
const
{
categories
,
series
}
=
this
.
elementData
.
dataList
// 等待子组件完全挂载完成---chart初始化完成
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$nextTick
().
then
(()
=>
{
this
.
$set
(
this
.
ec
.
option
,
'series'
,
this
.
dealSeriesData
(
series
))
const
{
categories
,
series
}
=
this
.
elementData
.
dataList
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
if
(
this
.
labelShow
)
{
if
(
chart
)
{
// 处理初始状态时,数值显示的数量是否超过了配置的最大值
// 重新setOption,使得设置的formatter生效
let
count
=
categories
.
length
chart
.
setOption
(
this
.
ec
.
option
)
if
(
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
)
{
}
count
=
count
*
(
this
.
elementInfo
.
dataZoom
.
end
-
this
.
elementInfo
.
dataZoom
.
start
)
/
100
}
if
(
count
>
this
.
elementInfo
.
option
.
dataset
.
maxCount
)
{
this
.
elementInfo
.
option
.
dataset
.
show
=
false
}
}
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
if
(
chart
)
{
const
option
=
chart
.
getOption
()
option
.
series
=
dealSeries
// 重新setOption,使得设置的formatter生效
chart
.
setOption
(
option
)
}
})
},
},
/**
/**
* 处理数据
* 处理数据
...
@@ -109,6 +130,27 @@
...
@@ -109,6 +130,27 @@
}
}
})
})
return
newData
return
newData
},
/**
* 处理图表的数值是否显示
* 超过10个时隐藏点的数值
* event: 包含dataZoom的start和end
*/
dealLabelShowStatus
(
event
)
{
// 当前图表初始设置了labelShow=true时,才判断超过10个隐藏
if
(
this
.
labelShow
)
{
const
count
=
this
.
elementData
.
dataList
.
categories
.
length
*
(
event
.
end
-
event
.
start
)
/
100
const
option
=
chart
.
getOption
()
// TODO:切换全屏后返回,chart实例不存在了
if
(
!
option
)
{
return
}
const
series
=
option
.
series
series
.
map
(
item
=>
{
item
.
label
.
show
=
count
<=
this
.
elementInfo
.
option
.
dataset
.
maxCount
})
chart
.
setOption
(
option
)
}
}
}
}
}
}
}
...
...
components/NormalLine/NormalLine.vue
View file @
b7d9ea83
...
@@ -17,15 +17,19 @@
...
@@ -17,15 +17,19 @@
ec
:
{
ec
:
{
lazyLoad
:
true
,
lazyLoad
:
true
,
option
:
{}
option
:
{}
}
},
labelShow
:
false
// 记录当前设置的label.show的值
}
}
},
},
components
:
{
components
:
{
uniEcCanvas
uniEcCanvas
},
},
created
()
{
this
.
labelShow
=
this
.
elementInfo
.
option
.
dataset
.
show
},
mounted
()
{
mounted
()
{
this
.
$refs
[
'normalLineCanvas'
].
init
(
this
.
inited
)
this
.
$refs
[
'normalLineCanvas'
].
init
(
this
.
inited
)
},
},
methods
:
{
methods
:
{
inited
(
canvas
,
width
,
height
,
canvasDpr
)
{
inited
(
canvas
,
width
,
height
,
canvasDpr
)
{
chart
=
this
.
$echarts
.
init
(
canvas
,
null
,
{
chart
=
this
.
$echarts
.
init
(
canvas
,
null
,
{
...
@@ -35,7 +39,7 @@
...
@@ -35,7 +39,7 @@
})
})
canvas
.
setChart
(
chart
)
canvas
.
setChart
(
chart
)
const
{
categories
=
[],
series
=
[]
}
=
this
.
elementData
.
dataList
const
{
categories
=
[],
series
=
[]
}
=
this
.
elementData
.
dataList
const
that
=
this
const
that
=
this
that
.
ec
.
option
=
{
that
.
ec
.
option
=
{
...
that
.
elementInfo
.
option
,
...
that
.
elementInfo
.
option
,
color
:
[
'#00f2f1'
,
'#ed3f35'
,
'#1089E7'
,
"#F8B448"
,
"#8B78F6"
,
'#8cd8ff'
,
color
:
[
'#00f2f1'
,
'#ed3f35'
,
'#1089E7'
,
"#F8B448"
,
"#8B78F6"
,
'#8cd8ff'
,
...
@@ -67,25 +71,42 @@
...
@@ -67,25 +71,42 @@
},
},
dataZoom
:
that
.
elementInfo
.
dataZoom
&&
that
.
elementInfo
.
dataZoom
.
show
?
[{...
that
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}],
dataZoom
:
that
.
elementInfo
.
dataZoom
&&
that
.
elementInfo
.
dataZoom
.
show
?
[{...
that
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}],
series
:
that
.
dealSeriesData
(
series
)
series
:
that
.
dealSeriesData
(
series
)
}
}
chart
.
setOption
(
that
.
ec
.
option
)
chart
.
setOption
(
that
.
ec
.
option
)
chart
.
on
(
'click'
,
event
=>
{
chart
.
on
(
'click'
,
event
=>
{
that
.
handleEchartsClick
(
event
)
that
.
handleEchartsClick
(
event
)
})
})
chart
.
on
(
'datazoom'
,
event
=>
{
chart
.
on
(
'datazoom'
,
event
=>
{
that
.
echartsDataZoom
(
event
)
that
.
echartsDataZoom
(
event
)
})
that
.
dealLabelShowStatus
(
event
)
})
return
chart
return
chart
},
},
initChart
()
{
initChart
()
{
const
{
categories
,
series
}
=
this
.
elementData
.
dataList
// 等待子组件完全挂载完成---chart初始化完成
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$nextTick
().
then
(()
=>
{
this
.
$set
(
this
.
ec
.
option
,
'series'
,
this
.
dealSeriesData
(
series
))
const
{
categories
,
series
}
=
this
.
elementData
.
dataList
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
if
(
this
.
labelShow
)
{
if
(
chart
)
{
// 处理初始状态时,数值显示的数量是否超过了配置的最大值
// 重新setOption,使得设置的formatter生效
let
count
=
categories
.
length
chart
.
setOption
(
this
.
ec
.
option
)
if
(
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
)
{
}
count
=
count
*
(
this
.
elementInfo
.
dataZoom
.
end
-
this
.
elementInfo
.
dataZoom
.
start
)
/
100
}
if
(
count
>
this
.
elementInfo
.
option
.
dataset
.
maxCount
)
{
this
.
elementInfo
.
option
.
dataset
.
show
=
false
}
}
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
if
(
chart
)
{
const
option
=
chart
.
getOption
()
option
.
series
=
dealSeries
// 重新setOption,使得设置的formatter生效
chart
.
setOption
(
option
)
}
})
},
},
/**
/**
* 处理数据
* 处理数据
...
@@ -103,7 +124,6 @@
...
@@ -103,7 +124,6 @@
return
that
.
$u
.
common
.
converFunction
(
that
.
elementInfo
.
option
.
dataset
return
that
.
$u
.
common
.
converFunction
(
that
.
elementInfo
.
option
.
dataset
.
formatter
,
val
)
.
formatter
,
val
)
},
},
show
:
item
.
data
.
length
>
10
?
false
:
true
}
}
}
}
return
{
return
{
...
@@ -112,6 +132,27 @@
...
@@ -112,6 +132,27 @@
}
}
})
})
return
newData
return
newData
},
/**
* 处理图表的数值是否显示
* 超过10个时隐藏点的数值
* event: 包含dataZoom的start和end
*/
dealLabelShowStatus
(
event
)
{
// 当前图表初始设置了labelShow=true时,才判断超过10个隐藏
if
(
this
.
labelShow
)
{
const
count
=
this
.
elementData
.
dataList
.
categories
.
length
*
(
event
.
end
-
event
.
start
)
/
100
const
option
=
chart
.
getOption
()
// TODO:切换全屏后返回,chart实例不存在了
if
(
!
option
)
{
return
}
const
series
=
option
.
series
series
.
map
(
item
=>
{
item
.
label
.
show
=
count
<=
this
.
elementInfo
.
option
.
dataset
.
maxCount
})
chart
.
setOption
(
option
)
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment