* Create a Number Display widget. * * @example * // create a number display under #chart-container1 element using the default global chart group * var display1 = new NumberDisplay('#chart-container1'); * @param {String|node|d3.selection} parent - Any valid * {@link http
(parent, chartGroup)
| 35 | * Interaction with a chart will only trigger events and redraws within the chart's group. |
| 36 | */ |
| 37 | constructor (parent, chartGroup) { |
| 38 | super(); |
| 39 | |
| 40 | this._formatNumber = format('.2s'); |
| 41 | this._html = {one: '', some: '', none: ''}; |
| 42 | this._lastValue = undefined; |
| 43 | this._ariaLiveRegion = false; |
| 44 | |
| 45 | // dimension not required |
| 46 | this._mandatoryAttributes(['group']); |
| 47 | |
| 48 | // default to ordering by value, to emulate old group.top(1) behavior when multiple groups |
| 49 | this.ordering(kv => kv.value); |
| 50 | |
| 51 | this.data(group => { |
| 52 | const valObj = group.value ? group.value() : this._maxBin(group.all()); |
| 53 | return this.valueAccessor()(valObj); |
| 54 | }); |
| 55 | |
| 56 | this.transitionDuration(250); // good default |
| 57 | this.transitionDelay(0); |
| 58 | |
| 59 | this.anchor(parent, chartGroup); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Gets or sets an optional object specifying HTML templates to use depending on the number |
nothing calls this directly
no test coverage detected