PDA

View Full Version : [OPEN] bug in Ext.draw.Draw.snapEndsByDateAndSteps



JSGuy
22 Feb 2012, 3:16 AM
REQUIRED INFORMATION
Ext version tested:

Ext 4.0.7, 4.1b1, 4.1b2

Browser versions tested against:

Firefox 10
Chrome 17

Description:

There are two missing brackets in the Ext.draw.Draw.snapEndsByDateAndSteps method. This leads to a wrong calculation of the ends.

Steps to reproduce the problem:

see the attached example

The result that was expected:

correct calculation of the steps and ends

The result that occurs instead:

totally wrong calculation of the steps (NaN)

Test Case:


Ext.onReady(function() {

Ext.define('Point', {
extend : 'Ext.data.Model',
fields : ['y', {
name : 'date',
type : 'date',
dateFormat : 'timestamp',
}]
});

var store = Ext.create('Ext.data.Store', {
model : 'Point',
data : [{
y : 1,
date : 1316815200
}, {
y : 30,
date : 1319407200
}, {
y : 34,
date : 1322089200
}]
});

var chart = Ext.create('Ext.chart.Chart', {
store : store,
style : 'background:#fff',
axes : [{
type : 'Numeric',
position : 'left',
fields : 'y',
title : 'Y',
}, {
type : 'Time',
dateFormat : 'd.',
step : [Ext.Date.DAY, 7],
minorTickSteps : 6,
position : 'bottom',
fields : 'date',
title : 'Time',
fromDate : new Date(1316815200000),
toDate : new Date(1322089200000)
}],
series : [{
type : 'line',
axis : 'left',
xField : 'date',
yField : 'y',
axis : ['left', 'bottom'],
}]
})

var win = Ext.create('Ext.Window', {
width : 800,
height : 600,
hidden : false,
title : 'Line Chart',
renderTo : Ext.getBody(),
layout : 'fit',
items : chart
});

chart.redraw(true);
});


HELPFUL INFORMATION
Possible fix:

apply the following change to the mentioned method:



case Ext.Date.DAY:
//introduce brackets in Math.floor around fromStat[2] - 1!
testFrom = new Date(fromStat[0], fromStat[1],
Math.floor((fromStat[2] - 1) / step[1]) * step[1] + 1, 0, 0, 0, 0);
break;


Additional CSS used:

only default ext-all.css

Operating System:

Linux

mitchellsimoens
22 Feb 2012, 7:52 AM
Thanks for the report.