PDA

View Full Version : [FIXED][PR3] Bar Chart names are reverse

mitchellsimoens
10 Mar 2011, 1:07 PM
In your Bar Chart example, did you know the month names are opposite? January should be on top according to the store's data. In this picture, the number of hits is based on the data1 field in the record. Notice that January has 99 as it's data1 except the image says 53 but December has 99. I went through the records and they are inverse what they should be.

http://www.simoens.org/bugs/bar%20chart%20month%20error.png

mitchellsimoens
10 Mar 2011, 2:47 PM
Override that works for my testing. I just unshifts instead of pushes so that the ordered is inverse:

Ext.override(Ext.chart.axis.Axis, {
drawAxis: function (init) {
var me = this,
x = me.x,
y = me.y,
gutterX = me.chart.maxGutter[0],
gutterY = me.chart.maxGutter[1],
dashSize = me.dashSize,
length = me.length,
position = me.position,
inflections = [],
calcLabels = false,
stepCalcs = me.applyData(),
step = stepCalcs.step,
steps = stepCalcs.steps,
from = stepCalcs.from,
to = stepCalcs.to,
trueLength,
currentX,
currentY,
path,
prev,
delta;

//If no steps are specified
//then don't draw the axis. This generally happens
//when an empty store.
if (isNaN(step) || (from == to)) {
return;
}

me.from = stepCalcs.from;
me.to = stepCalcs.to;
if (position == 'left' || position == 'right') {
currentX = Math.floor(x) + 0.5;
path = ["M", currentX, y, "l", 0, -length];
trueLength = length - (gutterY * 2);
}
else {
currentY = Math.floor(y) + 0.5;
path = ["M", x, currentY, "l", length, 0];
trueLength = length - (gutterX * 2);
}

delta = trueLength / (steps || 1);
if (me.type == 'Numeric') {
calcLabels = true;
me.labels = [stepCalcs.from];
}
if (position == 'right' || position == 'left') {
currentY = y - gutterY;
currentX = x - ((position == 'left') * dashSize * 2);
while (currentY >= y - gutterY - trueLength) {
path = path.concat(["M", currentX, Math.floor(currentY) + 0.5, "l", dashSize * 2 + 1, 0]);
inflections.unshift([ Math.floor(x), Math.floor(currentY) ]);
currentY -= delta;
if (calcLabels) {
me.labels.push(me.labels[me.labels.length -1] + step);
}
}
if (Math.round(currentY + delta - (y - gutterY - trueLength))) {
path = path.concat(["M", currentX, Math.floor(y - length + gutterY) + 0.5, "l", dashSize * 2 + 1, 0]);
inflections.unshift([ Math.floor(x), Math.floor(currentY) ]);
if (calcLabels) {
me.labels.push(me.labels[me.labels.length -1] + step);
}
}
} else {
currentX = x + gutterX;
currentY = y - (!!(position == 'top') * dashSize * 2);
while (currentX <= x + gutterX + trueLength) {
path = path.concat(["M", Math.floor(currentX) + 0.5, currentY, "l", 0, dashSize * 2 + 1]);
inflections.push([ Math.floor(currentX), Math.floor(y) ]);
currentX += delta;
if (calcLabels) {
me.labels.push(me.labels[me.labels.length -1] + step);
}
}
if (Math.round(currentX - delta - (x + gutterX + trueLength))) {
path = path.concat(["M", Math.floor(x + length - gutterX) + 0.5, currentY, "l", 0, dashSize * 2 + 1]);
inflections.push([ Math.floor(currentX), Math.floor(y) ]);
if (calcLabels) {
me.labels.push(me.labels[me.labels.length -1] + step);
}
}
}
if (!me.axis) {
type: 'path',
path: path
}, me.axisStyle));
}
me.axis.setAttributes({
path: path
}, true);
me.inflections = inflections;
if (!init && me.grid) {
me.drawGrid();
}
me.axisBBox = me.axis.getBBox();
me.drawLabels();
}
});

evant
10 Mar 2011, 5:49 PM
Should be resolved in the next release.