MCPcopy Index your code
hub / github.com/plotly/plotly.py / performMoveTracesLike

Function performMoveTracesLike

js/src/widget.ts:1857–1884  ·  view source on GitHub ↗

* Perform a Plotly.moveTraces like operation on an input object array * @param parentArray * The object that the moveTraces operation should be applied to * @param currentInds * Array of the current indexes of traces to be moved * @param newInds * Array of the new indexes that traces select

(
  parentArray: any[],
  currentInds: number[],
  newInds: number[]
)

Source from the content-addressed store, hash-verified

1855 * d -> [{foo: 1}, {foo: 0}, {foo: 2}]
1856 */
1857function performMoveTracesLike(
1858 parentArray: any[],
1859 currentInds: number[],
1860 newInds: number[]
1861) {
1862 // ### Remove by currentInds in reverse order ###
1863 var movingTracesData: any[] = [];
1864 for (var ci = currentInds.length - 1; ci >= 0; ci--) {
1865 // Insert moving parentArray at beginning of the list
1866 movingTracesData.splice(0, 0, parentArray[currentInds[ci]]);
1867 parentArray.splice(currentInds[ci], 1);
1868 }
1869
1870 // ### Sort newInds and movingTracesData by newInds ###
1871 var newIndexSortedArrays = _(newInds)
1872 .zip(movingTracesData)
1873 .sortBy(0)
1874 .unzip()
1875 .value();
1876
1877 newInds = newIndexSortedArrays[0];
1878 movingTracesData = newIndexSortedArrays[1];
1879
1880 // ### Insert by newInds in forward order ###
1881 for (var ni = 0; ni < newInds.length; ni++) {
1882 parentArray.splice(newInds[ni], 0, movingTracesData[ni]);
1883 }
1884}
1885
1886/**
1887 * Remove nested properties from a parent object

Callers 1

do_moveTracesMethod · 0.85

Calls 2

_Class · 0.50
valueMethod · 0.45

Tested by

no test coverage detected