Skip to content

Commit

Permalink
Make creation of horizontal bar configs easier [BREAKING]
Browse files Browse the repository at this point in the history
Instead of passing the correct ChartType, you can just specify a boolean value representing if the chart will be horizontal or not.
  • Loading branch information
Joelius300 committed Oct 16, 2020
1 parent e4b493a commit 6a9d58e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

protected override void OnInitialized()
{
_config = new BarConfig(ChartType.HorizontalBar)
_config = new BarConfig(horizontal: true)
{
Options = new BarOptions
{
Expand Down
8 changes: 7 additions & 1 deletion src/ChartJs.Blazor/BarChart/BarConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public class BarConfig : ConfigBase<BarOptions>
/// <summary>
/// Creates a new instance of the <see cref="BarConfig"/> class.
/// </summary>
public BarConfig(ChartType type = null) : base(type ?? ChartType.Bar) { }
/// <param name="horizontal">
/// If <see langword="true"/>, the chart-type will be set to <see cref="ChartType.HorizontalBar"/>
/// instead of <see cref="ChartType.Bar"/> which turns this chart into a horizontal
/// bar chart. If set to <see langword="true"/>, you also have to pass in <see langword="true"/> for
/// the <see cref="BarDataset{T}"/>s.
/// </param>
public BarConfig(bool horizontal = false) : base(horizontal ? ChartType.HorizontalBar : ChartType.Bar) { }
}
}

0 comments on commit 6a9d58e

Please sign in to comment.