Skip to content

Toggling showLine only adds the line and does not remove it fully #11333

@stephanie-eng

Description

@stephanie-eng

Expected behavior

In the example linked below, we are trying to toggle the line on a scatter chart. When changing options.showLine to false, expected behaviour is that the lines for all points in the chart disappear, and reappear when options.showLine is set to true. This should happen for all data points regardless of when they are added to the chart.

See Current behaviour for detailed breakdown.

Current behavior

The following steps illustrates the issue:

  1. Load the example.
  2. Notice that there is a scatterplot with three pre-existing points, connected by lines. The status of options.showLine is displayed beside the buttons.
  3. Click the Toggle Line button, and observe nothing happens to the plot. The status of options.showLine has changed to false.
    • Expected behviour: Lines connecting the points should be removed
  4. Click the Add Data button to the chart, and observe new data points to the plot. The new data points do not have a line, but the pre-existing data points still maintain their line.
    • Expected behviour: No lines connecting any of the points
      image
  5. Click the Toggle Line button, and observe that lines have reappeared between all data points, as expected. The status of options.showLine is true.
  6. Go to step 3 and repeat.

Reproducible sample

https://codepen.io/kazaaak/pen/ZEmYEam

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.3.0

Browser name and version

Chrome, Firefox

Link to your project

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions