score:1

without seeing your code and data it is hard to provide a concrete example that matches exactly what you are doing. this can be done before using d3 or dimple by filtering and reducing your values in a few lines of code. Say your items have a label and a value and are in an array called "all_items". You will need to set a threshold value.

const threshold = 100;
big_items = all_items.filter(item => item.value > threshold);
small_items = all_items.filter(item => item.value <= threshold);
collected_value = { 
    label: `other - ${small_items.length} items`,
    value: small_items.reduce((accumulator, item) => accumulator + item.value, 0)
}
big_items.push(collected_value);

then you can create your chart using the big_items array. This doesn't automatically decide what threshold to use and do the work, which you might be looking for.


Related Query

More Query from same tag