EXTJS4.2 chart 柱状图
chart 柱状图

Ext.require('Ext.chart.*');
Ext.require(['Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit', 'Ext.window.MessageBox']);
var store_Watch = new Ext.data.JsonStore({
fields: ['ConversationId', 'ConversationSegContent', 'VotesCount', 'ParticipateCount'],//选项的 SegmentType = 2
data: [{
ConversationId: '1',
ConversationSegContent: '我要去北京哦',
VotesCount: 245000,
ParticipateCount: 3000000
}, {
ConversationId: '2',
ConversationSegContent: '我要去广州哦',
VotesCount: 200,
ParticipateCount: 3500000
}, {
ConversationId: '3',
ConversationSegContent: '我要去上海哦',
VotesCount: 19999,
ParticipateCount: 2000000
}, {
ConversationId: '4',
ConversationSegContent: '我要去深圳哦',
VotesCount: 200000,
ParticipateCount: 3200000
}, {
ConversationId: '5',
ConversationSegContent: '我要去美国哦',
VotesCount: 90000,
ParticipateCount: 3500000
}, {
ConversationId: '6',
ConversationSegContent: '我要去加拿大哦',
VotesCount: 395000,
ParticipateCount: 6800000
}, {
ConversationId: '7',
ConversationSegContent: '我要去火星哦',
VotesCount: 580600,
ParticipateCount: 8500000
}]
});
var chart = Ext.create('Ext.chart.Chart', {
animate: true,
style: 'background:#fff',
shadow: false,
store: store_Watch,
axes: [{
type: 'Numeric',
position: 'bottom',
fields: ['VotesCount'],
label: {
renderer: Ext.util.Format.numberRenderer('0,0')
},
title: '投票项个数',
minimum: 0
}, {
type: 'Category',
position: 'left',
fields: ['ConversationSegContent'],
title: '投票项'
}],
series: [{
type: 'bar',
axis: 'bottom',
tips: {
trackMouse: true,//数据提示框是否跟着鼠标移动
width: 180,//提示框宽度
height: 28,
renderer: function (storeItem, item) {
this.setTitle(storeItem.get('ConversationSegContent') + ' | 投票项个数' + storeItem.get('VotesCount') + ' ');
}
},
label: {
display: 'insideEnd',
field: ['VotesCount'],
renderer: Ext.util.Format.numberRenderer('0'),
orientation: 'horizontal',
color: '#333',
'text-anchor': 'middle',
contrast: true
},
xField: 'ConversationSegContent',
yField: ['VotesCount'],
//color renderer
renderer: function (sprite, record, attr, index, store) {
var fieldValue = Math.random() * 20 + 10;
var value = record.get('VotesCount');
var color;
//var color = ['rgb(213, 70, 121)',
// 'rgb(44, 153, 201)',
// 'rgb(146, 6, 157)',
// 'rgb(49, 149, 0)',
// 'rgb(249, 153, 0)'][value];
//根据数值的不同显示不同的颜色
if (value < 100000) {
color = '#00FF00';
}
else if (value > 100000 && value < 200000) {
color = "#00FFFF";
}
else if (value > 200000 && value < 300000) {
color = '#FF00FF';
}
else if (value > 300000 && value < 400000) {
color = '#FF0060';
}
else if (value > 400000) {
color = '#FF0000';
}
return Ext.apply(attr, {
fill: color
});
}
}]
});
var win_Watch = Ext.create('Ext.Window', {
width: 900,
height: 600,
minHeight: 400,
minWidth: 550,
maximizable: true,
title: '投票结果',
layout: "fit", //窗口布局类型
modal: true, //是否模态窗口,默认为false
resizable: false,
closeAction: 'hide',
plain: true,
draggable: true,
border: false,
items: chart,
tbar: [{
text: 'Reload Data',
handler: function () {
}
}]
});
EXTJS4.2 chart 柱状图的更多相关文章
- Extjs4新特性
Extjs 4相对于之前的版本作出了重大的修正.其中包括全新的类系统.新平台的引入.API的修整和加强还有新组件的引入(如新的图表和图形组件).Extjs 4提供更快速.更稳定的用户体验,并且让开发人 ...
- JfreeChart使用(转载)
http://www.cnblogs.com/xingyun/ http://www.huosen.net/archives/156.html(此篇除了struts2外,还介绍了servlet下Jfr ...
- 【转载】《Ext JS 4 First Look》翻译之一:新特性
免责声明: 本文转自网络文章,转载此文章仅为个人收藏,分享知识,如有侵权,请联系博主进行删除. 原文作者:^_^肥仔John 原文地址:http://www.cnblogs. ...
- android开源项目学习
FBReaderJ FBReaderJ用于Android平台的电子书阅读器,它支持多种电子书籍格式包括:oeb.ePub和fb2.此外还支持直接读取zip.tar和gzip等压缩文档. 项目地址:ht ...
- js相关(easyUI),触发器,ant,jbpm,hibernate二级缓存ehcache,Javamail,Lucene,jqplot,WebService,regex,struts2,oracle表空间
*********************************************js相关********************************************* // 在指 ...
- python模块之XlsxWriter 详解
Xlsx是python用来构造xlsx文件的模块,可以向excel2007+中写text,numbers,formulas 公式以及hyperlinks超链接. 可以完成xlsx文件的自动化构造,包括 ...
- python模块之XlsxWriter
官网Tutorial:http://xlsxwriter.readthedocs.io/tutorial Xlsx是python用来构造xlsx文件的模块,可以向excel2007+中写text,nu ...
- Visifire Chart控件设置 柱状图 条的宽窄
Chart myChart = new Chart();myChart.DataPointWidth = 5;宽度以PlotArea的百分比为单位,如下例: chart.Width = 500; c ...
- Chart图表整合——面积对比图、扇形图、柱状图
一. chart图表demo网址 网址:http://antv.alipay.com/zh-cn/f2/3.x/demo/index.html 二. 本文主要对面积对比图,扇形图,柱状图三大常见图进行 ...
随机推荐
- Eclipse+Axis使用WSDL文件生成Web Service服务端/客户端
JDK版本:1.5.0_22 Eclipse版本:Helios Service Release 2(3.6.2) WSDL文件的创建过程见http://blog.csdn.net/a19881029/ ...
- [改善Java代码]若有必要,使用变长数组
Java中的数组是定长的,一旦经过初始化声明就不可改变长度,这在实际使用的时候非常不方便.比如要对一个班级的学生信息进行统计,因为我们不知道班级会有多少个学生(随时可能有退学,入学,转学),所以需要一 ...
- [Wordpress]Wordpress使用SMTP发送电邮
参考:phpmailer_init中的代码,可以配置使用SMTP发送电邮 官方的案例代码是: add_action( 'phpmailer_init', 'my_phpmailer_example' ...
- ORACLE之PACKAGE
刚学pl/sql编程,写了两个package.pkg_temp_fn和pkg_temp_fn2.内容涉及pl/sql基本语法,游标,存储过程(in,out),函数(有返回值). pkg_temp_fn ...
- 如何更好的理解(pageX,pageY,clientX,clientY,eventX,eventY,scrollX,scrollY,screenX,screenY,event.offsetX,event.offsetY,offsetLeft,style.left)
1 pageX,pageY:鼠标指针相对于当前窗口的X,Y坐标,计算区域包括窗口自身的控件和滚动条.(火狐特有) 2 event.clientX,event.clientY:鼠标指针相对于当前窗口的X ...
- Tomcat - 持久化 Session
Session 是保存在内存中的,如果服务器重启.宕机的话,Session 就会丢失.有时候,我们需要对 Session 持久化以应对意外的情况发生.例如,客户端与服务器在交互过程中,可能因为 Ses ...
- Git CMD - branch: List, create, or delete branches
命令格式 git branch [--color[=<when>] | --no-color] [-r | -a] [--list] [-v [--abbrev=<length> ...
- 关于delegate, category和subclass
因为自己在学习这三个概念的时候,实在是走了很多的弯路,而且当我意识到这些概念在cocoa中很重要时,我便更糊涂了…或许从C++或者Java转过来的高手一看就明白,所以高手您随便拍砖,指正我的错误:新手 ...
- CF下Split的使用
在Compact Framework 下 String的Split不能正确的处理 字符串 分割字符串 如对字符串 "abcfdef12abcedef23" 以"ef&qu ...
- WCF学习笔记 -- 基本概念
WCF是实现WebService的一种微软提出的技术,整合了.Remote, .NET及ASP.NET服务的一种框架.是Windows Communication Foundation的缩写.WebS ...