echarts学习笔记:柱状图+雷达图+双环形图+地图可视化+数据传递关系图+关键词条图+数据总览图+AntV/G2/DataV

GitHub - lgd8981289/imooc-visualization: https://www.bilibili.com/video/BV1yu411E7cm/?vd_source=391a8dc379e0da60c77490e3221f097a 课程源码

国内echarts镜像站:ISQQW.COM x ECharts 文档(国内同步镜像) - 配置项

echarts图表集:echarts图表集

基于vite和tailwindcss创建项目,使用js

pnpm create vite

 一、横向柱状图,竖向柱状图

echarts图表绘制分为三大步: 

 1.横向柱状图

HorizontalBar.vue

<template>
	<div>
		<div>【大区数据信息】</div>
		<div ref="target" class="w-full h-full"></div>
	</div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue'
import * as echarts from 'echarts'

const props = defineProps({
	data: {
		type: Object,
		required: true
	}
})

// 获取 dom 实例
const target = ref()

// echarts 实例变量
let mChart = null
// 在 mounted 生命周期之后,实例化 echarts
onMounted(() => {
	mChart = echarts.init(target.value)
	// 渲染 echarts
	renderChart()
})

// 渲染图表
const renderChart = () => {
	const options = {
		// X 轴展示数据
		xAxis: {
			// 数据展示
			type: 'value',
			// 不显示轴
			show: false,
			// 最大值(防止触顶)
			max: function (value) {
				// 取整
				return parseInt(value.max * 1.2)
			}
		},
		// Y 轴展示选项
		yAxis: {
			type: 'category',
			// 根据根据服务端数据筛选
			data: props.data.regions.map((item) => item.name),
			// 反向展示
			inverse: true,
			// 不展示轴线
			axisLine: {
				show: false
			},
			// 不展示刻度
			axisTick: {
				show: false // 取消 Y 轴刻度
			},
			// 文字色值
			axisLabel: {
				color: '#9EB1C8'
			}
		},
		// echarts 网格绘制的位置,对应 上、右、下、左
		grid: {
			top: 0,
			right: 0,
			bottom: 0,
			left: 0,
			// 计算边距时,包含标签
			containLabel: true
		},
		// 柱形图核心配置
		series: [
			{
				// 图表类型
				type: 'bar',
				// 数据筛选
				data: props.data.regions.map((item) => ({
					name: item.name,
					value: item.value
				})),
				// 显示背景
				showBackground: true,
				// 背景色
				backgroundStyle: {
					color: 'rgba(180, 180, 180, 0.2)'
				},
				// 每个轴的样式
				itemStyle: {
					color: '#479AD3', // 设置柱子的颜色
					barBorderRadius: 5, // 设置柱子的圆角
					shadowColor: 'rgba(0, 0, 0, 0.3)', // 设置柱子的阴影颜色
					shadowBlur: 5 // 设置柱子的阴影模糊大小
				},
				// 轴宽度
				barWidth: 12,
				// 轴上的字体
				label: {
					show: true,
					// 设置标签位置为右侧
					position: 'right',
					textStyle: {
						// 设置标签文本颜色
						color: '#fff'
					}
				}
			}
		]
	}

	mChart.setOption(options)
}

// 监听数据的变化,重新渲染图表
watch(
	() => props.data,
	() => {
		renderChart()
	}
)
</script>

<style lang="scss" scoped></style>

2.竖向柱状图

VerticalBar.vue

<template>
	<div>
		<div>【服务资源占用比】</div>
		<div ref="target" class="w-full h-full"></div>
	</div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue'
import * as echarts from 'echarts'

const props = defineProps({
	data: {
		type: Object,
		required: true
	}
})

const target = ref()
let mChart = null
onMounted(() => {
	mChart = echarts.init(target.value)
	renderChart()
})

const renderChart = () => {
	const options = {
		// X 轴展示选项
		xAxis: {
			type: 'category',
			// 根据根据服务端数据筛选
			data: props.data.servers.map((item) => item.name),
			// 文字色值
			axisLabel: {
				color: '#9EB1C8'
			}
		},
		// Y 轴展示数据
		yAxis: {
			// 数据展示
			type: 'value',
			// 不显示轴
			show: false,
			// 最大值(防止触顶)
			max: function (value) {
				// 取整
				return parseInt(value.max * 1.2)
			}
		},
		// echarts 网格绘制的位置,对应 上、右、下、左
		grid: {
			top: 16,
			right: 0,
			bottom: 26,
			left: -26,
			// 计算边距时,包含标签
			containLabel: true
		},
		// 柱形图核心配置
		series: {
			// 柱形图
			type: 'bar',
			// 数据筛选
			data: props.data.servers.map((item) => ({
				name: item.name,
				value: item.value
			})),
			// 每个轴的样式
			itemStyle: {
				color: '#479AD3', // 设置柱子的颜色
				barBorderRadius: 5, // 设置柱子的圆角
				shadowColor: 'rgba(0, 0, 0, 0.3)', // 设置柱子的阴影颜色
				shadowBlur: 5 // 设置柱子的阴影模糊大小
			},
			// 柱子宽度
			barWidth: 12,
			// 文本
			label: {
				show: true,
				// 设置标签位置为顶部
				position: 'top',
				textStyle: {
					// 设置标签文本颜色
					color: '#fff'
				},
				// 设置数字为百分比
				formatter: '{c}%'
			}
		}
	}

	mChart.setOption(options)
}

// 监听数据的变化,重新渲染图表
watch(()=>props.data,renderChart)
// watch(
// 	() => props.data,
// 	() => {
// 		renderChart()
// 	}
// )
</script>

<style lang="scss" scoped></style>

 二、雷达图

RadarBar.vue

<template>
	<div>
		<div>【云端报警风险】</div>
		<div ref="target" class="w-full h-full"></div>
	</div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue'
import * as echarts from 'echarts'

const props = defineProps({
	data: {
		type: Object,
		required: true
	}
})

const target = ref()
let mChart = null
onMounted(() => {
	mChart = echarts.init(target.value)
	renderChart()
})

const renderChart = () => {
	const options = {
		// 雷达图坐标系配置
		radar: {
			// 坐标系名
			name: {
				textStyle: {
					color: '#05D5FF',
					fontSize: 14
				}
			},
			// 雷达绘制类型。polygon 多边形
			shape: 'polygon',
			// 居中
			center: ['50%', '50%'],
			// 边境
			radius: '80%',
			// 开始的角度(可以避免绘制到边框之外)
			startAngle: 120,
			// 轴线配置
			axisLine: {
				lineStyle: {
					color: 'rgba(5, 213, 255, .8)'
				}
			},
			// 网格线配置
			splitLine: {
				show: true,
				lineStyle: {
					width: 1,
					color: 'rgba(5, 213, 255, .8)' // 设置网格的颜色
				}
			},
			// 指示器文字
			indicator: props.data.risks.map((item) => ({
				name: item.name,
				max: 100
			})),
			// 不展示拆分区域
			splitArea: {
				show: false
			}
		},
		// 坐标居中
		polar: {
			center: ['50%', '50%'], // 默认全局居中
			radius: '0%'
		},
		// 坐标角度
		angleAxis: {
			// 坐标轴刻度最小值
			min: 0,
			// 坐标轴分割间隔
			interval: 5,
			// 刻度增长逆时针
			clockwise: false,
			// 不显示坐标轴刻度
			axisTick: {
				show: false
			},
			// 不显示坐标轴文字
			axisLabel: {
				show: false
			},
			// 不显示坐标轴线
			axisLine: {
				show: false
			},
			// 不显示分割线
			splitLine: {
				show: false
			}
		},
		// 径向轴
		radiusAxis: {
			// 最小值
			min: 0,
			// 间隔
			interval: 20,
			// 不显示分割线
			splitLine: {
				show: true
			}
		},
		// 图表核心配置
		series: [
			{
				// 雷达图
				type: 'radar',
				// 拐点的样式,还可以取值'rect','angle'等
				symbol: 'circle',
				// 拐点的大小
				symbolSize: 10,
				// 折线拐点标志的样式
				itemStyle: {
					normal: {
						color: '#05D5FF'
					}
				},
				// 区域填充样式
				areaStyle: {
					normal: {
						color: '#05D5FF',
						opacity: 0.5
					}
				},
				// 线条样式
				lineStyle: {
					width: 2,
					color: '#05D5FF'
				},
				// 图形上的文本标签
				label: {
					normal: {
						show: true,
						formatter: (params) => {
							return params.value
						},
						color: '#fff'
					}
				},
				// 数据
				data: [
					{
						value: props.data.risks.map((item) => item.value)
					}
				]
			}
		]
	}

	mChart.setOption(options)
}

// 监听数据的变化,重新渲染图表
watch(
	() => props.data,
	() => {
		renderChart()
	}
)
</script>

三、 异常处理双环形图

双环形图绘制原理:

 * 1. 环形图通过饼图绘制。内外边距的距离减小,即为环形。环形中心点需要不断改变,否则会重叠

 * 2. 环形图绘制分为 上层和底层 两部分。上层作为绘制进度,底层作为背景图

 * 3. 依据 getSeriesData 生成对应的 上层和底层 series 数据,进行渲染

<template>
	<div>
		<div>【大区异常处理】</div>
		<div ref="target" class="w-full h-full"></div>
	</div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue'
import * as echarts from 'echarts'

const props = defineProps({
	data: {
		type: Object,
		required: true
	}
})

const target = ref()
let mChart = null
onMounted(() => {
	mChart = echarts.init(target.value)
	renderChart()
})

/**
 * 双环形图绘制原理:
 * 1. 环形图通过饼图绘制。内外边距的距离减小,即为环形。环形中心点需要不断改变,否则会重叠
 * 2. 环形图绘制分为 上层和底层 两部分。上层作为绘制进度,底层作为背景图
 * 3. 依据 getSeriesData 生成对应的 上层和底层 series 数据,进行渲染
 */
const getSeriesData = () => {
	const series = []

	props.data.abnormals.forEach((item, index) => {
		// 上层环形绘制
		series.push({
			name: item.name,
			// 使用饼图绘制,减少饼图宽度即为环形图
			type: 'pie',
			// 逆时针排布
			clockWise: false,
			// 不展示鼠标移入动画
			hoverAnimation: false,
			// 半径位置,需要依次递减,否则会重复在一处进行展示
			radius: [73 - index * 15 + '%', 68 - index * 15 + '%'],
			// 中心点
			center: ['55%', '55%'],
			// 不展示 label
			label: { show: false },
			// 数据配置
			data: [
				// 设置数据与名称
				{ value: item.value, name: item.name },
				// 最大数据,展示比例
				{
					value: 1000,
					name: '',
					itemStyle: { color: 'rgba(0,0,0,0)', borderWidth: 0 },
					tooltip: { show: false },
					hoverAnimation: false
				}
			]
		})

		// 底层图
		series.push({
			name: item.name,
			type: 'pie',
			// 图形不响应事件
			silent: true,
			// z-index: 置于底层
			z: 1,
			// 逆时针排布
			clockWise: false,
			// 不展示鼠标移入动画
			hoverAnimation: false,
			// 半径位置,需要依次递减,否则会重复在一处进行展示
			radius: [73 - index * 15 + '%', 68 - index * 15 + '%'],
			// 中心点
			center: ['55%', '55%'],
			// 不展示 label
			label: { show: false },
			// 数据
			data: [
				// 绘制底线 75%
				{
					value: 7.5,
					itemStyle: { color: 'rgb(3, 31, 62)', borderWidth: 0 },
					tooltip: { show: false },
					hoverAnimation: false
				},
				// 绘制底线 25% 透明区域
				{
					value: 2.5,
					name: '',
					itemStyle: { color: 'rgba(0,0,0,0)', borderWidth: 0 },
					tooltip: { show: false },
					hoverAnimation: false
				}
			]
		})
	})

	return series
}

const renderChart = () => {
	const options = {
		// 图例配置
		legend: {
			show: true,
			// 图例色块
			icon: 'circle',
			// 位置
			top: '14%',
			left: '60%',
			// 展示数据
			data: props.data.abnormals.map((item) => item.name),
			// 总宽度(一列)
			width: -5,
			// 每个色块的宽
			itemWidth: 10,
			// 每个色块的高度
			itemHeight: 10,
			// item 间距
			itemGap: 6,
			// 展示内容
			formatter: function (name) {
				return '{title|' + name + '}'
			},
			// 字体配置
			textStyle: {
				rich: {
					title: {
						fontSize: 12,
						lineHeight: 5,
						color: 'rgba(255,255,255,0.8)'
					}
				}
			}
		},
		// 提示层
		tooltip: {
			show: true,
			trigger: 'item',
			formatter: '{a}<br>{b}:{c}({d}%)'
		},
		// Y 轴展示选项
		yAxis: [
			{
				type: 'category',
				// 反向展示
				inverse: true,
				// 不展示轴线
				axisLine: {
					show: false
				},
				// 不展示刻度
				axisTick: {
					show: false
				}
			}
		],
		// X 轴不展示
		xAxis: [
			{
				show: false
			}
		],
		// 每两个标记一条线
		series: getSeriesData()
	}

	mChart.setOption(options)
}

// 监听数据的变化,重新渲染图表
watch(
	() => props.data,
	() => {
		renderChart()
	}
)
</script>

<style lang="scss" scoped></style>

 四、数据传递关系图

Relation.vue

<template>
	<div>
		<div>【数据传递信息】</div>
		<div ref="target" class="w-full h-full"></div>
	</div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue'
import * as echarts from 'echarts'

const props = defineProps({
	data: {
		type: Object,
		required: true
	}
})

// 获取 dom 实例
const target = ref()

// echarts 实例变量
let mChart = null
// 在 mounted 生命周期之后,实例化 echarts
onMounted(() => {
	mChart = echarts.init(target.value)
	// 渲染 echarts
	renderChart()
})

