Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
00bce0ee
提交
00bce0ee
authored
3月 11, 2021
作者:
junjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(视图): echarts组件封装,初步实现
上级
faeedeb1
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
94 行增加
和
56 行删除
+94
-56
chart.js
frontend/src/views/chart/chart/chart.js
+18
-1
ChartComponent.vue
frontend/src/views/chart/components/ChartComponent.vue
+65
-0
QuotaItem.vue
frontend/src/views/chart/components/QuotaItem.vue
+2
-2
ChartEdit.vue
frontend/src/views/chart/view/ChartEdit.vue
+9
-53
没有找到文件。
frontend/src/views/chart/chart/chart.js
浏览文件 @
00bce0ee
...
@@ -15,6 +15,23 @@ export const BASE_BAR = {
...
@@ -15,6 +15,23 @@ export const BASE_BAR = {
series
:
[]
series
:
[]
}
}
export
const
BASE_LINE
=
{
title
:
{
text
:
''
},
tooltip
:
{},
legend
:
{
data
:
[]
},
xAxis
:
{
data
:
[]
},
yAxis
:
{
type
:
'value'
},
series
:
[]
}
export
default
{
export
default
{
BASE_BAR
BASE_BAR
,
BASE_LINE
}
}
frontend/src/views/chart/components/ChartComponent.vue
0 → 100644
浏览文件 @
00bce0ee
<
template
>
<div
class=
"Echarts"
style=
"height: 100%;display: flex;margin-top: 10px;"
>
<div
id=
"echart"
style=
"width: 100%;height: 80vh;"
/>
</div>
</
template
>
<
script
>
import
{
BASE_BAR
,
BASE_LINE
}
from
'../chart/chart'
export
default
{
name
:
'ChartComponent'
,
props
:
{
chart
:
{
type
:
Object
,
required
:
true
}
},
data
()
{
return
{}
},
watch
:
{
chart
()
{
this
.
drawEcharts
()
}
},
mounted
()
{
},
methods
:
{
drawEcharts
()
{
const
chart
=
this
.
chart
let
chart_option
=
{}
// todo type
if
(
chart
.
type
===
'bar'
)
{
chart_option
=
JSON
.
parse
(
JSON
.
stringify
(
BASE_BAR
))
}
else
if
(
chart
.
type
===
'line'
)
{
chart_option
=
JSON
.
parse
(
JSON
.
stringify
(
BASE_LINE
))
}
// console.log(chart_option);
if
(
chart
.
data
)
{
chart_option
.
title
.
text
=
chart
.
title
chart_option
.
xAxis
.
data
=
chart
.
data
.
x
chart
.
data
.
series
.
forEach
(
function
(
y
)
{
chart_option
.
legend
.
data
.
push
(
y
.
name
)
chart_option
.
series
.
push
(
y
)
})
}
// console.log(chart_option);
this
.
myEcharts
(
chart_option
)
},
myEcharts
(
option
)
{
// 基于准备好的dom,初始化echarts实例
var
myChart
=
this
.
$echarts
.
init
(
document
.
getElementById
(
'echart'
))
// 指定图表的配置项和数据
setTimeout
(
myChart
.
setOption
(
option
,
true
),
500
)
window
.
onresize
=
function
()
{
myChart
.
resize
()
}
}
}
}
</
script
>
<
style
scoped
>
</
style
>
frontend/src/views/chart/components/QuotaItem.vue
浏览文件 @
00bce0ee
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<span
<span
class=
"item-axis"
class=
"item-axis"
>
>
{{
item
.
name
}}
<span
class=
"summary-span"
>
(
{{
$t
(
'chart.'
+
item
.
summary
)
}}
)
</span><i
class=
"el-icon-arrow-down el-icon--right"
/>
{{
item
.
name
}}
<span
class=
"summary-span"
>
{{
$t
(
'chart.'
+
item
.
summary
)
}}
</span><i
class=
"el-icon-arrow-down el-icon--right"
/>
<span
/>
<span
/>
<el-dropdown-menu
slot=
"dropdown"
>
<el-dropdown-menu
slot=
"dropdown"
>
<el-dropdown-item
icon=
"el-icon-notebook-2"
>
<el-dropdown-item
icon=
"el-icon-notebook-2"
>
...
@@ -50,7 +50,7 @@ export default {
...
@@ -50,7 +50,7 @@ export default {
},
},
methods
:
{
methods
:
{
summary
(
param
)
{
summary
(
param
)
{
console
.
log
(
param
)
//
console.log(param)
this
.
item
.
summary
=
param
.
type
this
.
item
.
summary
=
param
.
type
this
.
$emit
(
'onQuotaSummaryChange'
,
this
.
item
)
this
.
$emit
(
'onQuotaSummaryChange'
,
this
.
item
)
},
},
...
...
frontend/src/views/chart/view/ChartEdit.vue
浏览文件 @
00bce0ee
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
@start="start1"
@start="start1"
>
>
<transition-group>
<transition-group>
<span
v-for=
"item in dimension"
:key=
"item.id"
class=
"item"
@
click=
"click1(item)"
>
{{
item
.
name
}}
</span>
<span
v-for=
"item in dimension"
:key=
"item.id"
class=
"item"
>
{{
item
.
name
}}
</span>
</transition-group>
</transition-group>
</draggable>
</draggable>
</div>
</div>
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
@start="start1"
@start="start1"
>
>
<transition-group>
<transition-group>
<span
v-for=
"item in quota"
:key=
"item.id"
class=
"item"
@
click=
"click2(item)"
>
{{
item
.
name
}}
</span>
<span
v-for=
"item in quota"
:key=
"item.id"
class=
"item"
>
{{
item
.
name
}}
</span>
</transition-group>
</transition-group>
</draggable>
</draggable>
</div>
</div>
...
@@ -131,9 +131,7 @@
...
@@ -131,9 +131,7 @@
</el-row>
</el-row>
</el-row>
</el-row>
<div
class=
"Echarts"
style=
"height: 100%;display: flex;margin-top: 10px;"
>
<chart-component
:chart=
"chart"
/>
<div
id=
"echart"
style=
"width: 100%;height: 80vh;"
/>
</div>
</el-row>
</el-row>
</el-col>
</el-col>
</el-row>
</el-row>
...
@@ -143,13 +141,13 @@
...
@@ -143,13 +141,13 @@
<
script
>
<
script
>
import
{
post
}
from
'@/api/dataset/dataset'
import
{
post
}
from
'@/api/dataset/dataset'
import
draggable
from
'vuedraggable'
import
draggable
from
'vuedraggable'
import
{
BASE_BAR
}
from
'../chart/chart'
import
DimensionItem
from
'../components/DimensionItem'
import
DimensionItem
from
'../components/DimensionItem'
import
QuotaItem
from
'../components/QuotaItem'
import
QuotaItem
from
'../components/QuotaItem'
import
ChartComponent
from
'../components/ChartComponent'
export
default
{
export
default
{
name
:
'ChartEdit'
,
name
:
'ChartEdit'
,
components
:
{
QuotaItem
,
DimensionItem
,
draggable
},
components
:
{
ChartComponent
,
QuotaItem
,
DimensionItem
,
draggable
},
data
()
{
data
()
{
return
{
return
{
table
:
{},
table
:
{},
...
@@ -173,7 +171,8 @@ export default {
...
@@ -173,7 +171,8 @@ export default {
arr2
:
[
arr2
:
[
{
id
:
11
,
name
:
'容量'
}
{
id
:
11
,
name
:
'容量'
}
],
],
moveId
:
-
1
moveId
:
-
1
,
chart
:
{}
}
}
},
},
computed
:
{
computed
:
{
...
@@ -225,26 +224,6 @@ export default {
...
@@ -225,26 +224,6 @@ export default {
this
.
quota
=
response
.
data
.
quota
this
.
quota
=
response
.
data
.
quota
})
})
},
},
click1
(
item
)
{
// console.log(item);
const
c
=
this
.
view
.
xaxis
.
filter
(
function
(
ele
)
{
return
ele
.
id
===
item
.
id
})
// console.log(c);
if
(
c
&&
c
.
length
===
0
)
{
this
.
view
.
xaxis
.
push
(
item
)
}
},
click2
(
item
)
{
// console.log(item);
const
c
=
this
.
view
.
yaxis
.
filter
(
function
(
ele
)
{
return
ele
.
id
===
item
.
id
})
// console.log(c);
if
(
c
&&
c
.
length
===
0
)
{
this
.
view
.
yaxis
.
push
(
item
)
}
},
get
(
id
)
{
get
(
id
)
{
if
(
id
)
{
if
(
id
)
{
post
(
'/chart/view/get/'
+
id
,
null
).
then
(
response
=>
{
post
(
'/chart/view/get/'
+
id
,
null
).
then
(
response
=>
{
...
@@ -290,20 +269,8 @@ export default {
...
@@ -290,20 +269,8 @@ export default {
this
.
view
=
response
.
data
this
.
view
=
response
.
data
this
.
view
.
xaxis
=
this
.
view
.
xaxis
?
JSON
.
parse
(
this
.
view
.
xaxis
)
:
[]
this
.
view
.
xaxis
=
this
.
view
.
xaxis
?
JSON
.
parse
(
this
.
view
.
xaxis
)
:
[]
this
.
view
.
yaxis
=
this
.
view
.
yaxis
?
JSON
.
parse
(
this
.
view
.
yaxis
)
:
[]
this
.
view
.
yaxis
=
this
.
view
.
yaxis
?
JSON
.
parse
(
this
.
view
.
yaxis
)
:
[]
// 将视图传入echart组件
const
chart
=
response
.
data
this
.
chart
=
response
.
data
const
chart_option
=
JSON
.
parse
(
JSON
.
stringify
(
BASE_BAR
))
// console.log(chart_option);
if
(
chart
.
data
)
{
chart_option
.
title
.
text
=
chart
.
title
chart_option
.
xAxis
.
data
=
chart
.
data
.
x
chart
.
data
.
series
.
forEach
(
function
(
y
)
{
chart_option
.
legend
.
data
.
push
(
y
.
name
)
chart_option
.
series
.
push
(
y
)
})
}
// console.log(chart_option);
this
.
myEcharts
(
chart_option
)
})
})
}
else
{
}
else
{
this
.
view
=
{}
this
.
view
=
{}
...
@@ -391,7 +358,6 @@ export default {
...
@@ -391,7 +358,6 @@ export default {
},
},
quotaSummaryChange
(
item
)
{
quotaSummaryChange
(
item
)
{
console
.
log
(
item
)
// 更新item
// 更新item
this
.
view
.
yaxis
.
forEach
(
function
(
ele
)
{
this
.
view
.
yaxis
.
forEach
(
function
(
ele
)
{
if
(
ele
.
id
===
item
.
id
)
{
if
(
ele
.
id
===
item
.
id
)
{
...
@@ -399,16 +365,6 @@ export default {
...
@@ -399,16 +365,6 @@ export default {
}
}
})
})
this
.
save
()
this
.
save
()
},
myEcharts
(
option
)
{
// 基于准备好的dom,初始化echarts实例
var
myChart
=
this
.
$echarts
.
init
(
document
.
getElementById
(
'echart'
))
// 指定图表的配置项和数据
setTimeout
(
myChart
.
setOption
(
option
,
true
),
500
)
window
.
onresize
=
function
()
{
myChart
.
resize
()
}
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论