mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
Morris.Donut#select(idx) for selecting donut segments (ref #79).
This commit is contained in:
parent
9bb723057f
commit
43019eeeaf
@ -85,13 +85,14 @@ class Morris.Donut
|
||||
idx = 0
|
||||
for d in @data
|
||||
if d.value == max_value
|
||||
@select @segments[idx]
|
||||
@select idx
|
||||
break
|
||||
idx += 1
|
||||
|
||||
# @private
|
||||
select: (segment) =>
|
||||
# Select the segment at the given index.
|
||||
select: (idx) =>
|
||||
s.deselect() for s in @segments
|
||||
segment = @segments[idx]
|
||||
segment.select()
|
||||
@setLabels segment.data.label, @options.formatter(segment.data.value)
|
||||
|
||||
|
@ -143,7 +143,7 @@
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
d = _ref2[_k];
|
||||
if (d.value === max_value) {
|
||||
this.select(this.segments[idx]);
|
||||
this.select(idx);
|
||||
break;
|
||||
}
|
||||
_results.push(idx += 1);
|
||||
@ -151,13 +151,14 @@
|
||||
return _results;
|
||||
};
|
||||
|
||||
Donut.prototype.select = function(segment) {
|
||||
var s, _i, _len, _ref;
|
||||
Donut.prototype.select = function(idx) {
|
||||
var s, segment, _i, _len, _ref;
|
||||
_ref = this.segments;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
s = _ref[_i];
|
||||
s.deselect();
|
||||
}
|
||||
segment = this.segments[idx];
|
||||
segment.select();
|
||||
return this.setLabels(segment.data.label, this.options.formatter(segment.data.value));
|
||||
};
|
||||
|
2
morris.min.js
vendored
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user