Ext chart 折线图表

今天做任务中修改图表任务,第一次做图表,有几个点研究了半天,在此记录一下

 

大体结构:

{
                xtype: 'chart',  //类型chart
                id:'id',
                store: this.store,
                legend: { }, //设置折线说明
                axes: [{ //坐标轴
                    type: 'Numeric',
                    position: 'left',
                }, {
                    type: 'Category',
                    position: 'bottom',
                }],
                series: [{ //设置图表
                    type: this.type, //折线类型
                    title:'1',
                    markerConfig: { },
                    listeners: {  },//监听事件
                    tips: {  }, //提示信息
                },{
                    type: this.type,
                    title:'2',
                    markerConfig: {  },
                    listeners: {  },
                    tips: {  }
                    },
                }]
            }
 

右侧的折线说明:使用  legend  关键字

多条折线:在series中设置多个{}

 

代码结构:

{
    	        xtype: 'chart',  //类型chart
    	        animate: true,
    	        region: 'north',
    	        shadow: true,
    	        id:'id',
    	        height:200,
    	        store: this.store,
    	        legend: {
//                    docked: 'bottom'
    			position: 'right',
    	                boxStroke: '#E0E0E0',
    	                update:false
                },
    	        axes: [{
    	            type: 'Numeric',
    	            position: 'left',
    	            fields: this.leftname,
    	            minimum: 0,
    	            title: false,
    	            grid: true
    	        }, {
    	            type: 'Category',
    	            position: 'bottom',
    	            fields: this.bottomtname,
    	            title: false
    	        }],
    	        series: [{
    	            type: this.type,
    	            title:'入库单价',
    	            axis: 'left',
    	            gutter: 80,
    	            xField: 'a', //x轴对应store字段
    	            yField: ['u'], //y轴对应store字段
    	            highlight: true,
    	            markerConfig: {
    	                radius: 6,
    	                size: 12,
    	                fill: '#a2b5ca',
    	                type: 'cross',
    	            },
    	            listeners: {
	                    'itemmouseup': function(item) {
	                         var series = Ext.getCmp('gooddetailed').series.get(0), //获取当前图表Id对应的第一条折线
	                         index = Ext.Array.indexOf(series.items, item),
	                         selectionModel = Ext.getCmp('gooddetailedgrid').getSelectionModel();
	                         selectedStoreItem = item.storeItem;
	                         selectionModel.select(index);
	                    }
	                },
    	            tips: {
	                    trackMouse: true,
	                    width: 200,
	                    height: 100,
	                    renderer: function(storeItem, item) { //设置悬浮提示内容
	                        this.setTitle('生产时间:'+storeItem.get('a') + '<br />' + '入库单价:' +storeItem.get('u'));
	                    }
	                },
    	        },{
    	            type: this.type,
    	            title:'采购单价',
    	            axis: 'left',
    	            gutter: 80,
    	            showInLegend : false, //是否显示
    	            xField: 'a',
    	            yField: ['p'],
    	            highlight: true,
    	            markerConfig: {
    	                radius: 6,
    	                size: 12,
    	                fill: '#B3EE3A',
    	                type: 'cross',
    	            },
    	            listeners: {
	                    'itemmouseup': function(item) {
	                         var series = Ext.getCmp('gooddetailed').series.get(1),
	                         index = Ext.Array.indexOf(series.items, item),
	                         selectionModel = Ext.getCmp('gooddetailedgrid').getSelectionModel();
	                         selectedStoreItem = item.storeItem;
	                         selectionModel.select(index);
	                    }
	                },
    	            tips: {
	                    trackMouse: true,
	                    width: 200,
	                    height: 100,
	                    renderer: function(storeItem, item) {
	                        this.setTitle('生产时间:'+storeItem.get('a') + '<br />' + '采购单价:' +storeItem.get('p'));
	                    }
	                },
    	        }]
    	    }

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值