Echarts横坐标倾斜,顶部显示数字
最近项目使用到Echarts,所以学习了下
根据API,实现Echarts很简单,在这就不多说了,下面就说说项目中碰到的一些需求
1.由于横坐标很多,导致数据不能展示完整,所以需要设置横坐标样式倾斜展示
2.每个数据列(比如柱形图),顶部需要显示具体数值
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="description" content="ECharts">
- <title>Echarts横坐标倾斜,顶部文字显示实现</title>
- <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
- </head>
- <script type="text/javascript">
- var width;
- var height;
- var myChart;
- $(function(){
- //自适应设置
- width = $(window).width();
- height = $(window).height();
- $("#mainBar").css("width",width-40);
- $("#mainBar").css("height",height-40);
- console.log(height);
- setEcharts();
- });
- $(window).resize(function() {
- width = $(window).width();
- height = $(window).height();
- $("#mainBar").css("width",width-40);
- $("#mainBar").css("height",height-40);
- });
- function setEcharts(){
- myChart = echarts.init(document.getElementById('mainBar'));
- //自适应
- window.onresize = myChart.resize;
- myChart.setOption({
- tooltip : {
- trigger: 'axis'
- },
- legend: {
- data:['蒸发量','降水量']
- },
- toolbox: {
- show : true,
- feature : {
- mark : {show: true},
- dataView : {show: true, readOnly: false},
- magicType : {show: true, type: ['line', 'bar']},
- restore : {show: true},
- saveAsImage : {show: true}
- }
- },
- calculable : true,
- xAxis : [
- {
- type : 'category',
- data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
- //设置字体倾斜
- axisLabel:{
- interval:0,
- rotate:45,//倾斜度 -90 至 90 默认为0
- margin:2,
- textStyle:{
- fontWeight:"bolder",
- color:"#000000"
- }
- },
- }
- ],
- yAxis : [
- {
- type : 'value',
- splitArea : {show : true}
- }
- ],
- series : [
- {
- name:'蒸发量',
- type:'bar',
- data:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
- },
- {
- name:'降水量',
- type:'bar',
- data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],
- //顶部数字展示pzr
- itemStyle: {
- normal: {
- label: {
- show: true,//是否展示
- textStyle: {
- fontWeight:'bolder',
- fontSize : '12',
- fontFamily : '微软雅黑',
- }
- }
- }
- },
- }
- ]
- });
- }
- </script>
- <body>
- <div id="mainBar" style="border:1px solid #ccc;padding:10px;"></div>
- <!-- 标签式引入Eharts 如果你把引用echarts的script标签放置head内在IE8-的浏览器中会出现报错,解决的办法就是把标签移动到body内(后)。 -->
- <script type="text/javascript" src="http://apps.bdimg.com/libs/echarts/2.1.9/source/echarts-all.js"></script>
- <script>
- </script>
- </body>
- </html>
效果图如下:

还有一个地方可以看到效果图,很不错的一个网站
Echarts横坐标倾斜,顶部显示数字的更多相关文章
- [置顶]
echarts x轴文字显示不全(xAxis文字倾斜比较全面的3种做法值得推荐)
echarts x轴标签文字过多导致显示不全 如图: 解决办法1:xAxis.axisLabel 属性 axisLabel的类型是object ,主要作用是:坐标轴刻度标签的相关设置.(当然yAxis ...
- echarts x轴文字显示不全解决办法
标题:echarts x轴文字显示不全(xAxis文字倾斜比较全面的3种做法值得推荐):http://blog.csdn.net/kebi007/article/details/68488694
- [收集]在iPhone桌面的应用程序图标右上角显示数字
能够在ios桌面的程序icon右上角显示数字(badge number)的方法 在ViewController中的viewDidLoad方法中添加如下代码即可 - (void)viewDidLoad ...
- HTML5效果:Canvas 实现圆形进度条并显示数字百分比
实现效果 1.首先创建html代码 <canvas id="canvas" width="500" height="500" styl ...
- flex学习笔记 显示数字步进
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...
- echarts隐藏之后的显示问题
好久没有更新博客了,今天搞了快一天的网页自适应,头晕...因为最近开始做项目,项目中需要用到图表方面的知识,于是乎接触到了echarts,所以其实我也算是新手了.只是近几天弄了很久的关于图表隐藏之后再 ...
- 【jQuery】页面顶部显示的进度条效果
<!Doctype html> <html> <head> <title>页面顶部显示的进度条效果</title> <meta htt ...
- 快速创建显示数字数据的动画——CountUp.js
由于项目需求,需要写一个数字增/减量的动画特效,最后找到了CountUp.js CountUp.js是一个无依赖,轻量级的JavaScript“类”,可用于快速创建以更有趣的方式显示数字数据的动画. ...
- 【Excle数据透视表】如何在组的顶部显示分类汇总
调整前 调整后 例 ...
随机推荐
- Tesorflow-自动编码器(AutoEncoder)
直接附上代码: import numpy as np import sklearn.preprocessing as prep import tensorflow as tf from tensorf ...
- PIE SDK彩色空间变换
1. 算法功能简介 使用彩色空间变换工具可以将三波段红.绿.蓝图像变换到一个特定的彩色空间,并且能从所选彩色空间变换回 RGB.两次变换之间,通过对比度拉伸,可以生成一个色彩增强的彩色合成图像.此外, ...
- PIE SDK小波变换
1.算法功能简介 小波变换是一种信号的时间——尺度分析方法,具有多分辨率分析的特点,而且在时频两域都具有表征信号局部特征的能力,是一种窗口大小固定不变但其形状可变,时间窗和频率窗都可变的时频局部化分析 ...
- spark SQL编程
1.编程实现将 RDD 转换为 DataFrame源文件内容如下(包含 id,name,age): 1,Ella,362,Bob,293,Jack,29 请将数据复制保存到 Linux 系统中,命名为 ...
- 《The Python Tutorial》——Errors and Exceptions 阅读笔记
Errors and Exceptions 官方文档:https://docs.python.org/3.5/tutorial/errors.html python中所有的异常都继承自BaseExce ...
- 两种请求方式URLHttpconnection 和Httpclient提交表单 网络篇(二)
安卓有两种发送请求的方式:URLHttpconnection 和Httpclient 下面就来讲下这两种方式,这篇是最基础的使用 进阶请看第二篇 先占位 打扫卫生去了T T 快过年了 框架就放网络篇 ...
- andoid 多线程断点下载
本示例介绍在Android平台下通过HTTP协议实现断点续传下载. 我们编写的是Andorid的HTTP协议多线程断点下载应用程序.直接使用单线程下载HTTP文件对我们来说是一件非常简单的事.那么,多 ...
- jqGrid 将行的字变成超连接
今天在项目中碰到要将jqGrid中的行做成超连接,请看代码步骤: name: , align: "left", formatter: function (cellValue, op ...
- 实现JFileChooser的多种文件类型限制(设置过滤器)
使用时直接调用方法. // 多类型时使用 public void FileFilter(JFileChooser F) { String[][] fileNames = { { ".java ...
- select支持多查询,获取分页count
在我们使用mybatis 时,当我们根据分页去查询数据集时,需要传入的参数有page(页码)和size(每页的条数),而我们期望获取到的数据有,小于或等于size的list数据集,同时我们还需要得到一 ...