-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Canvas height is always "width / 2" #75
Comments
P.S.: If setting width and height as described above, a check for undefined at the beginning of _resize has to be added:
|
getMaximumSize returns height = width / 2 because of the supplied aspect ratio of 2. As a workaround, I've disabled maintainAspectRatio in my code:
This behavior is highly confusing when starting with this library. As a new user, I didn't know about this option and it took me quite a while to figure this out, only by digging into the javascript code. Maybe the default behavior should be changed to MaintainAspectRatio = false. |
Thank you so much for your comment. I saw the issue with the line graph (only this one). I didn't want to change the I'm using the default values from the ChartJs documentation. Have you found the right configuration for the line chart? Is it now displayed using the size you want? |
If I MaintainAspectRatio to false it works as I need it. |
Overriding the defaults from C# should work I guess, no need to change chart.js Do you prefer to close the issue for now, or keep it open? |
Cool! Thank you for your update. We can close it then. |
Describe the bug
For line charts (and maybe others, I only tried this one), if setting width and height, the height parameter is ignored and is always "width / 2". This issue probably is related to #15
To Reproduce
Steps to reproduce the behavior:
<Chart Config="_config1" @ref="_chart1" Width="500px" Height="400px"></Chart>
Expected behavior
Desktop (please complete the following information):
Additional context
As far as I can see, the _resize method in chart.js (from line 6855) overrides the width and height:
If I change the lines setting the width to this, it works as expected:
So, "this.platform.getMaximumSize(canvas, width, height, aspectRatio);" returns a smaller maximum size than requested. Although I have an idea how this happens, I'm not sure what the best fix for this is. There probably is a reason why getMaximumSize returns a smaller size.
As a side note, I've noticed that the canvas element can be removed from Chart.razor:
I can remove this line, and everything still works as usual. It seems the canvas is created later in javascript.
The text was updated successfully, but these errors were encountered: