Articles in this section
Category / Section

How to set the selected theme for the ASP.NET Core Charts?

2 mins read

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.

image.png

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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied