Skip to content

Bug: Chart is duplicated after any filter change #55

@kknapp1

Description

@kknapp1

When applying a filter in the eventUsageMetrics Lightning Web Component (via the handleFilterChange method), the D3 chart is duplicated within the same .timeline container instead of being replaced. This results in multiple overlapping charts being rendered on the screen, causing visual clutter and performance issues. The bug occurs because existing elements in the .timeline container are not cleared before the new chart is rendered.

Image

Steps to Reproduce:

  1. Load the eventUsageMetrics LWC to display the initial chart.
  2. Trigger a filter change by interacting with the filtering options (e.g., selecting an event type or applying a date range).
  3. Observe that a new chart is rendered on top of the existing one without removing the previous chart.

Expected Behavior
The chart should be replaced with the updated filtered data, ensuring that only one chart is visible at any time.

Actual Behavior
The chart is duplicated once and each filter change is applied to both charts.

Possible Cause
In the initializeTimeline method, existing child nodes of the .timeline container are not fully removed before appending new SVG elements. This leaves old charts in place while rendering new ones.

Suggested Fix
Replace the existing logic for clearing child nodes in the initializeTimeline method with the following:

d3.select(rootElement).selectAll('*').remove();

This ensures that all elements within the .timeline container are removed before the new chart is rendered.

Environment
Streaming Monitor: v 3.16
Browser: Chrome 131.0.6778.265, also reproduced in Edge 132.0.2957.115

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions