"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. CE修改器入门:未知数值扫描

    经过第二关的练习,你已经理解了如何利用"精确数值"扫描查找数值了,让我们进行下一步,本关主要用来搜索进度条,人物血条等,因为这些数据通常是一个进度条,我们无法直接看到的数据,此时可 ...

  2. LoopAndLoop【安卓逆向】

    LoopAndLoop(阿里CTF) 首先是通用步骤 解压附件后发现是APK文件,打开jeb进行反编译,反编译结果如下: 可以看到程序自定了几个check函数,并且调用了自定义库"lhm&q ...

  3. Windows配置PHP的MongoDB扩展

    环境 Windows 10 PHP 5.6.40/8.1.11 配置 下载MongoDB扩展 下载地址:https://pecl.php.net/package/mongodb 下载PHP版本对应的扩 ...

  4. mysql 索引优化 explain,复合索引,联合索引,优化 user_base 和 log_login 实战

    本节是关于MySQL的复合索引相关的知识,两个或更多个列上的索引被称作复合索引,本文主要介绍了mysql 联合索引生效的条件及失效的条件 对于复合索引:Mysql从左到右的使用索引中的字段,一个查询可 ...

  5. python实现百度贴吧页面爬取

    import requests class TiebaSpider: """百度贴吧爬虫类""" def __init__(self, ti ...

  6. NC235247 Sramoc问题

    题目链接 题目 题目描述 \(Sramoc(K ,M)\) 表示用数字 \(0,1,2,3,4,...,k-1\) 组成的自然数中能被M整除的最小数.给定 \(K,M\) \(2\leq K\leq ...

  7. NC16666 [NOIP2006]开心的金明

    题目链接 题目 题目描述 金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间.更让他高兴的是,妈妈昨天对他说:"你的房间需要购买哪些物品,怎么布置,你说了算,只 ...

  8. ARM指针寄存器——堆栈指针寄存器SP、程序计数器PC、连接寄存器LR详解

    堆栈的实现方法    在随机存储器区划出一块区域作为堆栈区,数据可以一个个顺序地存入(压入)到这个区域之中,这个过程称为'压栈'(push ).通常用一个指针(堆栈指针 SP-StackPointer ...

  9. 【Unity3D】碰撞体组件Collider

    1 前言 ​ Unity3D 中碰撞体(Collider)组件用于检测运动的物体之间是否发生碰撞,也可以作为触发器使用.产生碰撞的条件是: 2 个游戏对象都有 Collider 至少有一个游戏对象有 ...

  10. 多线程系列(八) -ReentrantLock基本用法介绍

    一.简介 在之前的线程系列文章中,我们介绍到了使用synchronized关键字可以实现线程同步安全的效果,以及采用wait().notify()和notifyAll()方法,可以实现多个线程之间的通 ...