(color, mode)
| 457 | } |
| 458 | |
| 459 | function createColorData(color, mode) { |
| 460 | const f = getChannelsAndFunction(mode); |
| 461 | const method = (d) => d3[f.func](d); |
| 462 | |
| 463 | let dataA = color.map(function (d) { |
| 464 | let channelValue = method(d)[f.c1]; |
| 465 | // Need to do some geometry for polar colorspaces |
| 466 | if (mode === 'CAM02p' || mode === 'LCH' || mode === 'HSL' || mode === 'HSV' || mode === 'HSLuv') { |
| 467 | let s = mode === 'HSL' || mode === 'HSV' ? method(d)[f.c2] * 100 : method(d)[f.c2]; |
| 468 | let h = channelValue; |
| 469 | return filterNaN(convertToCartesian(s, h).x); |
| 470 | } else return filterNaN(channelValue); |
| 471 | }); |
| 472 | let dataB = color.map(function (d) { |
| 473 | let channelValue = method(d)[f.c3]; |
| 474 | if (mode === 'HSL' || mode === 'HSV') channelValue = channelValue * 100; |
| 475 | return filterNaN(channelValue); |
| 476 | }); |
| 477 | let dataC = color.map(function (d) { |
| 478 | let channelValue = method(d)[f.c2]; |
| 479 | // Need to do some geometry for polar colorspaces |
| 480 | if (mode === 'CAM02p' || mode === 'LCH' || mode === 'HSL' || mode === 'HSV' || mode === 'HSLuv') { |
| 481 | let s = mode === 'HSL' || mode === 'HSV' ? channelValue * 100 : channelValue; |
| 482 | let h = method(d)[f.c1]; |
| 483 | return filterNaN(convertToCartesian(s, h).y); |
| 484 | } |
| 485 | return filterNaN(channelValue); |
| 486 | }); |
| 487 | |
| 488 | return { |
| 489 | a: dataA, |
| 490 | b: dataB, |
| 491 | c: dataC |
| 492 | }; |
| 493 | } |
| 494 | |
| 495 | function getChannelsAndFunction(mode) { |
| 496 | let c1, c2, c3, func, yMin, yMax, yMin2, yMax2, c1Label, c2Label, c3Label; |
nothing calls this directly
no test coverage detected