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

[BUG] Not correct view of graphs #3491

Closed
RoundArh opened this issue Oct 20, 2016 · 1 comment
Closed

[BUG] Not correct view of graphs #3491

RoundArh opened this issue Oct 20, 2016 · 1 comment

Comments

@RoundArh
Copy link

Expected Behavior

Current Behavior

We made a values for graph and add min and max values
Area chart don't cut values and show over the category scales. Please follow the link to view issue

Possible Solution

Steps to Reproduce (for bugs)

Context

Environment

https://jsfiddle.net/RoundArh/Lkpaz9b6/2/

@etimberg
Copy link
Member

Closing as duplicate of #2873.

We initially had this clipping implemented but it caused a lot of problems with points that fall right at the edge. The simplest and most performant clipping method is to simply do a rectangle that is the chart area.

The 'best' solution would be to project all the points on the edges onto the rectangle and clip along an arbitrary path. Unfortunately, this is painful. IE has no support for https://developer.mozilla.org/en-US/docs/Web/API/Path2D which means we can't even build the path once and then just reclip later, we'd need to build the path each time we render (every animation frame) and this is going to cause problems.

If you're okay with the clipping of points at the edges then adding the following plugin will work just fine.

Chart.plugins.register({
  beforeDatasetsDraw: function(chartInstance) {
    var ctx = chartInstance.chart.ctx;
    var chartArea = chartInstance.chartArea;
    ctx.save();
    ctx.beginPath();
    ctx.rect(chartArea.left, chartArea.top, chartArea.right - chartArea.left, chartArea.bottom - chartArea.top);
    ctx.clip();
  },
  afterDatasetsDraw: function(chartInstance) {
    chartInstance.chart.ctx.restore();
  },
});

etimberg pushed a commit that referenced this issue Dec 3, 2016
Implements clipping of items outside the chart area. Resolves #3506 #3491 #2873
exwm pushed a commit to exwm/Chart.js that referenced this issue Apr 30, 2021
Implements clipping of items outside the chart area. Resolves chartjs#3506 chartjs#3491 chartjs#2873
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants