Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion docs/general/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ new Chart(ctx, {

### Automatic data decimation during draw

Line element will automatically decimate data, when the following conditions are met: `tension` is `0`, `steppedLine` is `false` (default), `fill` is `false` and `borderDash` is `[]` (default).`
Line element will automatically decimate data, when the following conditions are met: `tension` is `0`, `steppedLine` is `false` (default) and `borderDash` is `[]` (default).`
This improves rendering speed by skipping drawing of invisible line segments.

```javascript
Expand All @@ -109,6 +109,26 @@ new Chart(ctx, {
});
```

### Enable spanGaps

If you have a lot of data points, it can be more performant to enable `spanGaps`. This disables segmentation of the line, which can be an unneeded step.

To enable `spanGaps`:

```javascript
new Chart(ctx, {
type: 'line',
data: {
datasets: [{
spanGaps: true // enable for a single dataset
}]
},
options: {
spanGaps: true // enable for all datasets
}
});
```

### Disable Line Drawing

If you have a lot of data points, it can be more performant to disable rendering of the line for a dataset and only draw points. Doing this means that there is less to draw on the canvas which will improve render performance.
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/controller.line.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ module.exports = DatasetController.extend({

// Update Line
if (showLine && mode !== 'resize') {

const properties = {
_children: points,
points,
options: me._resolveDatasetElementOptions()
};

Expand Down
12 changes: 7 additions & 5 deletions src/controllers/controller.radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ module.exports = DatasetController.extend({
const meta = me._cachedMeta;
const line = meta.dataset;
const points = meta.data || [];

const labels = meta.iScale._getLabels();
const properties = {
_children: points,
points,
_loop: true,
_fullLoop: labels.length === points.length,
options: me._resolveDatasetElementOptions()
};

Expand Down Expand Up @@ -122,10 +123,11 @@ module.exports = DatasetController.extend({
const y = reset ? scale.yCenter : pointPosition.y;

const properties = {
x: x,
y: y,
x,
y,
angle: pointPosition.angle,
skip: isNaN(x) || isNaN(y),
options,
options
};

me._updateElement(point, index, properties, mode);
Expand Down
7 changes: 2 additions & 5 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,12 +876,9 @@ class Scale extends Element {
}

getBaseValue() {
var me = this;
var min = me.min;
var max = me.max;
const {min, max} = this;

return me.beginAtZero ? 0 :
min < 0 && max < 0 ? max :
return min < 0 && max < 0 ? max :
min > 0 && max > 0 ? min :
0;
}
Expand Down
Loading