Skip to content

Commit 5cfd75e

Browse files
committed
Update built file
1 parent 7c07db0 commit 5cfd75e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Chart.Smith.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
}
2929
};
3030

31+
function roundTo1Decimal(a) {
32+
return Math.round(a * 10) / 10;
33+
}
34+
3135
Chart.controllers.smith = Chart.controllers.line.extend({
3236
// Not needed since there is only a single scale
3337
linkScales: helpers.noop,
@@ -70,6 +74,14 @@
7074
}, this);
7175

7276
this.updateBezierControlPoints();
77+
78+
// fix points
79+
helpers.each(points, function(point) {
80+
point._model.controlPointPreviousX = roundTo1Decimal(point._model.controlPointPreviousX);
81+
point._model.controlPointPreviousY = roundTo1Decimal(point._model.controlPointPreviousY);
82+
point._model.controlPointNextX = roundTo1Decimal(point._model.controlPointNextX);
83+
point._model.controlPointNextY = roundTo1Decimal(point._model.controlPointNextY);
84+
});
7385
},
7486
updateElement: function(point, index, reset) {
7587
var scale = this.chart.scale;
@@ -85,13 +97,17 @@
8597
// Appearance
8698
tension: point.custom && point.custom.tension ? point.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension),
8799
radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius),
100+
pointStyle: point.custom && point.custom.pointStyle ? point.custom.pointStyle : helpers.getValueAtIndexOrDefault(this.getDataset().pointStyle, index, this.chart.options.elements.point.pointStyle),
88101
backgroundColor: this.getPointBackgroundColor(point, index),
89102
borderColor: this.getPointBorderColor(point, index),
90103
borderWidth: this.getPointBorderWidth(point, index),
91104
// Tooltip
92105
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius),
93106
};
94107

108+
point._model.x = roundTo1Decimal(point._model.x);
109+
point._model.y = roundTo1Decimal(point._model.y);
110+
95111
point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
96112
},
97113
calculatePointX: function(dataIndex) {
@@ -370,8 +386,8 @@
370386
// We have an r and a phi from the point (imagCenterX, imagCenterY)
371387
// translate to an x and a undefined
372388
return {
373-
x: (Math.cos(phi) * imagRadius) + imagCenterX,
374-
y: (Math.sin(phi) * imagRadius) + imagCenterY
389+
x: imag === 0 ? realCenterX - realRadius : (Math.cos(phi) * imagRadius) + imagCenterX,
390+
y: imag === 0 ? this.yCenter : (Math.sin(phi) * imagRadius) + imagCenterY
375391
};
376392
},
377393
getLabelForIndex: function(index, datasetIndex) {

0 commit comments

Comments
 (0)