I have a remove[] array which has all the index positions of all the element with 0 in the data array (as below).
data array:
Retail,1,Utilities,1,Food & Restaurant,3,No Data,4,Construction,0,Non-profit,1,Financial Services,12,Technology,2,Law,3,Religion,3,Retired,2,Insurance,0,Real Estate,2,Audit,3,Business Organizations,3,Media & Marketing,0,Education,3,Transportation,0,Manufacturing,0,Entertainment & Sports,0,Architecture & Engineering,0,Cultural Institutions,0,Government,0,Banking,0,Health Care,0,Business Services,0
my javascript
var remove = [];
$.each(options.series[0].data, function(index, item) {
if (options.series[0].data[index][1] == 0)
{
//options.series[0].data.splice(index,1);
remove[index] = index;
}
for (i=0; i<=remove.length; i++)
{
//alert(remove);
if (remove[i] != undefined)
options.series[0].data.splice(remove[i],1);
}
data array after splice(). A lot of elements with 0 are still there.
Retail,1,Utilities,1,Food & Restaurant,3,No Data,4,Non-profit,1,Financial Services,12,Technology,2,Law,3,Religion,3,Retired,2,Insurance,0,Audit,3,Business Organizations,3,Media & Marketing,0,Education,3,Manufacturing,0,Entertainment & Sports,0,Cultural Institutions,0,Banking,0,Business Services,0
if i changed the splice to include replacement element
options.series[0].data.splice(remove[i],1,'removed');
All 0 elements are removed from the data array. huh?
Retail,1,Utilities,1,Food & Restaurant,3,No Data,4,removed,Non-profit,1,Financial Services,12,Technology,2,Law,3,Religion,3,Retired,2,removed,Real Estate,2,Audit,3,Business Organizations,3,removed,Education,3,removed,removed,removed,removed,removed,removed,removed,removed,removed
How do I remove all the 0 elements in my data array?