Skip to content

Zero values are printed on top of other values when in stacked histogram mode #790

@dej611

Description

@dej611

Describe the bug
When the bar chart is set to histogram mode and the x Axis has a time scale, then when a bar value is 0 the bar itself is not rendered, while its value labels is, overlapping other bars values:

Screenshot 2020-08-21 at 18 57 04

To Reproduce
Steps to reproduce the behavior:

  1. Change the stories/bar/17_time_stacked.tsx as follow:
<Chart className="story-chart">
      <Settings
        debug={boolean('debug', false)}
        theme={{
          barSeriesStyle: { displayValue: { fill: 'white', fontSize: 25 } },
        }}
      />
...
<BarSeries
        id={KIBANA_METRICS.metrics.kibana_os_load[2].metric.label}
        xScaleType={ScaleType.Time}
        yScaleType={ScaleType.Linear}
        xAccessor={0}
        yAccessors={[1]}
        stackAccessors={[0]}
        data={KIBANA_METRICS.metrics.kibana_os_load[2].data.slice(0, 20)}
        displayValueSettings={{
          showValueLabel: true,
          isAlternatingValueLabel: false,
          isValueContainedInElement: true,
          hideClippedValue: true,
        }}
      />
      <BarSeries
        id={KIBANA_METRICS.metrics.kibana_os_load[1].metric.label}
        xScaleType={ScaleType.Time}
        yScaleType={ScaleType.Linear}
        xAccessor={0}
        yAccessors={[1]}
        stackAccessors={[0]}
        data={KIBANA_METRICS.metrics.kibana_os_load[1].data.slice(0, 20)}
        displayValueSettings={{
          showValueLabel: true,
          isAlternatingValueLabel: false,
          isValueContainedInElement: true,
          hideClippedValue: true,
        }}
      />
      <BarSeries
        id={KIBANA_METRICS.metrics.kibana_os_load[0].metric.label}
        xScaleType={ScaleType.Time}
        yScaleType={ScaleType.Linear}
        xAccessor={0}
        yAccessors={[1]}
        stackAccessors={[0]}
        data={KIBANA_METRICS.metrics.kibana_os_load[0].data.slice(0, 20)}
        displayValueSettings={{
          showValueLabel: true,
          isAlternatingValueLabel: false,
          isValueContainedInElement: true,
          hideClippedValue: true,
        }}
      />
    </Chart>
  1. Now change lines 38 to 49 in the src/utils/data_samples/test_dataset_kibana.ts as follow:
data: [
          [1551438000000, 0],
          [1551438030000, 0],
          [1551438060000, 0],
          [1551438090000, 0],
          [1551438120000, 0],
          [1551438150000, 0],
          [1551438180000, 0],
          [1551438210000, 0],
          [1551438240000, 0],
          [1551438270000, 0],
          [1551438300000, 0],
  1. Start Storybook and go to 'Bar Chart - Time Stacked Using Various Specs'
  2. See picture above

Expected behaviour
The 0 value labels are not rendered.

Additional context
Add any other context about the problem here.

Errors in browser console
No errors.

Kibana related PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    :xyBar/Line/Area chart relatedbugSomething isn't workinggood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions