carbon-design-system / carbon-charts

:bar_chart: :chart_with_upwards_trend:⠀Robust dataviz framework implemented using D3 & typescript
https://charts.carbondesignsystem.com
Apache License 2.0
904 stars 184 forks source link

[Bug]: Cannot use zoom bar with ScatterChart and a single data point #1877

Open a88zach opened 1 month ago

a88zach commented 1 month ago

Relevant package(s)

Carbon Charts Version

1.19.2

Which bundler are you using?

Vite

What happened and what did you expect to happen?

When rendering a scatter chart with the zoom bar enabled and a single data point, the data point is not shown on the chart.

The scatter chart displays correctly when there are more than 1 data point.

Chart data and options (automatically formatted so no need for backticks)

data = {
  group: 'Dataset 1',
  date: '2023-01-01',
  value: 50000
};

options = {
  title: 'Scatter (time series)',
  axes: {
    bottom: {
      title: '2019 Annual Sales Figures',
      scaleType: 'time',
      mapsTo: 'date'
    },
    left: {
      mapsTo: 'value'
    }
  },
  zoomBar: {
    top: {
      enabled: true,
    },
  },
  height: '400px'
}

JavaScript console or build output (if relevant)

No response

StackBlitz repro

https://stackblitz.com/edit/react-by6srr?file=src%2Findex.js

IBM Application/Team (if relevant)

No response

What priority level would this be in your opinion?

P2 (Medium)

a88zach commented 1 month ago

To reproduce, just load the Stackblitz. You can see it working correctly by doing 1 of 2 things

  1. comment out the zoomBar option
  2. add a 2nd data point