关于DOM element with id in Element cache is not the same as element in the Dom解决方法

ExtJS 5.1.1在使用统计图调用时,代码如下:

		var graph0101 = Ext.create('Ext.chart.CartesianChart',{
			id:				'graph_0101',
			insetPadding: 	{top: 60, bottom: 10, left: 40, right: 20},
			store:		loaderObj.chartStore,
			width: 		900,
			height: 	420,
			animate: true,
			shadow: true,
			legend:{
				position:	'bottom'
			},
			axes:	[
				{
					type:		'numeric',
					position:	'left',
					grid:		true,
					fields:		['items'],
		            grid: {
		                odd: {
		                    opacity: 1,
		                    fill: '#ddd',
		                    stroke: '#bbb',
		                    'stroke-width': 1
		                }
		            },
		            minimum:	0,
		            maximum:	total_xmsl+100,
					title:		{text: '目数(个)', fontSize: 16}
				},
				{
					type:		'category',
					title:		{text: '年份', fontSize: 16},
					position:	'bottom'
				}
			],
			series: [
			    {
			    	type: 			'bar',
			    	xField:			'year',
			    	yField:			['items'],
					gutter: 		20,
					groupGutter: 	10,
					axis: 			'left',
					highlight: 		true,
        	    	showInLegend :  true,
        			label : {
        				field :     ['items'],//标签字段名
        				contrast: 	true,  //统计图里的字反亮显示
        				display : 	'outside',//标签显现方式
        				color:		'blue',
	       				font : 		'12px 宋体',//字体
	       				orientation:	'horizontal',
        				renderer : function(v){//自定义标签渲染函数
        					return v+'个' ;
        				}
        			},
        	    	
			    }
			],
			sprites: {
				type:		'text',
				text:		Ext.getCmp('txt_charttitle').getValue(),
				font:		'25px 宋体',
				width:		300,
				height:		35,
				x:			150,
				y: 			40
			}
		});


,产生如下图的错误



解决方法,在以上代码前加上以下代码

	if(!Ext.Object.isEmpty(Ext.getCmp('graph_0101'))){
		Ext.destroy(Ext.getCmp('graph_0101'));
	}

就可以解决该错误。




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值