Skip to content

Commit

Permalink
Respect AspectRatio by making chart-dimensions nullable (#88)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
esso23 authored Mar 27, 2020
1 parent 907f3f2 commit bc4cb3b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ChartJs.Blazor/Charts/ChartBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public abstract class ChartBase<TConfig> : ComponentBase where TConfig : ConfigB
/// The width of the canvas HTML element used to draw the chart.
/// </summary>
[Parameter]
public int Width { get; set; } = 400;
public int? Width { get; set; }

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

/// <inheritdoc />
protected override Task OnAfterRenderAsync(bool firstRender)
Expand Down

0 comments on commit bc4cb3b

Please sign in to comment.