We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get a Series by ID or Name Instead of by Index

Thread ID:





148006 Oct 1,2019 05:52 PM UTC Oct 2,2019 01:33 PM UTC ASP.NET Core - EJ 2 1
Tags: Charts
Scott Hancock
Asked On October 1, 2019 05:52 PM UTC

I know that I can get a chart series with code like this:

     var chart = document.getElementById("container").ej2_instances[0];
     chart.series[3].visible = document.getElementById("chkTempLow").checked;

But my chart has a dynamic number of series so I don't know the index of the series I want.

Is there any way to find/refer to a series by something other than it's index?

For example:




Bhuvanesh Valarman [Syncfusion]
Replied On October 2, 2019 01:33 PM UTC

Hi Scott, 

Greetings from Syncfusion. 

We have analyzed your query. From that we suggest you to use the below workaround to achieve your scenario by using series name to get series. 

Code Snippet:  
<input id="seriesname" type="text" placeholder="Enter the series name to change color" style="width: 300px;" onchange="GetSeries()" /> 
<ejs-chart id="container" > 
    <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis> 
        <e-series dataSource="ViewBag.DataSource" xName="Day" yName="YValue" type="Column" name="Product A" width="2"></e-series> 
        <e-series dataSource="ViewBag.DataSource" xName="Day" yName="YValue2" type="Column" name="Product B" width="2"></e-series> 
        <e-series dataSource="ViewBag.DataSource" xName="Day" yName="YValue3" type="Column" name="Product C" width="2"></e-series> 
    function GetSeries() { 
        var chart = document.getElementById("container").ej2_instances[0]; 
        var name = document.getElementById('seriesname').value; 
        var series = GetSeriesByName(chart.series, name); 
        series.fill = "Purple"; 
    function GetSeriesByName(series, name) { 
        for (var i = 0; i < series.length; i++) { 
            if (series[i].name == name) { 
                return series[i]; 
        return null; 
Kindly revert us, if you any concerns about this. 

Bhuvanesh V. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon