(tooltip, rootValue, data)
| 572 | } |
| 573 | |
| 574 | function createFlamegraph(tooltip, rootValue, data) { |
| 575 | const chartArea = document.querySelector('.chart-area'); |
| 576 | const width = chartArea ? chartArea.clientWidth - 32 : window.innerWidth - 320; |
| 577 | const heatColors = getHeatColors(); |
| 578 | |
| 579 | const isDifferential = data && data.stats && data.stats.is_differential; |
| 580 | const diffColors = isDifferential ? getDiffColors() : null; |
| 581 | |
| 582 | let chart = flamegraph() |
| 583 | .width(width) |
| 584 | .cellHeight(20) |
| 585 | .transitionDuration(300) |
| 586 | .minFrameSize(1) |
| 587 | .tooltip(tooltip) |
| 588 | .inverted(true) |
| 589 | .setColorMapper(function (d) { |
| 590 | if (d.depth === 0) return 'transparent'; |
| 591 | |
| 592 | if (isDifferential) { |
| 593 | return getDiffColorForNode(d, diffColors); |
| 594 | } |
| 595 | |
| 596 | const percentage = d.data.value / rootValue; |
| 597 | const level = getHeatLevel(percentage); |
| 598 | return heatColors[level]; |
| 599 | }); |
| 600 | |
| 601 | return chart; |
| 602 | } |
| 603 | |
| 604 | function renderFlamegraph(chart, data) { |
| 605 | d3.select("#chart").datum(data).call(chart); |
no test coverage detected
searching dependent graphs…