Skip to content

BUG: Graph is stick out when set min or max options to yAxes. #3506

Closed

Description

@skjune12

Hello. When I set min (or max) parameter to yAxes options in line chart, data which less than min value (or greater than max value) is sticked out from drawing area, and labels are overlayed with lines. It also occurs in bar chart.

I know when I set suggestedMin options to yAxes, y-axis labels are auto-scaled. But I want to hide data less than specified value. Is that a bug or can I get any solutions?

Expected Behavior

Values less than min or greater than max value are not displayed from drawing area, and labels are not overlayed with data.

Current Behavior

Steps to Reproduce (for bugs)

  1. set max and min options to yAxis.
  2. generate datasets which includes values greater than max value or less than min value.

Environment

Activity

  1. etimberg commented on Oct 23, 2016

    @etimberg
    Member

    Thanks for the detailed report. You can add some basic clipping by adding the following plugin to your chart

    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();
      },
    });

    Closing as duplicate of #3491 and #2870

  2. added a commit that references this issue on Dec 3, 2016
    5a24bfa
  3. added a commit that references this issue on Apr 30, 2021
    f063f68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions