Created
August 15, 2012 06:28
-
-
Save ctavan/3357059 to your computer and use it in GitHub Desktop.
Patch against Ext-JS 4.0.2a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/chart/axis/Axis.js b/chart/axis/Axis.js | |
index ee759b8..ff886cd 100644 | |
--- a/chart/axis/Axis.js | |
+++ b/chart/axis/Axis.js | |
@@ -242,9 +242,11 @@ Ext.define('Ext.chart.axis.Axis', { | |
if (me.adjustMaximumByMajorUnit) { | |
out.to += out.step; | |
+ out.steps++; | |
} | |
if (me.adjustMinimumByMajorUnit) { | |
out.from -= out.step; | |
+ out.steps++; | |
} | |
me.prevMin = min == max? 0 : min; | |
me.prevMax = max; | |
@@ -256,7 +258,7 @@ Ext.define('Ext.chart.axis.Axis', { | |
*/ | |
drawAxis: function (init) { | |
var me = this, | |
- i, j, | |
+ i, j, c, | |
x = me.x, | |
y = me.y, | |
gutterX = me.chart.maxGutter[0], | |
@@ -276,11 +278,14 @@ Ext.define('Ext.chart.axis.Axis', { | |
trueLength, | |
currentX, | |
currentY, | |
+ base, | |
+ dashPos, subDashPos, | |
path, | |
prev, | |
dashesX, | |
dashesY, | |
- delta; | |
+ delta, | |
+ scale; | |
//If no steps are specified | |
//then don't draw the axis. This generally happens | |
@@ -301,6 +306,7 @@ Ext.define('Ext.chart.axis.Axis', { | |
path = ["M", x, currentY, "l", length, 0]; | |
trueLength = length - (gutterX * 2); | |
} | |
+ scale = trueLength/(me.to - me.from); | |
delta = trueLength / (steps || 1); | |
dashesX = Math.max(subDashesX +1, 0); | |
@@ -309,18 +315,23 @@ Ext.define('Ext.chart.axis.Axis', { | |
calcLabels = true; | |
me.labels = [stepCalcs.from]; | |
} | |
+ c = 0; | |
if (position == 'right' || position == 'left') { | |
currentY = y - gutterY; | |
+ base = currentY; | |
currentX = x - ((position == 'left') * dashSize * 2); | |
while (currentY >= y - gutterY - trueLength) { | |
- path.push("M", currentX, Math.floor(currentY) + 0.5, "l", dashSize * 2 + 1, 0); | |
+ dashPos = base-this.valueToLocal(step*c)*scale; | |
+ path.push("M", currentX, Math.floor(dashPos) + 0.5, "l", dashSize * 2 + 1, 0); | |
if (currentY != y - gutterY) { | |
for (i = 1; i < dashesY; i++) { | |
- path.push("M", currentX + dashSize, Math.floor(currentY + delta * i / dashesY) + 0.5, "l", dashSize + 1, 0); | |
+ subDashPos = base - this.valueToLocal(step*(c-1) + step*i/dashesY)*scale; | |
+ path.push("M", currentX + dashSize, Math.floor(subDashPos) + 0.5, "l", dashSize + 1, 0); | |
} | |
} | |
- inflections.push([ Math.floor(x), Math.floor(currentY) ]); | |
+ inflections.push([ Math.floor(x), Math.floor(dashPos) ]); | |
currentY -= delta; | |
+ c++; | |
if (calcLabels) { | |
me.labels.push(me.labels[me.labels.length -1] + step); | |
} | |
@@ -331,8 +342,10 @@ Ext.define('Ext.chart.axis.Axis', { | |
if (Math.round(currentY + delta - (y - gutterY - trueLength))) { | |
path.push("M", currentX, Math.floor(y - length + gutterY) + 0.5, "l", dashSize * 2 + 1, 0); | |
for (i = 1; i < dashesY; i++) { | |
+ //@TODO use this.valueToLocal() instead of currentY to enable logarithmic (and other) axis scalings with gutter | |
path.push("M", currentX + dashSize, Math.floor(y - length + gutterY + delta * i / dashesY) + 0.5, "l", dashSize + 1, 0); | |
} | |
+ //@TODO use this.valueToLocal() instead of currentY to enable logarithmic (and other) axis scalings with gutter | |
inflections.push([ Math.floor(x), Math.floor(currentY) ]); | |
if (calcLabels) { | |
me.labels.push(me.labels[me.labels.length -1] + step); | |
@@ -340,16 +353,20 @@ Ext.define('Ext.chart.axis.Axis', { | |
} | |
} else { | |
currentX = x + gutterX; | |
+ base = currentX; | |
currentY = y - ((position == 'top') * dashSize * 2); | |
while (currentX <= x + gutterX + trueLength) { | |
- path.push("M", Math.floor(currentX) + 0.5, currentY, "l", 0, dashSize * 2 + 1); | |
+ dashPos = base+this.valueToLocal(step*c)*scale; | |
+ path.push("M", Math.floor(dashPos) + 0.5, currentY, "l", 0, dashSize * 2 + 1); | |
if (currentX != x + gutterX) { | |
for (i = 1; i < dashesX; i++) { | |
- path.push("M", Math.floor(currentX - delta * i / dashesX) + 0.5, currentY, "l", 0, dashSize + 1); | |
+ subDashPos = base + this.valueToLocal(step*c - step*i/dashesX)*scale; | |
+ path.push("M", Math.floor(subDashPos) + 0.5, currentY, "l", 0, dashSize + 1); | |
} | |
} | |
- inflections.push([ Math.floor(currentX), Math.floor(y) ]); | |
+ inflections.push([ Math.floor(dashPos), Math.floor(y) ]); | |
currentX += delta; | |
+ c++; | |
if (calcLabels) { | |
me.labels.push(me.labels[me.labels.length -1] + step); | |
} | |
@@ -360,8 +377,10 @@ Ext.define('Ext.chart.axis.Axis', { | |
if (Math.round(currentX - delta - (x + gutterX + trueLength))) { | |
path.push("M", Math.floor(x + length - gutterX) + 0.5, currentY, "l", 0, dashSize * 2 + 1); | |
for (i = 1; i < dashesX; i++) { | |
+ //@TODO use this.valueToLocal() instead of currentY to enable logarithmic (and other) axis scalings with gutter | |
path.push("M", Math.floor(x + length - gutterX - delta * i / dashesX) + 0.5, currentY, "l", 0, dashSize + 1); | |
} | |
+ //@TODO use this.valueToLocal() instead of currentY to enable logarithmic (and other) axis scalings with gutter | |
inflections.push([ Math.floor(currentX), Math.floor(y) ]); | |
if (calcLabels) { | |
me.labels.push(me.labels[me.labels.length -1] + step); | |
@@ -822,5 +841,9 @@ Ext.define('Ext.chart.axis.Axis', { | |
y: y | |
} | |
}, true); | |
+ }, | |
+ | |
+ valueToLocal: function(value) { | |
+ return value; | |
} | |
}); | |
diff --git a/chart/axis/Numeric.js b/chart/axis/Numeric.js | |
index 2c505db..6e5c109 100644 | |
--- a/chart/axis/Numeric.js | |
+++ b/chart/axis/Numeric.js | |
@@ -192,6 +192,23 @@ Ext.define('Ext.chart.axis.Numeric', { | |
applyData: function() { | |
this.callParent(); | |
return this.calcEnds(); | |
+ }, | |
+ | |
+ calcEnds: function() { | |
+ var ends = this.callParent(); | |
+ if (this.scale == 'logarithmic') { | |
+ ends.from = ends.from <= 0 ? 0 : Math.log(ends.from); | |
+ ends.to = Math.log(ends.to); | |
+ } | |
+ return ends; | |
+ }, | |
+ | |
+ valueToLocal: function(value) { | |
+ if (this.scale == 'logarithmic') { | |
+ return value <= 0 ? 0 : Math.log(value); | |
+ } | |
+ return value; | |
} | |
+ | |
}); | |
diff --git a/chart/series/Scatter.js b/chart/series/Scatter.js | |
index d2048f1..099506f 100644 | |
--- a/chart/series/Scatter.js | |
+++ b/chart/series/Scatter.js | |
@@ -141,7 +141,8 @@ Ext.define('Ext.chart.series.Scatter', { | |
chart = me.chart, | |
store = chart.substore || chart.store, | |
axes = [].concat(me.axis), | |
- bbox, xScale, yScale, ln, minX, minY, maxX, maxY, i, axis, ends; | |
+ bbox, xScale, yScale, ln, minX, minY, maxX, maxY, i, axis, ends, | |
+ xAxis, yAxis; | |
me.setBBox(); | |
bbox = me.bbox; | |
@@ -153,10 +154,12 @@ Ext.define('Ext.chart.series.Scatter', { | |
if (axis.position == 'top' || axis.position == 'bottom') { | |
minX = ends.from; | |
maxX = ends.to; | |
+ xAxis = chart.axes.get(axes[i]); | |
} | |
else { | |
minY = ends.from; | |
maxY = ends.to; | |
+ yAxis = chart.axes.get(axes[i]); | |
} | |
} | |
} | |
@@ -200,6 +203,8 @@ Ext.define('Ext.chart.series.Scatter', { | |
bbox: bbox, | |
minX: minX, | |
minY: minY, | |
+ xAxis: xAxis, | |
+ yAxis: yAxis, | |
xScale: xScale, | |
yScale: yScale | |
}; | |
@@ -214,6 +219,8 @@ Ext.define('Ext.chart.series.Scatter', { | |
group = me.group, | |
bounds = me.bounds = me.getBounds(), | |
bbox = me.bbox, | |
+ xAxis = bounds.xAxis, | |
+ yAxis = bounds.yAxis, | |
xScale = bounds.xScale, | |
yScale = bounds.yScale, | |
minX = bounds.minX, | |
@@ -244,8 +251,8 @@ Ext.define('Ext.chart.series.Scatter', { | |
if (typeof yValue == 'string' || typeof yValue == 'object') { | |
yValue = i; | |
} | |
- x = boxX + (xValue - minX) * xScale; | |
- y = boxY + boxHeight - (yValue - minY) * yScale; | |
+ x = boxX + (xAxis.valueToLocal(xValue) - xAxis.valueToLocal(minX)) * xScale; | |
+ y = boxY + boxHeight - (yAxis.valueToLocal(yValue) - yAxis.valueToLocal(minY)) * yScale; | |
attrs.push({ | |
x: x, | |
y: y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Scatter_orig.js 2011-09-02 15:19:19.000000000 +0200 | |
+++ Scatter.js 2011-09-02 15:23:18.000000000 +0200 | |
@@ -373,12 +373,21 @@ | |
shadowGroups = me.shadowGroups, | |
shadowAttributes = me.shadowAttributes, | |
lnsh = shadowGroups.length, | |
- sprite, attrs, attr, ln, i, endMarkerStyle, shindex, type, shadows, | |
+ sprite, attrs, attr, ln, i, endMarkerStyle, shadowEndMarkerStyle, | |
+ shindex, type, shadowType, shadows, | |
rendererAttributes, shadowAttribute; | |
endMarkerStyle = Ext.apply(me.markerStyle, me.markerConfig); | |
- type = endMarkerStyle.type; | |
+ shadowEndMarkerStyle = Ext.apply({}, endMarkerStyle); | |
+ type = shadowType = endMarkerStyle.type; | |
delete endMarkerStyle.type; | |
+ delete shadowEndMarkerStyle.type; | |
+ if (shadowEndMarkerStyle.src) { | |
+ delete shadowEndMarkerStyle.src; | |
+ } | |
+ if (type == 'image') { | |
+ shadowType = 'square'; | |
+ } | |
//if the store is empty then there's nothing to be rendered | |
if (!store || !store.getCount()) { | |
@@ -395,15 +404,24 @@ | |
sprite = group.getAt(i); | |
Ext.apply(attr, endMarkerStyle); | |
+ if (attr.src && typeof attr.src == 'function') { | |
+ attr.fnSrc = attr.src; | |
+ attr.src = attr.src(this, store.getAt(i), i); | |
+ } | |
+ | |
// Create a new sprite if needed (no height) | |
if (!sprite) { | |
sprite = me.createPoint(attr, type); | |
if (enableShadows) { | |
- me.createShadow(sprite, endMarkerStyle, type); | |
+ me.createShadow(sprite, shadowEndMarkerStyle, shadowType); | |
} | |
} | |
shadows = sprite.shadows; | |
+ // src property cannot be animated, so set it directly | |
+ if (attr.src) { | |
+ sprite.setAttributes({src: attr.src}, true); | |
+ } | |
if (chart.animate) { | |
rendererAttributes = me.renderer(sprite, store.getAt(i), { translate: attr }, i, store); | |
sprite._to = rendererAttributes; | |
@@ -427,10 +445,12 @@ | |
sprite.setAttributes(rendererAttributes, true); | |
//update shadows | |
for (shindex = 0; shindex < lnsh; shindex++) { | |
- shadowAttribute = shadowAttributes[shindex]; | |
- rendererAttributes = me.renderer(shadows[shindex], store.getAt(i), Ext.apply({ | |
- x: attr.x, | |
- y: attr.y | |
+ shadowAttribute = Ext.apply({}, shadowAttributes[shindex]); | |
+ rendererAttributes = me.renderer(shadows[shindex], store.getAt(i), Ext.apply({}, { | |
+ translate: { | |
+ x: attr.x + (shadowAttribute.translate? shadowAttribute.translate.x : 0), | |
+ y: attr.y + (shadowAttribute.translate? shadowAttribute.translate.y : 0) | |
+ } | |
}, shadowAttribute), i, store); | |
shadows[shindex].setAttributes(rendererAttributes, true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Shape_orig.js 2011-09-01 16:54:43.000000000 +0200 | |
+++ Shape.js 2011-09-01 18:44:39.000000000 +0200 | |
@@ -24,6 +24,17 @@ | |
/* End Definitions */ | |
+ image: function (surface, opts) { | |
+ return surface.add(Ext.applyIf({ | |
+ type: 'image', | |
+ x: opts.x - opts.radius, | |
+ y: opts.y - opts.radius, | |
+ height: 2 * opts.radius, | |
+ width: 2 * opts.radius, | |
+ radius: null, | |
+ src: opts.src | |
+ }, opts)); | |
+ }, | |
circle: function (surface, opts) { | |
return surface.add(Ext.apply({ | |
type: 'circle', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment