echarts x轴下绘制表
效果图:
把下面代码复制到官网实例的js代码编辑中即可预览( 附连接:Examples - Apache ECharts)
let map = {
销售单价: [2200.0,4000.9,700.0,2003.2,2005.6,7006.7,10035.6,9602.2,3200.6,2000.0,1602.4,0],
市场价: [2200.6,8005.9,900.0,2006.4,2008.7,7000.7,10075.6,10082.2,4800.7,1008.8,600.0,0],
拨入量: [2.0, 2.2,3.3,4.5,6.3,10.2,10.3,13.4,13.0,16.5,12.0,0,87.5],
销售量: [1.0,2.2,4.3,4.5,7.3,10.2,11.3,15.4,18.0,18.5,12.0,0,104.7]
}; option = {
title: {
text: "2021年1-12月xxx量价对比图"
},
darkMode: true,
grid: {
x: 150,
// y:45,
x2: 50,
y2: 210
// borderWidth:1
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
crossStyle: {
color: "#999"
}
}
},
toolbox: {
feature: {
dataView: { show: true, readOnly: false },
magicType: { show: true, type: ["line", "bar"] },
restore: { show: true },
saveAsImage: { show: true }
}
},
legend: {
align: "right",
itemGap: 30,
orient: "vertical",
textStyle: { color: "#000" },
bottom: 10,
left: 0,
data: ["拨入量", "销售量", "销售单价", "平均单价"]
},
xAxis: [
{
type: "category",
max: 12,
interval: Math.ceil(12) / 12,
// axisTick: {
// interval: 12/12
// },
axisLabel: {
fontWeight: "bold",
show: true,
textStyle: {
// color: "#f4f4f4",
fontSize: "14px"
}
},
data: ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月","1-12月\n累计"],
axisPointer: {
type: "shadow"
}
},
{
position: "bottom", // 将分组x轴位置定至底部,不然默认在顶部
offset: 45, // 向下偏移,使分组文字显示位置不与原x轴重叠
// axisLine: {
// show: false // 隐藏分组x轴的轴线
// },
axisTick: {
length: -200, // 延长刻度线做分组线
inside: true, // 使刻度线相对轴线在上面与原x轴相接,默认在轴线下方
lineStyle: { color: "#000" } // 非必须,仅为了演示,明显标示出分组刻度线
// interval: function(index, value) {
// return index === 0 || index === 2 || index === 5; // 在0、5、6处各画一条刻度线
// }
// interval: 1,
},
// min: -30,
max: 12,
interval: 1,
axisLabel: {
inside: true, // 使刻度名称相对轴线在上面与原x轴相接,默认在轴线下方
interval: 0 // 强制显示全部刻度名
},
data: [""]
},
{
position: "bottom", // 将分组x轴位置定至底部,不然默认在顶部
offset: 36, // 向下偏移,使分组文字显示位置不与原x轴重叠
max: 12,
interval: Math.ceil(12) / 12,
axisTick: {
length: 0, // 延长刻度线做分组线
inside: true, // 使刻度线相对轴线在上面与原x轴相接,默认在轴线下方
lineStyle: { color: "#000" } // 非必须,仅为了演示,明显标示出分组刻度线
},
axisLabel: {
inside: true, // 使刻度名称相对轴线在上面与原x轴相接,默认在轴线下方
interval: 0 // 强制显示全部刻度名
}
},
{
position: "bottom", // 将分组x轴位置定至底部,不然默认在顶部
offset: 75, // 向下偏移,使分组文字显示位置不与原x轴重叠
max: 12,
interval: 1,
axisTick: {
length: 0, // 延长刻度线做分组线
inside: true, // 使刻度线相对轴线在上面与原x轴相接,默认在轴线下方
lineStyle: { color: "#000" } // 非必须,仅为了演示,明显标示出分组刻度线
},
axisLabel: {
inside: true, // 使刻度名称相对轴线在上面与原x轴相接,默认在轴线下方
interval: 0 // 强制显示全部刻度名
},
data: [
11.5,
25.8,
13.1,
17.2,
10.88,
14.21,
47.2,
90,
6,
12.2,
25.34,
0,
273.43
]
},
{
position: "bottom", // 将分组x轴位置定至底部,不然默认在顶部
offset: 120, // 向下偏移,使分组文字显示位置不与原x轴重叠
max: 12,
interval: Math.ceil(12) / 12,
axisTick: {
length: 0, // 延长刻度线做分组线
inside: true, // 使刻度线相对轴线在上面与原x轴相接,默认在轴线下方
lineStyle: { color: "#000" } // 非必须,仅为了演示,明显标示出分组刻度线
},
axisLabel: {
inside: true, // 使刻度名称相对轴线在上面与原x轴相接,默认在轴线下方
interval: 0 // 强制显示全部刻度名
},
data: [
11.5,
25.8,
13.1,
17.2,
10.88,
14.21,
47.2,
90,
6,
12.2,
25.34,
0,
273.43
]
},
{
position: "bottom", // 将分组x轴位置定至底部,不然默认在顶部
offset: 160, // 向下偏移,使分组文字显示位置不与原x轴重叠
max: 12,
interval: 1,
axisTick: {
length: 0, // 延长刻度线做分组线
inside: true, // 使刻度线相对轴线在上面与原x轴相接,默认在轴线下方
lineStyle: { color: "#000" } // 非必须,仅为了演示,明显标示出分组刻度线
},
axisLabel: {
inside: true, // 使刻度名称相对轴线在上面与原x轴相接,默认在轴线下方
interval: 0 // 强制显示全部刻度名
},
data: [
137850.1,
145620.3,
154562.6,
165230.2,
175623.2,
185620.7,
196523.5,
201520.9,
215230.6,
220325.7,
236520.7,
0
]
},
{
position: "bottom", // 将分组x轴位置定至底部,不然默认在顶部
offset: 200, // 向下偏移,使分组文字显示位置不与原x轴重叠
max: 12,
interval: 1,
axisTick: {
length: 0, // 延长刻度线做分组线
inside: true, // 使刻度线相对轴线在上面与原x轴相接,默认在轴线下方
lineStyle: { color: "#000" } // 非必须,仅为了演示,明显标示出分组刻度线
},
axisLabel: {
inside: true, // 使刻度名称相对轴线在上面与原x轴相接,默认在轴线下方
interval: 0 // 强制显示全部刻度名
},
data: [
137850.1,
145620.3,
154562.6,
165230.2,
175623.2,
185620.7,
196523.5,
201520.9,
215230.6,
220325.7,
236520.7,
0
]
}
],
yAxis: [
{
type: "value",
name: "数量:吨",
// min: 0,
max: Math.ceil(115),
interval: Math.ceil(115) / 5,
axisLabel: {
formatter: "{value}",
textStyle: {
// color: "#f4f4f4",
fontSize: "14px"
}
}
},
{
type: "value",
name: "价格:元/吨",
// min: 0,
max: Math.ceil(22500),
// splitNumber: 6,
interval: Math.ceil(22500) / 5,
axisLabel: {
formatter: "{value}"
}
}
],
series: [
{
name: "拨入量",
type: "bar",
unit: "吨",
groupName: "拨入/销售量",
data: map["拨入量"],
itemStyle: {
color: "rgb(242, 143, 133)"
}
},
{
name: "销售量",
type: "bar",
unit: "吨",
groupName: "拨入/销售量",
data: map["销售量"],
itemStyle: {
color: "rgb(183, 222, 232)"
}
},
{
name: "销售单价",
type: "line",
yAxisIndex: 1,
unit: "元/吨",
data: map["销售单价"],
itemStyle: {
color: "rgb(196, 23, 23)"
},
lineStyle: {
width: 5
}
},
{
name: "平均单价",
type: "line",
yAxisIndex: 1,
unit: "元/吨",
data: map["市场价"],
itemStyle: {
color: "rgb(0, 112, 192)"
},
lineStyle: {
width: 5,
type: [10, 10],
dashOffset: 5
}
}
]
};
具体复制到如下图位置:
原文链接:https://blog.csdn.net/qq_38974073/article/details/121588908 【本文为转载学习,如需删除请联系】
echarts x轴下绘制表的更多相关文章
- [置顶]
echarts x轴文字显示不全(xAxis文字倾斜比较全面的3种做法值得推荐)
echarts x轴标签文字过多导致显示不全 如图: 解决办法1:xAxis.axisLabel 属性 axisLabel的类型是object ,主要作用是:坐标轴刻度标签的相关设置.(当然yAxis ...
- echarts x轴文字显示不全(解决方案)
echarts x轴标签文字过多导致显示不全 如图: 解决办法1:xAxis.axisLabel 属性 axisLabel的类型是object ,主要作用是:坐标轴刻度标签的相关设置.(当然yAxis ...
- echarts x轴标签文字过多导致显示不全
原文电梯:https://blog.csdn.net/kebi007/article/details/68488694 echarts x轴标签文字过多导致显示不全 如图: 解决办法1:xAxis.a ...
- echarts Y轴名称显示不全(转载)
转载来源:https://blog.csdn.net/qq8241994/article/details/90720657今天在项目的开发中遇到的一个问题,echarts Y轴左侧的文字太多了,显示不 ...
- echarts x轴文字显示不全解决办法
标题:echarts x轴文字显示不全(xAxis文字倾斜比较全面的3种做法值得推荐):http://blog.csdn.net/kebi007/article/details/68488694
- echarts x轴名称太长
echarts x轴名称太长了,隐藏一部分,鼠标移到名称上,显示全称 function extension(mychart, type) { let extension = document.getE ...
- echarts 让轴自适应数据为小数整数
echarts 让轴自适应数据为小数整数,以解决y轴数值重复的问题 工作中突然遇到这个问题 试了一下用formatter自适应 ok 在yAxis中提阿尼按键属性 axisLabel 1 axis ...
- echarts在IE8下遮挡其他组件的问题
echarts的图在IE8下会浮在上层遮挡住其他组件,解决方式是页面中引入 <meta http-equiv="X-UA-Compatible" content=" ...
- Echarts x轴文本内容太长的几种解决方案
Echarts 标签中文本内容太长的时候怎么办 ? - 1对文本进行倾斜 在xAxis.axisLabe中修改rotate的值 xAxis: { data: ["衬衫11111", ...
- Echarts X轴 Y轴 线的类型、颜色、及标签字体颜色 设置
// 人均效能 var initRjxnChart = function () { var rjxnChart = echarts.init(document.getElementById(" ...
随机推荐
- python 无监督生成模型
无监督生成模型在机器学习中扮演着重要角色,特别是当我们在没有标签数据的情况下想要生成新的样本或理解数据的内在结构时.一种流行的无监督生成模型是生成对抗网络(Generative Adversarial ...
- Spring MVC 中使用 RESTFul 编程风格
1. Spring MVC 中使用 RESTFul 编程风格 @ 目录 1. Spring MVC 中使用 RESTFul 编程风格 2. RESTFul 编程风格 2.1 RESTFul 是什么 2 ...
- typora markdown笔记
前言 此为个人markdown笔记,不定时更新. 正文 1. mermaid 使用 横向流程图 源码 graph LR a(起始)-->b(中间) b-->c1<-->d b- ...
- C#开发一个混合Windows服务和Windows窗体的程序
很多时候,我们希望服务程序可以直接运行,或者可以响应一些参数,这时候,混合Windows服务和Windows窗体的程序就排上用场了.要实现同时支持Windows服务和Windows窗体,需要在启动的第 ...
- Mybatis 快速入门(注解方式)
导读 注解开发的方式只需要程序员开发Mapper接口即可,不需要编写映射文件(XML). 环境搭建 项目结构 SqlMapConfig.xml <!DOCTYPE configuration P ...
- 基于微信小程序的校园维修管理系统-开题报告参考
\n文末获取源码联系 感兴趣的可以先收藏起来,大家在毕设选题,项目以及论文编写等相关问题都可以给我加好友咨询 一.课题研究的目的和意义** 本研究开发基于微信小程序的物品维修系统,它不仅能实现专业的维 ...
- oeasy教您玩转vim - 64- # 参数argument
参数argument 回忆上次 上次了解了 窗口 window 窗口是用来装缓冲buffer的 buffer是在内存里面加载的硬盘文件 窗口的切分 :sp[lit] 水平切分 :vsp[lit] ...
- 对比`Pinia `和` Vuex`,全面了解` Vue`状态管理
Pinia和Vuex一样都是是vue的全局状态管理器.其实Pinia就是Vuex5,只不过为了尊重原作者的贡献就沿用了这个看起来很甜的名字Pinia. 本文将通过Vue3的形式对两者的不同实现方式进行 ...
- 如何安装 Arch Linux 操作系统?
Arch Linux Install 安装 到使用 Arch 说明前面或多或少已经接触过 Debian 系列和 Red Hat 系列相关 Linux 发行版,对于虚拟化软件 VirtualBox 如何 ...
- JavaScript一天一个算法题~持续更新中。。。。。
1,数组去重 i.暴力去重 思路:建一个空数组,通过判断原数组的元素是否在空数组内,如果在,不放入,不在,放入空数组. function clearCommnetArray(array){ let a ...