Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line Chart - line on the edge get cut fix ( #4202) #5321

Merged
merged 4 commits into from Apr 3, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/controllers/controller.line.js
Expand Up @@ -283,9 +283,15 @@ module.exports = function(Chart) {
var points = meta.data || [];
var area = chart.chartArea;
var ilen = points.length;
var halfBorderWidth = (meta.dataset._model.borderWidth || 0) / 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have read update() more carefully because _model is only available if options.showLine: true.

We could also avoid clipping if there is nothing to draw ...

if (lineEnabled(me.getDataset(), chart.options)) {
    halfBorderWidth = (meta.dataset._model.borderWidth || 0) / 2;

    helpers.canvas.clipArea(chart.ctx, {
        left: area.left,
        right: area.right,
        top: area.top - halfBorderWidth,
        bottom: area.bottom + halfBorderWidth
    });

    meta.dataset.draw();

    helpers.canvas.unclipArea(chart.ctx);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify that it works locally, I didn't test it, neither that tests pass (gulp test).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonbrunel
Yeah that fixed the problem, did some manual tests too, everything seems fine for both options: showLine: true and showLine: false.

var i = 0;

helpers.canvas.clipArea(chart.ctx, area);
helpers.canvas.clipArea(chart.ctx, {
left: area.left,
right: area.right,
top: area.top - halfBorderWidth,
bottom: area.bottom + halfBorderWidth
});

if (lineEnabled(me.getDataset(), chart.options)) {
meta.dataset.draw();
Expand Down