@@ -608,6 +608,7 @@ function generateInteractiveHistogram(timeDiffStats, title, filename) {
608608
609609 <div id="histogram" class="plot-container"></div>
610610 <div id="boxplot" class="plot-container"></div>
611+ <div id="cumulative" class="plot-container"></div>
611612 </div>
612613
613614 <script>
@@ -693,9 +694,84 @@ function generateInteractiveHistogram(timeDiffStats, title, filename) {
693694 margin: { t: 50, b: 50, l: 50, r: 50 }
694695 };
695696
697+ // Создаем накопительный график по диапазонам дней
698+ function createCumulativeChart() {
699+ // Сортируем данные по возрастанию
700+ const sortedData = [...data].sort((a, b) => a - b);
701+
702+ // Создаем диапазоны (например, по 10 дней)
703+ const rangeSize = 10;
704+ const maxValue = Math.max(...sortedData);
705+ const ranges = [];
706+ const cumulativeCounts = [];
707+ const labels = [];
708+
709+ let cumulativeSum = 0;
710+
711+ for (let i = rangeSize; i <= maxValue + rangeSize; i += rangeSize) {
712+ const rangeStart = i - rangeSize;
713+ const rangeEnd = i;
714+
715+ // Считаем количество элементов в текущем диапазоне
716+ const countInRange = sortedData.filter(val => val >= rangeStart && val < rangeEnd).length;
717+
718+ // Добавляем к накопительной сумме
719+ cumulativeSum += countInRange;
720+
721+ ranges.push(i);
722+ cumulativeCounts.push(cumulativeSum);
723+ labels.push(\`\${rangeStart.toFixed(0)}-\${rangeEnd.toFixed(0)} days\`);
724+ }
725+
726+ const cumulativeTrace = {
727+ x: ranges,
728+ y: cumulativeCounts,
729+ type: 'scatter',
730+ mode: 'lines+markers',
731+ name: 'Cumulative Sum',
732+ line: {
733+ color: 'rgba(31, 119, 180, 1)',
734+ width: 3
735+ },
736+ marker: {
737+ size: 8,
738+ color: 'rgba(31, 119, 180, 0.8)'
739+ },
740+ hovertemplate: 'Range: up to %{x} days<br>Cumulative Count: %{y}<br><extra></extra>',
741+ text: labels,
742+ hoverinfo: 'text+y'
743+ };
744+
745+ const cumulativeLayout = {
746+ title: {
747+ text: 'Cumulative Distribution by Day Ranges',
748+ font: { size: 18 }
749+ },
750+ xaxis: {
751+ title: 'Day Range (up to)',
752+ showgrid: true,
753+ gridcolor: 'rgba(128,128,128,0.2)'
754+ },
755+ yaxis: {
756+ title: 'Cumulative Count of Records',
757+ showgrid: true,
758+ gridcolor: 'rgba(128,128,128,0.2)'
759+ },
760+ plot_bgcolor: 'rgba(0,0,0,0)',
761+ paper_bgcolor: 'rgba(0,0,0,0)',
762+ showlegend: true,
763+ margin: { t: 50, b: 50, l: 50, r: 50 }
764+ };
765+
766+ return { trace: cumulativeTrace, layout: cumulativeLayout };
767+ }
768+
769+ const cumulativeChart = createCumulativeChart();
770+
696771 // Создаем графики
697772 Plotly.newPlot('histogram', [histogramTrace], histogramLayout, histogramConfig);
698773 Plotly.newPlot('boxplot', [boxplotTrace], boxplotLayout, histogramConfig);
774+ Plotly.newPlot('cumulative', [cumulativeChart.trace], cumulativeChart.layout, histogramConfig);
699775 </script>
700776</body>
701777</html>` ;
0 commit comments