How to show or hide the series in ASP.NET Core Charts on initial loading with specific time interval?
Description
This article shows how to show or hide the series in ASP.NET Core Charts on initial loading with specific time interval.
Solution
To show or hide a series in a chart, you can use the visible property of the series. This property can be set to “true” to show the series, or “false” to hide it. By enabling or disabling the “visible” property of a series, you can easily automate the process of showing or hiding the series in the chart.
To show or hide a series in specific intervals using setInterval, you can first define the function that will trigger the changes and then use setInterval to call that function at the desired intervals.
Code Snippet
The following code example shows how to show or hide the series.
<ejs-chart id="container"></ejs-chart>
<script>
var chart, intervalId,setTimeoutValue = 1000;
intervalId = setInterval(
function() {
if (document.getElementById('container') === null) {
clearInterval(intervalId);
} else {
chart = document.getElementById('container').ej2_instances[0];
for (var i = 0; i < chart.series.length; i++) {
chart.series[i].visible = chart.series[i].visible ? false : true;
}
chart.refresh();
}
}, setTimeoutValue);
</script>
The following image illustrates the output of the above code.
Conclusion
I hope you enjoyed learning how to show or hide the series in ASP.NET Core Charts on initial loading with specific time interval.
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!