简体   繁体   English

Sencha Touch错误:对象没有方法getShowInLegend

[英]Sencha Touch error: object has no method getShowInLegend

Sencha Touch 2.3.1 Cmd: 4.0.XX Sencha Touch 2.3.1 Cmd:4.0.XX

My Sencha Touch Charts app throws this error when it tries to draw charts: 我的Sencha触摸图应用程序尝试绘制图表时会引发以下错误:

Uncaught TypeError: Object [object Object] has no method 'getShowInLegend' AbstractChart.js?_dc=1395914109534:649 未捕获的TypeError:对象[object Object]没有方法'getShowInLegend'AbstractChart.js?_dc = 1395914109534:649
Ext.define.refreshLegendStore AbstractChart.js?_dc=1395914109534:649 Ext.define.refreshLegendStore AbstractChart.js?_dc = 1395914109534:649
Ext.define.updateSeries AbstractChart.js?_dc=1395914109534:877 Ext.define.updateSeries AbstractChart.js?_dc = 1395914109534:877
setter sencha-touch-all-debug.js:5491 设置器sencha-touch-all-debug.js:5491
Base.implement.initConfig sencha-touch-all-debug.js:4920 Base.implement.initConfig sencha-touch-all-debug.js:4920
Ext.define.constructor sencha-touch-all-debug.js:22651 Ext.define.constructor sencha-touch-all-debug.js:22651
Base.implement.callParent sencha-touch-all-debug.js:4656 Base.implement.callParent Sencha-touch-all-debug.js:4656
Ext.define.constructor sencha-touch-all-debug.js:32375 Ext.define.constructor sencha-touch-all-debug.js:32375
Base.implement.callSuper sencha-touch-all-debug.js:4735 Base.implement.call超级sencha-touch-all-debug.js:4735
Ext.define.constructor Component.js?_dc=1395914109519:100 Ext.define.constructor Component.js?_dc = 1395914109519:100
Base.implement.callSuper sencha-touch-all-debug.js:4735 Base.implement.call超级sencha-touch-all-debug.js:4735
Ext.define.constructor AbstractChart.js?_dc=1395914109534:626 Ext.define.constructor AbstractChart.js?_dc = 1395914109534:626
Class sencha-touch-all-debug.js:5208 类sencha-touch-all-debug.js:5208
(anonymous function) VM14212:3 (匿名功能)VM14212:3
Ext.ClassManager.instantiate sencha-touch-all-debug.js:6936 Ext.ClassManager.instantiate sencha-touch-all-debug.js:6936
Ext.ClassManager.instantiateByAlias sencha-touch-all-debug.js:6848 Ext.ClassManager.instantiateByAlias sencha-touch-all-debug.js:6848
Ext.apply.factory sencha-touch-all-debug.js:9980 Ext.apply.factory sencha-touch-all-debug.js:9980
Ext.define.factoryItem sencha-touch-all-debug.js:32637 Ext.define.factoryItem sencha-touch-all-debug.js:32637
Ext.define.add sencha-touch-all-debug.js:32714 Ext.define.add sencha-touch-all-debug.js:32714
Ext.define.applyItems sencha-touch-all-debug.js:32538 Ext.define.applyItems sencha-touch-all-debug.js:32538
setter sencha-touch-all-debug.js:5482 设置器sencha-touch-all-debug.js:5482
(anonymous function) sencha-touch-all-debug.js:5516 (匿名功能)sencha-touch-all-debug.js:5516
Ext.define.applyActiveItem sencha-touch-all-debug.js:33208 Ext.define.applyActiveItem sencha-touch-all-debug.js:33208
(anonymous function) sencha-touch-all-debug.js:16565 (匿名功能)sencha-touch-all-debug.js:16565
Base.implement.initConfig sencha-touch-all-debug.js:4920 Base.implement.initConfig sencha-touch-all-debug.js:4920
Ext.define.constructor sencha-touch-all-debug.js:22651 Ext.define.constructor sencha-touch-all-debug.js:22651
Base.implement.callParent sencha-touch-all-debug.js:4656 Base.implement.callParent Sencha-touch-all-debug.js:4656
Ext.define.constructor sencha-touch-all-debug.js:32375 Ext.define.constructor sencha-touch-all-debug.js:32375
Class sencha-touch-all-debug.js:5208 类sencha-touch-all-debug.js:5208
(anonymous function) VM14212:3 (匿名功能)VM14212:3
Ext.ClassManager.instantiate sencha-touch-all-debug.js:6936 Ext.ClassManager.instantiate sencha-touch-all-debug.js:6936
Ext.ClassManager.instantiateByAlias sencha-touch-all-debug.js:6848 Ext.ClassManager.instantiateByAlias sencha-touch-all-debug.js:6848
Ext.apply.factory sencha-touch-all-debug.js:9980 Ext.apply.factory sencha-touch-all-debug.js:9980
Ext.define.factoryItemWithDefaults sencha-touch-all-debug.js:32683 Ext.define.factoryItemWithDefaults sencha-touch-all-debug.js:32683
Ext.define.add sencha-touch-all-debug.js:32707 Ext.define.add sencha-touch-all-debug.js:32707
Ext.define.applyItems sencha-touch-all-debug.js:32538 Ext.define.applyItems sencha-touch-all-debug.js:32538
setter sencha-touch-all-debug.js:5482 设置器sencha-touch-all-debug.js:5482
(anonymous function) sencha-touch-all-debug.js:5516 (匿名功能)sencha-touch-all-debug.js:5516
Ext.define.applyActiveItem sencha-touch-all-debug.js:33208 Ext.define.applyActiveItem sencha-touch-all-debug.js:33208
Base.implement.callParent sencha-touch-all-debug.js:4656 Base.implement.callParent Sencha-touch-all-debug.js:4656
Ext.define.applyActiveItem sencha-touch-all-debug.js:46269 Ext.define.applyActiveItem sencha-touch-all-debug.js:46269
(anonymous function) sencha-touch-all-debug.js:16565 (匿名功能)sencha-touch-all-debug.js:16565
Base.implement.initConfig sencha-touch-all-debug.js:4920 Base.implement.initConfig sencha-touch-all-debug.js:4920
Ext.define.constructor sencha-touch-all-debug.js:22651 Ext.define.constructor sencha-touch-all-debug.js:22651
Base.implement.callParent sencha-touch-all-debug.js:4656 Base.implement.callParent Sencha-touch-all-debug.js:4656
Ext.define.constructor sencha-touch-all-debug.js:32375 Ext.define.constructor sencha-touch-all-debug.js:32375
Class sencha-touch-all-debug.js:5208 类sencha-touch-all-debug.js:5208
(anonymous function) VM14212:3 (匿名功能)VM14212:3
Ext.ClassManager.instantiate sencha-touch-all-debug.js:6936 Ext.ClassManager.instantiate sencha-touch-all-debug.js:6936
Ext.ClassManager.instantiateByAlias sencha-touch-all-debug.js:6848 Ext.ClassManager.instantiateByAlias sencha-touch-all-debug.js:6848
Ext.apply.factory sencha-touch-all-debug.js:9980 Ext.apply.factory sencha-touch-all-debug.js:9980
Ext.define.factoryItem sencha-touch-all-debug.js:32637 Ext.define.factoryItem sencha-touch-all-debug.js:32637
Ext.define.add sencha-touch-all-debug.js:32714 Ext.define.add sencha-touch-all-debug.js:32714
doCharts doCharts.js:394 doCharts doCharts.js:394
Ext.Ajax.request.success standardFunctions.js:166 Ext.Ajax.request.success standardFunctions.js:166
Ext.apply.callback sencha-touch-all-debug.js:10268 Ext.apply.callback sencha-touch-all-debug.js:10268
Ext.define.onComplete sencha-touch-all-debug.js:35765 Ext.define.onComplete sencha-touch-all-debug.js:35765
Ext.define.onStateChange sencha-touch-all-debug.js:35709 Ext.define.onStateChange sencha-touch-all-debug.js:35709
(anonymous function) (匿名功能)

The charts are rendered to this view: 图表呈现到此视图:

Ext.define('dashboards.view.Main', {
    extend: 'Ext.Panel',
    requires: [
        'Ext.chart.*',
        'Ext.draw.sprite.Sector',
        'Ext.chart.Chart', 
        'Ext.chart.series.Column',
        'Ext.chart.AbstractChart',
        'Ext.chart.SpaceFillingChart',
        'Ext.dataview.component.Container',
        'Ext.chart.series.Series',
        'Ext.chart.series.Gauge',
        'Ext.carousel.Indicator',
        'Ext.carousel.Infinite',
        'Ext.carousel.Item',
        'Ext.carousel.Carousel',
        'Ext.fx.easing.EaseOut',
        'Ext.util.TranslatableGroup',
        'Ext.chart.series.Cartesian',
        'Ext.chart.series.Area',
        'Ext.chart.Label',
        'Ext.chart.Highlight',
        'Ext.chart.Callout',
        'Ext.chart.Transformable',
        'Ext.chart.series.ItemEvents',
        'Ext.chart.theme.Style',
        'Ext.draw.Color', 
        'Ext.chart.series.Bar',
        'Ext.chart.series.Column',
        'Ext.chart.axis.Gauge',
        'Ext.chart.theme.Base',
        'Ext.chart.theme.Base',
        'Ext.chart.theme.TitleStyle',
        'Ext.chart.theme.GridStyle',
        'Ext.chart.Toolbar',
        'Ext.chart.legend.View',
        'Ext.chart.Legend',
        'Ext.chart.axis.Numeric',
        'Ext.chart.axis.Category',
        'Ext.draw.Surface',
        'Ext.draw.Draw',
        'Ext.draw.Matrix',
        'Ext.draw.engine.Canvas',
        'Ext.draw.CompositeSprite',
        'Ext.fx.Frame',
        'Ext.draw.Sprite',
        'Ext.fx.Sprite',
        'Ext.draw.sprite.Sector',
        'Ext.draw.sprite.Rect',
        'Ext.chart.interactions.Abstract',
        'Ext.chart.axis.Axis',
        'Ext.chart.axis.Abstract',
        'Ext.util.SizeMonitor',
        'Ext.chart.grid.HorizontalGrid','Ext.chart.grid.VerticalGrid','Ext.draw.fx.TimingFunctions','Ext.Container','Ext.TitleBar','Ext.data.Store','Ext.data.StoreManager'
        ],
    alias: 'widget.mainview',
    id: 'mainpage',
    getSlideLeftTransition: function () {
        return { type: 'slide', direction: 'left' };
    },

    getSlideRightTransition: function () {
        return { type: 'slide', direction: 'right' };
    },
    config: {
        layout: {
            type: 'fit'
        },
        items: [
            {
                 xtype : 'container',
                 flex: 1,
                 id: 'introtext',
                 html: '<p>Please select from your dashboards above</p>'
            },
            {
                 xtype : 'selectfield',
                 store : companiesStore2,
                 name : 'companies',
                 queryMode: 'local',
                 id : 'companiesSelect',
                    itemId: 'companySelect',
                    valueField : 'companyname',
                    displayField : 'companyname',
                    style: 'overflow:hidden',
                    listeners: {
                        change: function(field,value) {
                            getStats(value)
                        }
                    }   
              },

              {
                    xtype: 'toolbar',
                    docked: 'bottom',
                    id: 'bumtoolbar',
                    items: []
                },
                {
                layout: {
                    pack: 'end'
                },
                xtype: 'titlebar',
                id: 'titlebartop',
                title: 'axisfirst Dashboards',

                docked: 'top',
                items: [
                    {
                        xtype: 'button',
                        text: 'Log Off',
                        itemId: 'logOffButton2',
                        id: 'logOffButton2',
                        align: 'right',
                        cls: 'logoffBtn',
                        scope: this,
                        listeners: {                                
                            tap: function() {
                                Ext.Msg.confirm("Log out", "Are you sure you want to logout?", function(btn) {
                                if (btn === 'yes') {
                                    logout();
                                    //Ext.Viewport.setActiveItem({ xtype: loginview });

                                  } else {
                                    return false;
                                  }
                                }, this);

                            }                           
                        }
                    }
                ]
            }]
    }


});

The chart is added using a separate .js file. 该图表是使用单独的.js文件添加的。 The code looks like this: 代码如下:

var chartgx = {
                                    cls: 'thegauge',
                                    itemId: 'gauge'+tt2,
                                    xtype: 'chart',
                                    shadow: true,
                                    store: gaugeStore,
                                    width : 'auto',
                                    animate: true,
                                    insetPadding: 50,
                                    axes: [{
                                        type: 'gauge',
                                        position: 'gauge',
                                        minimum: 0,
                                        maximum: gaugemax,
                                        steps: 10,
                                        margin: 10,
                                        direction: 'right'
                                    }],
                                    series: [{
                                        showInLegend: false,
                                        type: 'gauge',
                                        position: 'gauge',
                                        minimum: 0,
                                        maximum: gaugemax,
                                        steps: 10,
                                        margin: 10,
                                        angleField: 'CurrentValue',
                                        donut: 30,
                                        colorSet:[gaugeColor,'#e1e1e1']

                                    }]

                                };


                                var gaugeText = '<p class="gaugetitle">' + gaugeTitle + ': ' + currentValue + '</p>';
                                var chartgx2 = Ext.Container({
                                        xtype : 'container',
                                        flex: 1,
                                        layout: 'fit',
                                        cls: 'gaugeContainer',
                                        needle: true,
                                        items: chartgx, 
                                        html: gaugeText
                                   });
                                  if (gaugeTitle !== '') {
                                      allcharts.push(chartgx2);
                                  }

