From 3e9bfe23d6293fb6dfa756cac2f63ecc337786ef Mon Sep 17 00:00:00 2001 From: Alexandre Rocha Lima e Marcondes Date: Wed, 29 Aug 2012 16:39:36 -0300 Subject: [PATCH] * Stream #2 Dimension correction * Interaction with data dump on tables sample --- examples/crossfilterWithDimentions.html | 4 +- examples/crossfilterWithTables.html | 270 ++++++++++++++++++++++++ src/models/lineWithFocusChart.js | 13 ++ 3 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 examples/crossfilterWithTables.html diff --git a/examples/crossfilterWithDimentions.html b/examples/crossfilterWithDimentions.html index ed9420e..62eb007 100644 --- a/examples/crossfilterWithDimentions.html +++ b/examples/crossfilterWithDimentions.html @@ -138,13 +138,13 @@ function testCrossfilterData() { data.datum.reduce(function (p, v) { p.count++; p.stream1 += v.stream1; - p.stream1 += v.stream2; + p.stream2 += v.stream2; p.stream3 += v.stream3; return p; }, function (p, v) { p.count--; p.stream1 -= v.stream1; - p.stream1 -= v.stream2; + p.stream2 -= v.stream2; p.stream3 -= v.stream3; return p; }, function () { return {count: 0, stream1: 0, stream2: 0, stream3: 0}; }); diff --git a/examples/crossfilterWithTables.html b/examples/crossfilterWithTables.html new file mode 100644 index 0000000..5e91352 --- /dev/null +++ b/examples/crossfilterWithTables.html @@ -0,0 +1,270 @@ + + + + + + + + +
+ +
+
+

Stream #1

+
+
+

Stream #2

+
+
+

Stream #3

+
+ + + + + + + + + + + + + diff --git a/src/models/lineWithFocusChart.js b/src/models/lineWithFocusChart.js index 384d6bb..94a1661 100644 --- a/src/models/lineWithFocusChart.js +++ b/src/models/lineWithFocusChart.js @@ -35,6 +35,8 @@ nv.models.lineWithFocusChart = function() { , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') ; + + var onClick = null; lines .clipEdge(true) @@ -378,6 +380,11 @@ nv.models.lineWithFocusChart = function() { brushExtent = brush.empty() ? null : brush.extent(); extent = brush.empty() ? x2.domain() : brush.extent(); + if (onClick !== undefined && onClick !== null) { + onClick(extent); + } + + updateBrushBG(); // Update Main (Focus) @@ -542,6 +549,12 @@ nv.models.lineWithFocusChart = function() { y2Axis.tickFormat(_); return chart; }; + + chart.onClick = function(_) { + if (!arguments.length) return onClick; + onClick = _; + return chart; + }; //============================================================