"echarts": "^5.2.2",

ChartSituation1

<template>
<div>
<EChartTemplate1 ref="eChartTemplate1Ref"></EChartTemplate1>
</div>
</template> <script>
import EChartTemplate1 from '../EChartTemplate1'
import mock from '../mockData'
export default {
name: 'ChartSituation1',
components: {
EChartTemplate1
},
props: {},
data () {
return {}
},
watch: {},
computed: {},
methods: {},
created () { },
activated () { },
mounted () {
const optionBusiness = {
title: '111',
legendData: ['历史差值', '2020年度', '2019年度'],
dataDiff: mock.lishichazhi,
data1: mock.year2020,
data2: mock.year2019,
xAxisData: mock.xAxisData
}
this.$refs.eChartTemplate1Ref.open(optionBusiness)
},
beforeDestroy () { }
}
</script> <style>
</style>

EChartTemplate1

<template>
<div>
<EChartComponent ref="eChartCompnentRef"></EChartComponent>
</div>
</template> <script>
import EChartComponent from '../EChartComponent'
export default {
name: 'EChartTemplate1',
components: {
EChartComponent
},
props: {},
data () {
return {}
},
watch: {},
computed: {},
methods: {
open (optionB) {
const lineList = this.getTableLine(4)
const option = {
color: ['#99bb5c', '#6585b8', '#b84f4b'],
grid: {
show: true,
containLabel: true,
height: 'auto' - 0,
top: 80,
left: 100,
right: 150,
bottom: 10,
},
title: [
{
textStyle: { fontSize: 30 },
left: 'center',
text: optionB.title
},
{
top: 50,
left: 30,
textStyle: { lineHeight: 20 },
text: '历\n史\n差\n值'
},
{
top: 50,
right: 70,
textStyle: { lineHeight: 20 },
text: '测\n评\n得\n分'
},
],
xAxis: [
{
axisLine: {
lineStyle: { color: '#ccc' },
onZero: false,
},
position: 'bottom',
axisTick: {
show: true,
length: this.getxAxisTickLength(optionB.xAxisData) // 193,
},
axisLabel: {
color: '#464646',
show: true,
fontSize: 14,
lineHeight: 16,
interval: 0, // 全部显示
rotate: 0,
formatter: function (value, index) {
return '{tableup|' + value + '\n}'
+ '\n{table|' + optionB.dataDiff[index] + '}'
+ '\n{table|' + optionB.data1[index] + '}'
+ '\n{table|' + optionB.data2[index] + '}'
},
rich: {
tableup: {
color: '#464646',
fontSize: 14,
lineHeight: 16,
},
table: {
color: '#464646',
fontSize: 14,
lineHeight: 25,
}
}
},
splitLine: { // 竖线
show: true,
lineStyle: { color: '#cccccc' }
},
splitArea: {
show: true
},
type: 'category', // 类别
data: this.xAxisData(optionB.xAxisData),
},
{
axisLine: {
lineStyle: {
color: '#ccc'
}
}
},
],
yAxis: [
{ // 左边
axisLabel: {
formatter: function (value, index) {
return value.toFixed(2)
},
fontSize: 14,
},
axisTick: {
show: true,
},
splitLine: { // 横线
show: false
},
min: this.getMinLeft(optionB.dataDiff, -5),
max: this.getMaxLeft(optionB.dataDiff, 15),
position: 'left',
name: '',
offset: 0,
type: 'value'
},
{ // 右边
axisLabel: {
formatter: function (value, index) {
return value.toFixed(2)
},
fontSize: 14,
},
axisTick: {
show: true,
},
splitLine: {
show: false
},
min: this.getMinRight([...optionB.data1, ...optionB.data2], 75.00),
max: this.getMaxRight([...optionB.data1, ...optionB.data2], 100.00),
position: 'right',
name: '',
type: 'value'
}
],
legend: [
{
textStyle: { fontSize: 14 },
orient: 'vertical',
right: 10,
top: 150,
data: optionB.legendData
},
{
textStyle: { fontSize: 14 },
orient: 'vertical',
left: 20,
bottom: 13,
data: optionB.legendData
}
],
series: [
{
label: {
show: true,
position: 'top'
},
symbol: 'rect',
symbolSize: 10,
yAxisIndex: 0,
type: 'line',
name: optionB.legendData[0],
data: optionB.dataDiff,
},
{
label: {
show: true,
position: 'bottom'
},
symbol: 'rect',
symbolSize: 10,
type: 'line',
name: optionB.legendData[1],
yAxisIndex: 1,
data: optionB.data1,
},
{
label: {
show: true,
position: 'top'
},
symbolSize: 10,
type: 'line',
symbol: 'diamond',
name: '2019年度',
yAxisIndex: 1,
data: optionB.data2,
},
],
graphic: lineList
}
this.$refs.eChartCompnentRef.open(option)
},
getxAxisTickLength (data) {
const arr = this.xAxisData(data)
const getEnterNumber = str => {
return str.split('\n').length
}
const numArr = arr.map(item => {
return getEnterNumber(item)
})
const maxNum = Math.max(...numArr)
// 16 是 lineHeight 多补了个回车 再加16 上面的padding是5
// 25 是数据的 lineHeight 3行
return maxNum * 16 + 16 + 5 + 25 * 3
},
getMinLeft (arr, defaultValue) { // 左侧轴 最小值计算
const min = Math.min(...arr)
if (min > defaultValue) {
return defaultValue
} else {
return parseInt(min - 2)
}
},
getMaxLeft (arr, defaultValue) { // 左侧轴 最大值计算
const max = Math.max(...arr)
if (max < defaultValue) {
return defaultValue
} else {
return parseInt(max + 2)
}
},
getMinRight (arr, defaultValue) { // 右侧轴 最小值计算
const min = Math.min(...arr)
if (min > defaultValue) {
return defaultValue
} else {
if (min <= 2) {
return 0
}
return parseInt(min - 2)
}
},
getMaxRight (arr, defaultValue) { // 右侧轴 最大值计算
const max = Math.max(...arr)
if (max < defaultValue) {
return defaultValue
} else {
if (max >= 98) {
return 100
}
return parseInt(max + 2)
}
},
getTableLine (num) {
let list = []
let bottom = 85
let height = 25
for (let i = 0; i < num; i++) {
list.push({
silent: true,
type: 'line',
bottom: bottom - i * height,
// left: 50,
right: 150 + 50,
style: {
stroke: 'inherit'
},
shape: {
x1: 0,
y1: 0,
x2: 3000,
y2: 0
} })
}
list.push({
style: {
stroke: 'inherit'
},
bottom: 10,
silent: true,
type: 'line',
shape: {
x1: 0,
y1: 0,
x2: 0,
y2: 75
}
})
return list
},
xAxisData (data) {
const ret = data.map(item => {
if (item.indexOf(' ') > -1) {
const t2 = item.split(' ')
const a = t2[0].split('')
const b = t2[1].split('')
let k
if (a.length > b.length) {
k = a
} else {
k = b
}
const ret = k.map((item1, index) => {
const a1 = a[index] ? a[index] : ' '
const b1 = b[index] ? b[index] : ' '
return a1 + ' ' + b1 + '\n'
}).join('')
return ret
}
return item.split('').join('\n')
})
const getEnterNumber = str => {
return str.split('\n').length
}
const getMaxNumber = arr => {
return Math.max(...arr)
}
const repeat = (src, n) => {
let k = ''
for (let i = 0; i < n; i++) {
k = k + src
}
return k
}
const supplementEnter = (str, maxNumber) => { // 补上回车
const enterLen = getEnterNumber(str)
const needNumber = maxNumber - enterLen
const n = repeat('\n', needNumber)
return str + n
} const maxNumber = getMaxNumber(ret.map(item => {
return getEnterNumber(item)
}))
const ret1 = ret.map(item => {
return supplementEnter(item, maxNumber)
})
return ret1
}
},
created () { },
activated () { },
mounted () {
},
beforeDestroy () { }
}
</script> <style>
</style>

EChartComponent

<template>
<div v-if="chartVif">
<ResizeZen @on-change="chartHeightSet"></ResizeZen>
<div ref="dom"
:style="{height: chartHeight + 'px'}"
style="width: 100%;"></div>
</div>
</template> <script>
import * as echarts from 'echarts'
export default {
name: 'EChartComponent',
components: {},
props: {},
data () {
return {
chartVif: false,
chartHeight: '550',
myChart: null
}
},
watch: {},
computed: {},
methods: {
chartHeightSet () {
this.chartHeight = window.innerHeight - 300
this.$nextTick(() => {
this.myChart.resize()
})
},
openChartVifSet (ctx, next) {
this.chartVif = false
this.$nextTick(() => {
this.chartVif = true
this.$nextTick(() => {
next()
})
})
},
openExe (ctx, next) {
this.myChart = echarts.init(this.$refs.dom)
this.myChart.setOption(ctx.option)
this.chartHeightSet()
},
open (option) {
const ac = this.$getAc()
ac.ctx.option = option
ac.use(this.openChartVifSet)
ac.use(this.openExe)
ac.run()
}
},
created () { },
activated () { },
mounted () { },
beforeDestroy () { }
}
</script> <style>
</style>

ResizeZen

<template>
<span></span>
</template> <script>
// window.innerHeight
export default {
name: 'ResizeZen',
components: {},
props: {},
data () {
return {}
},
watch: {},
computed: {},
methods: {
resize () {
this.$emit('on-change')
}
},
created () { },
activated () { },
mounted () {
window.addEventListener('resize', this.resize)
},
beforeDestroy () {
window.removeEventListener('resize', this.resize)
}
}
</script> <style>
</style>

echart 带表格的更多相关文章

  1. Bootstrap历练实例:带表格的面板

    带表格的面板 为了在面板中创建一个无边框的表格,我们可以在面板中使用 class .table.假设有个 <div> 包含 .panel-body,我们可以向表格的顶部添加额外的边框用来分 ...

  2. vue项目前台带表格的页面,让表格根据屏幕大小自适应高度,小屏幕时不出现多个滚动条

    参见馆藏库房系统, 右侧整体结构一般如下 <el-container class="ml10 mr10 br7 bgw"> <el-main> // el- ...

  3. bootsrtap带表格面板内容居中

    css中,添加 .table th, .table td { text-align: center; vertical-align: middle!important;}

  4. Silverlight项目笔记5:Oracle归档模式引起的异常&&表格控件绑定按钮

    1.Oracle归档模式产生日志文件引起数据库异常 连接数据库失败,提示监听错误,各种检查监听配置文件,删除再添加监听,无果. sqlplus下重启数据库数据库依然无果,期间碰到多个错误提示: ORA ...

  5. python提取网页表格并保存为csv

    0. 1.参考 W3C HTML 表格 表格标签 表格 描述 <table> 定义表格 <caption> 定义表格标题. <th> 定义表格的表头. <tr ...

  6. 如何用BarTender 2016字处理器完成表格设计

    很多时候,需要应客户要求,用BarTender 2016设计带表格的标签.在BarTender 2016中字处理器文本对象可以使用字处理中的诸多格式功能(如项目符号.编号列表.表格.混合字体以及RTF ...

  7. LigerUI ligerComboBox 下拉框 表格 多选无效

    $("#txt1").ligerComboBox({ width: 250, slide: false, selectBoxWidth: 500, selectBoxHeight: ...

  8. Css解决表格超出部分用省略号显示

    小伙伴们有没有的遇到页面显示时,因为数据太长导致显示的表格某一列过长,从而导致页面的不美观,下面我们来看一看如何用Css样式解决表格超出部分用省略号显示的问题. 主要设置两个样式: table{ ta ...

  9. 开源 iOS 项目分类索引大全 - 待整理

    开源 iOS 项目分类索引大全 GitHub 上大概600个开源 iOS 项目的分类和介绍,对于你挑选和使用开源项目应该有帮助 系统基础库 Category/Util sstoolkit 一套Cate ...

  10. bootstrap 组件

      bootstrap  组件 1下拉菜单(dropdown)  下拉菜单切换(dropdown-toggle)  下拉菜单对齐(dropdown-menu-right-右对齐) 下拉菜单分割线(di ...

随机推荐

  1. tensorflow语法【tf.concat()详解】

    相关文章: [一]tensorflow安装.常用python镜像源.tensorflow 深度学习强化学习教学 [二]tensorflow调试报错.tensorflow 深度学习强化学习教学 [三]t ...

  2. 记录一次py2编码带来的坑

    "中文" == u"中文" # PY2 False"中文" == u"中文" # PY3 True

  3. MySQL8.0配置my.cnf

    环境 centos7.9 mysql  Ver 8.0.32 因为是源码安装的MySQL8.0.32,查了一下MySQL 8.0之后源码中不包含my.cnf文件和my-default.cnf文件了. ...

  4. 使用CAShapeLayer,UIBezierPath,CAGradientLayer构建边框颜色会旋转的六边形

    主要思路是: 1.使用UIBezierPath绘制一个六边形路径 2.创建一个CAShapeLayer图层,将这个六边形path设置到CAShapeLayer属性上.然后设置fillColor为透明, ...

  5. mysql删除表中重复记录

    1.创建测试表,并插入数据 create table test( id int(11) primary key auto_increment comment '用户编号', username varc ...

  6. Linux 在线安装MySQL8.0

    1.更新Linux yum yum update 2.安装wget工具(如果已经安装wget,可以跳过该步骤) yum install wget 3.使用wget下载MySQL Yum Reposit ...

  7. java 从零开始手写 RPC (06) reflect 反射实现通用调用之客户端

    通用调用 java 从零开始手写 RPC (01) 基于 socket 实现 java 从零开始手写 RPC (02)-netty4 实现客户端和服务端 java 从零开始手写 RPC (03) 如何 ...

  8. 解决maven打包compliation failure程序包不存在

    1.问题说明 spring boot项目,在cmd中使用mvn clean package打包报错如下: 说这个程序包不存在,而实际上在eclipse中查看是能找到的. 2.问题原因 后来看了一下这个 ...

  9. 全栈式测试平台RunnerGo核心功能模块-接口管理

    ​全栈式测试平台RunnerGo相对于市面上其他性能测试产品来说更简单,它不用其他相关配件,天然支持分布式,有单独的机器做分布式的负载均衡,自有一套智能算法算压力机的配置从而平均分配,并从场景链路的流 ...

  10. 统信UOS系统开发笔记(一):国产统信UOS系统搭建开发环境之虚拟机安装

    前言   开发国产应用,需要使用到统信UOS系统,之前已经开发过国产银河麒麟V4.V7和V10版本了,本次新项目使用到统信UOS,记录UOS虚拟机安装流程,方便快捷进行相关开发工作.   提前准备 V ...