I have looked at AbstractChart.js and, sure enough, it is calling the function. 我看过AbstractChart.js,可以肯定的是,它正在调用该函数。 I have searched my entire directory (inc /app and /src) but cannot find the function. 我已经搜索了整个目录(inc / app和/ src),但是找不到该函数。

I have updated all files that 'Ext.chart.AbstractChart' requires and extends, but still get the error. 我已经更新了'Ext.chart.AbstractChart'所需并扩展的所有文件,但仍然收到错误。

Can someone please tell me which class the function belongs to, so I can update from docs.sencha.com, or, alternatively, tell me how to correct this error. 有人可以告诉我该函数属于哪个类,以便可以从docs.sencha.com更新,或者,可以告诉我如何更正此错误。

About your question, your "series" is defined on AbstractChart . 关于您的问题,您的“系列”是在AbstractChart上定义的。 Your chart extends AbstractChart so you dont need to add the require of it (AbstractChart). 您的图表扩展了AbstractChart,因此您无需添加它的需求(AbstractChart)。 The method getSeries is generated by the sencha-touch core. getSeries方法由sencha-touch核心生成。 All fields of a object that extends Ext.base has the get[MyField] and set[MyField]. 扩展Ext.base的对象的所有字段都具有get [MyField]和set [MyField]。

The error is happing on this function. 错误在于此功能。 When it trys to getShowInLegend. 尝试获取getShowInLegend时。 But each item of Series has the method getShowInLegend, you can confirm looking here on showInLegend: true, line. 但是Series的每个项目都具有方法getShowInLegend,您可以在showInLegend: true,上确认此处showInLegend: true,行。

Like I said in the first line, all objects that extends Ext.base have the get[MyField] method and Ext-chart-series-Series extends to Ext.base. 就像我在第一行中所说的那样,所有扩展Ext.base的对象都具有get [MyField]方法,而Ext-chart-series-Series扩展到Ext.base。

With this informations the problem is probably some misunderstanding on building the chart. 有了这些信息,问题可能是在构建图表时的一些误解。 But we dont have enogh information of how your chartgx is created. 但是我们没有关于Chartgx如何创建的完整信息。 Have you used the Ext.create? 您是否使用过Ext.create?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM