以该图左下方的图表为例,进行修改
(1)获取到对应的dom元素
编辑环境下拿到对应的组件名之后即可通过代码获取
- var dom = $('div[data-v-alias=right01_item06_echarts01]div div')[0]
复制代码 (2)将修改的options样式拿到,可在此进行编辑修改
(3)引入echarts,将刚刚修改好的options粘贴到代码中,获取dom元素修改echarts图表样式
//这里引入的是官方资源,也可以自行下载资源上传引入
- var dom = $('div[data-v-alias=right01_item06_echarts01]div div')[0]
- // echarts 初始化
- var bottomCharts = window.echarts.init(dom);
- option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- },
- backgroundColor: 'rgba(233, 24, 48, 0.5)',
- borderColor: 'rgba(233, 253, 238, 0.4)',
- textStyle: {
- color: '#CFE3FC',
- },
- borderWidth: 1
- },
- grid: {
- left: '10px',
- right: '10px',
- top: '20px',
- bottom: '1px',
- containLabel: true
- },
- toolbox: {
- show: true,
- orient: 'vertical',
- x: 'right',
- y: 'bottom'
- },
- xAxis: [
- {
- type: 'category',
- boundaryGap: true,
- axisTick: {
- show: false
- },
- data: ['A厂区', 'B厂区', 'C厂区', 'D厂区', '1区'],
- axisLine: {
- show: true,
- lineStyle: {
- color: 'rgba(255,255,255, 1)',
- opacity: 0.2
- }
- },
- // axisLabel: {
- // interval: 0,
- // color: 'rgba(255,255,255, 1)',
- // fontSize: 11,
- // }
- axisLabel: { // 改变x轴字体颜色和大小
- margin: 6,
- textStyle: {
- color: "rgba(255,255,255,1)",
- fontSize: 11,
- fontFamily: '青春体',
- }
- }
- }
- ],
- yAxis: [
- {
- type: 'value',
- axisTick: {
- show: false
- },
- splitNumber: 5,
- axisLine: {
- show: true,
- lineStyle: {
- color: 'rgba(255,255,255, 0.2)',
- },
- // symbol: ['none', 'arrow'],
- // symbolSize: [5, 12],
- // symbolOffset: [0, 10]
- },
- axisLabel: {
- interval: 0,
- color: 'rgba(255,255,255, 1)',
- fontSize: 9
- },
- splitLine: {
- show: false,
- lineStyle: {
- type: 'solid',
- color: 'rgba(255,255,255, 0.3)',
- width: 1,
- }
- }
- }
- ],
- series: [
- {
- type: 'bar',
- yAxisIndex: 0,
- name: '污水排放量',
- itemStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(
- 0,
- 0,
- 0,
- 1,
- [
- {
- offset: 0,
- color: 'rgba(222,199,255, 1)'
- },
- {
- offset: 1,
- color: 'rgba(233,199,255, 0)'
- }
- ],
- false
- )
- }
- },
- barWidth: 10,
- barGap: 1,
- data: [50, 40, 25, 22, 37, 29],
- label: {
- normal: {
- show: true,
- position: "top",
- textStyle: {
- color: 'rgba(0,241,255,1)',
- fontSize: 14,
- fontFamily: '青春体',
- // padding: [0, 0, 0, 0],
- },
- },
- },
- }
- ]
- }
- bottomCharts.setOption(option);
复制代码 (4)查看修改后效果
|
|