1. Tag Results
theme-changes (2)
1 - 2 of 2
How to Apply a Theme in Blazor Charts?
This article explains how to apply a theme in Blazor Charts using the Theme property of the SfChart component. Overview Blazor Charts allows you to customize the appearance of charts using predefined themes. You can apply a theme by setting the Theme property in the SfChart component. This enables consistent styling aligned with your application’s look and feel. Code Example The following example demonstrates how to apply the MaterialDark theme to a chart. @using Syncfusion.Blazor.Charts @using Syncfusion.Blazor <div> <SfChart Title="Olympic Medal Counts - RIO" Theme="@Theme"> <ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" Interval="1"> </ChartPrimaryXAxis> <ChartPrimaryYAxis Title="Medal Count" Maximum="50" Interval="10"> </ChartPrimaryYAxis> <ChartSeriesCollection> <ChartSeries TooltipMappingName="MappingName" DataSource="@ChartPoints" XName="Country" YName="GoldMedal" Name="Gold" ColumnSpacing="0.1" Type="Syncfusion.Blazor.Charts.ChartSeriesType.Column"> </ChartSeries> <ChartSeries TooltipMappingName="MappingName" DataSource="@ChartPoints" XName="Country" YName="SilverMedal" Name="Silver" ColumnSpacing="0.1" Type="Syncfusion.Blazor.Charts.ChartSeriesType.Column"> </ChartSeries> <ChartSeries TooltipMappingName="MappingName" DataSource="@ChartPoints" XName="Country" YName="BronzeMedal" Name="Bronze" ColumnSpacing="0.1" Type="Syncfusion.Blazor.Charts.ChartSeriesType.Column"> </ChartSeries> </ChartSeriesCollection> </SfChart> </div> @code { private Theme Theme { get; set; } public List<ColumnChartData> ChartPoints { get; set; } = new List<ColumnChartData> { new ColumnChartData { Country = "GBR", GoldMedal = 27, SilverMedal = 23, BronzeMedal = 17, MappingName = "Great Britain" }, new ColumnChartData { Country = "CHN", GoldMedal = 26, SilverMedal = 18, BronzeMedal = 26, MappingName = "China" }, new ColumnChartData { Country = "AUS", GoldMedal = 8, SilverMedal = 11, BronzeMedal = 10, MappingName = "Australia" }, new ColumnChartData { Country = "RUS", GoldMedal = 19, SilverMedal = 17, BronzeMedal = 20, MappingName = "Russia" }, new ColumnChartData { Country = "GER", GoldMedal = 17, SilverMedal = 10, BronzeMedal = 15, MappingName = "Germany" }, new ColumnChartData { Country = "UA", GoldMedal = 2, SilverMedal = 5, BronzeMedal = 24, MappingName = "Ukraine" }, new ColumnChartData { Country = "ES", GoldMedal = 7, SilverMedal = 4, BronzeMedal = 6, MappingName = "Spain" }, new ColumnChartData { Country = "UZB", GoldMedal = 4, SilverMedal = 2, BronzeMedal = 7, MappingName = "Uzbekistan" }, new ColumnChartData { Country = "JPN", GoldMedal = 12, SilverMedal = 8, BronzeMedal = 21, MappingName = "Japan" }, new ColumnChartData { Country = "NL", GoldMedal = 8, SilverMedal = 7, BronzeMedal = 4, MappingName = "NetherLand" }, new ColumnChartData { Country = "USA", GoldMedal = 46, SilverMedal = 37, BronzeMedal = 38, MappingName = "United States" }, }; protected override void OnInitialized() { Theme = Theme.MaterialDark; } public class ColumnChartData { public string Country { get; set; } public double GoldMedal { get; set; } public double SilverMedal { get; set; } public double BronzeMedal { get; set; } public string MappingName { get; set; } } } Output The chart will render with the Material Dark theme applied. Live Sample You can view a live example of applying a theme to Blazor Charts here. Conclusion: We hope you found this guide helpful in learning how to apply a theme in Blazor Charts. For more features, visit our [Blazor Charts feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our [Blazor Charts example to understand how to create and manipulate data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!
How to set the selected theme for the ASP.NET Core Charts?
Description This article shows how to set the selected theme for the ASP.NET Core Charts. Solution Syncfusion provides several built-in themes such as Material, Bootstrap, Fabric, and High Contrast etc. We can set these themes for the chart. We have rendered a dropdown alongside the chart. When a theme is selected from the dropdown, a change event is triggered. This event sets the corresponding theme to the chart using the theme property. The chart seamlessly adapts to the selected theme, providing either a dark or light theme appearance. Code Snippet The following code example shows how to set the theme in the chart. index.cshtml <div> <label for="themeDropdown">Select Theme:</label> <select id="themeDropdown"> <option value="Bootstrap5Dark">Bootstrap5Dark</option> <option value="Bootstrap5">Bootstrap5</option> <!-- Add more theme options here --> </select> </div> <ejs-chart theme="Bootstrap5Dark"> </ejs-chart> <script> document.getElementById("themeDropdown").addEventListener("change", function () { var selectedTheme = this.value; var chart = document.getElementById("container").ej2_instances[0]; chart.theme = selectedTheme; chart.refresh(); }); </script> The following image illustrates the output of the above code. Conclusion I hope you enjoyed learning how to set the selected theme for the ASP.NET Core Charts. You can refer to our ASP.NET Core Chart feature tour page to learn about its other features and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET Core Chart example to understand how to create and visualize data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comment section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!
No articles found
No articles found
1 of 1 pages (2 items)