|
28 | 28 | } |
29 | 29 | }; |
30 | 30 |
|
| 31 | + function roundTo1Decimal(a) { |
| 32 | + return Math.round(a * 10) / 10; |
| 33 | + } |
| 34 | + |
31 | 35 | Chart.controllers.smith = Chart.controllers.line.extend({ |
32 | 36 | // Not needed since there is only a single scale |
33 | 37 | linkScales: helpers.noop, |
|
70 | 74 | }, this); |
71 | 75 |
|
72 | 76 | 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 | + }); |
73 | 85 | }, |
74 | 86 | updateElement: function(point, index, reset) { |
75 | 87 | var scale = this.chart.scale; |
|
85 | 97 | // Appearance |
86 | 98 | tension: point.custom && point.custom.tension ? point.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension), |
87 | 99 | 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), |
88 | 101 | backgroundColor: this.getPointBackgroundColor(point, index), |
89 | 102 | borderColor: this.getPointBorderColor(point, index), |
90 | 103 | borderWidth: this.getPointBorderWidth(point, index), |
91 | 104 | // Tooltip |
92 | 105 | hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius), |
93 | 106 | }; |
94 | 107 |
|
| 108 | + point._model.x = roundTo1Decimal(point._model.x); |
| 109 | + point._model.y = roundTo1Decimal(point._model.y); |
| 110 | + |
95 | 111 | point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y)); |
96 | 112 | }, |
97 | 113 | calculatePointX: function(dataIndex) { |
|
370 | 386 | // We have an r and a phi from the point (imagCenterX, imagCenterY) |
371 | 387 | // translate to an x and a undefined |
372 | 388 | 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 |
375 | 391 | }; |
376 | 392 | }, |
377 | 393 | getLabelForIndex: function(index, datasetIndex) { |
|
0 commit comments