Hi.i'm trying to explode the clicked slice but i need only the current one to remain exploded. that means that when a second slice is clicked- i must 'unexplode' the prev slice.can't find a way to do that.thank you.
Hi itai,
Thank you for posting on our forums.
I've created a sample on jsFiddle which uses the available sliceClick event to set the explodedSlices accordingly.
Please review the sample and let me know if you have any questions.
thank you very much for your response.
can this solution be implemented when there's no id in the data to be used (no ui.slice.item.id)?
how can i know the index of the clicked slice?
thank you,
Itai
Hi,
Thank you for the update.
The igPieChart renders the slices by iterating through the JSON objects. For this reason, the zero-based id property is used to identify which slice corresponds to the object in your datasource. Alternatively, you can opt to create a function that loops through your datasource and adds a way to "id" the objects as I've done manually in my example. I would recommend using a zero-based integer since the explodedSlices option is of type array, which is also zero-based.
Please let me know if you have additional questions regarding this matter.
so, if i understand you correctly, this can't be done without an id property? it seems very strange to me, to be forced to use a property like that in my data. after all, i may have data that doesn't have that property...
I've tried using the isExploded property of the slice itself, but of-course, it doesn't change the "explodedSlices" array of the chart.
i've also tried saving the reference for the first slice in memory and setting its 'isExploded' property to false in the second click but it didn't work either.
can you offer a way to do that without an 'id' property in the data? what is the solution if the json objects 'id' is not a zero-based integer (like GUID)?
The explodedSlices option is an array of integers that indicate the indexes of the slices to explode. Moreover, the id property in each json object is used to identify the index for each slice in the collection. The ability to identify which slice corresponds to the slice click event is required in order to ensure you're exploding the correct slice.
Please let me know if you have further questions regarding this matter.