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
close icon

Hide legend

Hello,

In Multiline syncfusion chart, if series data name is null or empty then I want to hide this data and legend also,how??

  e.g.

Suppose I have ,

Series:[{  type:'line',

name='',

datasource:data.open,

},

type:'line',

name='Product A',

datasource:data.close,

}

}]


In above e.g. series[0] contains no name (blank name) so chart take legend as'series1' , In such a case I want to hide the legend and its corresponding values on chart.






3 Replies

PR Praveen Syncfusion Team April 10, 2015 11:50 AM UTC

Hi Kalpa serashiya,
Thanks for using Syncfusion product.
Currently there is no support to hide the visibility of the legend while series name is empty in chart. We would like to inform you that we have logged this as a feature request in our database. We will implement this feature in any of our upcoming releases. We usually have an interval of at least three months between releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We request you to visit our website periodically to know more about the feature update.

Query #1: series [0] contains no name (blank name) so chart take legend as'series1' , In such a case I want to hide the legend and its corresponding values on chart.

Response: We have analyzed your query and there is no way to directly achieve this .So we have hide the visibility of the legend while series name is empty in chart by using triggering events of ‘preRender’ and ‘loaded. The prerender event is used to hidden the series visibility and loaded event remove the legend from DOM. Right now we have removed the legend from DOM element but the legend item space calculated to render legenditmes willnot be removed. The following code snippet shows this,

[JS]

function series(sender)

{

for (var i = 0; i < sender.model.series.length; i++)

{

if(sender.model.series[i].name=="")

sender.model.series[i].visibility = "hidden";

}

}

function legend(sender)

{

for (var i = 0; i < sender.model.series.length; i++)

{

if (sender.model.series[i].name == "")

{

$("#" + this._id + "_svg_Legend" + i).remove();

}

}

}



Screen Shot:



We have preapared a sample for your convenience and it can be downloaded from the below link.

Sample : LegendHide.zip

Please let us know if you have any concern.

Thanks,
Praveenkumar



KS kalpa serashiya April 13, 2015 05:24 AM UTC

Hello,
Thank you.
Now my issue is resolved.


PR Praveen Syncfusion Team April 14, 2015 11:49 AM UTC

Hi Kalpa serashiya,
Thanks for your update.
Kindly let us know if you face any difficulties.

Thanks,
Praveenkumar.

Loader.
Live Chat Icon For mobile
Up arrow icon