简体   繁体   English

我正在尝试一个应用程序,该应用程序可以绘制商店中的图表。 它倾向于显示轴,但不显示图形线和点

[英]im trying out an app ,that plots charts from the store. It tends to display the axes but not the graphical lines and point

the store works fine for the rest of the app but im not able to use that data and plot that data in the graph. 该商店可在应用程序的其余部分正常工作,但无法使用该数据并在图表中绘制该数据。

i have done some basic work with the little knowledge i have with charts. 我已经掌握了一些图表方面的知识,从而完成了一些基础工作。

i tried out with other examples which work but im not able to figure out the problem with this. 我尝试了其他可行的示例,但是我无法解决这个问题。 the console says:Uncaught TypeError: Cannot read property '1' of undefined 控制台说:Uncaught TypeError:无法读取未定义的属性“ 1”

i have installed ruby,compass and sass 我已经安装了ruby,compass和sass

view: 视图:

Ext.define('CSBApp.view.graph', {
extend: 'Ext.chart.CartesianChart',
requires: [
    'Ext.TitleBar',
    'Ext.chart.CartesianChart',
    'Ext.chart.series.Line',
    'Ext.chart.axis.Numeric',
    'Ext.chart.axis.Category',
    'Ext.draw.sprite.Circle',

],
xtype: 'graph',
config: {
    flex: 1,
    xtype: 'chart',
    store: 'mystore',
    cls: 'chart',
    innerPadding: 10,
    animate: true,
    series: [
        {
            type: 'line',
            xField: 'date',
            yField: 'amount',
            title: 'Expenses',
            style: {
                stroke: '#003366',
                lineWidth: 3
            },
            marker: {
                type: 'circle',
                stroke: '#003366',
                radius: 5,
                lineWidth: 3
            }
        }
    ],
    axes: [
        {
            type: 'numeric',
            position: 'left',
            title: {
                fontSize: 15,
                text: 'Amount'
            },
            grid: {
                even: {
                    fill: '#f9f9f9'
                }
            }
        },
        {
            type: 'numeric',
            position: 'bottom',
            title: {
                fontSize: 15,
                text: 'date'
            },
            grid: {
                even: {
                    fill: '#f9f9f9'
                }
            }
        }
    ]
}
});

modal: 模式:

 Ext.define('CSBApp.model.expensemodel',{
 extend: 'Ext.data.Model',


   config: {

        identifier:{
          type:'uuid'
        },
       fields: [
        {
          name:'desc',
          type:'string'
        },

       {
          name: 'amount',
          type:'number'
       },
       {
          name: 'date',
          type:'date',
          defaultformat: 'Y-m-d' 
       },

       ],
       // autoLoad : true

 }
});

store: 商店:

Ext.define('CSBApp.store.mystore',{
extend : 'Ext.data.Store',

config : {
    model : 'CSBApp.model.expensemodel',
    storeId : 'mysqlstore',

    proxy : {
        type : 'sql',
        id : 'mystore',
        reader: {
            type: "sql"

        }

    },
    autoLoad : true
}
});

i have kind of figured it out. 我有点想通了。 the basic problem resides in the view and how it calls the store. 基本问题在于视图及其调用存储的方式。 so the app seems to work fine with the sql store. 因此该应用似乎可以与sql存储正常工作。 the main factor is that the 'requires' files have to be correct. 主要因素是“要求”文件必须正确。

here is the view: 这是视图:

Ext.define('CSBApp.view.graph', {
extend: 'Ext.chart.CartesianChart',
xtype: 'graph',

requires: [
    'Ext.chart.series.Line',
    'Ext.chart.axis.Numeric',
    'Ext.chart.axis.Category',
    'Ext.chart.CartesianChart',
    'Ext.chart.axis.layout.CombineDuplicate',
    'Ext.chart.axis.segmenter.Names'
],

config: {

   store:'mysqlstore' ,
   width : '100%',
   layout:'fit',
axes: [{
    type: 'numeric',
    position: 'left',
    title: {
        text: 'Sample Values',
        fontSize: 15
    },
    minimum:0,
    fields: 'amount'
    },

 {
    type: 'category',
    position: 'bottom',
    title: {
        text: 'Sample Values',
        fontSize: 15
    },
    fields: 'date',
    minimum:0,
}],
series: [{
    type: 'line',
    xField: 'date',
    yField: 'amount',
    minimum:0,
style: {
                stroke: '#003366',
                lineWidth: 3
            },

marker: {
                type: 'circle',
                stroke: '#003366',
                radius: 5,
                lineWidth: 3,

                }
            }
}]
}
});

this is pretty correct if you get the store rite. 如果您得到了商店礼仪,这是非常正确的。

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

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