Skip to content

Commit

Permalink
Port per-point custom.tension logic to the line controller
Browse files Browse the repository at this point in the history
  • Loading branch information
nagix committed Feb 7, 2019
1 parent 658e85f commit b9874a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/controllers/controller.line.js
Expand Up @@ -118,7 +118,7 @@ module.exports = DatasetController.extend({
backgroundColor: options.backgroundColor,
borderColor: options.borderColor,
borderWidth: options.borderWidth,
tension: lineModel ? lineModel.tension : 0,
tension: valueOrDefault(custom.tension, lineModel ? lineModel.tension : 0),
steppedLine: lineModel ? lineModel.steppedLine : false,
// Tooltip
hitRadius: options.hitRadius
Expand Down Expand Up @@ -156,7 +156,7 @@ module.exports = DatasetController.extend({
hoverRadius: 'pointHoverRadius',
pointStyle: 'pointStyle',
radius: 'pointRadius',
rotation: 'pointRotation',
rotation: 'pointRotation'
};
var keys = Object.keys(ELEMENT_OPTIONS);

Expand Down Expand Up @@ -211,7 +211,7 @@ module.exports = DatasetController.extend({
// to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158
// This option gives lines the ability to span gaps
values.spanGaps = valueOrDefault(dataset.spanGaps, options.spanGaps);
values.tension = resolve([custom.tension, dataset.lineTension, elementOptions.tension]);
values.tension = valueOrDefault(dataset.lineTension, elementOptions.tension);
values.steppedLine = resolve([custom.steppedLine, dataset.steppedLine, elementOptions.stepped]);

return values;
Expand Down
7 changes: 5 additions & 2 deletions src/controllers/controller.radar.js
Expand Up @@ -73,6 +73,7 @@ module.exports = DatasetController.extend({
var scale = me.chart.scale;
var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]);
var options = me._resolvePointOptions(point, index);
var lineModel = me.getMeta().dataset._model;
var x = reset ? scale.xCenter : pointPosition.x;
var y = reset ? scale.yCenter : pointPosition.y;

Expand All @@ -94,7 +95,7 @@ module.exports = DatasetController.extend({
backgroundColor: options.backgroundColor,
borderColor: options.borderColor,
borderWidth: options.borderWidth,
tension: resolve([custom.tension, dataset.lineTension, me.chart.options.elements.line.tension]),
tension: valueOrDefault(custom.tension, lineModel ? lineModel.tension : 0),

// Tooltip
hitRadius: options.hitRadius
Expand Down Expand Up @@ -132,7 +133,7 @@ module.exports = DatasetController.extend({
hoverRadius: 'pointHoverRadius',
pointStyle: 'pointStyle',
radius: 'pointRadius',
rotation: 'pointRotation',
rotation: 'pointRotation'
};
var keys = Object.keys(ELEMENT_OPTIONS);

Expand Down Expand Up @@ -181,6 +182,8 @@ module.exports = DatasetController.extend({
]);
}

values.tension = valueOrDefault(dataset.lineTension, options.tension);

return values;
},

Expand Down

0 comments on commit b9874a3

Please sign in to comment.