ExtJS 4 绘图和图表示例不是绘图

发布于 2025-01-04 03:48:52 字数 1409 浏览 3 评论 0原文

这让我发疯,我尝试了多种不同的选择。我正在此处浏览所有材料,试图在一个项目中将尽可能多的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜还是长夜 2025-01-11 03:48:52

该修复涉及将 .show(true) 添加到 sprite 语句的末尾。像这样:

var myCircle = drawComponent.surface.add({
    type: 'circle',
    x: 100,
    y: 100,
    radius: 100,
    fill: '#cc5'
}).show(true);

我真的希望这已经出现在 ExtJS 4 文档中。

The fix involves adding .show(true) to the end of the sprite statement. Like this:

var myCircle = drawComponent.surface.add({
    type: 'circle',
    x: 100,
    y: 100,
    radius: 100,
    fill: '#cc5'
}).show(true);

I really wish this had been in the ExtJS 4 documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文