New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chart size updates #384
Chart size updates #384
Conversation
Following chart.js specs: Allow chart container sizes to be set via width and height attributes. Allow chart container sizes to be set to any unit of measure (%, v[h|w], px, etc). Allow chart size to fill it's container. Allow disabling of MaintainAspectRatio.
Following chart.js specs: Allow chart container sizes to be set via width and height attributes. Allow chart container sizes to be set to any unit of measure (%, v[h|w], px, etc). Allow chart size to fill it's container. Allow disabling of MaintainAspectRatio.
@xramcire Thank you for your pull request. When I was testing it, I found something weird. Can you please review it once ? Please see the attached video for your reference. Start up project: BlazorBootstrap.Demo.WebAssembly blazorbootstrap_pr_384.mp4 |
Will do! |
MaintainAspectRatio is supposed to be true by default. If it's set to false valid height and width must be supplied.
I misread the docs from chart.js. The MaintainAspectRatio property needed to be true by default. This is now set. This will compile: <BarChart @ref="barChart" Width="200" Class="mb-4" /> The .NetFramework has the concept of a Unit. You or I could introduce something along those lines. That would also be a breaking change. |
@gvreddy04 Any update in this? |
@xramcire Sorry for the late response. I prefer Unit Parameter instead of manually typing the unit types. Added Unit enum in the v1.10.3 release. Can you use the Unit enum parameter? Also update We can use something like |
Sounds good. I'll make the requested changes. |
@xramcire Thank you for making the requested changes. One question, do you think user will use two different units for width and height. Can we use Unit param instead of WidthUnit and HeightUnit. All other changes good to me. I'll test this PR later and add if any demo scenarios required. |
My use case has a chart of fixed height and varable width. However my use case is less important than the fact that CSS and ChartJS both support arbitrary units and unit types for height and width. We can never know every use case. I must admit I find the two properties less attractive and less intuitive than the more traditional value. This is likely why Microsoft uses the Unit struct. As we discussed earlier this would be a breaking change for you but I think in the end would make for a more intuitive product. In markup you could support a struct without it being a breaking change: In code you would still have a breaking change in: Unit => https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.unit?view=netframework-4.8.1 On a slightly related note. CSS and ChartJS both support doubles for width and height. My use case does not require this but someone elses might in the future. Doubles are far more common when declaring sizes in EM and REM. Either way, let me know if I can help. |
@xramcire Thanks for the updates. I'm testing this pull request. Please watch out for any notifications. |
https://www.chartjs.org/docs/latest/configuration/responsive.html
Following chart.js specs:
Allow chart container sizes to be set via width and height attributes.
Allow chart container sizes to be set to any unit of measure (%, v[h|w], px, etc).
Allow chart size to fill it's container.
Allow disabling of MaintainAspectRatio.