Extjs中使用Echarts(自适应)
来源:互联网 发布:创世数据网 编辑:程序博客网 时间:2024/06/10 01:53
首先我们需要在extjs中引用echarts
1.index.html文件中引入Echarts
<script type="text/javascript" src="js/echarts-min.js"></script>
“js/echarts-min.js”替换成自己的echart文件路径;下载的时候根据的自己的需求下载不同的js.
2. 新建一个Panel(其他控件都OK),名字叫做PanelEcharts,名字可以根据自己项目需要取,代码如下:
3.我这里用的是仪表盘的例子。
/** * * echarts的公共panel */Ext.define('Ux.layout.PanelEcharts', { extend: 'Ext.panel.Panel', requires: [], alias: [ 'widget.panelecharts' ], width: this.width,//当用afterrender方法时这里的width、height都是固定的需要自己给定。 height: this.height, option: {},// border:false, initComponent: function () { var me = this; me.on({ //在extjs5中使用echarts的时候如何才能让图表随浏览器的改变?网上有很多方法,官网使用的是resize //自适应当前panel的宽和高,图形也会自适应 resize: function (field,width,height ) { this.width=width this.height=height var overTimeChart = echarts.init(field.getEl().dom); var option = me.option; overTimeChart.setOption(option,true); }, /* afterrender: function (field) { var overTimeChart = echarts.init(field.getEl().dom); var option = me.option; overTimeChart.setOption(option); }*/ }) me.callParent(arguments); }});
在自己用的界面引用上面的panel
requires: [
‘Ux.layout.PanelEcharts’,
],
var me = this; Ext.ajax({ url: '../../url', method: 'post', params: { orgId: '', } }, function (json) { var _panel = Ext.getCmp('centerpanel'), _width = _panel.getWidth(), _height = _panel.getHeight() - 5; _panel.removeAll(true); switch (json.length) { case 0: return; break; case 1: break; case 2: _width -= 20; _height = _height / 2; _height = _width / 2; break; default: _width -= 20; _height = _height / 2; _width = _width / 4; break; } var _color = [[50 / 200, '#ff0000'], [1, '#A8A8A8']], _name = ''; Ext.Array.each(json.content, function (n) { if (n.stagnationMinute) { _color = [[(n.value) / 200, '#ff0000'], [1, '#A8A8A8']]; _name = '数据停滞' + n.stagnationMinute + '分钟'; } else { _color = [[(n.value) / 200, '#00b351'], [1, '#A8A8A8']]; _name = ''; } var _vboxPanel = { xtype: 'panelecharts', width: _width, height: _height, option: { tooltip: { formatter: "{a} <br/> {c}" }, series: [{ //类型 type: 'gauge', name: '关井预警', //半径 /* detail: { formatter: function (params) { console.log(arguments) } },*/ radius: 110, center: ['50%', '50%', '50%', '50%'], //仪表盘轴线相关配置。 axisLine: { show: true, // 属性lineStyle控制线条样式 lineStyle: { width: 30, color: _color } }, startAngle: 180, //结束角度。 endAngle: 0, min: 0, max: 200, data: [{value: (n.value), name: _name}], //仪表盘标题。 title: { show: true, offsetCenter: [0, '45%'], // x, y,单位px textStyle: { color: '#hhh', fontSize: 20 } }, //仪表盘详情,用于显示数据。 detail: { show: true, offsetCenter: [0, '20%'], formatter: '' + n.wellName + '', textStyle: { color: 'black', fontSize: 20 } }, }] } }; _panel.add(_vboxPanel); }) })
这是仪表盘的自适应的图
阅读全文
0 0
- Extjs中使用Echarts(自适应)
- react 中 使用echarts 单图标自适应大小方法
- echarts中y轴的自适应
- react中使用echarts
- vuejs中使用echarts
- React中使用ECharts
- angular中使用ECharts
- webpack中使用echarts
- extjs中创建自适应大小grid
- Extjs中layout:column的布局,容器大小使用百分比,不能自适应(自动缩放)
- ExtJs 解决在GridPanel中使用bbar或者tbar的分页条的宽度自适应问题
- 如何让echarts在extjs5中自适应大小
- echarts使用,[自适应、右上角的工具图标、标题、图例问题]
- Android项目中使用echarts
- vue项目中使用echarts
- 在 webpack 中使用 ECharts
- Vue.js中,使用echarts
- Echarts 如何自适应大小
- mysql order by case when
- BottomNavigationBar 取代 TabHost的时候早已到来
- SSM框架整合所需相关jra包的maven地址
- unity中XML和JSON文档的解析
- Git使用提交代码遇到『Everything up-to-date』
- Extjs中使用Echarts(自适应)
- 随笔--工作一月
- 小游戏
- leetcode 349[easy]---Intersection of Two Arrays
- Java 大堆排序从0开始
- bootstrap 布局图片列表
- Android的CheckBox控件设置自定义图片
- 建设数据中心机房主要看这几点,否则被定为劣质机房!!!
- DUBBO常用xml配置总结与分类