Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix #377: Ensure multi renderer consults it's sub renderers about how…

… they perceive their domain
  • Loading branch information...
commit 6e52a834622ff8985135f5e22ba981ceeb9dd68d 1 parent 8087c85
@dwt dwt authored
View
10 src/js/Rickshaw.Graph.Renderer.Multi.js
@@ -41,8 +41,14 @@ Rickshaw.Graph.Renderer.Multi = Rickshaw.Class.create( Rickshaw.Graph.Renderer,
.map( function(s) { return s.stack });
if (!data.length) return;
-
- var domain = $super(data);
+
+ var domain = null;
+ if (group.renderer && group.renderer.domain) {
+ domain = group.renderer.domain(data);
+ }
+ else {
+ domain = $super(data);
+ }
domains.push(domain);
});
View
51 tests/Rickshaw.Graph.Renderer.Multi.js
@@ -0,0 +1,51 @@
+var Rickshaw = require("../rickshaw");
+
+exports['should determine domain from subrenderers'] = function(test) {
+
+ // document comes from jsdom
+ var el = document.createElement("div");
+
+ Rickshaw.namespace('Rickshaw.Graph.Renderer.DomainSubrenderer');
+ Rickshaw.Graph.Renderer.DomainSubrenderer = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
+ name: 'domain',
+ domain: function(data) {
+ return {x: [-10, 20], y: [-15, 30]};
+ }
+ });
+
+ var graph = new Rickshaw.Graph({
+ element: el, width: 960, height: 500,
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
+ renderer: 'domain',
+ series: [
+ {
+ color: 'steelblue',
+ data: [
+ { x: 0, y: 40 },
+ { x: 1, y: 49 }
+ ]
+ }
+ ]
+ });
+ test.deepEqual(graph.renderer.domain(), {x: [-10, 20], y: [-15, 30]});
+
+
+ var graph = new Rickshaw.Graph({
+ element: el, width: 960, height: 500,
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
+ renderer: 'multi',
+ series: [
+ {
+ renderer: 'domain',
+ data: [
+ { x: 0, y: 40 },
+ { x: 1, y: 49 }
+ ]
+ }
+ ]
+ });
+ test.deepEqual(graph.renderer.domain(), {x: [-10, 20], y: [-15, 30]});
+
+ test.done();
+};
+
Please sign in to comment.
Something went wrong with that request. Please try again.