Skip to content

Commit

Permalink
Merge pull request #568 from apexcharts/add-clustered-legend-options
Browse files Browse the repository at this point in the history
Add clustered legend options
  • Loading branch information
joadan authored Jan 8, 2025
2 parents 069ed67 + 14d5dda commit e23e11f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
<DemoContainer>
<ApexChart TItem="Order"
Title="Order Net Value"
Options=options>
Title="Order Net Value"
Options=options Debug="true">

<ApexPointSeries TItem="Order"
Items="Orders"
Name="Gross Value Budget"
Group="Budget"
SeriesType="SeriesType.Bar"
XValue="@(e => e.Country)"
YAggregate="@(e => e.Sum(e => e.GrossValue) - 10000)"
OrderByDescending="e=>e.Y"
ShowDataLabels />
Items="Orders"
Name="Gross Value Budget"
Group="Budget"
SeriesType="SeriesType.Bar"
XValue="@(e => e.Country)"
YAggregate="@(e => e.Sum(e => e.GrossValue) - 10000)"
OrderByDescending="e=>e.Y"
ShowDataLabels />

<ApexPointSeries TItem="Order"
Items="Orders"
Name="Gross Value"
Group="Actual"
SeriesType="SeriesType.Bar"
XValue="@(e => e.Country)"
YAggregate="@(e => e.Sum(e => e.GrossValue))"
OrderByDescending="e=>e.Y"
ShowDataLabels />
Items="Orders"
Name="Gross Value"
Group="Actual"
SeriesType="SeriesType.Bar"
XValue="@(e => e.Country)"
YAggregate="@(e => e.Sum(e => e.GrossValue))"
OrderByDescending="e=>e.Y"
ShowDataLabels />



<ApexPointSeries TItem="Order"
Items="Orders"
Name="Net Value Budget"
Group="Budget"
SeriesType="SeriesType.Bar"
XValue="@(e => e.Country)"
YAggregate="@(e => e.Sum(e => e.NetValue))"
OrderByDescending="e=>e.Y"
ShowDataLabels />
Items="Orders"
Name="Net Value Budget"
Group="Budget"
SeriesType="SeriesType.Bar"
XValue="@(e => e.Country)"
YAggregate="@(e => e.Sum(e => e.NetValue))"
OrderByDescending="e=>e.Y"
ShowDataLabels />

<ApexPointSeries TItem="Order"
Items="Orders"
Name="Net Value"
Group="Actual"
SeriesType="SeriesType.Bar"
XValue="@(e => e.Country)"
YAggregate="@(e => e.Sum(e => e.NetValue))"
OrderByDescending="e=>e.Y"
ShowDataLabels />
Items="Orders"
Name="Net Value"
Group="Actual"
SeriesType="SeriesType.Bar"
XValue="@(e => e.Country)"
YAggregate="@(e => e.Sum(e => e.NetValue))"
OrderByDescending="e=>e.Y"
ShowDataLabels />
</ApexChart>
</DemoContainer>
@code {
Expand All @@ -66,6 +66,7 @@
Horizontal = true
}
},
Legend = new Legend { ClusterGroupedSeriesOrientation = ClusterGroupedSeriesOrientation.Horizontal },
Colors = new List<string> { "#80c7fd", "#008FFB", "#80f1cb", "#00E396" },
Xaxis = new XAxis { Categories = new List<string> { "Category1", "Category2", "Category3", "Category4" } }
};
Expand Down
23 changes: 23 additions & 0 deletions src/Blazor-ApexCharts/Models/ApexChartOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2321,8 +2321,22 @@ public class Legend
/// Allows you to overwrite the default legend items with this customized set of labels. Please note that the click/hover events of the legend will stop working if you provide these custom legend labels.
/// </summary>
public List<string> CustomLegendItems { get; set; }

/// <summary>
/// Indicates if the Legends should grouped by Cluster
/// Default is true in Apexcharts.js
/// </summary>
public bool? ClusterGroupedSeries { get; set; }

/// <summary>
/// Orientation for the Clustered Grouped Series
/// </summary>
public ClusterGroupedSeriesOrientation? ClusterGroupedSeriesOrientation { get; set; }

}



/// <summary>
/// Undocumented, this class exists in the TypeScript definition
/// </summary>
Expand Down Expand Up @@ -5521,6 +5535,15 @@ public enum ShapeEnum
Rect
};

/// <summary>
/// Orientation options for the Clustered Grouped Series
/// </summary>
public enum ClusterGroupedSeriesOrientation
{
Horizontal,
Vertical
};

/// <summary>
/// A list of alignment options for vertical placement
/// </summary>
Expand Down

0 comments on commit e23e11f

Please sign in to comment.