Skip to content

Commit

Permalink
Hover styling for dataset in 'dataset' mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Sep 18, 2019
1 parent 29f1337 commit c32fa33
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/controllers/controller.line.js
Expand Up @@ -315,4 +315,19 @@ module.exports = DatasetController.extend({
model.borderWidth = valueOrDefault(options.hoverBorderWidth, options.borderWidth);
model.radius = valueOrDefault(options.hoverRadius, options.radius);
},

setDatasetHoverStyle: function() {
var line = this.getMeta().dataset;
var model = line._model;
var config = this._config;
var getHoverColor = helpers.getHoverColor;

line.$previousStyle = {
backgroundColor: model.backgroundColor,
borderColor: model.borderColor
};

model.backgroundColor = valueOrDefault(config.hoverBackgroundColor, getHoverColor(config.backgroundColor));
model.borderColor = valueOrDefault(config.hoverBorderColor, getHoverColor(config.borderColor));
},
});
5 changes: 5 additions & 0 deletions src/core/core.controller.js
Expand Up @@ -964,6 +964,11 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
this.getDatasetMeta(element._datasetIndex).controller[method](element);
}
}

if (mode === 'dataset') {
method = enabled ? 'setDatasetHoverStyle' : 'removeDatasetHoverStyle';
this.getDatasetMeta(elements[0]._datasetIndex).controller[method]();
}
},

/**
Expand Down
6 changes: 6 additions & 0 deletions src/core/core.datasetController.js
Expand Up @@ -453,6 +453,12 @@ helpers.extend(DatasetController.prototype, {
model.borderWidth = resolve([custom.hoverBorderWidth, dataset.hoverBorderWidth, model.borderWidth], undefined, index);
},

removeDatasetHoverStyle: function() {
this.removeHoverStyle(this.getMeta().dataset);
},

setDatasetHoverStyle: helpers.noop,

/**
* @private
*/
Expand Down

0 comments on commit c32fa33

Please sign in to comment.