EXTJS4自学手册——分组区域图

一、数据容器:

var groupAreaCharStore = Ext.create('Ext.data.JsonStore', {
    fields: ['', '', '', ''],
    data: [
        { '': 10000, '': 8000, '': 7000, '': '2008' },
        { '': 11000, '': 10000, '': 8000, '': '2009' },
        { '': 8000, '': 11000, '': 10000, '': '2010' },
        { '': 15000, '': 11500, '': 11000, '': '2010' }
    ]
});

二、创建分组区域图:

注意其和区域图的区别,是更改了axes的fields属性,和series的yFields属性

Ext.define("ExtStudy.GroupAreaChar", {
    extend: 'Ext.window.Window',
    width: 500,
    height: 300,
    layout: 'fit',
    maximizable: true,
    items: {
        xtype: 'chart',
        style: 'background:#fff',
        animate: true,
        store: groupAreaCharStore,
        axes: [{
            type: 'Numeric',
            position: 'left',
            fields: ['', '', ''],
            title: '数量',
            grid: true,
            minimum: 0
        }, {
            type: 'Category',
            position: 'bottom',
            fields: [''],
            calculateCategoryCount: false,
            title: '年份'
        }],
        legend: {
            position: 'right'
        },
        series: [{//图像显示配置
            type: 'area',//采用区域图
            highlight: true,
            tips: {//鼠标指到特定柱状图时显示的信息
                trackMouse: true,
                width: 140,
                height: 28,
                renderer: function (storeItem, item) {
                    this.setTitle(item.storeField + ': ' + storeItem.get(item.storeField));
                }
            },
            xField: '年份',
            yField: ['', '', '']
        }]
    }
})

效果图:

image

posted @ 2014-01-09 13:35  争世不悔  阅读(256)  评论(0编辑  收藏  举报