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

Fix: Fill vertical lines #8919

Merged
merged 1 commit into from Apr 17, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/plugins/plugin.filler.js
Expand Up @@ -496,7 +496,7 @@ function _fill(ctx, cfg) {

function doFill(ctx, cfg) {
const {line, target, above, below, area, scale} = cfg;
const property = line._loop ? 'angle' : 'x';
const property = line._loop ? 'angle' : cfg.axis;

ctx.save();

Expand All @@ -514,14 +514,14 @@ function doFill(ctx, cfg) {

function drawfill(ctx, source, area) {
const target = getTarget(source);
const {line, scale} = source;
const {line, scale, axis} = source;
const lineOpts = line.options;
const fillOption = lineOpts.fill;
const color = lineOpts.backgroundColor;
const {above = color, below = color} = fillOption || {};
if (target && line.points.length) {
clipArea(ctx, area);
doFill(ctx, {line, target, above, below, area, scale});
doFill(ctx, {line, target, above, below, area, scale, axis});
unclipArea(ctx);
}
}
Expand All @@ -545,6 +545,7 @@ export default {
index: i,
fill: decodeFill(line, i, count),
chart,
axis: meta.controller.options.indexAxis,
scale: meta.vScale,
line,
};
Expand Down
42 changes: 42 additions & 0 deletions test/fixtures/plugin.filler/line/vertical.js
@@ -0,0 +1,42 @@
const data = [
{y: 1, x: 12},
{y: 3, x: 14},
{y: 4, x: 20},
{y: 6, x: 13},
{y: 9, x: 18},
];

module.exports = {
config: {
type: 'line',
data: {
datasets: [{
data: data,
borderColor: 'red',
fill: false,
}, {
data: data.map((v) => ({y: v.y, x: 2 * v.x - 1.5 * v.y})),
fill: '-1',
borderColor: 'blue',
backgroundColor: 'rgba(255, 200, 0, 0.5)',
}]
},
options: {
indexAxis: 'y',
radius: 0,
plugins: {
legend: false
},
scales: {
x: {
display: false,
type: 'linear'
},
y: {
display: false,
type: 'linear'
}
}
}
}
};
Binary file added test/fixtures/plugin.filler/line/vertical.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.