ExtJs图表带有时间轴,更新问题

Sab*_*ina 5 charts extjs4

我正在使用Ext4 js来创建图表.我的图表是显示时间内事件演变的折线图,所以我的下轴是时间轴:

    {
    type: 'Time',
    position: 'bottom',
    grid: grid,
    fields: 'name',
    title: false,
    dateFormat: 'd/m/y',
    groupBy: 'year,month,day',

    aggregateOp: 'sum',
    label: {
        orientation: 'horizontal',
        rotate: {
            degrees: label_rotation
        }
    }
Run Code Online (Sandbox Code Playgroud)

我有改变比例的链接.单击其中一个链接应更改dateformat和groupby选项.这里的代码:

scaleGroups = {
    'DAY': {
    dateFormat: 'd/m/y',
        groupBy: 'year,month,day' 
    },
    'MONTH' :{
            dateFormat: 'M Y',
            groupBy: 'year,month'
    },
    'YEAR' :{
            dateFormat: 'Y',
            groupBy: 'year'
    }
};


function changeChartScale(chart_id, scale) {
    var chart = Ext.getCmp(chart_id);
    var axis = chart.axes.get(1);
    selectedGroup = scaleGroups[scale];
    axis.dateFormat = selectedGroup.dateFormat;
    axis.groupBy = selectedGroup.groupBy;

    chart.redraw();
}
Run Code Online (Sandbox Code Playgroud)

问题是从一个规模变为另一个规模,例如从几天到几个月,之前的标签仍然存在.所以这条线是正确的,但我看到了日标签和月标签.

有谁知道为什么?

先谢谢,萨布丽娜

更新07/06/2011:示例html页面上的相同代码,只导入此JavaScript库,工作.

也许这是与我使用的其他javascript库兼容的问题(Jquery,googlempas ......).有没有人遇到过同样的问题?

小智 5

我找到了一个解决方法,因为chart.redraw()方法不会自动重绘轴刻度/值.

设置轴的新最大值,然后在重绘图表之前使用axis.drawAxis()方法...

当用户在绑定网格上对列进行排序时,我的图表会重新绘制.

    chart.axes.items[0].fields = [column.dataIndex];
    chart.series.items[0].yField = [column.dataIndex];


    var s = Ext.data.StoreManager.lookup('myStore');
    var max = s.max(column.dataIndex);


    chart.axes.items[0].maximum = max;
    chart.axes.items[0].drawAxis();


    chart.redraw();
Run Code Online (Sandbox Code Playgroud)


小智 1

我想我找到了解决办法!只需将轴中的最小和最大属性设置为合理的值(即:每天设置 31,每月设置 12)。这个对我有用!