Skip to content

Bar: add option to place label below/above the bar if its value is negative/positive #4760

@asmallproblem

Description

@asmallproblem

Question: (Ask your question here)
How do i set the Value to show below the bar chart? I currenly have a barChart that can both contain negative and positive numbers. I want so that if it is a negative value, the value label should be displayed below the bar chart

I have highlighted where the bar chart has a negativ value, and where it should be.

Image

ScottPlot Version: (What NuGet package are you using?)
5.0.53

Code Sample: See http://scottplot.net/faq/repro/ for tips about creating reproducible code samples

List<Bar> bars = new List<Bar>();
foreach (var item in nettoVaekst.Select((value, i) => (value, i)))
{
    bars.Add(new()
    {
        Position = item.i,
        FillColor = ScottPlot.Color.FromHex("#80933f"),
        LineWidth = 0,
        Size = 0.6,
        Value = item.value.Vaekst,
        Label = $"{item.value.Vaekst}",                   
    });
}

Plot barChart = new();

 var barPlot = barChart.Add.Bars(bars);

 barPlot.ValueLabelStyle.FontSize = 16
 barPlot.ValueLabelStyle.Bold = true;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help WantedScott won't do this soon, but PRs from the community are welcome!⚠️ HIGH PRIORITY

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions