Skip to content

Commit 27a59d8

Browse files
replace last few unnecessary/misleading selectAll
if it's always one item, and it's matched by an append or insert (which do `select` internally), it should be a `select` fixes #1239
1 parent dbb1123 commit 27a59d8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 2.0 Series
22
## 2.0.0
33
* Bubble chart and heatmap correctly re-select (not selectAll) the sub-components in order to correctly apply new data when redrawn. This affects uses of dc.js where the data is replaced instead of being modified in place. (For example, the case where crossfilter is not used.) By Steffen Dienst and Matt Traynham. ([#1032](https://github.com/dc-js/dc.js/pull/1032), [#1237](https://github.com/dc-js/dc.js/pull/1237))
4+
* Further changed other unnecessary uses of `selectAll` to `select` - when appending or inserting a single element, one should almost always match that with `select` for updates. ([#1239](https://github.com/dc-js/dc.js/issues/1239))
45
* Heatmap column/row filtering is a lot faster ([#649](https://github.com/dc-js/dc.js/issues/649))
56
* `colorMixin.colorCalculator` properly documented and deprecated ([#1225](https://github.com/dc-js/dc.js/issues/1225))
67
* Development dependencies upgraded, by Matt Traynham ([#1233](https://github.com/dc-js/dc.js/pull/1233))

src/coordinate-grid-mixin.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,15 @@ dc.coordinateGridMixin = function (_chart) {
518518
}
519519

520520
_chart.renderXAxis = function (g) {
521-
var axisXG = g.selectAll('g.x');
521+
var axisXG = g.select('g.x');
522522

523523
if (axisXG.empty()) {
524524
axisXG = g.append('g')
525525
.attr('class', 'axis x')
526526
.attr('transform', 'translate(' + _chart.margins().left + ',' + _chart._xAxisY() + ')');
527527
}
528528

529-
var axisXLab = g.selectAll('text.' + X_AXIS_LABEL_CLASS);
529+
var axisXLab = g.select('text.' + X_AXIS_LABEL_CLASS);
530530
if (axisXLab.empty() && _chart.xAxisLabel()) {
531531
axisXLab = g.append('text')
532532
.attr('class', X_AXIS_LABEL_CLASS)
@@ -547,7 +547,7 @@ dc.coordinateGridMixin = function (_chart) {
547547
};
548548

549549
function renderVerticalGridLines (g) {
550-
var gridLineG = g.selectAll('g.' + VERTICAL_CLASS);
550+
var gridLineG = g.select('g.' + VERTICAL_CLASS);
551551

552552
if (_renderVerticalGridLine) {
553553
if (gridLineG.empty()) {
@@ -647,7 +647,7 @@ dc.coordinateGridMixin = function (_chart) {
647647
_chart.renderYAxisLabel = function (axisClass, text, rotation, labelXPosition) {
648648
labelXPosition = labelXPosition || _yAxisLabelPadding;
649649

650-
var axisYLab = _chart.g().selectAll('text.' + Y_AXIS_LABEL_CLASS + '.' + axisClass + '-label');
650+
var axisYLab = _chart.g().select('text.' + Y_AXIS_LABEL_CLASS + '.' + axisClass + '-label');
651651
var labelYPosition = (_chart.margins().top + _chart.yAxisHeight() / 2);
652652
if (axisYLab.empty() && text) {
653653
axisYLab = _chart.g().append('text')
@@ -664,7 +664,7 @@ dc.coordinateGridMixin = function (_chart) {
664664
};
665665

666666
_chart.renderYAxisAt = function (axisClass, axis, position) {
667-
var axisYG = _chart.g().selectAll('g.' + axisClass);
667+
var axisYG = _chart.g().select('g.' + axisClass);
668668
if (axisYG.empty()) {
669669
axisYG = _chart.g().append('g')
670670
.attr('class', 'axis ' + axisClass)
@@ -685,7 +685,7 @@ dc.coordinateGridMixin = function (_chart) {
685685
};
686686

687687
_chart._renderHorizontalGridLinesForAxis = function (g, scale, axis) {
688-
var gridLineG = g.selectAll('g.' + HORIZONTAL_CLASS);
688+
var gridLineG = g.select('g.' + HORIZONTAL_CLASS);
689689

690690
if (_renderHorizontalGridLine) {
691691
var ticks = axis.tickValues() ? axis.tickValues() : scale.ticks(axis.ticks()[0]);

0 commit comments

Comments
 (0)