Skip to content

BarChart minBarHeight at 0 can still be highlighted #294

@brenkao

Description

@brenkao

Background

I am trying to make a stacked bar chart where some values are 0. I don't expect these values to show up on the final chart.

Problem

Even when the value is 0, I can still highlight the pixel for the 0 value.

Cause

Rectangle is created even when the height is set to 0. This is regardless of minBarHeight={0}.

Possible Solution

Modify BarChart.js to not create a rectangle when height is 0

// Allow negative values. Minimum bar height = 1 pixel.
// Stack negative bars below X-axis and positive above X-Axis
var positiveBar = height >= 0;
height = Math.max(Math.abs(height), minBarHeight);
var y = positiveBar ? yposPositive - height : yposNegative;
if(height == 0) return;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions