Skip to content

Commit e225d5f

Browse files
authored
Merge pull request #63 from apexcharts/xaxis-groups
Added Support for XAxis groups
2 parents a22e965 + 5484512 commit e225d5f

File tree

10 files changed

+31872
-3
lines changed

10 files changed

+31872
-3
lines changed

docs/BlazorApexCharts.Docs/Components/ChartTypes/BarCharts/Basic.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
@code {
2424
private List<Order> Orders { get; set; } = SampleData.GetOrders();
25-
}
25+
}

docs/BlazorApexCharts.Docs/Components/ChartTypes/BoxPlotCharts/Basic.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
@code {
1212
private List<SupportIncident> incidents { get; set; } = SampleData.GetSupportIncidents(30,60);
13-
}
13+
}

docs/BlazorApexCharts.Docs/Components/Features/Annotations/Basic.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
protected override void OnInitialized()
2929
{
30+
3031
options.Annotations = new Annotations
3132
{
3233
Xaxis = new List<AnnotationsXAxis> { new AnnotationsXAxis
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@page "/features/axis"
2+
3+
<DocExamples Title="Axis">
4+
5+
<CodeSnippet Title="XAxis Groups" ClassName=@typeof(XAxisGroupsChart).ToString()>
6+
<Snippet>
7+
<XAxisGroupsChart />
8+
</Snippet>
9+
</CodeSnippet>
10+
11+
12+
13+
</DocExamples>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<DemoContainer>
2+
<ApexChart TItem="Order"
3+
Title="Order Net Value"
4+
Options=options>
5+
6+
<ApexPointSeries TItem="Order"
7+
Items="Orders"
8+
Name="Gross Value"
9+
XValue="@(e => e.Country)"
10+
YAggregate="@(e => e.Sum(e => e.GrossValue))"
11+
SeriesType="SeriesType.Bar" />
12+
13+
<ApexPointSeries TItem="Order"
14+
Items="Orders"
15+
Name="Net Value"
16+
XValue="@(e => e.Country)"
17+
YAggregate="@(e => e.Sum(e => e.NetValue))"
18+
SeriesType="SeriesType.Bar" />
19+
</ApexChart>
20+
</DemoContainer>
21+
22+
@code {
23+
private List<Order> Orders { get; set; } = SampleData.GetOrders();
24+
private ApexChartOptions<Order> options { get; set; } = new();
25+
26+
protected override void OnInitialized()
27+
{
28+
options.Xaxis = new XAxis
29+
{
30+
Group = new XAxisGroups
31+
{
32+
Style = new XAxisGroupStyle { FontSize = "20px" },
33+
Groups = new List<XAxisGroup> {
34+
new XAxisGroup { Title = "Group 1", Cols = 2 },
35+
new XAxisGroup { Title = "Group 2", Cols = 2 }
36+
}
37+
}
38+
};
39+
40+
options.Legend = new Legend { Position = LegendPosition.Top };
41+
42+
}
43+
44+
}

docs/BlazorApexCharts.Docs/Data/SampleData.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,19 @@ public static List<Order> GetOrders()
5959
orders.Add(new Order { CustomerName = "Ani Vent", Country = "France", OrderDate = DateTimeOffset.Now.AddDays(-17), GrossValue = 2134, DiscountPrecentage = 34, OrderType = OrderType.Phone });
6060
orders.Add(new Order { CustomerName = "Ani Vent", Country = "France", OrderDate = DateTimeOffset.Now.AddDays(-27), GrossValue = 11345, DiscountPrecentage = 12, OrderType = OrderType.Phone });
6161
orders.Add(new Order { CustomerName = "Ani Vent", Country = "France", OrderDate = DateTimeOffset.Now.AddDays(-124), GrossValue = 17002, DiscountPrecentage = 32, OrderType = OrderType.Mail });
62-
6362
orders.Add(new Order { CustomerName = "Cali Inc", Country = "France", OrderDate = DateTimeOffset.Now.AddDays(-10), GrossValue = 77000, DiscountPrecentage = 17, OrderType = OrderType.Web });
6463
orders.Add(new Order { CustomerName = "Cali Inc", Country = "France", OrderDate = DateTimeOffset.Now.AddDays(-110), GrossValue = 120000, DiscountPrecentage = 23, OrderType = OrderType.Web });
6564
orders.Add(new Order { CustomerName = "Cali Inc", Country = "France", OrderDate = DateTimeOffset.Now.AddDays(-243), GrossValue = 44000, DiscountPrecentage = 8, OrderType = OrderType.Web });
6665

66+
67+
orders.Add(new Order { CustomerName = "Chart Inc", Country = "Brazil", OrderDate = DateTimeOffset.Now.AddDays(-11), GrossValue = 2345, DiscountPrecentage = 11, OrderType = OrderType.Phone });
68+
orders.Add(new Order { CustomerName = "Chart Inc", Country = "Brazil", OrderDate = DateTimeOffset.Now.AddDays(-14), GrossValue = 34567, DiscountPrecentage = 22, OrderType = OrderType.Phone });
69+
orders.Add(new Order { CustomerName = "Chart Inc", Country = "Brazil", OrderDate = DateTimeOffset.Now.AddDays(-121), GrossValue = 45662, DiscountPrecentage = 23, OrderType = OrderType.Mail });
70+
orders.Add(new Order { CustomerName = "Chart Inc", Country = "Brazil", OrderDate = DateTimeOffset.Now.AddDays(-11), GrossValue = 66000, DiscountPrecentage = 11, OrderType = OrderType.Web });
71+
orders.Add(new Order { CustomerName = "Chart Inc", Country = "Brazil", OrderDate = DateTimeOffset.Now.AddDays(-90), GrossValue = 10000, DiscountPrecentage = 8, OrderType = OrderType.Web });
72+
orders.Add(new Order { CustomerName = "Chart Inc", Country = "Brazil", OrderDate = DateTimeOffset.Now.AddDays(-123), GrossValue = 69000, DiscountPrecentage = 25, OrderType = OrderType.Web });
73+
74+
6775
return orders;
6876
}
6977

docs/BlazorApexCharts.Docs/Shared/MainNavigation.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113

114114
<SubMenu>
115115
<NavbarMenuItem Text="Annotations" Href="features/annotations" />
116+
<NavbarMenuItem Text="Axis" Href="features/axis" />
116117
<NavbarMenuItem Text="Formatters" Href="features/formatters" />
117118
<NavbarMenuItem Text="Legend" Href="features/legend" />
118119
<NavbarMenuItem Text="Performance" Href="features/performance" />

src/Blazor-ApexCharts/Blazor-ApexCharts.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222

2323
<ItemGroup>
24+
<Content Update="wwwroot\js\apex-charts.debug.js">
25+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
26+
</Content>
2427
<Content Update="wwwroot\js\apex-charts.min.js">
2528
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2629
</Content>

src/Blazor-ApexCharts/Models/ApexChartOptions.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,29 @@ public class XAxis
12941294
public AxisTitle Title { get; set; }
12951295
public AxisTooltip Tooltip { get; set; }
12961296
public XAxisType? Type { get; set; }
1297+
public XAxisGroups Group { get; set; }
1298+
}
1299+
1300+
public class XAxisGroups
1301+
{
1302+
public List<XAxisGroup> Groups { get; set; }
1303+
public XAxisGroupStyle Style { get; set; }
1304+
1305+
}
1306+
1307+
public class XAxisGroup
1308+
{
1309+
public string Title { get; set; }
1310+
public int Cols { get; set; }
1311+
}
1312+
1313+
public class XAxisGroupStyle
1314+
{
1315+
public List<string> Colors { get; set; }
1316+
public string FontSize { get; set; }
1317+
public string FontFamily { get; set; }
1318+
public string FontWeight { get; set; }
1319+
public string CssClass { get; set; }
12971320
}
12981321

12991322
public enum TickPlacement

0 commit comments

Comments
 (0)