Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
glsk-data-view-pd
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 67a8fd1c
authored
Jul 11, 2023
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交地图
1 parent
54326505
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
153 deletions
src/components/Charts.vue
src/utils/china.js
src/components/Charts.vue
View file @
67a8fd1
<!--
<!--
* @Author: 前端 qianduan01@didihu.com.cn
* @Description:
* @Date: 2022-10-25 10:12:26
* @Author: huyue
* @Date: 2023-07-04 17:23:09
* @LastEditors: huyue
* @LastEditors: huyue
* @LastEditTime: 2023-07-04 18:05:08
* @LastEditTime: 2023-07-10 17:07:39
* @FilePath: \dj-data-view\src\components\ViewTitle.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
-->
<
template
>
<
template
>
<div>
<div
class=
"mapChart"
>
<
div>
测试图
</div
>
<
h2
class=
"title-item"
>
{{
title
}}
</h2
>
<div
id=
"demo"
style=
"width: 100vw;height: 50vh
"
></div>
<div
id=
"demo"
class=
"midtop
"
></div>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
type=
"text/ecmascript-6"
>
import
*
as
echarts
from
'echarts'
import
*
as
echarts
from
'echarts'
import
'@/utils/china.js'
export
default
{
export
default
{
name
:
'Charts'
,
name
:
'Charts'
,
// mixins: [resize],
props
:
{
id
:
{
type
:
String
,
default
:
''
// required: true
},
chartData
:
{
type
:
Array
,
default
:
()
=>
[],
// required: true
},
title
:
{
type
:
String
,
default
:
''
,
// required: true
}
},
data
()
{
data
()
{
return
{}
return
{
chart
:
null
}
},
},
mounted
()
{
watch
:
{
var
chartDom
=
document
.
getElementById
(
'demo'
)
chartData
:
{
var
myChart
=
echarts
.
init
(
chartDom
)
deep
:
true
,
var
option
handler
(
val
)
{
const
xAxisData
=
[]
this
.
setOptions
(
val
)
const
data1
=
[]
const
data2
=
[]
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
xAxisData
.
push
(
'Class'
+
i
)
data1
.
push
(
+
(
Math
.
random
()
*
2
).
toFixed
(
2
))
data2
.
push
(
+
(
Math
.
random
()
*
5
).
toFixed
(
2
))
}
}
var
emphasisStyle
=
{
itemStyle
:
{
shadowBlur
:
10
,
shadowColor
:
'rgba(0,0,0,0.3)'
}
}
},
beforeDestroy
()
{
if
(
!
this
.
chart
)
{
return
}
}
option
=
{
this
.
chart
.
dispose
()
legend
:
{
this
.
chart
=
null
data
:
[
'bar'
,
'bar2'
,
'line'
],
left
:
'10%'
},
},
brush
:
{
mounted
()
{
toolbox
:
[
'rect'
,
'polygon'
,
'lineX'
,
'lineY'
,
'keep'
,
'clear'
],
this
.
$nextTick
(()
=>
{
xAxisIndex
:
0
this
.
initChart
()
})
},
methods
:
{
initChart
()
{
this
.
chart
=
echarts
.
init
(
document
.
getElementById
(
'demo'
))
this
.
setOptions
(
this
.
chartData
)
this
.
chart
.
on
(
'click'
,
function
(
params
)
{
console
.
log
(
params
.
name
)
})
},
setOptions
(
data
=
[])
{
this
.
chart
.
setOption
({
tooltip
:
{
trigger
:
'item'
,
formatter
:
'{b}<br/>{c} (人)'
},
},
toolbox
:
{
toolbox
:
{
show
:
true
,
orient
:
'vertical'
,
left
:
'right'
,
top
:
'center'
,
feature
:
{
feature
:
{
magicType
:
{
dataView
:
{
readOnly
:
false
},
type
:
[
'stack'
]
restore
:
{},
},
saveAsImage
:
{}
dataView
:
{}
}
}
},
},
tooltip
:
{},
visualMap
:
{
xAxis
:
{
min
:
800
,
data
:
xAxisData
,
max
:
50000
,
name
:
'X Axis'
,
text
:
[
'High'
,
'Low'
],
axisLine
:
{
onZero
:
true
},
realtime
:
false
,
splitLine
:
{
show
:
false
},
calculable
:
true
,
splitArea
:
{
show
:
false
}
left
:
'5%'
,
},
bottom
:
'8%'
,
yAxis
:
{},
textStyle
:
{
grid
:
{
color
:
'#fff'
bottom
:
100
},
series
:
[
{
name
:
'bar'
,
type
:
'bar'
,
stack
:
'one'
,
emphasis
:
emphasisStyle
,
data
:
data1
,
label
:
{
show
:
true
},
},
itemStyle
:
{
color
:
'#fff'
,
barBorderRadius
:
[
2
,
2
,
0
,
0
],
// 柱体圆角
inRange
:
{
color
:
function
(
params
)
{
color
:
[
'lightskyblue'
,
'yellow'
,
'orangered'
]
console
.
log
(
params
)
const
colorList
=
[
[
'#22D8FF'
,
'#5C56FF'
],
[
'#2AD190'
,
'#00B7DF'
],
[
'#22D8FF'
,
'#5C56FF'
],
[
'#2AD190'
,
'#00B7DF'
],
[
'#22D8FF'
,
'#5C56FF'
],
[
'#2AD190'
,
'#00B7DF'
],
[
'#22D8FF'
,
'#5C56FF'
],
[
'#2AD190'
,
'#00B7DF'
],
[
'#22D8FF'
,
'#5C56FF'
],
[
'#2AD190'
,
'#00B7DF'
],
[
'#22D8FF'
,
'#5C56FF'
],
[
'#2AD190'
,
'#00B7DF'
]
]
var
colorItem
=
colorList
[
params
.
dataIndex
]
return
new
echarts
.
graphic
.
LinearGradient
(
0
,
0
,
0
,
1
,
[{
// 代表渐变色从正上方开始
offset
:
0
,
// offset范围是0~1,用于表示位置,0是指0%处的颜色
color
:
colorItem
[
0
]
},
// 柱图渐变色
{
offset
:
1
,
// 指100%处的颜色
color
:
colorItem
[
1
]
}]
)
}
}
}
},
},
series
:
[
{
{
name
:
'bar2'
,
type
:
'map'
,
type
:
'bar'
,
map
:
'china'
,
stack
:
'one'
,
label
:
{
label
:
{
show
:
true
show
:
true
,
color
:
'yellow'
},
},
emphasis
:
emphasisStyle
,
data
data
:
data2
,
itemStyle
:
{
barBorderRadius
:
[
2
,
2
,
0
,
0
],
// 柱体圆角
color
:
function
(
params
)
{
console
.
log
(
params
)
const
colorList
=
[
[
'#11627A'
,
'#282F7A'
],
[
'#145F4E'
,
'#035972'
],
[
'#11627A'
,
'#282F7A'
],
[
'#145F4E'
,
'#035972'
],
[
'#11627A'
,
'#282F7A'
],
[
'#145F4E'
,
'#035972'
],
[
'#11627A'
,
'#282F7A'
],
[
'#145F4E'
,
'#035972'
],
[
'#11627A'
,
'#282F7A'
],
[
'#145F4E'
,
'#035972'
],
[
'#11627A'
,
'#282F7A'
],
[
'#145F4E'
,
'#035972'
]
]
var
colorItem
=
colorList
[
params
.
dataIndex
]
return
new
echarts
.
graphic
.
LinearGradient
(
0
,
0
,
0
,
1
,
[{
// 代表渐变色从正上方开始
offset
:
0
,
// offset范围是0~1,用于表示位置,0是指0%处的颜色
color
:
colorItem
[
0
]
},
// 柱图渐变色
{
offset
:
1
,
// 指100%处的颜色
color
:
colorItem
[
1
]
}]
)
}
}
},
{
name
:
'Dynamic Line'
,
type
:
'line'
,
data
:
data2
}
}
]
]
}
myChart
.
on
(
'brushSelected'
,
function
(
params
)
{
var
brushed
=
[]
var
brushComponent
=
params
.
batch
[
0
]
for
(
var
sIdx
=
0
;
sIdx
<
brushComponent
.
selected
.
length
;
sIdx
++
)
{
var
rawIndices
=
brushComponent
.
selected
[
sIdx
].
dataIndex
brushed
.
push
(
'[Series '
+
sIdx
+
'] '
+
rawIndices
.
join
(
', '
))
}
myChart
.
setOption
({
title
:
{
backgroundColor
:
'#333'
,
text
:
'SELECTED DATA INDICES: \n'
+
brushed
.
join
(
'\n'
),
bottom
:
0
,
right
:
'10%'
,
width
:
100
,
textStyle
:
{
fontSize
:
12
,
color
:
'#fff'
}
}
})
})
})
option
&&
myChart
.
setOption
(
option
)
}
}
}
}
}
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.mapChart
{
text-align
:
center
;
width
:
100%
;
font-size
:
12px
;
font-weight
:
normal
;
letter-spacing
:
2px
;
font-weight
:
normal
;
overflow
:
hidden
;
}
.midtop
{
width
:
99%
;
height
:
430px
;
}
</
style
>
</
style
>
src/utils/china.js
0 → 100644
View file @
67a8fd1
This diff is collapsed.
Click to expand it.
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