Javascript EXT JS 4折线图显示数据不正确

Javascript EXT JS 4折线图显示数据不正确,javascript,extjs,charts,Javascript,Extjs,Charts,我的问题与上面描述的非常相似,但不完全相同 我用时间戳和一个应该显示在折线图上的整数值动态填充数据库中的图表。图表显示的数据不正确。例如,此数据集有3项,其中y=1、y=5、y=1与下面对应的X值时间戳匹配 此图表有两个项目,在X轴上指示的时间戳处y=1和y=1。问题是,图表在这里复制了两次。不知道发生了什么事 如您所见,高亮显示的元素表示点应在y=5处绘制,而不是y=1.5ish。最左边的点也应该从y=1开始,而不是y=0。我一整天都在阅读文档、论坛等,感到非常困惑。我甚至已经重写了两次这个愚

我的问题与上面描述的非常相似,但不完全相同

我用时间戳和一个应该显示在折线图上的整数值动态填充数据库中的图表。图表显示的数据不正确。例如,此数据集有3项,其中y=1、y=5、y=1与下面对应的X值时间戳匹配

此图表有两个项目,在X轴上指示的时间戳处y=1和y=1。问题是,图表在这里复制了两次。不知道发生了什么事

如您所见,高亮显示的元素表示点应在y=5处绘制,而不是y=1.5ish。最左边的点也应该从y=1开始,而不是y=0。我一整天都在阅读文档、论坛等,感到非常困惑。我甚至已经重写了两次这个愚蠢的东西,以遵循“好”的例子,这似乎也没有帮助

模型代码

  Ext.define('ROOT.model.dataset', {
    extend: 'Ext.data.Model',
    alias: 'event',
    fields: ['count', 'time'],

    constructor: function (config) {
        this.callParent(arguments);
        Ext.apply(this, config);
    }
});
图形代码

Ext.define('Root.view.ChartPanel', {
    extend: 'Ext.panel.Panel',
    title: 'Event Metrics',

    initComponent: function () {
        Ext.apply(this, {
            store: new Ext.data.SimpleStore({fields: [
            {name: 'count', type: 'int'},
            {name: 'time', type: 'string'}
            ]})
        });
        this.callParent(arguments);

        //CREATE CHART
        this.barChart = Ext.create('Ext.chart.Chart', {
            renderTo: Ext.getBody(),
            width: 700,
            height: 500,
            animate: false,
            store: this.store,

            axes: [
                {
                    type: 'Numeric',
                    position: 'left',
                    fields: ['count'],
                    label: {
                        renderer: Ext.util.Format.numberRenderer('0,0')
                    },
                    title: 'Count',
                    grid: true,
                    adjustMaximumByMajorUnit: false,
                   adjustMinimumByMajorUnit: false,
                    minorTickSteps: 5,
                    majorTickSteps: 3,
                    minimum: 0
                },
                {
                    type: 'Category',
                    position: 'bottom',
                    fields: ['time'],
                    title: 'Date'
                }
            ],

            series: [
                {
                    type: 'line',
                    axis: ['left', 'bottom'],
                    highlight: true,
                    tips: {
                        trackMouse: true,
                        width: 175,
                        height: 20,
                        renderer: function(storeItem, item) {
                            this.setTitle(storeItem.get('time') + ': ' + storeItem.get('count'));
                        }
                    },
                  /*  label: {
                        display: 'insideEnd',
                        field: 'count',
                        renderer: Ext.util.Format.numberRenderer('0'),
                        orientation: 'horizontal',
                        color: '#333',
                        'text-anchor': 'middle',
                        constrast: true
                    },*/
                    xField: 'time',
                    yField: ['count'],
                    markerConfig: {
                        type: 'cross',
                        size: 4,
                        radius: 4,
                        'stroke-width': 0
                    }
                }   
            ]
        });
        this.add(this.barChart);
    }, //end init



    refreshEventChart: function (data) {
        this.clear();
        this.store.loadData(data);
        this.barChart.redraw();
    },

    clear: function() {
        this.store.removeAll();
        this.barChart.surface.removeAll();
    }
});

如果您能帮我解决这个问题,我们将不胜感激

我发现了这个问题。事实证明,在我请求数据时,我的数据提供程序没有将字符串中的值转换为整数——因此,这张图表看起来不可靠。修改数据提供程序以确保count字段始终生成整数后,当来自服务器时,图表开始正常工作。

我发现了问题。事实证明,在我请求数据时,我的数据提供程序没有将字符串中的值转换为整数——因此,这张图表看起来不可靠。在修改数据提供程序以确保count字段始终生成整数后,当来自服务器时,图表开始正常工作。

我也遇到了同样的问题,并且在使用JSON\u NUMERIC\u CHECK将您的解决方案应用于我的php代码之后

json\u编码($response,json\u NUMERIC\u CHECK)

问题仍然没有解决

我正在动态生成我的折线图,并且在生成时必须输入最大步长值。我发现,如果最大值设置为小于5,则步长将中断,如果值为5或更大,则步长看起来很好

  axes: [{
            type: 'Numeric',
            minimum: 0,                
            maximum: maxValue,                     
            position: 'left',
            fields:  vs ,
            grid: true,
            title: 'Visitors',
            label: {
               renderer: Ext.util.Format.numberRenderer('0,0'),
                font: '10px Arial'
            }
希望这对其他人有帮助。
链接到maxValue设置为4和5的示例图像

我也遇到了同样的问题,在使用JSON\u NUMERIC\u CHECK将您的解决方案应用到我的php代码之后

json\u编码($response,json\u NUMERIC\u CHECK)

问题仍然没有解决

我正在动态生成我的折线图,并且在生成时必须输入最大步长值。我发现,如果最大值设置为小于5,则步长将中断,如果值为5或更大,则步长看起来很好

  axes: [{
            type: 'Numeric',
            minimum: 0,                
            maximum: maxValue,                     
            position: 'left',
            fields:  vs ,
            grid: true,
            title: 'Visitors',
            label: {
               renderer: Ext.util.Format.numberRenderer('0,0'),
                font: '10px Arial'
            }
希望这对其他人有帮助。
链接到maxValue设置为4和5的示例图像