]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Just assign instead of extend
authorMathias Küsel <mathiask@hotmail.de>
Fri, 15 Jan 2016 12:05:23 +0000 (13:05 +0100)
committerMathias Küsel <mathiask@hotmail.de>
Fri, 15 Jan 2016 12:05:23 +0000 (13:05 +0100)
src/controllers/controller.line.js

index a87814eaf4946b2a530cd03bd93c09da56066e10..e557a02ec4b42c63be6366aab31e86ad79d29cfb 100644 (file)
 
                        // Update Line
                        if (this.chart.options.showLines) {
-                               helpers.extend(line, {
-                                       // Utility
-                                       _scale: yScale,
-                                       _datasetIndex: this.index,
-                                       // Data
-                                       _children: points,
-                                       // Model
-                                       _model: {
-                                               // Appearance
-                                               tension: line.custom && line.custom.tension ? line.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension),
-                                               backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor),
-                                               borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth),
-                                               borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor),
-                                               borderCapStyle: line.custom && line.custom.borderCapStyle ? line.custom.borderCapStyle : (this.getDataset().borderCapStyle || this.chart.options.elements.line.borderCapStyle),
-                                               borderDash: line.custom && line.custom.borderDash ? line.custom.borderDash : (this.getDataset().borderDash || this.chart.options.elements.line.borderDash),
-                                               borderDashOffset: line.custom && line.custom.borderDashOffset ? line.custom.borderDashOffset : (this.getDataset().borderDashOffset || this.chart.options.elements.line.borderDashOffset),
-                                               borderJoinStyle: line.custom && line.custom.borderJoinStyle ? line.custom.borderJoinStyle : (this.getDataset().borderJoinStyle || this.chart.options.elements.line.borderJoinStyle),
-                                               fill: line.custom && line.custom.fill ? line.custom.fill : (this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill),
-                                               // Scale
-                                               scaleTop: yScale.top,
-                                               scaleBottom: yScale.bottom,
-                                               scaleZero: scaleBase,
-                                       },
-                               });
+                               // Utility
+                               line._scale = yScale;
+                               line._datasetIndex = this.index;
+                               // Data
+                               line._children = points;
+                               // Model
+                               line._model = {
+                                       // Appearance
+                                       tension: line.custom && line.custom.tension ? line.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension),
+                                       backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor),
+                                       borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth),
+                                       borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor),
+                                       borderCapStyle: line.custom && line.custom.borderCapStyle ? line.custom.borderCapStyle : (this.getDataset().borderCapStyle || this.chart.options.elements.line.borderCapStyle),
+                                       borderDash: line.custom && line.custom.borderDash ? line.custom.borderDash : (this.getDataset().borderDash || this.chart.options.elements.line.borderDash),
+                                       borderDashOffset: line.custom && line.custom.borderDashOffset ? line.custom.borderDashOffset : (this.getDataset().borderDashOffset || this.chart.options.elements.line.borderDashOffset),
+                                       borderJoinStyle: line.custom && line.custom.borderJoinStyle ? line.custom.borderJoinStyle : (this.getDataset().borderJoinStyle || this.chart.options.elements.line.borderJoinStyle),
+                                       fill: line.custom && line.custom.fill ? line.custom.fill : (this.getDataset().fill !== undefined ? this.getDataset().fill : this.chart.options.elements.line.fill),
+                                       // Scale
+                                       scaleTop: yScale.top,
+                                       scaleBottom: yScale.bottom,
+                                       scaleZero: scaleBase
+                               };
                                line.pivot();
                        }
 
                                scaleBase = yScale.getPixelForValue(0);
                        }
 
-                       helpers.extend(point, {
-                               // Utility
-                               _chart: this.chart.chart,
-                               _xScale: xScale,
-                               _yScale: yScale,
-                               _datasetIndex: this.index,
-                               _index: index,
-
-                               // Desired view properties
-                               _model: {
-                                       x: xScale.getPixelForValue(this.getDataset().data[index], index, this.index, this.chart.isCombo),
-                                       y: reset ? scaleBase : this.calculatePointY(this.getDataset().data[index], index, this.index, this.chart.isCombo),
-                                       // Appearance
-                                       tension: point.custom && point.custom.tension ? point.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension),
-                                       radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius),
-                                       backgroundColor: this.getPointBackgroundColor(point, index),
-                                       borderColor: this.getPointBorderColor(point, index),
-                                       borderWidth: this.getPointBorderWidth(point, index),
-                                       // Tooltip
-                                       hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius),
-                               },
-                       });
+                       // Utility
+                       point._chart = this.chart.chart;
+                       point._xScale = xScale;
+                       point._yScale = yScale;
+                       point._datasetIndex = this.index;
+                       point._index = index;
+
+                       // Desired view properties
+                       point._model = {
+                               x: xScale.getPixelForValue(this.getDataset().data[index], index, this.index, this.chart.isCombo),
+                               y: reset ? scaleBase : this.calculatePointY(this.getDataset().data[index], index, this.index, this.chart.isCombo),
+                               // Appearance
+                               tension: point.custom && point.custom.tension ? point.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension),
+                               radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius),
+                               backgroundColor: this.getPointBackgroundColor(point, index),
+                               borderColor: this.getPointBorderColor(point, index),
+                               borderWidth: this.getPointBorderWidth(point, index),
+                               // Tooltip
+                               hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius)
+                       };
 
                        point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
                },