public interface KeyFunction<T>
Single argument Selection.data()
methods use a default by-index behavior to map data with elements. This interface can be passed to
Selection.data(com.google.gwt.core.client.JavaScriptObject, KeyFunction)
and variants to map data to elements using a different criteria.
The #apply(Element, Datum, int)
method will be called once for each element in the new data array, and once again for each existing element in the selection. The result
will be used to map the passed data to the passed element.
#apply(Element, Datum, int)
T map(com.google.gwt.dom.client.Element context, Array<?> newDataArray, Value datum, int index)
The returned value is used as a key to map the new data array elements to existing (or future) elements of the selection:
UpdateSelection.enter()
UpdateSelection.exit()
.
context
- the current element when this method is invoked for the existing elements of the selection,
or null when this method is invoked for the new data arraynewDataArray
- the new data array when this method is invoked for the elements in the new data array,
or null when this method is invoked for the existing elements of the selection.datum
- the datum element of the new data array, or the datum of the current element contextindex
- the index of the datum in the new data array, or the index of the element in the selectionSelection.data(com.google.gwt.core.client.JavaScriptObject, KeyFunction)
Copyright © 2015 gwt-d3. All rights reserved.