* Perform a Plotly.restyle like operation on an input object array * * @param {Array. } parentArray * The object that the restyle operation should be applied to * @param {Object} restyleData * A restyle object as accepted by Plotly.restyle * @param {Array. } restyleTraces * A
( parentArray: any[], restyleData: any, restyleTraces: number[] )
| 1800 | * |
| 1801 | */ |
| 1802 | function performRestyleLike( |
| 1803 | parentArray: any[], |
| 1804 | restyleData: any, |
| 1805 | restyleTraces: number[] |
| 1806 | ) { |
| 1807 | // Loop over the properties of restyleData |
| 1808 | for (var rawKey in restyleData) { |
| 1809 | if (!restyleData.hasOwnProperty(rawKey)) { |
| 1810 | continue; |
| 1811 | } |
| 1812 | |
| 1813 | // Extract value for property and normalize into a value list |
| 1814 | var valArray = restyleData[rawKey]; |
| 1815 | if (!Array.isArray(valArray)) { |
| 1816 | valArray = [valArray]; |
| 1817 | } |
| 1818 | |
| 1819 | // Loop over the indexes of the traces being restyled |
| 1820 | for (var i = 0; i < restyleTraces.length; i++) { |
| 1821 | // Get trace object |
| 1822 | var traceInd = restyleTraces[i]; |
| 1823 | var trace = parentArray[traceInd]; |
| 1824 | |
| 1825 | // Extract value for this trace |
| 1826 | var singleVal = valArray[i % valArray.length]; |
| 1827 | |
| 1828 | // Set property value |
| 1829 | if (singleVal === null) { |
| 1830 | _.unset(trace, rawKey); |
| 1831 | } else if (singleVal !== undefined) { |
| 1832 | _.set(trace, rawKey, singleVal); |
| 1833 | } |
| 1834 | } |
| 1835 | } |
| 1836 | } |
| 1837 | |
| 1838 | /** |
| 1839 | * Perform a Plotly.moveTraces like operation on an input object array |
no test coverage detected