Skip to content

Commit bc4cb3b

Browse files
authored
Respect AspectRatio by making chart-dimensions nullable (#88)
Changes the width/height properties to be nullable. This is required for AspectRatio to work since it's ignored when height is set (and it's always set if it's not nullable). The defaults of 400/400 are also removed. - As stated in the [responsive section](https://www.chartjs.org/docs/latest/general/responsive.html#configuration-options). > Note that this option (AspectRatio) is ignored if the height is explicitly defined either as attribute or via the style.
1 parent 907f3f2 commit bc4cb3b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ChartJs.Blazor/Charts/ChartBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ public abstract class ChartBase<TConfig> : ComponentBase where TConfig : ConfigB
2525
/// The width of the canvas HTML element used to draw the chart.
2626
/// </summary>
2727
[Parameter]
28-
public int Width { get; set; } = 400;
28+
public int? Width { get; set; }
2929

3030
/// <summary>
31-
/// The height of the canvas HTML element used to draw the chart.
31+
/// The height of the canvas HTML element used to draw the chart. Use null value when using AspectRatio.
3232
/// </summary>
3333
[Parameter]
34-
public int Height { get; set; } = 400;
34+
public int? Height { get; set; }
3535

3636
/// <inheritdoc />
3737
protected override Task OnAfterRenderAsync(bool firstRender)

0 commit comments

Comments
 (0)