mattosaurus / ChartJSCore

Implementation of Chart.js for use with .NET Core.
GNU General Public License v3.0
116 stars 34 forks source link

Bar Thickness Scale Options #40

Closed erinachavez closed 5 years ago

erinachavez commented 5 years ago

Hello, I'm having an issue getting 4 different options working: BarPercentage, CategoryPercentage, BarThickness, and MaxBarThickness. I tested setting each in turn, but none have any effect on my charts. After reading through Chart.js documentation, and observing the outputted js code, I believe the 4 options are being set and generated in the wrong place. Rather, I think they should be contained within the Options/Scales/Scale.cs class...

Let me know if this sounds right!

Chart chart = new Chart()
{
    Type = Enums.ChartType.HorizontalBar,
};

chart.Options = new BarOptions
{
    Scales = new Scales
    {
        XAxes = new List<Scale>
        {
            new CartesianScale
            {
                Ticks = new CartesianLinearTick
                {
                    BeginAtZero = true,
                    StepSize = 1,
                },
                Stacked = true,
                // Should be part of Scale.cs
            },
        },
        YAxes = new List<Scale>
        {
            new CartesianScale
            {
                Stacked = true,
                // Should be part of Scale.cs
            }
        }
    },
    MaxBarThickness = 25, // Shouldn't be under Options.cs
};
mattosaurus commented 5 years ago

You're right, not sure if these have moved since I first created this or I just did it wrong initially. I've moved these to the scale and have updated the NuGet package to 1.5.3.

I created a new BarScale object to hold these which you can see in this test.

erinachavez commented 5 years ago

Works great! Thanks so much again for the fast fix