Ext学习笔记(5):DrawComponent使用 Demo

<html>
<head>
<!-- Ext DrawComponent Demo -->
<script src="js/ext-all.js"></script>
<link href="css/ext-theme-gray-all.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
	Ext.onReady(function() {
		var drawComponent = Ext.create('Ext.draw.Component', {
		    width: 800,
		    height: 600,
		    renderTo: Ext.DomQuery.selectNode("div[@id='chart1']")
		});
		
		/*
		Ext.draw.Component.surface
		表面实例管理该组件*/
		surface = drawComponent.surface;

		surface.add([{
		    type: 'circle',
		    radius: 10,
		    fill: '#f00',
		    x: 10,
		    y: 10,
		    group: 'circles'
		}, {
		    type: 'circle',
		    radius: 10,
		    fill: '#0f0',
		    x: 50,
		    y: 50,
		    group: 'circles'
		}, {
		    type: 'circle',
		    radius: 10,
		    fill: '#00f',
		    x: 100,
		    y: 100,
		    group: 'circles'
		}, {
		    type: 'rect',
		    width: 20,
		    height: 20,
		    fill: '#f00',
		    x: 10,
		    y: 10,
		    group: 'rectangles'
		}, {
		    type: 'rect',
		    width: 20,
		    height: 20,
		    fill: '#0f0',
		    x: 50,
		    y: 50,
		    group: 'rectangles'
		},{
		    type: 'rect',
		    width: 20,
		    height: 20,
		    fill: '#00f',
		    x: 100,
		    y: 100,
		    group: 'rectangles'
		}]);

		// Get references to my groups
		circles = surface.getGroup('circles');
		rectangles = surface.getGroup('rectangles');

		// 使圆形竖直向下移动
		circles.animate({
		    duration: 1000,//执行时间
		    to: {
		        translate: {
		            y: 200//y=y+200
		        }
		    }
		});

		// 使正方形水平向右移动
		rectangles.animate({
		    duration: 1000,//执行时间
		    to: {
		        translate: {//转化
		            x: 200//x=x+200
		        }
		    }
		});

		Ext.create('Ext.panel.Panel', {
		    title: 'Panel with VerticalTextItem',
		    width: 300,
		    height: 200,
		    lbar: {
		        layout: {
		            align: 'center'
		        },
		        items: [{
		            xtype: 'text',
		            text: 'Sample VerticalTextItem',
		            degrees: 60//旋转60度角
		        }]
		    },
		    renderTo: Ext.DomQuery.selectNode("div[@id='chart2']")
		});
	});
</script>
</head>
<body>
	<div id="chart1" style="margin-left: 100px;"></div>
	<div id="chart2" style="margin-left: 100px;"></div>
</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值