Giter Site home page Giter Site logo

Comments (4)

cnickel avatar cnickel commented on August 24, 2024 2

@Joelius300, Thank you so much for the swift reply, along with the simple work around, I appreciate it. As you have stated adding the Offset=true did in fact work in my project as well.

Thanks again.

from chartjs.blazor.

mariusmuntean avatar mariusmuntean commented on August 24, 2024 1

That was an oversight on my part.
I've reintroduced the T4 template and adjusted it such that the category axis for bar charts is initialized with the Offset property set to true.

from chartjs.blazor.

Joelius300 avatar Joelius300 commented on August 24, 2024

Thank you for the detailed report! It really helps to know all those details when providing support.

You're correct that this is a bug but probably not in the sense you think.

This is the expected behaviour when using a cartesian axis that has the property Offset (or offset on js-side) set to false. The thing is, we've written in the property summary that this is set to true in category scales for bar-charts by default. However, the default for all the other cartesian axes is false and we (actually it was me) forgot to manually change it when I created the extended versions for the bar chart.
So even though you're using a category axis in a bar chart (which should satisfy what we wrote) Offset stays false.

FYI here's the property summary for CartesianAxis.Offset:

If true, extra space is added to the both edges and the axis is scaled to fit into the chart area.
This is set to true for a category scale in a bar chart by default.

This is fixed easily by just setting Offset to true in BarCategoryAxiss constructor. However, we need to keep in mind that if you use a regular CategoryAxis in a bar-chart, Offset will still be set to false. Therefore we also need to update the summary to make that clear.
I will provide a fix for this (after the other thing is cleared up, see below). I don't know when it'll be updated in the nuget.

To work around the issue you can manually set Offset = true in the x-axis (BarCategoryAxis) you add in your chart (just add it to the other initalization options like BarPercentage = 0.5). I've tested it and it works exactly like expected.

@mariusmuntean When looking at this issue I've noticed that you've removed the ExtendedCartesianAxes.tt in 88ed13d which generated the extended versions of the cartesian axes for the bar chart. May I ask why you did that and also if we should opt that back in? If not, I'll just provide the fix for the "static" file. Keep in mind that any change to the regular cartesian axes will need to be mirrored manually to the bar axes if we don't use the code-template for this.

This issue will be closed once the fix is done and merged into master (aka do not close yet), thanks :)

from chartjs.blazor.

mariusmuntean avatar mariusmuntean commented on August 24, 2024

Feel free to reopen this issue if you think there's more to do there.
My commits: 9aa52da c718735

from chartjs.blazor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.