Skip to content

Commit

Permalink
make barChart.onClick a proper override
Browse files Browse the repository at this point in the history
fixes the common complaint that it's hard to add click-bar behavior
to charts with quantitative scales, e.g. #168
  • Loading branch information
gordonwoodhull committed Jan 21, 2015
1 parent ebae20a commit 074e222
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
9 changes: 5 additions & 4 deletions dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,7 @@ dc.baseMixin = function (_chart) {
**/
_chart.renderlet = dc.logger.deprecate(function (_) {
_chart.on('renderlet.' + dc.utils.uniqueId(), _);
return _chart;
}, 'chart.renderlet has been deprecated. Please use chart.on("renderlet.<renderletKey>", renderletFunction)');

/**
Expand Down Expand Up @@ -4252,7 +4253,7 @@ dc.barChart = function (parent, chartGroup) {
}

if (_chart.isOrdinal()) {
bars.on('click', onClick);
bars.on('click', _chart.onClick);
}

dc.transition(bars, _chart.transitionDuration())
Expand Down Expand Up @@ -4349,9 +4350,9 @@ dc.barChart = function (parent, chartGroup) {
return _chart;
};

function onClick(d) {
_chart.onClick(d.data);
}
dc.override(_chart, 'onClick', function (d) {
_chart._onClick(d.data);
});

/**
#### .barPadding([padding])
Expand Down
4 changes: 2 additions & 2 deletions dc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dc.min.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/bar-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ dc.barChart = function (parent, chartGroup) {
}

if (_chart.isOrdinal()) {
bars.on('click', onClick);
bars.on('click', _chart.onClick);
}

dc.transition(bars, _chart.transitionDuration())
Expand Down Expand Up @@ -196,9 +196,9 @@ dc.barChart = function (parent, chartGroup) {
return _chart;
};

function onClick(d) {
_chart.onClick(d.data);
}
dc.override(_chart, 'onClick', function (d) {
_chart._onClick(d.data);
});

/**
#### .barPadding([padding])
Expand Down
9 changes: 5 additions & 4 deletions web/js/dc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,7 @@ dc.baseMixin = function (_chart) {
**/
_chart.renderlet = dc.logger.deprecate(function (_) {
_chart.on('renderlet.' + dc.utils.uniqueId(), _);
return _chart;
}, 'chart.renderlet has been deprecated. Please use chart.on("renderlet.<renderletKey>", renderletFunction)');

/**
Expand Down Expand Up @@ -4252,7 +4253,7 @@ dc.barChart = function (parent, chartGroup) {
}

if (_chart.isOrdinal()) {
bars.on('click', onClick);
bars.on('click', _chart.onClick);
}

dc.transition(bars, _chart.transitionDuration())
Expand Down Expand Up @@ -4349,9 +4350,9 @@ dc.barChart = function (parent, chartGroup) {
return _chart;
};

function onClick(d) {
_chart.onClick(d.data);
}
dc.override(_chart, 'onClick', function (d) {
_chart._onClick(d.data);
});

/**
#### .barPadding([padding])
Expand Down

0 comments on commit 074e222

Please sign in to comment.