mariusmuntean / ChartJs.Blazor

Brings Chart.js charts to Blazor
https://www.iheartblazor.com/
MIT License
677 stars 151 forks source link

Width and Height get not applied #99

Closed Schrall closed 4 years ago

Schrall commented 4 years ago

Describe the bug

<ChartJsBarChart @ref="_barChartJs" Config="@_config" Width="400" Height="200" /> should render a Chart with a Canvas Size 400x200px. Instead i get a Canvas with following Measurements:

<canvas id="64316256-f732-4b9d-b3fa-2b44d11e9939" width="1629" height="814" class="chartjs-render-monitor" style="display: block; width: 1629px; height: 814px;"></canvas>

Which Blazor project type is your bug related to?

Which charts does this bug apply to?

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ChartJSBlazor 1.1.0
  2. Run this code https://raw.githubusercontent.com/mariusmuntean/ChartJs.Blazor/master/samples/Shared/ChartJs.Blazor.Sample.Shared/Components/BarCharts/TimeBarChartComponent.razor

Expected behavior

Get a Chart with a Size 400x200px

Joelius300 commented 4 years ago

Thanks for contacting us.

Have you set the Responsive option to true in your config (like in the example you liked)? If so, the behaviour is expected (read this). I think it's suboptimal behaviour but for now you'll have to add a container div around it with a fixed height if you want to keep responsivness while restricting to a certain size. Otherwise just set Responsive to false and the fixed size should apply.

Schrall commented 4 years ago

Thank you.