// 渲染图表
const renderChart = () => {
	const options = {
		// X 轴不需要展示
		xAxis: {
			show: false,
			type: 'value'
		},
		// X 轴不需要展示
		yAxis: {
			show: false,
			type: 'value'
		},
		// 核心数据配置
		series: [
			{
				// 用于展现节点以及节点之间的关系数据
				type: 'graph',
				// 不采用任何布局
				layout: 'none',
				// 使用二维的直角坐标系
				coordinateSystem: 'cartesian2d',
				// 节点标记的大小
				symbolSize: 26,
				// z-index
				z: 3,
				// 边界标签(线条文字)
				edgeLabel: {
					normal: {
						show: true,
						color: '#fff',
						textStyle: {
							fontSize: 14
						},
						formatter: function (params) {
							let txt = ''
							if (params.data.speed !== undefined) {
								txt = params.data.speed
							}
							return txt
						}
					}
				},
				// 圆饼下文字
				label: {
					normal: {
						show: true,
						position: 'bottom',
						color: '#5e5e5e'
					}
				},
				// 边两端的标记类型
				edgeSymbol: ['none', 'arrow'],
				// 边两端的标记大小
				edgeSymbolSize: 8,
				// 圆数据
				data: props.data.relations.map((item) => {
					// id 为 0 ,表示数据中心,数据中心单独设置
					if (item.id !== 0) {
						return {
							name: item.name,
							category: 0,
							active: true,
							speed: `${item.speed}kb/s`,
							// 位置
							value: item.value
						}
					} else {
						return {
							name: item.name,
							// 位置
							value: item.value,
							// 数据中心圆的大小
							symbolSize: 100,
							// 圆的样式
							itemStyle: {
								normal: {
									// 渐变色
									color: {
										colorStops: [
											{ offset: 0, color: '#157eff' },
											{ offset: 1, color: '#35c2ff' }
										]
									}
								}
							},
							// 字体
							label: { normal: { fontSize: '14' } }
						}
					}
				}),
				// 线
				links: props.data.relations.map((item, index) => ({
					// 方向
					source: item.source,
					target: item.target,
					// 线上的文字
					speed: `${item.speed}kb/s`,
					// 线的样式
					lineStyle: { normal: { color: '#12b5d0', curveness: 0.2 } },
					// 文字位置
					label: {
						show: true,
						position: 'middle',
						offset: [10, 0]
					}
				}))
			},
			{
				// 用于带有起点和终点信息的线数据的绘制
				type: 'lines',
				// 使用二维的直角坐标系
				coordinateSystem: 'cartesian2d',
				// z-index
				z: 1,
				// 线特效的配置
				effect: {
					show: true,
					smooth: false,
					trailLength: 0,
					symbol: 'arrow',
					color: 'rgba(55,155,255,0.5)',
					symbolSize: 12
				},
				// 线的样式
				lineStyle: {
					normal: {
						curveness: 0.2
					}
				},
				// 线的数据级,前后线需要重合。数据固定
				data: [
					[{ coord: [0, 300] }, { coord: [50, 200] }],
					[{ coord: [0, 100] }, { coord: [50, 200] }],
					[{ coord: [50, 200] }, { coord: [100, 100] }],
					[{ coord: [50, 200] }, { coord: [100, 300] }]
				]
			}
		]
	}

	mChart.setOption(options)
}

// 监听数据的变化,重新渲染图表
watch(
	() => props.data,
	() => {
		renderChart()
	}
)
</script>

<style lang="scss" scoped></style>

五、关键词条云文档图

pnpm i --save echarts-wordcloud@2.1.0

WordCloud.vue 

<template>
	<div>
		<div>【数据传递信息】</div>
		<div ref="target" class="w-full h-full"></div>
	</div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue'
import * as echarts from 'echarts'

const props = defineProps({
	data: {
		type: Object,
		required: true
	}
})

// 获取 dom 实例
const target = ref()

// echarts 实例变量
let mChart = null
// 在 mounted 生命周期之后,实例化 echarts
onMounted(() => {
	mChart = echarts.init(target.value)
	// 渲染 echarts
	renderChart()
})

// 渲染图表
const renderChart = () => {
	const options = {
		// X 轴不需要展示
		xAxis: {
			show: false,
			type: 'value'
		},
		// X 轴不需要展示
		yAxis: {
			show: false,
			type: 'value'
		},
		// 核心数据配置
		series: [
			{
				// 用于展现节点以及节点之间的关系数据
				type: 'graph',
				// 不采用任何布局
				layout: 'none',
				// 使用二维的直角坐标系
				coordinateSystem: 'cartesian2d',
				// 节点标记的大小
				symbolSize: 26,
				// z-index
				z: 3,
				// 边界标签(线条文字)
				edgeLabel: {
					normal: {
						show: true,
						color: '#fff',
						textStyle: {
							fontSize: 14
						},
						formatter: function (params) {
							let txt = ''
							if (params.data.speed !== undefined) {
								txt = params.data.speed
							}
							return txt
						}
					}
				},
				// 圆饼下文字
				label: {
					normal: {
						show: true,
						position: 'bottom',
						color: '#5e5e5e'
					}
				},
				// 边两端的标记类型
				edgeSymbol: ['none', 'arrow'],
				// 边两端的标记大小
				edgeSymbolSize: 8,
				// 圆数据
				data: props.data.relations.map((item) => {
					// id 为 0 ,表示数据中心,数据中心单独设置
					if (item.id !== 0) {
						return {
							name: item.name,
							category: 0,
							active: true,
							speed: `${item.speed}kb/s`,
							// 位置
							value: item.value
						}
					} else {
						return {
							name: item.name,
							// 位置
							value: item.value,
							// 数据中心圆的大小
							symbolSize: 100,
							// 圆的样式
							itemStyle: {
								normal: {
									// 渐变色
									color: {
										colorStops: [
											{ offset: 0, color: '#157eff' },
											{ offset: 1, color: '#35c2ff' }
										]
									}
								}
							},
							// 字体
							label: { normal: { fontSize: '14' } }
						}
					}
				}),
				// 线
				links: props.data.relations.map((item, index) => ({
					// 方向
					source: item.source,
					target: item.target,
					// 线上的文字
					speed: `${item.speed}kb/s`,
					// 线的样式
					lineStyle: { normal: { color: '#12b5d0', curveness: 0.2 } },
					// 文字位置
					label: {
						show: true,
						position: 'middle',
						offset: [10, 0]
					}
				}))
			},
			{
				// 用于带有起点和终点信息的线数据的绘制
				type: 'lines',
				// 使用二维的直角坐标系
				coordinateSystem: 'cartesian2d',
				// z-index
				z: 1,
				// 线特效的配置
				effect: {
					show: true,
					smooth: false,
					trailLength: 0,
					symbol: 'arrow',
					color: 'rgba(55,155,255,0.5)',
					symbolSize: 12
				},
				// 线的样式
				lineStyle: {
					normal: {
						curveness: 0.2
					}
				},
				// 线的数据级,前后线需要重合。数据固定
				data: [
					[{ coord: [0, 300] }, { coord: [50, 200] }],
					[{ coord: [0, 100] }, { coord: [50, 200] }],
					[{ coord: [50, 200] }, { coord: [100, 100] }],
					[{ coord: [50, 200] }, { coord: [100, 300] }]
				]
			}
		]
	}

	mChart.setOption(options)
}

// 监听数据的变化,重新渲染图表
watch(
	() => props.data,
	() => {
		renderChart()
	}
)
</script>

<style lang="scss" scoped></style>

六、 数据总览图

实现自增效果:pnpm i --save countup.js@2.6.2

TotalData.vue

<template>
	<div class="p-6">
		<div class="text-slate-300 text-center">
			数据总量:
			<span
				ref="totalCountTarget"
				class="text-7xl ml-2 mr-2 font-bold font-[Electronic] text-gradient"
			>
				679,473,929
			</span>
			条记录
		</div>
		<div class="mt-3 flex flex-wrap">
			<div class="w-1/3 text-center text-slate-400 text-sm">
				华北:
				<span ref="city1" class="text-[#5DC5EF] text-3xl font-[Electronic]">
					8,778,988
				</span>
			</div>
			<div class="w-1/3 text-center text-slate-400 text-sm">
				东北:<span
					ref="city2"
					class="text-[#5DC5EF] text-3xl font-[Electronic]"
					>8,778,988</span
				>
			</div>
			<div class="w-1/3 text-center text-slate-400 text-sm">
				华东:<span
					ref="city3"
					class="text-[#5DC5EF] text-3xl font-[Electronic]"
					>8,778,988</span
				>
			</div>
			<div class="w-1/3 text-center text-slate-400 text-sm">
				中南:<span
					ref="city4"
					class="text-[#5DC5EF] text-3xl font-[Electronic]"
					>8,778,988</span
				>
			</div>
			<div class="w-1/3 text-center text-slate-400 text-sm">
				西南:<span
					ref="city5"
					class="text-[#5DC5EF] text-3xl font-[Electronic]"
					>8,778,988</span
				>
			</div>
			<div class="w-1/3 text-center text-slate-400 text-sm">
				西北:<span
					ref="city6"
					class="text-[#5DC5EF] text-3xl font-[Electronic]"
					>8,778,988</span
				>
			</div>
		</div>
	</div>
</template>

<script setup>
import { onMounted, ref } from 'vue'
// @ts-ignore
import { CountUp } from 'countup.js'

const props = defineProps({
	data: {
		type: Object,
		required: true
	}
})

const totalCountTarget = ref(null)
const city1 = ref(null)
const city2 = ref(null)
const city3 = ref(null)
const city4 = ref(null)
const city5 = ref(null)
const city6 = ref(null)

onMounted(() => {
	new CountUp(totalCountTarget.value, props.data.total).start()
	new CountUp(city1.value, props.data.hb).start()
	new CountUp(city2.value, props.data.db).start()
	new CountUp(city3.value, props.data.hd).start()
	new CountUp(city4.value, props.data.zn).start()
	new CountUp(city5.value, props.data.xn).start()
	new CountUp(city6.value, props.data.xb).start()
})
</script>

<style lang="scss" scoped></style>

 七、地图可视化分析

时间线+右侧柱形图+中国地图+散点图绘制

全文忽略ts语法错误:

// @ts-nocheck

<template>
	<div>
		<div ref="target" class="w-full h-full"></div>
	</div>
</template>

<script setup>
// @ts-nocheck
import { onMounted, ref } from 'vue'
import * as echarts from 'echarts'
import mapJson from '../assets/MapData/china.json'

const props = defineProps({
	data: {
		type: Object,
		required: true
	}
})

const target = ref()
let mChart = null
onMounted(() => {
	mChart = echarts.init(target.value)
	renderChart()
})

const renderChart = () => {
	// echarts 渲染
	echarts.registerMap('china', mapJson)

	let options = {
		// 时间线,提供了在多个 ECharts option 间进行切换
		timeline: {
			// 数据
			data: props.data.voltageLevel,
			// 类目轴
			axisType: 'category',
			// 自动切换
			autoPlay: true,
			// 间隔时间
			playInterval: 3000,
			// 位置
			left: '10%',
			right: '10%',
			bottom: '0%',
			width: '80%',
			// 轴的文本标签
			label: {
				// 默认状态
				normal: {
					textStyle: {
						color: '#ddd'
					}
				},
				// 高亮状态
				emphasis: {
					textStyle: {
						color: '#fff'
					}
				}
			},
			// 文字大小
			symbolSize: 10,
			// 线的样式
			lineStyle: {
				color: '#555'
			},
			// 选中点的样式
			checkpointStyle: {
				borderColor: '#888',
				borderWidth: 2
			},
			// 控件样式
			controlStyle: {
				// 上一步按钮
				showNextBtn: true,
				// 下一步按钮
				showPrevBtn: true,
				// 默认样式
				normal: {
					color: '#666',
					borderColor: '#666'
				},
				// 高亮样式
				emphasis: {
					color: '#aaa',
					borderColor: '#aaa'
				}
			}
		},
		// 柱形图右侧展示
		baseOption: {
			grid: {
				right: '2%',
				top: '15%',
				bottom: '10%',
				width: '20%'
			},

			// 中国地图
			geo: {
				// 展示
				show: true,
				// 中国地图
				map: 'china',
				// 开启缩放
				roam: true,
				// 初始缩放
				zoom: 0.8,
				// 中心点
				center: [113.83531246, 34.0267395887],
				// 默认状态的省份样式
				itemStyle: {
					normal: {
						// 边框色值
						borderColor: 'rgba(147, 235, 248, 1)',
						// 边框宽度
						borderWidth: 1,
						// 区域颜色
						areaColor: {
							// 经向色值
							type: 'radial',
							x: 0.5,
							y: 0.5,
							r: 0.5,
							colorStops: [
								// 0% 处的颜色
								{
									offset: 0,
									color: 'rgba(147, 235, 248, 0)'
								},
								// 100% 处的颜色
								{
									offset: 1,
									color: 'rgba(147, 235, 248, .2)'
								}
							],
							// 缺省为 false
							globalCoord: false
						}
					},
					// 鼠标移入的色值
					emphasis: {
						areaColor: '#389BB7',
						borderWidth: 0
					}
				}
			}
		},
		// 绑定时间轴的多个图表
		options: []
	}

	// 为每一年度的图表添加数据
	props.data.voltageLevel.forEach((item, index) => {
		options.options.push({
			// 背景色
			backgroundColor: '#142037',
			title: [
				// 主标题,对应地图
				{
					// @ts-ignore
					text: '2019-2023 年度数据统计',
					left: '0%',
					top: '0',
					textStyle: {
						color: '#ccc',
						fontSize: 30
					}
				},
				// 副标题,对应柱形图
				{
					id: 'statistic',
					text: item + '年数据统计情况',
					right: '0%',
					top: '4%',
					textStyle: {
						color: '#ccc',
						fontSize: 20
					}
				}
			],
			// X 轴配置
			xAxis: {
				// 数据轴
				type: 'value',
				// 脱离 0 值比例
				scale: true,
				// 位置
				position: 'top',
				// 不显示分割线
				splitLine: {
					show: false
				},
				// 不显示轴线
				axisLine: {
					show: false
				},
				// 不显示刻度尺
				axisTick: {
					show: false
				},
				// 类别文字
				axisLabel: {
					margin: 2,
					textStyle: {
						color: '#aaa'
					}
				}
			},
			// Y 轴
			yAxis: {
				// 选项轴
				type: 'category',
				// 轴线
				axisLine: {
					show: true,
					lineStyle: {
						color: '#ddd'
					}
				},
				// 轴刻度
				axisTick: {
					show: false,
					lineStyle: {
						color: '#ddd'
					}
				},
				// 轴标签
				axisLabel: {
					interval: 0,
					textStyle: {
						color: '#ddd'
					}
				},
				// 根据年份,获取对应数据
				data: props.data.categoryData[item].map((item) => item.name)
			},
			// 核心配置
			series: [
				// 柱形图
				{
					zlevel: 1.5,
					// 柱形图
					type: 'bar',
					// 每个柱子的色值
					itemStyle: {
						normal: {
							color: props.data.colors[index]
						}
					},
					// 根据年份,获取对应数据
					data: props.data.categoryData[item].map((item) => item.value)
				},
				// 散点图
				{
					// 散点(气泡)图
					type: 'effectScatter',
					// 使用地理坐标系
					coordinateSystem: 'geo',
					// 数据
					data: props.data.topData[item],
					// 标记大小
					symbolSize: function (val) {
						return val[2] / 4
					},
					// 绘制完成后显示特效
					showEffectOn: 'render',
					// 展示涟漪特效
					rippleEffect: {
						brushType: 'stroke'
					},
					// 文字
					label: {
						normal: {
							formatter: '{b}',
							position: 'right',
							show: true
						}
					},
					// 每一项的配置
					itemStyle: {
						normal: {
							color: props.data.colors[index],
							// 阴影配置
							shadowBlur: 5,
							shadowColor: props.data.colors[index]
						}
					},
					zlevel: 1
				}
			]
		})
	})

	mChart.setOption(options)
}
</script>

<style lang="scss" scoped></style>

 八、AntV、G2、DataV

 G2:G2

antv: https://antv.antgroup.com/

datav: DataV

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/599410.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

《QT实用小工具·五十三》会跑走的按钮

1、概述 源码放在文章末尾 该项目实现了会逃跑的按钮&#xff1a; 两个按钮&#xff0c;一个为普通按钮&#xff0c;另一个为会跑走的按钮 鼠标移到上面时&#xff0c;立刻跑掉 针对鼠标、键盘、触屏进行优化 随机交换两个按钮的文字、偶尔钻到另一个按钮下面、鼠标移开自…

node.js中path模块-路径处理,语法讲解

node中的path 模块是node.js的基础语法&#xff0c;实际开发中&#xff0c;我们通过使用 path 模块来得到绝对路径&#xff0c;避免因为相对路径带来的找不到资源的问题。 具体来说&#xff1a;Node.js 执行 JS 代码时&#xff0c;代码中的路径都是以终端所在文件夹出发查找相…

成人职场英语口语柯桥外语培训之Big deal不是“大事”!别再翻译错啦!

关于deal&#xff0c; 其实有很多容易被人误解的表达&#xff0c; 小编今天就来给大家一一盘点~ 1, deal n. deal 作名词的时候意思是“交易&#xff1b;买卖”。 ❖ She got a new car for $1000! That was really a good deal! 她一千美金买了辆车&#xff01;真是158575…

Xshell生成ssh密钥及使用

目录 1. 概述2. 环境3. 步骤3.1 生成密钥3.2 部署密钥3.3 使用密钥 1. 概述 使用Xshell软件生成ssh秘钥&#xff0c;正常连接服务器。 2. 环境 Xshell 6 3. 步骤 3.1 生成密钥 1. 打开Xshell --> 工具 --> 新建用户密钥生成向导 2. 选择密钥类型&#xff0c;建议…

2024.1.1 IntelliJ IDEA 使用记录

2024.1.1 IntelliJ IDEA 使用记录 下载设置文件编码maven 配置 插件可以中文语言包安装lombok 插件Smart Tomcat ( 根据需要安装)Smart Tomcat 配置 项目导入java 设置maven 配置 项目运行SpringBoot 项目运行tomcat 运行 (根据需要)相关依赖添加运行配置 下载 IntelliJ IDEA …

【智能优化算法】金枪鱼群优化(Tuna Swarm Optimization,TSO)

金枪鱼群优化&#xff08;Tuna Swarm Optimization,TSO&#xff09;是期刊“Computational Intelligence and Neuroscience”&#xff08;IF&#xff1a;1.8&#xff09;的2021年智能优化算法 01.引言 金枪鱼群优化&#xff08;Tuna Swarm Optimization,TSO&#xff09;的主要…

贪吃蛇小游戏(c语言)

1.效果展示 屏幕录制 2024-04-28 205129 2.基本功能 • 贪吃蛇地图绘制 • 蛇吃食物的功能 &#xff08;上、下、左、右方键控制蛇的动作&#xff09; • 蛇撞墙死亡 • 蛇撞自身死亡 • 计算得分 • 蛇身加速、减速 • 暂停游戏 3.技术要点 C语言函数、枚举、结构…

Linux搭建http发布yum源

1、搭建http源yum仓库 &#xff08;1&#xff09;在yum仓库服务端安装httpd yum -y install httpd &#xff08;2&#xff09;修改配置文件 我们httpd 中默认提供web 界面的位置是我们/var/www/html 目录&#xff0c;如果我们yum 源想指定目录&#xff0c;就需要修改蓝框2处…

【第6节课笔记】LagentAgentLego

Lagent 最中间部分的是LLM&#xff0c;即为大语言模型模块&#xff0c;他可以思考planning和调用什么action&#xff0c;再将其转发给动作执行器action executer执行。 支持的工具如下&#xff1a; Arxiv 搜索 Bing 地图 Google 学术搜索 Google 搜索 交互式 IPython 解释器 IP…

STM32循迹小车系列教程(三)—— 使用灰度传感器循迹

本章节主要讲解如何获取灰度传感器值以及如何使用灰度传感器循迹 灰度传感器简介 灰度传感器如图 1 所示&#xff1a; 灰度传感器 使用一对抗干扰较强的光电传感器&#xff0c;其中发射管的光源采用高亮白色聚光 LED&#xff0c;发射管端发出的光线通过不同环境背景的反射之…

软件系统安全设计规范(word原件)

1.1安全建设原则 1.2 安全管理体系 1.3 安全管理规范 1.4 数据安全保障措施 1.4.1 数据库安全保障 1.4.2 操作系统安全保障 1.4.3 病毒防治 1.5安全保障措施 1.5.1实名认证保障 1.5.2 接口安全保障 1.5.3 加密传输保障 1.5.4终端安全保障 软件资料清单列表部分文档…

嵌入式全栈开发学习笔记---C语言笔试复习大全13(编程题9~16)

目录 9.查找字符数组中字符位置&#xff08;输入hello e 输出2&#xff09;&#xff1b; 10、查找字符数组中字符串的位置&#xff08;输入hello ll 输出3&#xff09;&#xff1b; 11、字符数组中在指定位置插入字符&#xff1b;&#xff08;输入hello 3 a 输出heallo…

编程算法赛

1偶数累加 2、统计字符的数量 3、计算表达式的值 4、哥德巴赫猜想 5、进制的转换

英语学习笔记5——Nice to meet you.

Nice to meet you. 很高兴见到你。 词汇 Vocabulary Mr. 先生 用法&#xff1a;自己全名 / 姓 例如&#xff1a;Mr. Zhang Mingdong 或 Mr. Zhang&#xff0c;绝对不能是 Mr. Mingdong&#xff01; Miss 女士&#xff0c;小姐 未婚 用法&#xff1a;自己全名 / 姓 例如&#…

【论文阅读】Fuzz4All: Universal Fuzzing with Large Language Models

文章目录 摘要一、介绍二、Fuzz4All的方法2.1、自动提示2.1.1、自动提示算法2.1.2、自动提示的例子2.1.3、与现有自动提示技术的比较 2.2、fuzzing循环2.2.1、模糊循环算法2.2.2、Oracle 三、实验设计3.1、实现3.2、被测系统和baseline3.3、实验设置以及评估指标 四、结果分析4…

P8801 [蓝桥杯 2022 国 B] 最大数字

P8801 [蓝桥杯 2022 国 B] 最大数字 分析 dfs 思路&#xff1a;题目的意思&#xff0c;要让一个数最大&#xff0c;用贪心去考虑&#xff0c;从高位开始&#xff0c;对其进行a / b操作&#xff0c;使其变为9&#xff0c;可让该数最大 1.a 操作&#xff1a;1&#xff1b;b 操…

嵌入式学习<1>:建立工程、GPIO

嵌入式学习_part1 本部分笔记用于学习记录&#xff0c;笔记源头 >>b站江科大_STM32入门教程 建立工程、GPIO 开发环境&#xff1a;keil MDK、STM32F103C8T6 1 &#xff09;建立工程 &#xff08;1&#xff09;基于寄存器开发、基于标准库 或者 基于HAL库开发; &…

【代码随想录——哈希表】

1.哈希表理论基础 首先什么是 哈希表&#xff0c;哈希表&#xff08;英文名字为Hash table&#xff0c;国内也有一些算法书籍翻译为散列表&#xff0c;大家看到这两个名称知道都是指hash table就可以了&#xff09;。 那么哈希表能解决什么问题呢&#xff0c;一般哈希表都是用…

高素质高学历婚恋相亲交友平台有哪些?分享我的网上找对象成功脱单经历!

尽管觉得在社交软件上找到真爱的可能性很小&#xff0c;但我却时常看到别人成功的案例&#xff0c;这也让我跃跃欲试了。没想到&#xff0c;我真的成功了&#xff01;以下是我亲身使用过的一些方法&#xff0c;在此与大家分享&#xff0c;仅供参考哦&#xff01; &#x1f449;…

c++ cpp 在类中执行线程 进行恒定计算

在编程中&#xff0c;顺序执行是常见的模式&#xff0c;但是对cpu的利用率不是很高&#xff0c;采用线程池&#xff0c;又太麻烦了&#xff0c;原因是还得不断地把任务拆分&#xff0c;扫描返回值。 如果 初始化n个类的时候&#xff0c;传递数据自身即可异步计算&#xff0c;那…
最新文章