diff --git a/src/row-chart.js b/src/row-chart.js index d7a16decc..04fde80da 100644 --- a/src/row-chart.js +++ b/src/row-chart.js @@ -53,6 +53,8 @@ dc.rowChart = function (parent, chartGroup) { var _rowData; + var _useRightYAxis = false; + _chart.rowsCap = _chart.cap; function calculateAxisScale() { @@ -61,8 +63,13 @@ dc.rowChart = function (parent, chartGroup) { if (extent[0] > 0) { extent[0] = 0; } - _x = d3.scale.linear().domain(extent) - .range([0, _chart.effectiveWidth()]); + + var domain = d3.scale.linear().domain(extent); + if (_useRightYAxis) { + _x = domain.range([_chart.effectiveWidth(), 0]); + } else { + _x = domain.range([0, _chart.effectiveWidth()]); + } } _xAxis.scale(_x); } @@ -387,6 +394,19 @@ dc.rowChart = function (parent, chartGroup) { return _chart; }; + /** + #### .useRightYAxis() + Gets or sets whether the chart should be drawn with a right axis instead of a left axis. + **/ + + _chart.useRightYAxis = function (_) { + if (!arguments.length) { + return _useRightYAxis; + } + _useRightYAxis = _; + return _chart; + }; + function isSelectedRow (d) { return _chart.hasFilter(_chart.cappedKeyAccessor(d)); } diff --git a/web/examples/index.html b/web/examples/index.html index 412fb599a..eb21a829c 100644 --- a/web/examples/index.html +++ b/web/examples/index.html @@ -30,13 +30,14 @@