Skip to content

BarSeries: fails to plot negative values #2147

@swharden

Description

@swharden

I think the bug is here (it always assumes values are positive):

private RectangleF GetPixelRect(PlotDimensions dims, Bar bar)
{
if (bar.IsVertical)
{
float left = dims.GetPixelX(bar.Position - bar.Thickness / 2);
float right = dims.GetPixelX(bar.Position + bar.Thickness / 2);
float bottom = dims.GetPixelY(bar.ValueBase);
float top = dims.GetPixelY(bar.Value);
float width = right - left;
float height = bottom - top;
return new RectangleF(left, top, width, height);
}
else
{
float left = dims.GetPixelX(bar.ValueBase);
float right = dims.GetPixelX(bar.Value);
float top = dims.GetPixelY(bar.Position + bar.Thickness / 2);
float bottom = dims.GetPixelY(bar.Position - bar.Thickness / 2);
float width = right - left;
float height = bottom - top;
return new RectangleF(left, top, width, height);
}
}

Spillover from #2145

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions