"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. 构建Keepalived高可用集群

    Keepalived的作用是检测服务器的状态,如果有一台web服务器宕机或工作出现故障,Keepalived将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替该服务器的工作,当服务器工作 ...

  2. IT技术:开篇 - IT技术系列文章

    笔者已经工作了十多年,在这十多年里,笔者在博客上也对自己所学的技术方面的事情记录成了博文.这些博文有些是笔者自己所学所记,有些是将网上的博文进行的转载.在经历了这么多的技术学习之后,笔者将自己的经验记 ...

  3. Git企业开发控制理论和实操-从入门到深入(一)|为什么需要Git|Git的安装

    前言 那么这里博主先安利一些干货满满的专栏了! 首先是博主的高质量博客的汇总,这个专栏里面的博客,都是博主最最用心写的一部分,干货满满,希望对大家有帮助. 高质量博客汇总https://blog.cs ...

  4. 小知识:使用MOS下载Oracle介质快速参考

    之前对选Release.Patch Set.PSU都有专门的文档,现在早已简化,针对这些以及之后RU.RUR等都包含在MOS文档:2118136.2 Assistant: Download Refer ...

  5. .NET Core开发实战(第17课:为选项数据添加验证:避免错误配置的应用接收用户流量)--学习笔记

    17 | 为选项数据添加验证:避免错误配置的应用接收用户流量 三种验证方法 1.直接注册验证函数 2.实现 IValidateOptions 3.使用 Microsoft.Extensions.Opt ...

  6. [SpringBoot][Maven]关于maven pom文件的packaging属性

    关于maven pom文件的packaging属性 前几天在调试源码运行程序的时候,因为将项目中pom文件的packaging属性用错导致源码包无法引入使用而报Bean注入错误,在此进行总结整理记录. ...

  7. Java并发编程实例--15.在同步代码块中使用条件

    并发编程中有个经典问题: 生产消费者问题. 我们有一个数据缓冲区,一个或多个生产者往其中存入对象,另外一个或多个消费者从中取走. 因此,该数据缓冲区是一个共享数据结构,我们需要对其添加读取同步机制,但 ...

  8. [超实用插件]在Visual Studio中查看EF Core查询计划

    前言 EF Core是我们.NET开发中比较常用的一款ORM框架,今天我们分享一款可以直接在Visual Studio中查看EF Core查询计划调试器可视化工具(帮助开发者分析和优化数据库查询性能) ...

  9. django的orm多表查询作业第五题答案

    5.每个作者出版的所有书的最高价格以及最高价格的那本书的名称. 用django的模型类写不出来的,只能用原生sql写这题 关于第五题,mysql5.7及以上版本,使用下面的答案 set sql_mod ...

  10. day06---基础优化之防火墙,yum源,字符集,vim补充,echo命令

    1.系统版本号 cat /etc/redhat-release hostnamectl uname -r 2.系统 时间硬件时间 date hwclock clock hwclock systohc ...