| OLD | NEW |
| 1 // | 1 // |
| 2 // Copyright 2014 Google Inc. All rights reserved. | 2 // Copyright 2014 Google Inc. All rights reserved. |
| 3 // | 3 // |
| 4 // Use of this source code is governed by a BSD-style | 4 // Use of this source code is governed by a BSD-style |
| 5 // license that can be found in the LICENSE file or at | 5 // license that can be found in the LICENSE file or at |
| 6 // https://developers.google.com/open-source/licenses/bsd | 6 // https://developers.google.com/open-source/licenses/bsd |
| 7 // | 7 // |
| 8 | 8 |
| 9 part of charted.charts; | 9 part of charted.charts; |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 _tooltipRoot.append('div') | 85 _tooltipRoot.append('div') |
| 86 ..classed('tooltip-total') | 86 ..classed('tooltip-total') |
| 87 ..text((formatter != null) ? formatter(total) : total.toString()); | 87 ..text((formatter != null) ? formatter(total) : total.toString()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Find the currently selectedMeasures and hoveredMeasures and show | 90 // Find the currently selectedMeasures and hoveredMeasures and show |
| 91 // tooltip for them, if none is selected/hovered, show all. | 91 // tooltip for them, if none is selected/hovered, show all. |
| 92 var activeMeasures = []; | 92 var activeMeasures = []; |
| 93 if (showSelectedMeasure) { | 93 if (showSelectedMeasure) { |
| 94 activeMeasures.addAll(_state.selection); | 94 if(_state != null) { |
| 95 activeMeasures | 95 activeMeasures.addAll(_state.selection); |
| 96 .add(_state.preview != null ? _state.preview : _state.hovered.first); | 96 activeMeasures |
| 97 .add(_state.preview != null |
| 98 ? _state.preview |
| 99 : _state.hovered.first); |
| 100 } else { |
| 101 |
| 102 // If state is null, chart tooltip will not capture selection, but only |
| 103 // display for the currently hovered measure column. |
| 104 activeMeasures.add(e.column); |
| 105 } |
| 97 if (activeMeasures.isEmpty) { | 106 if (activeMeasures.isEmpty) { |
| 98 for (var series in _area.config.series) { | 107 for (var series in _area.config.series) { |
| 99 activeMeasures.addAll(series.measures); | 108 activeMeasures.addAll(series.measures); |
| 100 } | 109 } |
| 101 } | 110 } |
| 102 activeMeasures.sort(); | 111 activeMeasures.sort(); |
| 103 } | 112 } |
| 104 | 113 |
| 105 var data = (showSelectedMeasure) ? activeMeasures : e.series.measures; | 114 var data = (showSelectedMeasure) ? activeMeasures : e.series.measures; |
| 106 | 115 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 195 } |
| 187 | 196 |
| 188 FormatFunction _getFormatterForColumn(int column) => | 197 FormatFunction _getFormatterForColumn(int column) => |
| 189 _area.data.columns.elementAt(column).formatter; | 198 _area.data.columns.elementAt(column).formatter; |
| 190 | 199 |
| 191 hide(ChartEvent e) { | 200 hide(ChartEvent e) { |
| 192 if (_tooltipRoot == null) return; | 201 if (_tooltipRoot == null) return; |
| 193 _tooltipRoot.style('opacity', '0'); | 202 _tooltipRoot.style('opacity', '0'); |
| 194 } | 203 } |
| 195 } | 204 } |
| OLD | NEW |