Commit 67a8fd1c by 胡悦

提交地图

1 parent 54326505
<!-- <!--
* @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',
data() { // mixins: [resize],
return {} props: {
id: {
type: String,
default: ''
// required: true
},
chartData: {
type: Array,
default: () => [],
// required: true
},
title: {
type: String,
default: '',
// required: true
}
}, },
mounted() { data() {
var chartDom = document.getElementById('demo') return {
var myChart = echarts.init(chartDom) chart: null
var option
const xAxisData = []
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: { watch: {
shadowBlur: 10, chartData: {
shadowColor: 'rgba(0,0,0,0.3)' deep: true,
handler(val) {
this.setOptions(val)
} }
} }
option = { },
legend: { beforeDestroy() {
data: ['bar', 'bar2', 'line'], if (!this.chart) {
left: '10%' return
}, }
brush: { this.chart.dispose()
toolbox: ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear'], this.chart = null
xAxisIndex: 0 },
}, mounted() {
toolbox: { this.$nextTick(() => {
feature: { this.initChart()
magicType: { })
type: ['stack'] },
}, methods: {
dataView: {} initChart() {
} this.chart = echarts.init(document.getElementById('demo'))
}, this.setOptions(this.chartData)
tooltip: {}, this.chart.on('click', function (params) {
xAxis: { console.log(params.name)
data: xAxisData, })
name: 'X Axis', },
axisLine: { onZero: true }, setOptions(data = []) {
splitLine: { show: false }, this.chart.setOption({
splitArea: { show: false } tooltip: {
}, trigger: 'item',
yAxis: {}, formatter: '{b}<br/>{c} (人)'
grid: {
bottom: 100
},
series: [
{
name: 'bar',
type: 'bar',
stack: 'one',
emphasis: emphasisStyle,
data: data1,
label: {
show: true
},
itemStyle: {
barBorderRadius: [2, 2, 0, 0], // 柱体圆角
color: function(params) {
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]
}]
)
}
}
}, },
{ toolbox: {
name: 'bar2', show: true,
type: 'bar', orient: 'vertical',
stack: 'one', left: 'right',
label: { top: 'center',
show: true feature: {
}, dataView: { readOnly: false },
emphasis: emphasisStyle, restore: {},
data: data2, saveAsImage: {}
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]
}]
)
}
} }
}, },
{ visualMap: {
name: 'Dynamic Line', min: 800,
type: 'line', max: 50000,
data: data2 text: ['High', 'Low'],
} realtime: false,
] calculable: true,
} left: '5%',
myChart.on('brushSelected', function(params) { bottom: '8%',
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: { textStyle: {
fontSize: 12,
color: '#fff' color: '#fff'
},
color: '#fff',
inRange: {
color: ['lightskyblue', 'yellow', 'orangered']
}
},
series: [
{
type: 'map',
map: 'china',
label: {
show: true,
color: 'yellow'
},
data
} }
} ]
}) })
}) }
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>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!