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 柱状图的更多相关文章

  1. Extjs4新特性

    Extjs 4相对于之前的版本作出了重大的修正.其中包括全新的类系统.新平台的引入.API的修整和加强还有新组件的引入(如新的图表和图形组件).Extjs 4提供更快速.更稳定的用户体验,并且让开发人 ...

  2. JfreeChart使用(转载)

    http://www.cnblogs.com/xingyun/ http://www.huosen.net/archives/156.html(此篇除了struts2外,还介绍了servlet下Jfr ...

  3. 【转载】《Ext JS 4 First Look》翻译之一:新特性

    免责声明:     本文转自网络文章,转载此文章仅为个人收藏,分享知识,如有侵权,请联系博主进行删除.     原文作者:^_^肥仔John      原文地址:http://www.cnblogs. ...

  4. android开源项目学习

    FBReaderJ FBReaderJ用于Android平台的电子书阅读器,它支持多种电子书籍格式包括:oeb.ePub和fb2.此外还支持直接读取zip.tar和gzip等压缩文档. 项目地址:ht ...

  5. js相关(easyUI),触发器,ant,jbpm,hibernate二级缓存ehcache,Javamail,Lucene,jqplot,WebService,regex,struts2,oracle表空间

    *********************************************js相关********************************************* // 在指 ...

  6. python模块之XlsxWriter 详解

    Xlsx是python用来构造xlsx文件的模块,可以向excel2007+中写text,numbers,formulas 公式以及hyperlinks超链接. 可以完成xlsx文件的自动化构造,包括 ...

  7. python模块之XlsxWriter

    官网Tutorial:http://xlsxwriter.readthedocs.io/tutorial Xlsx是python用来构造xlsx文件的模块,可以向excel2007+中写text,nu ...

  8. Visifire Chart控件设置 柱状图 条的宽窄

     Chart myChart = new Chart();myChart.DataPointWidth = 5;宽度以PlotArea的百分比为单位,如下例: chart.Width = 500; c ...

  9. Chart图表整合——面积对比图、扇形图、柱状图

    一. chart图表demo网址 网址:http://antv.alipay.com/zh-cn/f2/3.x/demo/index.html 二. 本文主要对面积对比图,扇形图,柱状图三大常见图进行 ...

随机推荐

  1. [改善Java代码]预防线程死锁

    线程死锁DeadLock是多线程编码中最头疼的问题,也是最难重现的问题,因为Java是单进程多线程语言.

  2. 关于JDK中的集合总结(三)

    泛型: jdk1.5出现的安全机制. 好处: 1,将运行时期的问题ClassCastException转到了编译时期. 2,避免了强制转换的麻烦. <>:什么时候用?当操作的引用数据类型不 ...

  3. Linux下RPM软件包的安装及卸载

    http://os.51cto.com/art/201001/177866.htm 在 Linux 操作系统下,几乎所有的软件均通过RPM 进行安装.卸载及管理等操作.RPM 的全称为Redhat P ...

  4. Agile.Net 组件式开发平台 - 组件开发示例

    所谓组件式开发平台,它所有的功能模块都是以组件的形式扩展的,下面我来演示一个简单的组件开发例程. Agile.Net开发管理平台项目,已经托管在开源中国码云平台(http://git.oschina. ...

  5. Javascript Error: 11233 Content-Length mismatch

    Today I got a error in fiddler: Failed to obtain request body. System.IO.InvalidDataException The re ...

  6. TFS2012常见问题及解答

    1.删除workItem工作项(包括Bug,用户场景,任务等) 需要利用到witadmin工具,目录在cd %programfiles%\Microsoft Visual Studio 11.0\Co ...

  7. 获取bundle目录下的所有图片文件名

    今天在写代码时候,偶然发现自己忘记了一些oc的基础知识(这里指的是获取bundle目录下的所有图片),感到很不爽.在百度了几次,发现自己的领悟能力实在不行,感觉萌萌的::>_<:: 好了, ...

  8. 关于百度编辑器UEditor(1.4.3)在C#.NET中的应用实例

    首先去百度UEditor官网下载 1.4.3 .net版本 http://ueditor.baidu.com/build/build_down.php?n=ueditor&v=1_4_3-ut ...

  9. CodeSmith Template Model Output

    背景:上学那会儿就接触CodeSmith,是一款非常优秀的代码自动生成工具.以前写过好些基本模版,可惜早不知道扔到哪儿去了,如今只能重新开始,把它捡回来,加油. 效果:将数据库 DataBase 应用 ...

  10. ASP.NET MVC 路由进阶(之二)--自定义路由约束

    3.自定义路由约束 什么叫自定义路由约束呢?假如路由格式为archive/{year}/{month}/{day},其中year,month,day是有约束条件的,必须是数字,而且有一定范围. 这时候 ...