question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Barchart scaling not aligned

See original GitHub issue

The bar chart seems not to scale correct with multiple data series.

Using Latest Chartjs master and Blazor on server-side app.

BarDataset<double> _barDataSet3 = new BarDataset<double>
    {
        Label = "A",
        BackgroundColor = ColorUtil.RandomColorString(),
        BorderWidth = 0,
        HoverBackgroundColor = ColorUtil.RandomColorString(),
        HoverBorderColor = ColorUtil.RandomColorString(),
        HoverBorderWidth = 1,
        BorderColor = "#ffffff"
    };


    _barChartConfig.Data.Labels.AddRange(new[] { "A"});
    _barDataSet3.Add(2.6);
    _barChartConfig.Data.Datasets.Add(_barDataSet3);


    BarDataset<double> _barDataSet4 = new BarDataset<double>
    {
        Label = "B",
        BackgroundColor = ColorUtil.RandomColorString(),
        BorderWidth = 0,
        HoverBackgroundColor = ColorUtil.RandomColorString(),
        HoverBorderColor = ColorUtil.RandomColorString(),
        HoverBorderWidth = 1,
        BorderColor = "#ffffff"
    };


    _barChartConfig.Data.Labels.AddRange(new[] { "B" });
    _barDataSet4.Add(4.5);
    _barChartConfig.Data.Datasets.Add(_barDataSet4); 

Config code:

_barChartConfig = new BarConfig
    {
        Options = new BarOptions
        {
            Title = new OptionsTitle
            {
                Display = true,
                Text = "Simple Bar Chart"
            },
            Scales = new BarScales
            {
                XAxes = new List<CartesianAxis>
            {
                    new BarCategoryAxis
                    {
                        BarPercentage = 0.5,
                        BarThickness = BarThickness.Flex
                    }
                },
                YAxes = new List<CartesianAxis>
            {
                    new BarLinearCartesianAxis
                    {
                        Ticks = new LinearCartesianTicks
                        {
                            BeginAtZero = true
                        }
                    }
                }
            }
        }
    };

Link to illustrate the issue: https://i.stack.imgur.com/7O8Cu.png

Hope it is enough information.

SO Link: https://stackoverflow.com/questions/62204374/chartsjs-blazor-barchart-not-alinged

/Thomas

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
tsgraucommented, Jun 12, 2020

Thank you for the feedback, i will try on SO. I created this: https://codepen.io/tsgrau/pen/QWyNQwN

0reactions
Joelius300commented, Oct 20, 2020

Closing this due to inactivity. Please respond if this issue should be reopened.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stacked bar chart results in misaligned bars
I'm using Chart.js with angular charts. I have the stacked property set accordingly with: stacked: true , yet the bars do not align...
Read more >
Recharts, Barchart not aligning bars correctly : r/reactjs
I'm completely new to recharts and liking it so far but I have a weird issue where my bars are not aligned right...
Read more >
FCC: D3 Bar Chart X-Axis not aligned with data - JavaScript
The problem is your x-axis is a linear scale (plain numbers) when the data is time (years, quarters). The tests for the bar...
Read more >
Bar chart vertical alignment and scaling
I'm having problems with the vertical alignment of my bar chart. I started using a single xbar chart for my data, but it...
Read more >
How to fix width of row header in Bar Chart
Hey all,. I'm facing an issue with row headers in the bar charts in my dashboard. I created a dashboard showing 3 bar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found