ExtJS 4 绘图和图表示例不是绘图
这让我发疯,我尝试了多种不同的选择。我正在此处浏览所有材料,试图在一个项目中将尽可能多的 ExtJS 4 塞进我的大脑中。在绘图和图表部分有两个示例。下面,第一个示例绘制了一个黄色圆圈,第二个示例没有绘制圆圈。为什么?
第一个示例(绘制黄色圆圈):
Ext.application({
name: 'HelloExt',
launch: function(){
var drawComponent = Ext.create('Ext.draw.Component', {
viewBox: false,
items: [{
type: 'circle',
fill: '#ffc',
radius: 100,
x: 100,
y: 100
}]
});
Ext.create('Ext.Window', {
width: 230,
height: 230,
layout: 'fit',
items: [drawComponent]
}).show();
}
});
第二个示例(不绘制圆圈):
Ext.application({
name: 'HelloExt',
launch: function(){
// Create a draw component
var drawComponent = Ext.create('Ext.draw.Component', {
viewBox: false
});
// Create a window to place the draw component in
Ext.create('Ext.Window', {
width: 220,
height: 230,
layout: 'fit',
items: [drawComponent]
}).show();
// Add a circle sprite
var myCircle = drawComponent.surface.add({
type: 'circle',
x: 100,
y: 100,
radius: 100,
fill: '#cc5'
});
}
});
我尝试了无数种将 Sprite 添加到 drawComponent 的方法,唯一有效的方法是将其作为 drawComponent 实例化中项目的声明成员。我在控制台中没有收到任何错误。
This is driving me crazy and I've tried a number of different options. I'm going through all the materials here, trying to cram as much ExtJS 4 into my brain as possible for a project. In the Drawing and Charting section there are two examples. Below, the first example draws a yellow circle, the second example draws no circle. Why?
First example (draws a yellow circle):
Ext.application({
name: 'HelloExt',
launch: function(){
var drawComponent = Ext.create('Ext.draw.Component', {
viewBox: false,
items: [{
type: 'circle',
fill: '#ffc',
radius: 100,
x: 100,
y: 100
}]
});
Ext.create('Ext.Window', {
width: 230,
height: 230,
layout: 'fit',
items: [drawComponent]
}).show();
}
});
Second example (draws no circle):
Ext.application({
name: 'HelloExt',
launch: function(){
// Create a draw component
var drawComponent = Ext.create('Ext.draw.Component', {
viewBox: false
});
// Create a window to place the draw component in
Ext.create('Ext.Window', {
width: 220,
height: 230,
layout: 'fit',
items: [drawComponent]
}).show();
// Add a circle sprite
var myCircle = drawComponent.surface.add({
type: 'circle',
x: 100,
y: 100,
radius: 100,
fill: '#cc5'
});
}
});
I've tried innumerable ways of adding the Sprite to the drawComponent and the only that works is if I give it as a declared member of items in the drawComponent instantiation. I'm getting no errors in the Console.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该修复涉及将
.show(true)
添加到 sprite 语句的末尾。像这样:我真的希望这已经出现在 ExtJS 4 文档中。
The fix involves adding
.show(true)
to the end of the sprite statement. Like this:I really wish this had been in the ExtJS 4 documentation.